1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 package info.magnolia.cms.gui.dialog;
35
36 import info.magnolia.cms.gui.misc.CssConstants;
37
38 import java.io.IOException;
39 import java.io.Writer;
40
41 import org.apache.commons.lang.StringUtils;
42
43
44
45
46
47
48 public class DialogBox extends DialogControlImpl {
49
50 public static final int BOXTYPE_2COLS = 0;
51
52 public static final int BOXTYPE_1COL = 1;
53
54 private int boxType = BOXTYPE_2COLS;
55
56 public void setBoxType(int i) {
57 this.boxType = i;
58 }
59
60 public int getBoxType() {
61 String configBoxType = this.getConfigValue("boxType");
62 if (configBoxType.equals("1Col")) {
63 return BOXTYPE_1COL;
64 }
65 return this.boxType;
66
67 }
68
69 public void drawHtmlPre(Writer out) throws IOException {
70 if (this.getConfigValue("lineSemi", "false").equals("true")) {
71 out.write(new DialogLine().getHtml(1, 1));
72 }
73 else if (this.getConfigValue("line", "true").equals("true")) {
74 out.write(new DialogLine().getHtml());
75 }
76 out.write("<tr>");
77 if (this.getBoxType() == BOXTYPE_2COLS) {
78 out.write("<td style=\"width:1%\" class=\"" + CssConstants.CSSCLASS_BOXLABEL + "\">");
79
80 out.write(this.getMessage(this.getLabel()));
81 if (this.isRequired()) {
82 out.write(" (*)");
83 }
84 if (StringUtils.isNotEmpty(this.getConfigValue("labelDescription"))) {
85 String desc = this.getConfigValue("labelDescription");
86 desc = this.getMessage(desc);
87 out.write("<div class=\"" + CssConstants.CSSCLASS_DESCRIPTION + "\">" + desc + "</div>");
88 }
89 out.write("</td>");
90 String cssClass = CssConstants.CSSCLASS_BOXINPUT;
91 if (this.getClass().getName().indexOf("DialogStatic") != -1
92 || this.getClass().getName().indexOf("DialogButton") != -1) {
93 cssClass = CssConstants.CSSCLASS_BOXLABEL;
94 }
95 out.write("<td style=\"width:100%\" class=\"" + cssClass + "\">");
96 }
97 else {
98 out.write("<td style=\"width:100%\" colspan=\"2\" class=\"" + CssConstants.CSSCLASS_BOXLABEL + "\">");
99 if (StringUtils.isNotEmpty(this.getLabel())) {
100 out.write("<div class=\""
101 + CssConstants.CSSCLASS_BOXLABEL
102 + "\">"
103 + this.getMessage(this.getLabel())
104 + (this.isRequired() ? "(*)" : "")
105 + "</div>");
106 }
107 if (StringUtils.isNotEmpty(this.getConfigValue("labelDescription"))) {
108 String desc = this.getConfigValue("labelDescription");
109 out.write("<div class=\""
110 + CssConstants.CSSCLASS_DESCRIPTION
111 + "\">"
112 + this.getMessage(desc)
113 + "</div>");
114 }
115 }
116 }
117
118 public void drawHtmlPost(Writer out) throws IOException {
119 out.write(this.getHtmlDescription());
120
121 if (this.getConfigValue("saveHandler") != null) {
122 out.write("<input type=\"hidden\" name=\"");
123 out.write(this.getName());
124 out.write("_saveHandler\" value=\"");
125 out.write(this.getConfigValue("saveHandler"));
126 out.write("\" />");
127
128 out.write("<input type=\"hidden\" name=\"");
129 out.write(this.getName());
130 out.write("_configNode\" value=\"");
131 out.write(this.getConfigValue("handle"));
132 out.write("\" />");
133 }
134
135 out.write("</td></tr>\n");
136 }
137
138 public String getHtmlDescription() {
139
140
141 if (StringUtils.isNotEmpty(this.getDescription())) {
142 String desc = this.getDescription();
143 desc = this.getMessage(desc);
144 return "<div class=\"" + CssConstants.CSSCLASS_DESCRIPTION + "\">" + desc + "</div>";
145 }
146
147 return StringUtils.EMPTY;
148 }
149
150 }