1 13 package info.magnolia.cms.gui.dialog; 14 15 import info.magnolia.cms.core.Content; 16 import info.magnolia.cms.gui.control.Button; 17 import info.magnolia.cms.gui.control.Edit; 18 import info.magnolia.cms.gui.misc.CssConstants; 19 import info.magnolia.cms.i18n.TemplateMessagesUtil; 20 21 import java.io.IOException ; 22 import java.io.Writer ; 23 import java.util.ArrayList ; 24 import java.util.List ; 25 26 import javax.jcr.PropertyType; 27 import javax.jcr.RepositoryException; 28 import javax.servlet.http.HttpServletRequest ; 29 import javax.servlet.http.HttpServletResponse ; 30 31 32 36 public class DialogEditWithButton extends DialogBox { 37 38 private List buttons = new ArrayList (); 39 40 43 protected DialogEditWithButton() { 44 } 45 46 49 public void init(HttpServletRequest request, HttpServletResponse response, Content websiteNode, Content configNode) 50 throws RepositoryException { 51 super.init(request, response, websiteNode, configNode); 52 buttons.add(new Button()); 53 } 54 55 public Button getButton() { 56 return this.getButton(0); 57 } 58 59 public Button getButton(int index) { 60 return (Button) this.getButtons().get(index); 61 } 62 63 public void setButtons(List l) { 64 this.buttons = l; 65 } 66 67 public List getButtons() { 68 return this.buttons; 69 } 70 71 74 public void drawHtml(Writer out) throws IOException { 75 Edit control = new Edit(this.getName(), this.getValue()); 76 control.setType(this.getConfigValue("type", PropertyType.TYPENAME_STRING)); if (this.getConfigValue("saveInfo").equals("false")) { control.setSaveInfo(false); 79 } 80 control.setCssClass(CssConstants.CSSCLASS_EDIT); 81 control.setRows(this.getConfigValue("rows", "1")); control.setCssStyles("width", "100%"); if (this.getConfigValue("onchange", null) != null) { control.setEvent("onchange", this.getConfigValue("onchange")); } 86 this.drawHtmlPre(out); 87 String width = this.getConfigValue("width", "100%"); out.write("<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"" + width + "\">"); out.write("<tr><td width=\"100%\" class=\"" + CssConstants.CSSCLASS_EDITWITHBUTTON + "\">"); out.write(control.getHtml()); 91 if (this.getConfigValue("buttonLabel", null) != null) { String label = this.getConfigValue("buttonLabel"); label = TemplateMessagesUtil.get(this.getRequest(), label); 94 this.getButton().setLabel(label); 95 } 96 for (int i = 0; i < this.getButtons().size(); i++) { 97 out.write("</td><td></td><td class=\"" + CssConstants.CSSCLASS_EDITWITHBUTTON + "\">"); out.write(this.getButton(i).getHtml()); 99 } 100 out.write("</td></tr></table>"); 102 this.drawHtmlPost(out); 103 } 104 } | Popular Tags |