|
@@ -23,8 +23,7 @@ |
23 |
23 |
|
* |
24 |
24 |
|
* @param <RowType> the type of the row values |
25 |
25 |
|
*/ |
26 |
|
- |
public class DefaultTableDefinition<RowType> implements TableDefinition<RowType> |
27 |
|
- |
{ |
|
26 |
+ |
public class DefaultTableDefinition<RowType> implements TableDefinition<RowType> { |
28 |
27 |
|
/** |
29 |
28 |
|
* The default {@link RowRenderer} to use when the |
30 |
29 |
|
* {@link DefaultTableDefinition} does not specify one. |
|
@@ -50,8 +49,7 @@ |
50 |
49 |
|
/** |
51 |
50 |
|
* Create a new {@link TableDefinition}. |
52 |
51 |
|
*/ |
53 |
|
- |
public DefaultTableDefinition() |
54 |
|
- |
{ |
|
52 |
+ |
public DefaultTableDefinition() { |
55 |
53 |
|
this( new ArrayList<ColumnDefinition<RowType, ?>>() ); |
56 |
54 |
|
} |
57 |
55 |
|
|
|
@@ -61,8 +59,7 @@ |
61 |
59 |
|
* |
62 |
60 |
|
* @param columnDefs the {@link ColumnDefinition ColumnDefinitions} to render |
63 |
61 |
|
*/ |
64 |
|
- |
public DefaultTableDefinition( List<ColumnDefinition<RowType, ?>> columnDefs ) |
65 |
|
- |
{ |
|
62 |
+ |
public DefaultTableDefinition( List<ColumnDefinition<RowType, ?>> columnDefs ) { |
66 |
63 |
|
this.columnDefs = columnDefs; |
67 |
64 |
|
hiddenColumnDefs = new HashSet<ColumnDefinition<RowType, ?>>(); |
68 |
65 |
|
} |
|
@@ -72,8 +69,7 @@ |
72 |
69 |
|
* |
73 |
70 |
|
* @param columnDef the {@link ColumnDefinition} to add |
74 |
71 |
|
*/ |
75 |
|
- |
public void addColumnDefinition( ColumnDefinition<RowType, ?> columnDef ) |
76 |
|
- |
{ |
|
72 |
+ |
public void addColumnDefinition( ColumnDefinition<RowType, ?> columnDef ) { |
77 |
73 |
|
columnDefs.add( columnDef ); |
78 |
74 |
|
} |
79 |
75 |
|
|
|
@@ -83,8 +79,7 @@ |
83 |
79 |
|
* @param index the index to place the {@link ColumnDefinition} |
84 |
80 |
|
* @param columnDef the {@link ColumnDefinition} to add |
85 |
81 |
|
*/ |
86 |
|
- |
public void addColumnDefinition( int index, ColumnDefinition<RowType, ?> columnDef ) |
87 |
|
- |
{ |
|
82 |
+ |
public void addColumnDefinition( int index, ColumnDefinition<RowType, ?> columnDef ) { |
88 |
83 |
|
columnDefs.add( index, columnDef ); |
89 |
84 |
|
} |
90 |
85 |
|
|
|
@@ -98,31 +93,25 @@ |
98 |
93 |
|
* @throws IndexOutOfBoundsException if the column is not defined |
99 |
94 |
|
*/ |
100 |
95 |
|
public ColumnDefinition<RowType, ?> getColumnDefinition( int column ) |
101 |
|
- |
throws IndexOutOfBoundsException |
102 |
|
- |
{ |
|
96 |
+ |
throws IndexOutOfBoundsException { |
103 |
97 |
|
return columnDefs.get( column ); |
104 |
98 |
|
} |
105 |
99 |
|
|
106 |
100 |
|
/** |
107 |
101 |
|
* @return the number of {@link ColumnDefinition ColumnDefinitions}. |
108 |
102 |
|
*/ |
109 |
|
- |
public int getColumnDefinitionCount() |
110 |
|
- |
{ |
|
103 |
+ |
public int getColumnDefinitionCount() { |
111 |
104 |
|
return columnDefs.size(); |
112 |
105 |
|
} |
113 |
106 |
|
|
114 |
|
- |
public RowRenderer<RowType> getRowRenderer() |
115 |
|
- |
{ |
|
107 |
+ |
public RowRenderer<RowType> getRowRenderer() { |
116 |
108 |
|
return rowRenderer; |
117 |
109 |
|
} |
118 |
110 |
|
|
119 |
|
- |
public List<ColumnDefinition<RowType, ?>> getVisibleColumnDefinitions() |
120 |
|
- |
{ |
|
111 |
+ |
public List<ColumnDefinition<RowType, ?>> getVisibleColumnDefinitions() { |
121 |
112 |
|
List<ColumnDefinition<RowType, ?>> visibleColumns = new ArrayList<ColumnDefinition<RowType, ?>>(); |
122 |
|
- |
for ( ColumnDefinition<RowType, ?> columnDef : columnDefs ) |
123 |
|
- |
{ |
124 |
|
- |
if ( isColumnVisible( columnDef ) ) |
125 |
|
- |
{ |
|
113 |
+ |
for ( ColumnDefinition<RowType, ?> columnDef : columnDefs ) { |
|
114 |
+ |
if ( isColumnVisible( columnDef ) ) { |
126 |
115 |
|
visibleColumns.add( columnDef ); |
127 |
116 |
|
} |
128 |
117 |
|
} |
|
@@ -136,8 +125,7 @@ |
136 |
125 |
|
* |
137 |
126 |
|
* @return true if visible, false if hidden |
138 |
127 |
|
*/ |
139 |
|
- |
public boolean isColumnVisible( ColumnDefinition<RowType, ?> colDef ) |
140 |
|
- |
{ |
|
128 |
+ |
public boolean isColumnVisible( ColumnDefinition<RowType, ?> colDef ) { |
141 |
129 |
|
return !hiddenColumnDefs.contains( colDef ); |
142 |
130 |
|
} |
143 |
131 |
|
|
|
@@ -146,13 +134,11 @@ |
146 |
134 |
|
* |
147 |
135 |
|
* @param columnDef the {@link ColumnDefinition} to remove |
148 |
136 |
|
*/ |
149 |
|
- |
public void removeColumnDefinition( ColumnDefinition<RowType, ?> columnDef ) |
150 |
|
- |
{ |
|
137 |
+ |
public void removeColumnDefinition( ColumnDefinition<RowType, ?> columnDef ) { |
151 |
138 |
|
columnDefs.remove( columnDef ); |
152 |
139 |
|
} |
153 |
140 |
|
|
154 |
|
- |
public void renderRows( int startRowIndex, Iterator<RowType> rowValues, AbstractRowView<RowType> view ) |
155 |
|
- |
{ |
|
141 |
+ |
public void renderRows( int startRowIndex, Iterator<RowType> rowValues, AbstractRowView<RowType> view ) { |
156 |
142 |
|
List<ColumnDefinition<RowType, ?>> visibleColumns = getVisibleColumnDefinitions(); |
157 |
143 |
|
view.renderRowsImpl( startRowIndex, rowValues, rowRenderer, visibleColumns ); |
158 |
144 |
|
} |
|
@@ -163,14 +149,10 @@ |
163 |
149 |
|
* @param colDef the {@link ColumnDefinition} |
164 |
150 |
|
* @param visible true to show it, false to hide |
165 |
151 |
|
*/ |
166 |
|
- |
public void setColumnVisible( ColumnDefinition<RowType, ?> colDef, boolean visible ) |
167 |
|
- |
{ |
168 |
|
- |
if ( visible ) |
169 |
|
- |
{ |
|
152 |
+ |
public void setColumnVisible( ColumnDefinition<RowType, ?> colDef, boolean visible ) { |
|
153 |
+ |
if ( visible ) { |
170 |
154 |
|
hiddenColumnDefs.remove( colDef ); |
171 |
|
- |
} |
172 |
|
- |
else |
173 |
|
- |
{ |
|
155 |
+ |
} else { |
174 |
156 |
|
hiddenColumnDefs.add( colDef ); |
175 |
157 |
|
} |
176 |
158 |
|
} |
|
@@ -178,8 +160,7 @@ |
178 |
160 |
|
/** |
179 |
161 |
|
* Set the {@link RowRenderer} used to render rows. |
180 |
162 |
|
*/ |
181 |
|
- |
public void setRowRenderer( RowRenderer<RowType> rowRenderer ) |
182 |
|
- |
{ |
|
163 |
+ |
public void setRowRenderer( RowRenderer<RowType> rowRenderer ) { |
183 |
164 |
|
assert rowRenderer != null : "rowRenderer cannot be null"; |
184 |
165 |
|
this.rowRenderer = rowRenderer; |
185 |
166 |
|
} |