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 @Override
88 public String getHtml() {
89 StringBuffer html = new StringBuffer();
90 if (StringUtils.isEmpty(this.getCssClass())) {
91 if (this.getSmall()) {
92 this.setCssClass(CSSCLASS_CONTROLBARSMALL);
93 }
94 else {
95 this.setCssClass(CSSCLASS_CONTROLBAR);
96 }
97 }
98 html.append("<table");
99 html.append(this.getHtmlEvents());
100 html.append(this.getHtmlCssClass());
101 if (this.getId() != null) {
102 html.append(" id=\"" + this.getId() + "\" cellspacing=\"0\"");
103 }
104 html.append(">");
105 html.append("<tr>");
106
107
108 List btnLeft = this.getButtonsLeft();
109 if (!btnLeft.isEmpty()) {
110 html.append("<td class=\"mgnlBtnsLeft\">");
111 Iterator itLeft = btnLeft.iterator();
112 while (itLeft.hasNext()) {
113 Button b = (Button) itLeft.next();
114 if (this.getSmall()) {
115 b.setSmall(true);
116 }
117 b.setCssStyles("background", "transparent");
118 b.setSaveInfo(false);
119 html.append(b.getHtml());
120 }
121 html.append("</td>");
122 }
123
124
125 final String label = getLabel();
126 if (StringUtils.isNotEmpty(label)) {
127 html.append("<td class=\"smothBarLabelContainer\">");
128 html.append("<table class=\"smothBarLabel\"><tr><td class=\"smothBarLabel\">");
129 html.append(label);
130 html.append("</td></tr></table>");
131 html.append("</td>");
132 }
133
134
135 List btnRight = this.getButtonsRight();
136 if (!btnRight.isEmpty()) {
137 html.append("<td class=\"mgnlBtnsRight\">");
138
139 Iterator itRight = this.getButtonsRight().iterator();
140 while (itRight.hasNext()) {
141 ControlImpl c = (ControlImpl) itRight.next();
142 if(c instanceof Button){
143 if (this.getSmall()) {
144 ((Button)c).setSmall(true);
145 }
146 c.setCssStyles("background", "transparent");
147 }
148 c.setSaveInfo(false);
149 html.append(c.getHtml());
150 }
151 html.append("</td>");
152 }
153
154 html.append("</tr>");
155 html.append("</table>");
156 return html.toString();
157 }
158
159 }