]>
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
.argeo
.docbook
.DbkType
;
10 import org
.eclipse
.swt
.SWT
;
11 import org
.eclipse
.swt
.widgets
.Composite
;
12 import org
.eclipse
.swt
.widgets
.Control
;
14 /** An editable section. */
15 public class TextSection
extends Section
{
16 private static final long serialVersionUID
= -8625209546243220689L;
17 private String defaultTextStyle
= DbkType
.para
.name();
18 private String titleStyle
;
20 private final boolean flat
;
22 private boolean titleReadOnly
= false;
24 private final int level
;
26 public TextSection(Composite parent
, int style
, Node node
) {
27 this(parent
, findSection(parent
), style
, node
);
30 public TextSection(TextSection section
, int style
, Node node
) {
31 this(section
, section
.getParentSection(), style
, node
);
34 private TextSection(Composite parent
, Section parentSection
, int style
, Node node
) {
35 super(parent
, parentSection
, style
, node
);
36 flat
= SWT
.FLAT
== (style
& SWT
.FLAT
);
37 if (parentSection
instanceof TextSection
) {
38 level
= ((TextSection
) parentSection
).getLevel() + 1;
42 CmsUiUtils
.style(this, DbkType
.section
.name());
45 public String
getDefaultTextStyle() {
46 return defaultTextStyle
;
49 public boolean isFlat() {
53 /** The level of this section, similar to h1, h2, etc. in HTML. */
54 public int getLevel() {
58 public String
getTitleStyle() {
59 if (titleStyle
!= null)
61 // TODO make base H styles configurable
62 // Integer relativeDepth = getRelativeDepth();
63 // System.out.println("Level: "+getLevel());
64 return getLevel() == 0 ? TextStyles
.TEXT_TITLE
: "h" + getLevel();
67 public void setDefaultTextStyle(String defaultTextStyle
) {
68 this.defaultTextStyle
= defaultTextStyle
;
71 public void setTitleStyle(String titleStyle
) {
72 this.titleStyle
= titleStyle
;
75 public boolean isTitleReadOnly() {
79 public void setTitleReadOnly(boolean titleReadOnly
) {
80 this.titleReadOnly
= titleReadOnly
;