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.control;
35
36 import java.util.ArrayList;
37 import java.util.Iterator;
38 import java.util.List;
39
40 import org.apache.commons.lang.StringUtils;
41
42
43
44
45
46
47 public class Bar extends ControlImpl {
48
49 private List buttonsLeft = new ArrayList();
50
51 private List buttonsRight = new ArrayList();
52
53 private boolean small = true;
54
55 public void setButtonsLeft(List buttons) {
56 this.buttonsLeft = buttons;
57 }
58
59 public void setButtonsLeft(Button button) {
60 this.getButtonsLeft().add(button);
61 }
62
63 public List getButtonsLeft() {
64 return this.buttonsLeft;
65 }
66
67 public void setButtonsRight(List buttons) {
68 this.buttonsRight = buttons;
69 }
70
71 public void setButtonsRight(Button button) {
72 this.getButtonsRight().add(button);
73 }
74
75 public List getButtonsRight() {
76 return this.buttonsRight;
77 }
78
79 public void setSmall(boolean b) {
80 this.small = b;
81 }
82
83 public boolean getSmall() {
84 return this.small;
85 }
86
87 public String getHtml() {
88 StringBuffer html = new StringBuffer();
89 if (StringUtils.isEmpty(this.getCssClass())) {
90 if (this.getSmall()) {
91 this.setCssClass(CSSCLASS_CONTROLBARSMALL);
92 }
93 else {
94 this.setCssClass(CSSCLASS_CONTROLBAR);
95 }
96 }
97 html.append("<table");
98 html.append(this.getHtmlEvents());
99 html.append(this.getHtmlCssClass());
100 if (this.getId() != null) {
101 html.append(" id=\"" + this.getId() + "\" cellspacing=\"0\"");
102 }
103 html.append(">");
104 html.append("<tr>");
105
106
107 List btnLeft = this.getButtonsLeft();
108 if (!btnLeft.isEmpty()) {
109 html.append("<td class=\"mgnlBtnsLeft\">");
110 Iterator itLeft = btnLeft.iterator();
111 while (itLeft.hasNext()) {
112 Button b = (Button) itLeft.next();
113 if (this.getSmall()) {
114 b.setSmall(true);
115 }
116 b.setCssStyles("background", "transparent");
117 b.setSaveInfo(false);
118 html.append(b.getHtml());
119 }
120 html.append("</td>");
121 }
122
123
124 final String label = getLabel();
125 if (StringUtils.isNotEmpty(label)) {
126 html.append("<td class=\"smothBarLabelContainer\">");
127 html.append("<table class=\"smothBarLabel\"><tr><td class=\"smothBarLabel\">");
128 html.append(label);
129 html.append("</td></tr></table>");
130 html.append("</td>");
131 }
132
133
134 List btnRight = this.getButtonsRight();
135 if (!btnRight.isEmpty()) {
136 html.append("<td class=\"mgnlBtnsRight\">");
137
138 Iterator itRight = this.getButtonsRight().iterator();
139 while (itRight.hasNext()) {
140 ControlImpl c = (ControlImpl) itRight.next();
141 if(c instanceof Button){
142 if (this.getSmall()) {
143 ((Button)c).setSmall(true);
144 }
145 c.setCssStyles("background", "transparent");
146 }
147 c.setSaveInfo(false);
148 html.append(c.getHtml());
149 }
150 html.append("</td>");
151 }
152
153 html.append("</tr>");
154 html.append("</table>");
155 return html.toString();
156 }
157
158 }