]> git.argeo.org Git - gpl/argeo-suite.git/blob - docbook/ui/DocumentTextEditor.java
Prepare next development cycle
[gpl/argeo-suite.git] / docbook / ui / DocumentTextEditor.java
1 package org.argeo.docbook.ui;
2
3 import javax.jcr.Node;
4 import javax.jcr.Property;
5 import javax.jcr.RepositoryException;
6
7 import org.argeo.cms.text.TextSection;
8 import org.argeo.cms.ui.CmsEditable;
9 import org.argeo.cms.ui.util.CmsUiUtils;
10 import org.eclipse.swt.widgets.Composite;
11
12 /** Text editor where sections and subsections can be managed by the user. */
13 public class DocumentTextEditor extends AbstractDbkViewer {
14 private static final long serialVersionUID = 6049661610883342325L;
15
16 public DocumentTextEditor(Composite parent, int style, Node textNode, CmsEditable cmsEditable) {
17 super(new TextSection(parent, style, textNode), style, cmsEditable);
18 refresh();
19 getMainSection().setLayoutData(CmsUiUtils.fillWidth());
20 }
21
22 @Override
23 protected void initModel(Node textNode) throws RepositoryException {
24 if (isFlat()) {
25 textNode.addNode(DocBookNames.DBK_PARA, DocBookTypes.PARA)
26 .addNode(DocBookNames.JCR_XMLTEXT, DocBookTypes.XMLTEXT)
27 .setProperty(DocBookNames.JCR_XMLCHARACTERS, "Hello World!");
28 }
29 // else
30 // textNode.setProperty(DocBookNames.DBK_TITLE, textNode.getName());
31 }
32
33 @Override
34 protected Boolean isModelInitialized(Node textNode) throws RepositoryException {
35 return textNode.hasProperty(Property.JCR_TITLE) || textNode.hasNode(DocBookNames.DBK_PARA)
36 || (!isFlat() && textNode.hasNode(DocBookNames.DBK_SECTION));
37 }
38
39 }