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