]> git.argeo.org Git - gpl/argeo-suite.git/blob - publishing/org.argeo.publishing.ui/src/org/argeo/cms/text/TextSection.java
Improve terms framework.
[gpl/argeo-suite.git] / publishing / org.argeo.publishing.ui / src / org / argeo / cms / text / TextSection.java
1 package org.argeo.cms.text;
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 public TextSection(Composite parent, int style, Node node) {
24 this(parent, findSection(parent), style, node);
25 }
26
27 public TextSection(TextSection section, int style, Node node) {
28 this(section, section.getParentSection(), style, node);
29 }
30
31 private TextSection(Composite parent, Section parentSection, int style, Node node) {
32 super(parent, parentSection, style, node);
33 flat = SWT.FLAT == (style & SWT.FLAT);
34 // CmsUiUtils.style(this, TextStyles.TEXT_SECTION);
35 }
36
37 public String getDefaultTextStyle() {
38 return defaultTextStyle;
39 }
40
41 public boolean isFlat() {
42 return flat;
43 }
44
45 public String getTitleStyle() {
46 if (titleStyle != null)
47 return titleStyle;
48 // TODO make base H styles configurable
49 Integer relativeDepth = getRelativeDepth();
50 return relativeDepth == 0 ? TextStyles.TEXT_TITLE : TextStyles.TEXT_H + relativeDepth;
51 }
52
53 public void setDefaultTextStyle(String defaultTextStyle) {
54 this.defaultTextStyle = defaultTextStyle;
55 }
56
57 public void setTitleStyle(String titleStyle) {
58 this.titleStyle = titleStyle;
59 }
60
61 public boolean isTitleReadOnly() {
62 return titleReadOnly;
63 }
64
65 public void setTitleReadOnly(boolean titleReadOnly) {
66 this.titleReadOnly = titleReadOnly;
67 }
68 }