|
@@ -23,8 +23,7 @@ |
23 |
23 |
|
* @param <RowType> the type of the row value |
24 |
24 |
|
* @param <ColType> the data type of the column |
25 |
25 |
|
*/ |
26 |
|
- |
public abstract class AbstractColumnDefinition<RowType, ColType> implements ColumnDefinition<RowType, ColType> |
27 |
|
- |
{ |
|
26 |
+ |
public abstract class AbstractColumnDefinition<RowType, ColType> implements ColumnDefinition<RowType, ColType> { |
28 |
27 |
|
|
29 |
28 |
|
/** |
30 |
29 |
|
* The default {@link CellRenderer} to use when the |
|
@@ -47,20 +46,17 @@ |
47 |
46 |
|
*/ |
48 |
47 |
|
private ColumnPropertyManager properties = new ColumnPropertyManager(); |
49 |
48 |
|
|
50 |
|
- |
public CellEditor<ColType> getCellEditor() |
51 |
|
- |
{ |
|
49 |
+ |
public CellEditor<ColType> getCellEditor() { |
52 |
50 |
|
return cellEditor; |
53 |
51 |
|
} |
54 |
52 |
|
|
55 |
|
- |
public CellRenderer<RowType, ColType> getCellRenderer() |
56 |
|
- |
{ |
|
53 |
+ |
public CellRenderer<RowType, ColType> getCellRenderer() { |
57 |
54 |
|
return cellRenderer; |
58 |
55 |
|
} |
59 |
56 |
|
|
60 |
57 |
|
public abstract ColType getCellValue( RowType rowValue ); |
61 |
58 |
|
|
62 |
|
- |
public <P extends ColumnProperty> P getColumnProperty( ColumnProperty.Type<P> type ) |
63 |
|
- |
{ |
|
59 |
+ |
public <P extends ColumnProperty> P getColumnProperty( ColumnProperty.Type<P> type ) { |
64 |
60 |
|
return properties.getColumnProperty( type ); |
65 |
61 |
|
} |
66 |
62 |
|
|
|
@@ -71,16 +67,14 @@ |
71 |
67 |
|
* |
72 |
68 |
|
* @return the footer for the given row |
73 |
69 |
|
*/ |
74 |
|
- |
public Object getFooter( int row ) |
75 |
|
- |
{ |
|
70 |
+ |
public Object getFooter( int row ) { |
76 |
71 |
|
return getColumnProperty( FooterProperty.TYPE ).getFooter( row ); |
77 |
72 |
|
} |
78 |
73 |
|
|
79 |
74 |
|
/** |
80 |
75 |
|
* @return get the number of footers below the column |
81 |
76 |
|
*/ |
82 |
|
- |
public int getFooterCount() |
83 |
|
- |
{ |
|
77 |
+ |
public int getFooterCount() { |
84 |
78 |
|
return getColumnProperty( FooterProperty.TYPE ).getFooterCount(); |
85 |
79 |
|
} |
86 |
80 |
|
|
|
@@ -91,16 +85,14 @@ |
91 |
85 |
|
* |
92 |
86 |
|
* @return the header for the given row |
93 |
87 |
|
*/ |
94 |
|
- |
public Object getHeader( int row ) |
95 |
|
- |
{ |
|
88 |
+ |
public Object getHeader( int row ) { |
96 |
89 |
|
return getColumnProperty( HeaderProperty.TYPE ).getHeader( row ); |
97 |
90 |
|
} |
98 |
91 |
|
|
99 |
92 |
|
/** |
100 |
93 |
|
* @return get the number of headers above the column |
101 |
94 |
|
*/ |
102 |
|
- |
public int getHeaderCount() |
103 |
|
- |
{ |
|
95 |
+ |
public int getHeaderCount() { |
104 |
96 |
|
return getColumnProperty( HeaderProperty.TYPE ).getHeaderCount(); |
105 |
97 |
|
} |
106 |
98 |
|
|
|
@@ -111,8 +103,7 @@ |
111 |
103 |
|
* |
112 |
104 |
|
* @return the maximum allowable width of the column |
113 |
105 |
|
*/ |
114 |
|
- |
public int getMaximumColumnWidth() |
115 |
|
- |
{ |
|
106 |
+ |
public int getMaximumColumnWidth() { |
116 |
107 |
|
return getColumnProperty( MaximumWidthProperty.TYPE ).getMaximumColumnWidth(); |
117 |
108 |
|
} |
118 |
109 |
|
|
|
@@ -123,8 +114,7 @@ |
123 |
114 |
|
* |
124 |
115 |
|
* @return the minimum allowable width of the column |
125 |
116 |
|
*/ |
126 |
|
- |
public int getMinimumColumnWidth() |
127 |
|
- |
{ |
|
117 |
+ |
public int getMinimumColumnWidth() { |
128 |
118 |
|
return getColumnProperty( MinimumWidthProperty.TYPE ).getMinimumColumnWidth(); |
129 |
119 |
|
} |
130 |
120 |
|
|
|
@@ -136,8 +126,7 @@ |
136 |
126 |
|
* |
137 |
127 |
|
* @return the preferred width of the column |
138 |
128 |
|
*/ |
139 |
|
- |
public int getPreferredColumnWidth() |
140 |
|
- |
{ |
|
129 |
+ |
public int getPreferredColumnWidth() { |
141 |
130 |
|
return getColumnProperty( PreferredWidthProperty.TYPE ).getPreferredColumnWidth(); |
142 |
131 |
|
} |
143 |
132 |
|
|
|
@@ -146,32 +135,28 @@ |
146 |
135 |
|
* |
147 |
136 |
|
* @return true if the column is sortable, false if it is not sortable |
148 |
137 |
|
*/ |
149 |
|
- |
public boolean isColumnSortable() |
150 |
|
- |
{ |
|
138 |
+ |
public boolean isColumnSortable() { |
151 |
139 |
|
return getColumnProperty( SortableProperty.TYPE ).isColumnSortable(); |
152 |
140 |
|
} |
153 |
141 |
|
|
154 |
142 |
|
/** |
155 |
143 |
|
* @return true if the column is truncatable, false if not |
156 |
144 |
|
*/ |
157 |
|
- |
public boolean isColumnTruncatable() |
158 |
|
- |
{ |
|
145 |
+ |
public boolean isColumnTruncatable() { |
159 |
146 |
|
return getColumnProperty( TruncationProperty.TYPE ).isColumnTruncatable(); |
160 |
147 |
|
} |
161 |
148 |
|
|
162 |
149 |
|
/** |
163 |
150 |
|
* @return true if the footer table is truncatable, false if not |
164 |
151 |
|
*/ |
165 |
|
- |
public boolean isFooterTruncatable() |
166 |
|
- |
{ |
|
152 |
+ |
public boolean isFooterTruncatable() { |
167 |
153 |
|
return getColumnProperty( TruncationProperty.TYPE ).isFooterTruncatable(); |
168 |
154 |
|
} |
169 |
155 |
|
|
170 |
156 |
|
/** |
171 |
157 |
|
* @return true if the header table is truncatable, false if not |
172 |
158 |
|
*/ |
173 |
|
- |
public boolean isHeaderTruncatable() |
174 |
|
- |
{ |
|
159 |
+ |
public boolean isHeaderTruncatable() { |
175 |
160 |
|
return getColumnProperty( TruncationProperty.TYPE ).isHeaderTruncatable(); |
176 |
161 |
|
} |
177 |
162 |
|
|
|
@@ -180,8 +165,7 @@ |
180 |
165 |
|
* |
181 |
166 |
|
* @param type the type of the property to remove |
182 |
167 |
|
*/ |
183 |
|
- |
public <P extends ColumnProperty> P removeColumnProperty( ColumnProperty.Type<P> type ) |
184 |
|
- |
{ |
|
168 |
+ |
public <P extends ColumnProperty> P removeColumnProperty( ColumnProperty.Type<P> type ) { |
185 |
169 |
|
return properties.removeColumnProperty( type ); |
186 |
170 |
|
} |
187 |
171 |
|
|
|
@@ -191,8 +175,7 @@ |
191 |
175 |
|
* |
192 |
176 |
|
* @param cellEditor the {@link CellEditor} to use for this column |
193 |
177 |
|
*/ |
194 |
|
- |
public void setCellEditor( CellEditor<ColType> cellEditor ) |
195 |
|
- |
{ |
|
178 |
+ |
public void setCellEditor( CellEditor<ColType> cellEditor ) { |
196 |
179 |
|
this.cellEditor = cellEditor; |
197 |
180 |
|
} |
198 |
181 |
|
|
|
@@ -202,8 +185,7 @@ |
202 |
185 |
|
* |
203 |
186 |
|
* @param cellRenderer the {@link CellRenderer} to use for this column |
204 |
187 |
|
*/ |
205 |
|
- |
public void setCellRenderer( CellRenderer<RowType, ColType> cellRenderer ) |
206 |
|
- |
{ |
|
188 |
+ |
public void setCellRenderer( CellRenderer<RowType, ColType> cellRenderer ) { |
207 |
189 |
|
assert cellRenderer != null : "cellRenderer cannot be null"; |
208 |
190 |
|
this.cellRenderer = cellRenderer; |
209 |
191 |
|
} |
|
@@ -217,8 +199,7 @@ |
217 |
199 |
|
* @param type the {@link ColumnProperty} type |
218 |
200 |
|
* @param property the property to set |
219 |
201 |
|
*/ |
220 |
|
- |
public <P extends ColumnProperty> void setColumnProperty( ColumnProperty.Type<P> type, P property ) |
221 |
|
- |
{ |
|
202 |
+ |
public <P extends ColumnProperty> void setColumnProperty( ColumnProperty.Type<P> type, P property ) { |
222 |
203 |
|
properties.setColumnProperty( type, property ); |
223 |
204 |
|
} |
224 |
205 |
|
|
|
@@ -227,8 +208,7 @@ |
227 |
208 |
|
* |
228 |
209 |
|
* @param sortable true to make sortable, false to make unsortable |
229 |
210 |
|
*/ |
230 |
|
- |
public void setColumnSortable( boolean sortable ) |
231 |
|
- |
{ |
|
211 |
+ |
public void setColumnSortable( boolean sortable ) { |
232 |
212 |
|
setColumnProperty( SortableProperty.TYPE, new SortableProperty( sortable ) ); |
233 |
213 |
|
} |
234 |
214 |
|
|
|
@@ -237,16 +217,12 @@ |
237 |
217 |
|
* |
238 |
218 |
|
* @param truncatable true to make truncatable, false to make non truncatable |
239 |
219 |
|
*/ |
240 |
|
- |
public void setColumnTruncatable( boolean truncatable ) |
241 |
|
- |
{ |
|
220 |
+ |
public void setColumnTruncatable( boolean truncatable ) { |
242 |
221 |
|
TruncationProperty prop = properties.getColumnProperty( TruncationProperty.TYPE, false ); |
243 |
|
- |
if ( prop == null ) |
244 |
|
- |
{ |
|
222 |
+ |
if ( prop == null ) { |
245 |
223 |
|
prop = new TruncationProperty( truncatable ); |
246 |
224 |
|
setColumnProperty( TruncationProperty.TYPE, prop ); |
247 |
|
- |
} |
248 |
|
- |
else |
249 |
|
- |
{ |
|
225 |
+ |
} else { |
250 |
226 |
|
prop.setColumnTruncatable( truncatable ); |
251 |
227 |
|
} |
252 |
228 |
|
} |
|
@@ -259,11 +235,9 @@ |
259 |
235 |
|
* @param row the row index from the top |
260 |
236 |
|
* @param footer the footer |
261 |
237 |
|
*/ |
262 |
|
- |
public void setFooter( int row, Object footer ) |
263 |
|
- |
{ |
|
238 |
+ |
public void setFooter( int row, Object footer ) { |
264 |
239 |
|
FooterProperty prop = properties.getColumnProperty( FooterProperty.TYPE, false ); |
265 |
|
- |
if ( prop == null ) |
266 |
|
- |
{ |
|
240 |
+ |
if ( prop == null ) { |
267 |
241 |
|
prop = new FooterProperty(); |
268 |
242 |
|
setColumnProperty( FooterProperty.TYPE, prop ); |
269 |
243 |
|
} |
|
@@ -275,11 +249,9 @@ |
275 |
249 |
|
* |
276 |
250 |
|
* @param footerCount the number of footers |
277 |
251 |
|
*/ |
278 |
|
- |
public void setFooterCount( int footerCount ) |
279 |
|
- |
{ |
|
252 |
+ |
public void setFooterCount( int footerCount ) { |
280 |
253 |
|
FooterProperty prop = properties.getColumnProperty( FooterProperty.TYPE, false ); |
281 |
|
- |
if ( prop == null ) |
282 |
|
- |
{ |
|
254 |
+ |
if ( prop == null ) { |
283 |
255 |
|
prop = new FooterProperty(); |
284 |
256 |
|
setColumnProperty( FooterProperty.TYPE, prop ); |
285 |
257 |
|
} |
|
@@ -291,11 +263,9 @@ |
291 |
263 |
|
* |
292 |
264 |
|
* @param truncatable true to make truncatable, false to make non truncatable |
293 |
265 |
|
*/ |
294 |
|
- |
public void setFooterTruncatable( boolean truncatable ) |
295 |
|
- |
{ |
|
266 |
+ |
public void setFooterTruncatable( boolean truncatable ) { |
296 |
267 |
|
TruncationProperty prop = properties.getColumnProperty( TruncationProperty.TYPE, false ); |
297 |
|
- |
if ( prop == null ) |
298 |
|
- |
{ |
|
268 |
+ |
if ( prop == null ) { |
299 |
269 |
|
prop = new TruncationProperty(); |
300 |
270 |
|
setColumnProperty( TruncationProperty.TYPE, prop ); |
301 |
271 |
|
} |
|
@@ -310,11 +280,9 @@ |
310 |
280 |
|
* @param row the row index from the bottom |
311 |
281 |
|
* @param header the header |
312 |
282 |
|
*/ |
313 |
|
- |
public void setHeader( int row, Object header ) |
314 |
|
- |
{ |
|
283 |
+ |
public void setHeader( int row, Object header ) { |
315 |
284 |
|
HeaderProperty prop = properties.getColumnProperty( HeaderProperty.TYPE, false ); |
316 |
|
- |
if ( prop == null ) |
317 |
|
- |
{ |
|
285 |
+ |
if ( prop == null ) { |
318 |
286 |
|
prop = new HeaderProperty(); |
319 |
287 |
|
setColumnProperty( HeaderProperty.TYPE, prop ); |
320 |
288 |
|
} |
|
@@ -326,11 +294,9 @@ |
326 |
294 |
|
* |
327 |
295 |
|
* @param headerCount the number of headers |
328 |
296 |
|
*/ |
329 |
|
- |
public void setHeaderCount( int headerCount ) |
330 |
|
- |
{ |
|
297 |
+ |
public void setHeaderCount( int headerCount ) { |
331 |
298 |
|
HeaderProperty prop = properties.getColumnProperty( HeaderProperty.TYPE, false ); |
332 |
|
- |
if ( prop == null ) |
333 |
|
- |
{ |
|
299 |
+ |
if ( prop == null ) { |
334 |
300 |
|
prop = new HeaderProperty(); |
335 |
301 |
|
setColumnProperty( HeaderProperty.TYPE, prop ); |
336 |
302 |
|
} |
|
@@ -342,11 +308,9 @@ |
342 |
308 |
|
* |
343 |
309 |
|
* @param truncatable true to make truncatable, false to make non truncatable |
344 |
310 |
|
*/ |
345 |
|
- |
public void setHeaderTruncatable( boolean truncatable ) |
346 |
|
- |
{ |
|
311 |
+ |
public void setHeaderTruncatable( boolean truncatable ) { |
347 |
312 |
|
TruncationProperty prop = properties.getColumnProperty( TruncationProperty.TYPE, false ); |
348 |
|
- |
if ( prop == null ) |
349 |
|
- |
{ |
|
313 |
+ |
if ( prop == null ) { |
350 |
314 |
|
prop = new TruncationProperty(); |
351 |
315 |
|
setColumnProperty( TruncationProperty.TYPE, prop ); |
352 |
316 |
|
} |
|
@@ -358,8 +322,7 @@ |
358 |
322 |
|
* |
359 |
323 |
|
* @param maxWidth the max width |
360 |
324 |
|
*/ |
361 |
|
- |
public void setMaximumColumnWidth( int maxWidth ) |
362 |
|
- |
{ |
|
325 |
+ |
public void setMaximumColumnWidth( int maxWidth ) { |
363 |
326 |
|
setColumnProperty( MaximumWidthProperty.TYPE, new MaximumWidthProperty( maxWidth ) ); |
364 |
327 |
|
} |
365 |
328 |
|
|
|
@@ -368,8 +331,7 @@ |
368 |
331 |
|
* |
369 |
332 |
|
* @param minWidth the min width |
370 |
333 |
|
*/ |
371 |
|
- |
public void setMinimumColumnWidth( int minWidth ) |
372 |
|
- |
{ |
|
334 |
+ |
public void setMinimumColumnWidth( int minWidth ) { |
373 |
335 |
|
setColumnProperty( MinimumWidthProperty.TYPE, new MinimumWidthProperty( minWidth ) ); |
374 |
336 |
|
} |
375 |
337 |
|
|
|
@@ -380,8 +342,7 @@ |
380 |
342 |
|
* |
381 |
343 |
|
* @see #getPreferredColumnWidth() |
382 |
344 |
|
*/ |
383 |
|
- |
public void setPreferredColumnWidth( int preferredWidth ) |
384 |
|
- |
{ |
|
345 |
+ |
public void setPreferredColumnWidth( int preferredWidth ) { |
385 |
346 |
|
setColumnProperty( PreferredWidthProperty.TYPE, new PreferredWidthProperty( preferredWidth ) ); |
386 |
347 |
|
} |
387 |
348 |
|
} |