]> git.argeo.org Git - gpl/argeo-suite.git/blob - publishing/org.argeo.publishing.ui/src/org/argeo/docbook/ui/DocumentTextEditor.java
Introduce Terms manager service.
[gpl/argeo-suite.git] / publishing / org.argeo.publishing.ui / src / org / argeo / 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.argeo.jcr.Jcr;
11 import org.argeo.jcr.JcrxType;
12 import org.eclipse.swt.widgets.Composite;
13
14 /** Text editor where sections and subsections can be managed by the user. */
15 public class DocumentTextEditor extends AbstractDbkViewer {
16 private static final long serialVersionUID = 6049661610883342325L;
17
18 public DocumentTextEditor(Composite parent, int style, Node textNode, CmsEditable cmsEditable) {
19 super(new TextSection(parent, style, textNode), style, cmsEditable);
20 refresh();
21 getMainSection().setLayoutData(CmsUiUtils.fillWidth());
22 }
23
24 @Override
25 protected void initModel(Node textNode) throws RepositoryException {
26 if (isFlat()) {
27 textNode.addNode(DocBookNames.DBK_PARA, DocBookTypes.PARA).addNode(Jcr.JCR_XMLTEXT, JcrxType.JCRX_XMLTEXT)
28 .setProperty(Jcr.JCR_XMLCHARACTERS, "");
29 }
30 // else
31 // textNode.setProperty(DocBookNames.DBK_TITLE, textNode.getName());
32 }
33
34 @Override
35 protected Boolean isModelInitialized(Node textNode) throws RepositoryException {
36 return textNode.hasProperty(Property.JCR_TITLE) || textNode.hasNode(DocBookNames.DBK_PARA)
37 || (!isFlat() && textNode.hasNode(DocBookNames.DBK_SECTION));
38 }
39
40 }