1 13 package info.magnolia.cms.gui.dialog; 14 15 import info.magnolia.cms.gui.misc.CssConstants; 16 17 import java.io.IOException ; 18 import java.io.Writer ; 19 20 import org.apache.commons.lang.StringUtils; 21 22 23 27 public class DialogBox extends DialogControlImpl { 28 29 public static final int BOXTYPE_2COLS = 0; 30 31 public static final int BOXTYPE_1COL = 1; 32 33 private int boxType = BOXTYPE_2COLS; 34 35 38 protected DialogBox() { 39 } 40 41 public void setBoxType(int i) { 42 this.boxType = i; 43 } 44 45 public int getBoxType() { 46 String configBoxType = this.getConfigValue("boxType"); if (configBoxType.equals("1Col")) { return BOXTYPE_1COL; 49 } 50 return this.boxType; 51 52 } 53 54 public void drawHtmlPre(Writer out) throws IOException { 55 if (this.getConfigValue("lineSemi", "false").equals("true")) { out.write(new DialogLine().getHtml(1, 1)); 57 } 58 else if (this.getConfigValue("line", "true").equals("true")) { out.write(new DialogLine().getHtml()); 60 } 61 out.write("<tr>"); if (this.getBoxType() == BOXTYPE_2COLS) { 63 out.write("<td width=\"1%\" class=\"" + CssConstants.CSSCLASS_BOXLABEL + "\">"); out.write(this.getMessage(this.getLabel())); 66 if (this.isRequired()) { 67 out.write("(*)"); 68 } 69 if (StringUtils.isNotEmpty(this.getConfigValue("labelDescription"))) { String desc = this.getConfigValue("labelDescription"); desc = this.getMessage(desc); 72 out.write("<div class=\"" + CssConstants.CSSCLASS_DESCRIPTION + "\">" + desc + "</div>"); } 74 out.write("</td>"); String cssClass = CssConstants.CSSCLASS_BOXINPUT; 76 if (this.getClass().getName().indexOf("DialogStatic") != -1 || this.getClass().getName().indexOf("DialogButton") != -1) { cssClass = CssConstants.CSSCLASS_BOXLABEL; 79 } 80 out.write("<td width=\"100%\" class=\"" + cssClass + "\">"); } 82 else { 83 out.write("<td width=\"100%\" colspan=\"2\" class=\"" + CssConstants.CSSCLASS_BOXLABEL + "\">"); if (StringUtils.isNotEmpty(this.getLabel())) { 85 out.write("<div class=\"" + CssConstants.CSSCLASS_BOXLABEL 87 + "\">" + this.getMessage(this.getLabel()) 89 + "</div>"); } 91 if (StringUtils.isNotEmpty(this.getConfigValue("labelDescription"))) { String desc = this.getConfigValue("labelDescription"); out.write("<div class=\"" + CssConstants.CSSCLASS_DESCRIPTION 95 + "\">" + this.getMessage(desc) 97 + "</div>"); } 99 } 100 } 101 102 public void drawHtmlPost(Writer out) throws IOException { 103 out.write(this.getHtmlDescription()); 104 out.write("</td></tr>"); } 106 107 public String getHtmlDescription() { 108 109 if (StringUtils.isNotEmpty(this.getDescription())) { 111 String desc = this.getDescription(); 112 desc = this.getMessage(desc); 113 return "<div class=\"" + CssConstants.CSSCLASS_DESCRIPTION + "\">" + desc + "</div>"; } 115 116 return StringUtils.EMPTY; 117 } 118 119 } | Popular Tags |