KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > info > magnolia > cms > gui > controlx > list > ListColumn


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.controlx.list;
14
15 import info.magnolia.cms.gui.controlx.impl.AbstractControl;
16
17 import org.apache.commons.lang.StringUtils;
18
19
20 /**
21  * This represents a column in a list.
22  * @author Philipp Bracher
23  * @version $Revision: 6434 $ ($Author: philipp $)
24  */

25 public class ListColumn extends AbstractControl {
26
27     /**
28      *
29      */

30     public static final String JavaDoc RENDER_TYPE = "listColumn";
31
32     /**
33      * The columnName of the column.
34      */

35     private String JavaDoc columnName;
36
37     /**
38      * The label showed
39      */

40     private String JavaDoc label;
41
42     /**
43      * Width of the table
44      */

45     private String JavaDoc width;
46
47     /**
48      * Show a separator after this column
49      */

50     private boolean separator;
51
52     /**
53      * Empty Constructor. Used for anonymous classes.
54      */

55     public ListColumn() {
56         this.setRenderType(RENDER_TYPE);
57     }
58
59     /**
60      * Create a new column.
61      * @param columnName
62      * @param label
63      * @param width
64      * @param separator
65      */

66     public ListColumn(String JavaDoc columnName, String JavaDoc label, String JavaDoc width, boolean separator) {
67         this();
68         this.setName(columnName);
69         this.setColumnName(columnName);
70         this.setLabel(label);
71         this.setWidth(width);
72         this.setSeparator(separator);
73     }
74
75     /**
76      * Get the list control this column belongs to.
77      * @return the list control
78      */

79     public ListControl getListControl() {
80         return (ListControl) this.getParent();
81     }
82
83     /**
84      * @return Returns the label.
85      */

86     public String JavaDoc getLabel() {
87         if (this.label == null) {
88             return this.getName();
89         }
90         return this.label;
91     }
92
93     /**
94      * @param label The label to set.
95      */

96     public void setLabel(String JavaDoc label) {
97         this.label = label;
98     }
99
100     /**
101      * @return Returns the separator.
102      */

103     public boolean isSeparator() {
104         return this.separator;
105     }
106
107     /**
108      * @param separator The separator to set.
109      */

110     public void setSeparator(boolean separator) {
111         this.separator = separator;
112     }
113
114     /**
115      * @return Returns the width.
116      */

117     public String JavaDoc getWidth() {
118         return this.width;
119     }
120
121     /**
122      * @param width The width to set.
123      */

124     public void setWidth(String JavaDoc width) {
125         this.width = width;
126     }
127
128     /**
129      * Called by the renderer
130      * @return the object to render
131      */

132     public Object JavaDoc getValue() {
133         return this.getListControl().getIteratorValue(this.getColumnName());
134     }
135
136     /**
137      * @return Returns the columnName.
138      */

139     public String JavaDoc getColumnName() {
140         if(this.columnName == null){
141             return this.getName();
142         }
143         return this.columnName;
144     }
145
146     /**
147      * @param columnName The columnName to set.
148      */

149     public void setColumnName(String JavaDoc columnName) {
150         this.columnName = columnName;
151     }
152
153 }
154
Popular Tags