1 13 package info.magnolia.cms.gui.control; 14 15 import java.util.ArrayList ; 16 import java.util.Iterator ; 17 import java.util.List ; 18 19 20 24 public class Bar extends ControlSuper { 25 26 private List buttonsLeft = new ArrayList (); 27 28 private List buttonsRight = new ArrayList (); 29 30 private boolean small = true; 31 32 public void setButtonsLeft(List buttons) { 33 this.buttonsLeft = buttons; 34 } 35 36 public void setButtonsLeft(Button button) { 37 this.getButtonsLeft().add(button); 38 } 39 40 public List getButtonsLeft() { 41 return this.buttonsLeft; 42 } 43 44 public void setButtonsRight(List buttons) { 45 this.buttonsRight = buttons; 46 } 47 48 public void setButtonsRight(Button button) { 49 this.getButtonsRight().add(button); 50 } 51 52 public List getButtonsRight() { 53 return this.buttonsRight; 54 } 55 56 public void setSmall(boolean b) { 57 this.small = b; 58 } 59 60 public boolean getSmall() { 61 return this.small; 62 } 63 64 public String getHtml() { 65 StringBuffer html = new StringBuffer (); 66 String cssClass; 67 if (this.getSmall()) { 68 cssClass = CSSCLASS_CONTROLBARSMALL; 69 } 70 else { 71 cssClass = CSSCLASS_CONTROLBAR; 72 } 73 html.append("<table"); html.append(this.getHtmlEvents()); 75 html.append(" class=\"" + cssClass + "\""); if (this.getId() != null) { 77 html.append(" id=\"" + this.getId() + "\" cellspacing=\"0\""); } 79 html.append(">"); html.append("<tr>"); 82 List btnLeft = this.getButtonsLeft(); 84 if (!btnLeft.isEmpty()) { 85 html.append("<td class=\"mgnlBtnsLeft\">"); Iterator itLeft = btnLeft.iterator(); 87 while (itLeft.hasNext()) { 88 Button b = (Button) itLeft.next(); 89 if (this.getSmall()) { 90 b.setSmall(true); 91 } 92 b.setCssStyles("background", "transparent"); b.setSaveInfo(false); 94 html.append(b.getHtml()); 95 } 96 html.append("</td>"); } 98 99 List btnRight = this.getButtonsRight(); 101 if (!btnRight.isEmpty()) { 102 html.append("<td class=\"mgnlBtnsRight\">"); 104 Iterator itRight = this.getButtonsRight().iterator(); 105 while (itRight.hasNext()) { 106 Button b = (Button) itRight.next(); 107 if (this.getSmall()) { 108 b.setSmall(true); 109 } 110 b.setCssStyles("background", "transparent"); b.setSaveInfo(false); 112 html.append(b.getHtml()); 113 } 114 html.append("</td>"); } 116 117 html.append("</tr>"); html.append("</table>"); return html.toString(); 120 } 121 122 } 123 | Popular Tags |