]> git.argeo.org Git - gpl/argeo-suite.git/blob - publishing/org.argeo.publishing.ui/src/org/argeo/cms/text/StandardTextEditor.java
[maven-release-plugin] prepare release argeo-suite-2.1.17
[gpl/argeo-suite.git] / publishing / org.argeo.publishing.ui / src / org / argeo / cms / text / StandardTextEditor.java
1 package org.argeo.cms.text;
2
3 import static javax.jcr.Property.JCR_TITLE;
4
5 import javax.jcr.Node;
6 import javax.jcr.Property;
7 import javax.jcr.RepositoryException;
8
9 import org.argeo.cms.ui.CmsEditable;
10 import org.argeo.cms.ui.util.CmsUiUtils;
11 import org.argeo.cms.ui.viewers.Section;
12 import org.eclipse.swt.widgets.Composite;
13
14 /** Text editor where sections and subsections can be managed by the user. */
15 public class StandardTextEditor extends AbstractTextViewer {
16 private static final long serialVersionUID = 6049661610883342325L;
17
18 public StandardTextEditor(Composite parent, int style, Node textNode,
19 CmsEditable cmsEditable) throws RepositoryException {
20 super(new TextSection(parent, style, textNode), style, cmsEditable);
21 refresh();
22 getMainSection().setLayoutData(CmsUiUtils.fillWidth());
23 }
24
25 @Override
26 protected void initModel(Node textNode) throws RepositoryException {
27 if (isFlat())
28 textNode.addNode(CMS_P).addMixin(CmsTypes.CMS_STYLED);
29 else
30 textNode.setProperty(JCR_TITLE, textNode.getName());
31 }
32
33 @Override
34 protected Boolean isModelInitialized(Node textNode)
35 throws RepositoryException {
36 return textNode.hasProperty(Property.JCR_TITLE)
37 || textNode.hasNode(CMS_P)
38 || (!isFlat() && textNode.hasNode(CMS_H));
39 }
40
41 @Override
42 public Section getMainSection() {
43 // TODO Auto-generated method stub
44 return super.getMainSection();
45 }
46 }