]> git.argeo.org Git - gpl/argeo-suite.git/blob - publishing/org.argeo.publishing.ui/src/org/argeo/docbook/ui/TextSection.java
Fix & in RAP links.
[gpl/argeo-suite.git] / publishing / org.argeo.publishing.ui / src / org / argeo / docbook / ui / TextSection.java
1 package org.argeo.docbook.ui;
2
3 import javax.jcr.Node;
4
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;
12
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;
18
19 private final boolean flat;
20
21 private boolean titleReadOnly = false;
22
23 private final int level;
24
25 public TextSection(Composite parent, int style, Node node) {
26 this(parent, findSection(parent), style, node);
27 }
28
29 public TextSection(TextSection section, int style, Node node) {
30 this(section, section.getParentSection(), style, node);
31 }
32
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;
38 } else {
39 level = 0;
40 }
41 // CmsUiUtils.style(this, TextStyles.TEXT_SECTION);
42 }
43
44 public String getDefaultTextStyle() {
45 return defaultTextStyle;
46 }
47
48 public boolean isFlat() {
49 return flat;
50 }
51
52 /** The level of this section, similar to h1, h2, etc. in HTML. */
53 public int getLevel() {
54 return level;
55 }
56
57 public String getTitleStyle() {
58 if (titleStyle != null)
59 return titleStyle;
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();
64 }
65
66 public void setDefaultTextStyle(String defaultTextStyle) {
67 this.defaultTextStyle = defaultTextStyle;
68 }
69
70 public void setTitleStyle(String titleStyle) {
71 this.titleStyle = titleStyle;
72 }
73
74 public boolean isTitleReadOnly() {
75 return titleReadOnly;
76 }
77
78 public void setTitleReadOnly(boolean titleReadOnly) {
79 this.titleReadOnly = titleReadOnly;
80 }
81 }