]> git.argeo.org Git - gpl/argeo-suite.git/blob - DocumentTextEditor.java
7d41117a29fb3ce26beafb750383270fcadf6958
[gpl/argeo-suite.git] / DocumentTextEditor.java
1 package org.argeo.app.ui.docbook;
2
3 import javax.jcr.Node;
4 import javax.jcr.RepositoryException;
5
6 import org.argeo.api.cms.ux.CmsEditable;
7 import org.argeo.app.docbook.DbkType;
8 import org.argeo.app.docbook.DbkUtils;
9 import org.argeo.cms.swt.CmsSwtUtils;
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(CmsSwtUtils.fillWidth());
20 }
21
22 @Override
23 protected void initModel(Node textNode) throws RepositoryException {
24 if (isFlat()) {
25 DbkUtils.addParagraph(textNode, "");
26 }
27 // else
28 // textNode.setProperty(DocBookNames.DBK_TITLE, textNode.getName());
29 }
30
31 @Override
32 protected Boolean isModelInitialized(Node textNode) throws RepositoryException {
33 return textNode.hasNode(DbkType.title.get()) || textNode.hasNode(DbkType.para.get())
34 || (!isFlat() && textNode.hasNode(DbkType.section.get()));
35 }
36
37 }