]> git.argeo.org Git - gpl/argeo-suite.git/blob - docbook/TextSection.java
Prepare next development cycle
[gpl/argeo-suite.git] / docbook / TextSection.java
1 package org.argeo.app.swt.docbook;
2
3 import org.argeo.api.acr.Content;
4 import org.argeo.app.docbook.DbkType;
5 import org.argeo.cms.swt.CmsSwtUtils;
6 import org.argeo.cms.swt.acr.SwtSection;
7 import org.eclipse.swt.SWT;
8 import org.eclipse.swt.widgets.Composite;
9
10 /** An editable section. */
11 public class TextSection extends SwtSection {
12 private static final long serialVersionUID = -8625209546243220689L;
13 private String defaultTextStyle = DbkType.para.name();
14 private String titleStyle;
15
16 private final boolean flat;
17
18 private boolean titleReadOnly = false;
19
20 private final int level;
21
22 public TextSection(Composite parent, int style, Content node) {
23 this(parent, findSection(parent), style, node);
24 }
25
26 public TextSection(TextSection section, int style, Content node) {
27 this(section, section.getParentSection(), style, node);
28 }
29
30 private TextSection(Composite parent, SwtSection parentSection, int style, Content node) {
31 super(parent, parentSection, style, node);
32 flat = SWT.FLAT == (style & SWT.FLAT);
33 if (parentSection instanceof TextSection) {
34 level = ((TextSection) parentSection).getLevel() + 1;
35 } else {
36 level = 0;
37 }
38 CmsSwtUtils.style(this, DbkType.section.name());
39 }
40
41 public String getDefaultTextStyle() {
42 return defaultTextStyle;
43 }
44
45 public boolean isFlat() {
46 return flat;
47 }
48
49 /** The level of this section, similar to h1, h2, etc. in HTML. */
50 public int getLevel() {
51 return level;
52 }
53
54 public String getTitleStyle() {
55 if (titleStyle != null)
56 return titleStyle;
57 // TODO make base H styles configurable
58 // Integer relativeDepth = getRelativeDepth();
59 // System.out.println("Level: " + getLevel());
60 return "h" + (getLevel() + 1);
61 }
62
63 public void setDefaultTextStyle(String defaultTextStyle) {
64 this.defaultTextStyle = defaultTextStyle;
65 }
66
67 public void setTitleStyle(String titleStyle) {
68 this.titleStyle = titleStyle;
69 }
70
71 public boolean isTitleReadOnly() {
72 return titleReadOnly;
73 }
74
75 public void setTitleReadOnly(boolean titleReadOnly) {
76 this.titleReadOnly = titleReadOnly;
77 }
78 }