Use released Argeo Maven plugin
[gpl/argeo-suite.git] / publishing / org.argeo.publishing.ui / src / org / argeo / docbook / ui / TextSection.java
index cb2e309b3bf6480706918b7df8f112af1d06420d..76ba661c3fd00461c962f023bd19fe7cff7f9c5d 100644 (file)
@@ -6,6 +6,7 @@ import org.argeo.cms.ui.util.CmsUiUtils;
 import org.argeo.cms.ui.viewers.EditablePart;
 import org.argeo.cms.ui.viewers.Section;
 import org.argeo.cms.ui.widgets.TextStyles;
+import org.argeo.docbook.DbkType;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Control;
@@ -13,13 +14,15 @@ import org.eclipse.swt.widgets.Control;
 /** An editable section. */
 public class TextSection extends Section {
        private static final long serialVersionUID = -8625209546243220689L;
-       private String defaultTextStyle = TextStyles.TEXT_DEFAULT;
+       private String defaultTextStyle = DbkType.para.name();
        private String titleStyle;
 
        private final boolean flat;
 
        private boolean titleReadOnly = false;
 
+       private final int level;
+
        public TextSection(Composite parent, int style, Node node) {
                this(parent, findSection(parent), style, node);
        }
@@ -31,7 +34,12 @@ public class TextSection extends Section {
        private TextSection(Composite parent, Section parentSection, int style, Node node) {
                super(parent, parentSection, style, node);
                flat = SWT.FLAT == (style & SWT.FLAT);
-               // CmsUiUtils.style(this, TextStyles.TEXT_SECTION);
+               if (parentSection instanceof TextSection) {
+                       level = ((TextSection) parentSection).getLevel() + 1;
+               } else {
+                       level = 0;
+               }
+               CmsUiUtils.style(this, DbkType.section.name());
        }
 
        public String getDefaultTextStyle() {
@@ -42,12 +50,18 @@ public class TextSection extends Section {
                return flat;
        }
 
+       /** The level of this section, similar to h1, h2, etc. in HTML. */
+       public int getLevel() {
+               return level;
+       }
+
        public String getTitleStyle() {
                if (titleStyle != null)
                        return titleStyle;
                // TODO make base H styles configurable
-               Integer relativeDepth = getRelativeDepth();
-               return relativeDepth == 0 ? TextStyles.TEXT_TITLE : TextStyles.TEXT_H + relativeDepth;
+//             Integer relativeDepth = getRelativeDepth();
+//             System.out.println("Level: " + getLevel());
+               return "h" + (getLevel() + 1);
        }
 
        public void setDefaultTextStyle(String defaultTextStyle) {
@@ -64,5 +78,5 @@ public class TextSection extends Section {
 
        public void setTitleReadOnly(boolean titleReadOnly) {
                this.titleReadOnly = titleReadOnly;
-       }       
+       }
 }