KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > info > magnolia > cms > gui > control > Bar


1 /**
2  *
3  * Magnolia and its source-code is licensed under the LGPL.
4  * You may copy, adapt, and redistribute this file for commercial or non-commercial use.
5  * When copying, adapting, or redistributing this document in keeping with the guidelines above,
6  * you are required to provide proper attribution to obinary.
7  * If you reproduce or distribute the document without making any substantive modifications to its content,
8  * please use the following attribution line:
9  *
10  * Copyright 1993-2005 obinary Ltd. (http://www.obinary.com) All rights reserved.
11  *
12  */

13 package info.magnolia.cms.gui.control;
14
15 import java.util.ArrayList JavaDoc;
16 import java.util.Iterator JavaDoc;
17 import java.util.List JavaDoc;
18
19
20 /**
21  * @author Vinzenz Wyser
22  * @version 2.0
23  */

24 public class Bar extends ControlSuper {
25
26     private List JavaDoc buttonsLeft = new ArrayList JavaDoc();
27
28     private List JavaDoc buttonsRight = new ArrayList JavaDoc();
29
30     private boolean small = true;
31
32     public void setButtonsLeft(List JavaDoc buttons) {
33         this.buttonsLeft = buttons;
34     }
35
36     public void setButtonsLeft(Button button) {
37         this.getButtonsLeft().add(button);
38     }
39
40     public List JavaDoc getButtonsLeft() {
41         return this.buttonsLeft;
42     }
43
44     public void setButtonsRight(List JavaDoc buttons) {
45         this.buttonsRight = buttons;
46     }
47
48     public void setButtonsRight(Button button) {
49         this.getButtonsRight().add(button);
50     }
51
52     public List JavaDoc 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 JavaDoc getHtml() {
65         StringBuffer JavaDoc html = new StringBuffer JavaDoc();
66         String JavaDoc cssClass;
67         if (this.getSmall()) {
68             cssClass = CSSCLASS_CONTROLBARSMALL;
69         }
70         else {
71             cssClass = CSSCLASS_CONTROLBAR;
72         }
73         html.append("<table"); //$NON-NLS-1$
74
html.append(this.getHtmlEvents());
75         html.append(" class=\"" + cssClass + "\""); //$NON-NLS-1$ //$NON-NLS-2$
76
if (this.getId() != null) {
77             html.append(" id=\"" + this.getId() + "\" cellspacing=\"0\""); //$NON-NLS-1$ //$NON-NLS-2$
78
}
79         html.append(">"); //$NON-NLS-1$
80
html.append("<tr>"); //$NON-NLS-1$
81

82         // left
83
List JavaDoc btnLeft = this.getButtonsLeft();
84         if (!btnLeft.isEmpty()) {
85             html.append("<td class=\"mgnlBtnsLeft\">"); //$NON-NLS-1$
86
Iterator JavaDoc 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"); //$NON-NLS-1$ //$NON-NLS-2$
93
b.setSaveInfo(false);
94                 html.append(b.getHtml());
95             }
96             html.append("</td>"); //$NON-NLS-1$
97
}
98
99         // right
100
List JavaDoc btnRight = this.getButtonsRight();
101         if (!btnRight.isEmpty()) {
102             html.append("<td class=\"mgnlBtnsRight\">"); //$NON-NLS-1$
103

104             Iterator JavaDoc 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"); //$NON-NLS-1$ //$NON-NLS-2$
111
b.setSaveInfo(false);
112                 html.append(b.getHtml());
113             }
114             html.append("</td>"); //$NON-NLS-1$
115
}
116
117         html.append("</tr>"); //$NON-NLS-1$
118
html.append("</table>"); //$NON-NLS-1$
119
return html.toString();
120     }
121
122 }
123
Popular Tags