]>
git.argeo.org Git - gpl/argeo-suite.git/blob - swt/org.argeo.app.swt/src/org/argeo/app/swt/docbook/TextSection.java
1 package org
.argeo
.app
.swt
.docbook
;
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
;
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
;
16 private final boolean flat
;
18 private boolean titleReadOnly
= false;
20 private final int level
;
22 public TextSection(Composite parent
, int style
, Content node
) {
23 this(parent
, findSection(parent
), style
, node
);
26 public TextSection(TextSection section
, int style
, Content node
) {
27 this(section
, section
.getParentSection(), style
, node
);
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;
38 CmsSwtUtils
.style(this, DbkType
.section
.name());
41 public String
getDefaultTextStyle() {
42 return defaultTextStyle
;
45 public boolean isFlat() {
49 /** The level of this section, similar to h1, h2, etc. in HTML. */
50 public int getLevel() {
54 public String
getTitleStyle() {
55 if (titleStyle
!= null)
57 // TODO make base H styles configurable
58 // Integer relativeDepth = getRelativeDepth();
59 // System.out.println("Level: " + getLevel());
60 return "h" + (getLevel() + 1);
63 public void setDefaultTextStyle(String defaultTextStyle
) {
64 this.defaultTextStyle
= defaultTextStyle
;
67 public void setTitleStyle(String titleStyle
) {
68 this.titleStyle
= titleStyle
;
71 public boolean isTitleReadOnly() {
75 public void setTitleReadOnly(boolean titleReadOnly
) {
76 this.titleReadOnly
= titleReadOnly
;