Introduce publishing styles.
[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.Section;
7 import org.argeo.cms.ui.widgets.TextStyles;
8 import org.eclipse.swt.widgets.Composite;
9
10 public class TextSection extends Section implements CmsNames {
11         private static final long serialVersionUID = -8625209546243220689L;
12         private String defaultTextStyle = TextStyles.TEXT_DEFAULT;
13         private String titleStyle;
14
15         public TextSection(Composite parent, int style, Node node) {
16                 this(parent, findSection(parent), style, node);
17         }
18
19         public TextSection(TextSection section, int style, Node node) {
20                 this(section, section.getParentSection(), style, node);
21         }
22
23         private TextSection(Composite parent, Section parentSection, int style, Node node) {
24                 super(parent, parentSection, style, node);
25                 CmsUiUtils.style(this, TextStyles.TEXT_SECTION);
26         }
27
28         public String getDefaultTextStyle() {
29                 return defaultTextStyle;
30         }
31
32         public String getTitleStyle() {
33                 if (titleStyle != null)
34                         return titleStyle;
35                 // TODO make base H styles configurable
36                 Integer relativeDepth = getRelativeDepth();
37                 return relativeDepth == 0 ? TextStyles.TEXT_TITLE : TextStyles.TEXT_H + relativeDepth;
38         }
39
40         public void setDefaultTextStyle(String defaultTextStyle) {
41                 this.defaultTextStyle = defaultTextStyle;
42         }
43
44         public void setTitleStyle(String titleStyle) {
45                 this.titleStyle = titleStyle;
46         }
47 }