]>
git.argeo.org Git - gpl/argeo-suite.git/blob - publishing/org.argeo.publishing.ui/src/org/argeo/docbook/ui/TextSection.java
1 package org
.argeo
.docbook
.ui
;
5 import org
.argeo
.cms
.ui
.util
.CmsUiUtils
;
6 import org
.argeo
.cms
.ui
.viewers
.EditablePart
;
7 import org
.argeo
.cms
.ui
.viewers
.Section
;
8 import org
.argeo
.cms
.ui
.widgets
.TextStyles
;
9 import org
.eclipse
.swt
.SWT
;
10 import org
.eclipse
.swt
.widgets
.Composite
;
11 import org
.eclipse
.swt
.widgets
.Control
;
13 /** An editable section. */
14 public class TextSection
extends Section
{
15 private static final long serialVersionUID
= -8625209546243220689L;
16 private String defaultTextStyle
= TextStyles
.TEXT_DEFAULT
;
17 private String titleStyle
;
19 private final boolean flat
;
21 private boolean titleReadOnly
= false;
23 private final int level
;
25 public TextSection(Composite parent
, int style
, Node node
) {
26 this(parent
, findSection(parent
), style
, node
);
29 public TextSection(TextSection section
, int style
, Node node
) {
30 this(section
, section
.getParentSection(), style
, node
);
33 private TextSection(Composite parent
, Section parentSection
, int style
, Node node
) {
34 super(parent
, parentSection
, style
, node
);
35 flat
= SWT
.FLAT
== (style
& SWT
.FLAT
);
36 if (parentSection
instanceof TextSection
) {
37 level
= ((TextSection
) parentSection
).getLevel() + 1;
41 // CmsUiUtils.style(this, TextStyles.TEXT_SECTION);
44 public String
getDefaultTextStyle() {
45 return defaultTextStyle
;
48 public boolean isFlat() {
52 /** The level of this section, similar to h1, h2, etc. in HTML. */
53 public int getLevel() {
57 public String
getTitleStyle() {
58 if (titleStyle
!= null)
60 // TODO make base H styles configurable
61 // Integer relativeDepth = getRelativeDepth();
62 // System.out.println("Level: "+getLevel());
63 return getLevel() == 0 ? TextStyles
.TEXT_TITLE
: "h" + getLevel();
66 public void setDefaultTextStyle(String defaultTextStyle
) {
67 this.defaultTextStyle
= defaultTextStyle
;
70 public void setTitleStyle(String titleStyle
) {
71 this.titleStyle
= titleStyle
;
74 public boolean isTitleReadOnly() {
78 public void setTitleReadOnly(boolean titleReadOnly
) {
79 this.titleReadOnly
= titleReadOnly
;