|
@@ -15,8 +15,6 @@ |
15 |
15 |
|
*/ |
16 |
16 |
|
package com.google.gwt.gen2.table.client; |
17 |
17 |
|
|
18 |
|
- |
import java.util.*; |
19 |
|
- |
|
20 |
18 |
|
import org.litesoft.commonfoundation.html.*; |
21 |
19 |
|
|
22 |
20 |
|
import com.google.gwt.core.client.*; |
|
@@ -33,6 +31,8 @@ |
33 |
31 |
|
import com.google.gwt.user.client.ui.*; |
34 |
32 |
|
import com.google.gwt.widgetideas.client.*; |
35 |
33 |
|
|
|
34 |
+ |
import java.util.*; |
|
35 |
+ |
|
36 |
36 |
|
/** |
37 |
37 |
|
* <p> |
38 |
38 |
|
* A ScrollTable consists of a fixed header and footer (optional) that remain |
|
@@ -76,13 +76,11 @@ |
76 |
76 |
|
* </dl> |
77 |
77 |
|
*/ |
78 |
78 |
|
public abstract class AbstractScrollTable extends Gen2TableComplexPanel implements ResizableWidget, |
79 |
|
- |
HasScrollHandlers |
80 |
|
- |
{ |
|
79 |
+ |
HasScrollHandlers { |
81 |
80 |
|
/** |
82 |
81 |
|
* Browser specific implementation class for {@link AbstractScrollTable}. |
83 |
82 |
|
*/ |
84 |
|
- |
private static class Impl |
85 |
|
- |
{ |
|
83 |
+ |
private static class Impl { |
86 |
84 |
|
/** |
87 |
85 |
|
* Create a spacer element that allows the header table to scroll over the |
88 |
86 |
|
* vertical scroll bar of the data table. |
|
@@ -91,8 +89,7 @@ |
91 |
89 |
|
* |
92 |
90 |
|
* @return the spacer element |
93 |
91 |
|
*/ |
94 |
|
- |
public Element createSpacer( FixedWidthFlexTable table, Element wrapper ) |
95 |
|
- |
{ |
|
92 |
+ |
public Element createSpacer( FixedWidthFlexTable table, Element wrapper ) { |
96 |
93 |
|
resizeSpacer( table, null, 15 ); |
97 |
94 |
|
return null; |
98 |
95 |
|
} |
|
@@ -105,14 +102,11 @@ |
105 |
102 |
|
* |
106 |
103 |
|
* @return the width |
107 |
104 |
|
*/ |
108 |
|
- |
public int getTableWidth( FixedWidthFlexTable table, boolean includeSpacer ) |
109 |
|
- |
{ |
|
105 |
+ |
public int getTableWidth( FixedWidthFlexTable table, boolean includeSpacer ) { |
110 |
106 |
|
int scrollWidth = table.getElement().getScrollWidth(); |
111 |
|
- |
if ( !includeSpacer ) |
112 |
|
- |
{ |
|
107 |
+ |
if ( !includeSpacer ) { |
113 |
108 |
|
int spacerWidth = getSpacerWidth( table ); |
114 |
|
- |
if ( spacerWidth > 0 ) |
115 |
|
- |
{ |
|
109 |
+ |
if ( spacerWidth > 0 ) { |
116 |
110 |
|
scrollWidth -= spacerWidth; |
117 |
111 |
|
} |
118 |
112 |
|
} |
|
@@ -125,8 +119,7 @@ |
125 |
119 |
|
* @param scrollTable the scroll table |
126 |
120 |
|
* @param command an optional command to execute while recalculating |
127 |
121 |
|
*/ |
128 |
|
- |
public void recalculateIdealColumnWidths( AbstractScrollTable scrollTable, Command command ) |
129 |
|
- |
{ |
|
122 |
+ |
public void recalculateIdealColumnWidths( AbstractScrollTable scrollTable, Command command ) { |
130 |
123 |
|
FixedWidthFlexTable headerTable = scrollTable.getHeaderTable(); |
131 |
124 |
|
FixedWidthFlexTable footerTable = scrollTable.getFooterTable(); |
132 |
125 |
|
FixedWidthGrid dataTable = scrollTable.getDataTable(); |
|
@@ -134,30 +127,26 @@ |
134 |
127 |
|
// Setup all inner tables |
135 |
128 |
|
dataTable.recalculateIdealColumnWidthsSetup(); |
136 |
129 |
|
headerTable.recalculateIdealColumnWidthsSetup(); |
137 |
|
- |
if ( footerTable != null ) |
138 |
|
- |
{ |
|
130 |
+ |
if ( footerTable != null ) { |
139 |
131 |
|
footerTable.recalculateIdealColumnWidthsSetup(); |
140 |
132 |
|
} |
141 |
133 |
|
|
142 |
134 |
|
// Perform operations |
143 |
135 |
|
dataTable.recalculateIdealColumnWidthsImpl(); |
144 |
136 |
|
headerTable.recalculateIdealColumnWidthsImpl(); |
145 |
|
- |
if ( footerTable != null ) |
146 |
|
- |
{ |
|
137 |
+ |
if ( footerTable != null ) { |
147 |
138 |
|
footerTable.recalculateIdealColumnWidthsImpl(); |
148 |
139 |
|
} |
149 |
140 |
|
|
150 |
141 |
|
// Execute the optional command |
151 |
|
- |
if ( command != null ) |
152 |
|
- |
{ |
|
142 |
+ |
if ( command != null ) { |
153 |
143 |
|
command.execute(); |
154 |
144 |
|
} |
155 |
145 |
|
|
156 |
146 |
|
// Teardown all inner tables |
157 |
147 |
|
dataTable.recalculateIdealColumnWidthsTeardown(); |
158 |
148 |
|
headerTable.recalculateIdealColumnWidthsTeardown(); |
159 |
|
- |
if ( footerTable != null ) |
160 |
|
- |
{ |
|
149 |
+ |
if ( footerTable != null ) { |
161 |
150 |
|
footerTable.recalculateIdealColumnWidthsTeardown(); |
162 |
151 |
|
} |
163 |
152 |
|
} |
|
@@ -168,19 +157,16 @@ |
168 |
157 |
|
* @param scrollTable the scroll table |
169 |
158 |
|
* @param force if true, ignore the scroll policy |
170 |
159 |
|
*/ |
171 |
|
- |
public void repositionSpacer( AbstractScrollTable scrollTable, boolean force ) |
172 |
|
- |
{ |
|
160 |
+ |
public void repositionSpacer( AbstractScrollTable scrollTable, boolean force ) { |
173 |
161 |
|
// Only ScrollPolicy.BOTH has a vertical scroll bar |
174 |
|
- |
if ( !force && scrollTable.scrollPolicy != ScrollPolicy.BOTH ) |
175 |
|
- |
{ |
|
162 |
+ |
if ( !force && scrollTable.scrollPolicy != ScrollPolicy.BOTH ) { |
176 |
163 |
|
return; |
177 |
164 |
|
} |
178 |
165 |
|
|
179 |
166 |
|
Element dataWrapper = scrollTable.dataWrapper; |
180 |
167 |
|
int spacerWidth = dataWrapper.getOffsetWidth() - dataWrapper.getPropertyInt( "clientWidth" ); |
181 |
168 |
|
resizeSpacer( scrollTable.headerTable, scrollTable.headerSpacer, spacerWidth ); |
182 |
|
- |
if ( scrollTable.footerTable != null ) |
183 |
|
- |
{ |
|
169 |
+ |
if ( scrollTable.footerTable != null ) { |
184 |
170 |
|
resizeSpacer( scrollTable.footerTable, scrollTable.footerSpacer, spacerWidth ); |
185 |
171 |
|
} |
186 |
172 |
|
} |
|
@@ -188,25 +174,19 @@ |
188 |
174 |
|
/** |
189 |
175 |
|
* @return true if the scroll bar is on the right |
190 |
176 |
|
*/ |
191 |
|
- |
boolean isScrollBarOnRight() |
192 |
|
- |
{ |
|
177 |
+ |
boolean isScrollBarOnRight() { |
193 |
178 |
|
return true; |
194 |
179 |
|
} |
195 |
180 |
|
|
196 |
|
- |
void resizeSpacer( FixedWidthFlexTable table, Element spacer, int spacerWidth ) |
197 |
|
- |
{ |
|
181 |
+ |
void resizeSpacer( FixedWidthFlexTable table, Element spacer, int spacerWidth ) { |
198 |
182 |
|
// Exit early if the spacer is already the correct size |
199 |
|
- |
if ( spacerWidth == getSpacerWidth( table ) ) |
200 |
|
- |
{ |
|
183 |
+ |
if ( spacerWidth == getSpacerWidth( table ) ) { |
201 |
184 |
|
return; |
202 |
185 |
|
} |
203 |
186 |
|
|
204 |
|
- |
if ( isScrollBarOnRight() ) |
205 |
|
- |
{ |
|
187 |
+ |
if ( isScrollBarOnRight() ) { |
206 |
188 |
|
table.getElement().getStyle().setPropertyPx( "paddingRight", spacerWidth ); |
207 |
|
- |
} |
208 |
|
- |
else |
209 |
|
- |
{ |
|
189 |
+ |
} else { |
210 |
190 |
|
table.getElement().getStyle().setPropertyPx( "paddingLeft", spacerWidth ); |
211 |
191 |
|
} |
212 |
192 |
|
} |
|
@@ -218,32 +198,25 @@ |
218 |
198 |
|
* |
219 |
199 |
|
* @return the current width |
220 |
200 |
|
*/ |
221 |
|
- |
private int getSpacerWidth( FixedWidthFlexTable table ) |
222 |
|
- |
{ |
|
201 |
+ |
private int getSpacerWidth( FixedWidthFlexTable table ) { |
223 |
202 |
|
// Get the padding string |
224 |
203 |
|
String paddingStr; |
225 |
|
- |
if ( isScrollBarOnRight() ) |
226 |
|
- |
{ |
|
204 |
+ |
if ( isScrollBarOnRight() ) { |
227 |
205 |
|
paddingStr = table.getElement().getStyle().getProperty( "paddingRight" ); |
228 |
|
- |
} |
229 |
|
- |
else |
230 |
|
- |
{ |
|
206 |
+ |
} else { |
231 |
207 |
|
paddingStr = table.getElement().getStyle().getProperty( "paddingLeft" ); |
232 |
208 |
|
} |
233 |
209 |
|
|
234 |
210 |
|
// Check the padding string |
235 |
|
- |
if ( paddingStr == null || paddingStr.length() < 3 ) |
236 |
|
- |
{ |
|
211 |
+ |
if ( paddingStr == null || paddingStr.length() < 3 ) { |
237 |
212 |
|
return -1; |
238 |
213 |
|
} |
239 |
214 |
|
|
240 |
215 |
|
// Parse the int from the padding |
241 |
|
- |
try |
242 |
|
- |
{ |
|
216 |
+ |
try { |
243 |
217 |
|
return Integer.parseInt( paddingStr.substring( 0, paddingStr.length() - 2 ) ); |
244 |
218 |
|
} |
245 |
|
- |
catch ( NumberFormatException e ) |
246 |
|
- |
{ |
|
219 |
+ |
catch ( NumberFormatException e ) { |
247 |
220 |
|
return -1; |
248 |
221 |
|
} |
249 |
222 |
|
} |
|
@@ -252,10 +225,9 @@ |
252 |
225 |
|
/** |
253 |
226 |
|
* Opera and Old Mozilla put the scroll bar on the left side in RTL mode. |
254 |
227 |
|
*/ |
255 |
|
- |
private static class ImplLeftScrollBar extends Impl |
256 |
|
- |
{ |
257 |
|
- |
@Override boolean isScrollBarOnRight() |
258 |
|
- |
{ |
|
228 |
+ |
private static class ImplLeftScrollBar extends Impl { |
|
229 |
+ |
@Override |
|
230 |
+ |
boolean isScrollBarOnRight() { |
259 |
231 |
|
return !LocaleInfo.getCurrentLocale().isRTL(); |
260 |
232 |
|
} |
261 |
233 |
|
} |
|
@@ -265,8 +237,7 @@ |
265 |
237 |
|
* doesn't work, so we use a separate element. |
266 |
238 |
|
*/ |
267 |
239 |
|
@SuppressWarnings("unused") |
268 |
|
- |
private static class ImplIE6 extends ImplLeftScrollBar |
269 |
|
- |
{ |
|
240 |
+ |
private static class ImplIE6 extends ImplLeftScrollBar { |
270 |
241 |
|
/** |
271 |
242 |
|
* Adding padding to a table in IE will mess up the layout, so we use an |
272 |
243 |
|
* absolutely positioned div to add padding. In RTL mode, the div needs to |
|
@@ -275,14 +246,12 @@ |
275 |
246 |
|
* number, improving performance. |
276 |
247 |
|
*/ |
277 |
248 |
|
@Override |
278 |
|
- |
public Element createSpacer( FixedWidthFlexTable table, Element wrapper ) |
279 |
|
- |
{ |
|
249 |
+ |
public Element createSpacer( FixedWidthFlexTable table, Element wrapper ) { |
280 |
250 |
|
Element spacer = DOM.createDiv(); |
281 |
251 |
|
spacer.getStyle().setPropertyPx( "height", 1 ); |
282 |
252 |
|
spacer.getStyle().setPropertyPx( "top", 1 ); |
283 |
253 |
|
spacer.getStyle().setProperty( "position", "absolute" ); |
284 |
|
- |
if ( !LocaleInfo.getCurrentLocale().isRTL() ) |
285 |
|
- |
{ |
|
254 |
+ |
if ( !LocaleInfo.getCurrentLocale().isRTL() ) { |
286 |
255 |
|
spacer.getStyle().setPropertyPx( "left", 1 ); |
287 |
256 |
|
spacer.getStyle().setPropertyPx( "width", 10000 ); |
288 |
257 |
|
} |
|
@@ -291,8 +260,7 @@ |
291 |
260 |
|
} |
292 |
261 |
|
|
293 |
262 |
|
@Override |
294 |
|
- |
public int getTableWidth( FixedWidthFlexTable table, boolean includeSpacer ) |
295 |
|
- |
{ |
|
263 |
+ |
public int getTableWidth( FixedWidthFlexTable table, boolean includeSpacer ) { |
296 |
264 |
|
return table.getElement().getScrollWidth(); |
297 |
265 |
|
} |
298 |
266 |
|
|
|
@@ -301,17 +269,15 @@ |
301 |
269 |
|
* width of a parent element. |
302 |
270 |
|
*/ |
303 |
271 |
|
@Override |
304 |
|
- |
public void recalculateIdealColumnWidths( AbstractScrollTable scrollTable, Command command ) |
305 |
|
- |
{ |
|
272 |
+ |
public void recalculateIdealColumnWidths( AbstractScrollTable scrollTable, Command command ) { |
306 |
273 |
|
scrollTable.getAbsoluteElement().getStyle().setPropertyPx( "width", 1 ); |
307 |
274 |
|
super.recalculateIdealColumnWidths( scrollTable, command ); |
308 |
275 |
|
scrollTable.getAbsoluteElement().getStyle().setProperty( "width", "100%" ); |
309 |
276 |
|
} |
310 |
277 |
|
|
311 |
|
- |
@Override void resizeSpacer( FixedWidthFlexTable table, Element spacer, int width ) |
312 |
|
- |
{ |
313 |
|
- |
if ( LocaleInfo.getCurrentLocale().isRTL() ) |
314 |
|
- |
{ |
|
278 |
+ |
@Override |
|
279 |
+ |
void resizeSpacer( FixedWidthFlexTable table, Element spacer, int width ) { |
|
280 |
+ |
if ( LocaleInfo.getCurrentLocale().isRTL() ) { |
315 |
281 |
|
int headerWidth = table.getOffsetWidth(); |
316 |
282 |
|
spacer.getStyle().setPropertyPx( "width", width ); |
317 |
283 |
|
spacer.getStyle().setPropertyPx( "right", headerWidth ); |
|
@@ -323,8 +289,7 @@ |
323 |
289 |
|
* A helper class that handles some of the mouse events associated with |
324 |
290 |
|
* resizing columns. |
325 |
291 |
|
*/ |
326 |
|
- |
private static class MouseResizeWorker |
327 |
|
- |
{ |
|
292 |
+ |
private static class MouseResizeWorker { |
328 |
293 |
|
/** |
329 |
294 |
|
* The width of the area that is available for resize. |
330 |
295 |
|
*/ |
|
@@ -364,11 +329,9 @@ |
364 |
329 |
|
* A timer used to resize the columns. As long as the timer is active, it |
365 |
330 |
|
* will poll for the new row size and resize the columns. |
366 |
331 |
|
*/ |
367 |
|
- |
private Timer resizeTimer = new Timer() |
368 |
|
- |
{ |
|
332 |
+ |
private Timer resizeTimer = new Timer() { |
369 |
333 |
|
@Override |
370 |
|
- |
public void run() |
371 |
|
- |
{ |
|
334 |
+ |
public void run() { |
372 |
335 |
|
resizeColumn(); |
373 |
336 |
|
schedule( 100 ); |
374 |
337 |
|
} |
|
@@ -397,16 +360,14 @@ |
397 |
360 |
|
/** |
398 |
361 |
|
* @return the current cell |
399 |
362 |
|
*/ |
400 |
|
- |
public Element getCurrentCell() |
401 |
|
- |
{ |
|
363 |
+ |
public Element getCurrentCell() { |
402 |
364 |
|
return curCell; |
403 |
365 |
|
} |
404 |
366 |
|
|
405 |
367 |
|
/** |
406 |
368 |
|
* @return true if a header is currently being resized |
407 |
369 |
|
*/ |
408 |
|
- |
public boolean isResizing() |
409 |
|
- |
{ |
|
370 |
+ |
public boolean isResizing() { |
410 |
371 |
|
return resizing; |
411 |
372 |
|
} |
412 |
373 |
|
|
|
@@ -416,8 +377,7 @@ |
416 |
377 |
|
* |
417 |
378 |
|
* @param event the mouse event |
418 |
379 |
|
*/ |
419 |
|
- |
public void resizeColumn( Event event ) |
420 |
|
- |
{ |
|
380 |
+ |
public void resizeColumn( Event event ) { |
421 |
381 |
|
mouseXCurrent = DOM.eventGetClientX( event ); |
422 |
382 |
|
} |
423 |
383 |
|
|
|
@@ -428,62 +388,47 @@ |
428 |
388 |
|
* |
429 |
389 |
|
* @return true if the cell was actually changed |
430 |
390 |
|
*/ |
431 |
|
- |
public boolean setCurrentCell( Event event ) |
432 |
|
- |
{ |
|
391 |
+ |
public boolean setCurrentCell( Event event ) { |
433 |
392 |
|
// Check the resize policy of the table |
434 |
393 |
|
Element cell = null; |
435 |
|
- |
if ( table.columnResizePolicy == ColumnResizePolicy.MULTI_CELL ) |
436 |
|
- |
{ |
|
394 |
+ |
if ( table.columnResizePolicy == ColumnResizePolicy.MULTI_CELL ) { |
437 |
395 |
|
cell = table.headerTable.getEventTargetCell( event ); |
438 |
|
- |
} |
439 |
|
- |
else if ( table.columnResizePolicy == ColumnResizePolicy.SINGLE_CELL ) |
440 |
|
- |
{ |
|
396 |
+ |
} else if ( table.columnResizePolicy == ColumnResizePolicy.SINGLE_CELL ) { |
441 |
397 |
|
cell = table.headerTable.getEventTargetCell( event ); |
442 |
|
- |
if ( cell != null && cell.getPropertyInt( "colSpan" ) > 1 ) |
443 |
|
- |
{ |
|
398 |
+ |
if ( cell != null && cell.getPropertyInt( "colSpan" ) > 1 ) { |
444 |
399 |
|
cell = null; |
445 |
400 |
|
} |
446 |
401 |
|
} |
447 |
402 |
|
|
448 |
403 |
|
// See if we are near the edge of the cell |
449 |
404 |
|
int clientX = event.getClientX(); |
450 |
|
- |
if ( cell != null ) |
451 |
|
- |
{ |
|
405 |
+ |
if ( cell != null ) { |
452 |
406 |
|
int absLeft = cell.getAbsoluteLeft() - Window.getScrollLeft(); |
453 |
|
- |
if ( LocaleInfo.getCurrentLocale().isRTL() ) |
454 |
|
- |
{ |
455 |
|
- |
if ( clientX < absLeft || clientX > absLeft + RESIZE_CURSOR_WIDTH ) |
456 |
|
- |
{ |
|
407 |
+ |
if ( LocaleInfo.getCurrentLocale().isRTL() ) { |
|
408 |
+ |
if ( clientX < absLeft || clientX > absLeft + RESIZE_CURSOR_WIDTH ) { |
457 |
409 |
|
cell = null; |
458 |
410 |
|
} |
459 |
|
- |
} |
460 |
|
- |
else |
461 |
|
- |
{ |
|
411 |
+ |
} else { |
462 |
412 |
|
int absRight = absLeft + cell.getOffsetWidth(); |
463 |
|
- |
if ( clientX < absRight - RESIZE_CURSOR_WIDTH || clientX > absRight ) |
464 |
|
- |
{ |
|
413 |
+ |
if ( clientX < absRight - RESIZE_CURSOR_WIDTH || clientX > absRight ) { |
465 |
414 |
|
cell = null; |
466 |
415 |
|
} |
467 |
416 |
|
} |
468 |
417 |
|
} |
469 |
418 |
|
|
470 |
419 |
|
// Change out the current cell |
471 |
|
- |
if ( cell != curCell ) |
472 |
|
- |
{ |
|
420 |
+ |
if ( cell != curCell ) { |
473 |
421 |
|
// Clear the old cell |
474 |
|
- |
if ( curCell != null ) |
475 |
|
- |
{ |
|
422 |
+ |
if ( curCell != null ) { |
476 |
423 |
|
curCell.getStyle().setProperty( "cursor", "" ); |
477 |
424 |
|
} |
478 |
425 |
|
|
479 |
426 |
|
// Set the new cell |
480 |
427 |
|
curCell = cell; |
481 |
|
- |
if ( curCell != null ) |
482 |
|
- |
{ |
|
428 |
+ |
if ( curCell != null ) { |
483 |
429 |
|
// Check the cell index |
484 |
430 |
|
curCellIndex = getCellIndex( curCell ); |
485 |
|
- |
if ( curCellIndex < 0 ) |
486 |
|
- |
{ |
|
431 |
+ |
if ( curCellIndex < 0 ) { |
487 |
432 |
|
curCell = null; |
488 |
433 |
|
return false; |
489 |
434 |
|
} |
|
@@ -492,15 +437,12 @@ |
492 |
437 |
|
boolean resizable = false; |
493 |
438 |
|
int colSpan = cell.getPropertyInt( "colSpan" ); |
494 |
439 |
|
curCells = table.getColumnWidthInfo( curCellIndex, colSpan ); |
495 |
|
- |
for ( ColumnWidthInfo info : curCells ) |
496 |
|
- |
{ |
497 |
|
- |
if ( !info.hasMaximumWidth() || !info.hasMinimumWidth() || info.getMaximumWidth() != info.getMinimumWidth() ) |
498 |
|
- |
{ |
|
440 |
+ |
for ( ColumnWidthInfo info : curCells ) { |
|
441 |
+ |
if ( !info.hasMaximumWidth() || !info.hasMinimumWidth() || info.getMaximumWidth() != info.getMinimumWidth() ) { |
499 |
442 |
|
resizable = true; |
500 |
443 |
|
} |
501 |
444 |
|
} |
502 |
|
- |
if ( !resizable ) |
503 |
|
- |
{ |
|
445 |
+ |
if ( !resizable ) { |
504 |
446 |
|
curCell = null; |
505 |
447 |
|
curCells = null; |
506 |
448 |
|
return false; |
|
@@ -521,8 +463,7 @@ |
521 |
463 |
|
* |
522 |
464 |
|
* @param table the scroll table |
523 |
465 |
|
*/ |
524 |
|
- |
public void setScrollTable( AbstractScrollTable table ) |
525 |
|
- |
{ |
|
466 |
+ |
public void setScrollTable( AbstractScrollTable table ) { |
526 |
467 |
|
this.table = table; |
527 |
468 |
|
} |
528 |
469 |
|
|
|
@@ -532,10 +473,8 @@ |
532 |
473 |
|
* |
533 |
474 |
|
* @param event the mouse event |
534 |
475 |
|
*/ |
535 |
|
- |
public void startResizing( Event event ) |
536 |
|
- |
{ |
537 |
|
- |
if ( curCell != null ) |
538 |
|
- |
{ |
|
476 |
+ |
public void startResizing( Event event ) { |
|
477 |
+ |
if ( curCell != null ) { |
539 |
478 |
|
resizing = true; |
540 |
479 |
|
mouseXStart = event.getClientX(); |
541 |
480 |
|
mouseXLast = mouseXStart; |
|
@@ -558,10 +497,8 @@ |
558 |
497 |
|
* |
559 |
498 |
|
* @param event the mouse event |
560 |
499 |
|
*/ |
561 |
|
- |
public void stopResizing( Event event ) |
562 |
|
- |
{ |
563 |
|
- |
if ( curCell != null && resizing ) |
564 |
|
- |
{ |
|
500 |
+ |
public void stopResizing( Event event ) { |
|
501 |
+ |
if ( curCell != null && resizing ) { |
565 |
502 |
|
curCell.getStyle().setProperty( "cursor", "" ); |
566 |
503 |
|
curCell = null; |
567 |
504 |
|
resizing = false; |
|
@@ -579,8 +516,7 @@ |
579 |
516 |
|
* |
580 |
517 |
|
* @return the scroll table |
581 |
518 |
|
*/ |
582 |
|
- |
protected AbstractScrollTable getScrollTable() |
583 |
|
- |
{ |
|
519 |
+ |
protected AbstractScrollTable getScrollTable() { |
584 |
520 |
|
return table; |
585 |
521 |
|
} |
586 |
522 |
|
|
|
@@ -591,8 +527,7 @@ |
591 |
527 |
|
* |
592 |
528 |
|
* @return the cell index |
593 |
529 |
|
*/ |
594 |
|
- |
private int getCellIndex( Element cell ) |
595 |
|
- |
{ |
|
530 |
+ |
private int getCellIndex( Element cell ) { |
596 |
531 |
|
int row = OverrideDOM.getRowIndex( DOM.getParent( cell ) ) - 1; |
597 |
532 |
|
int column = OverrideDOM.getCellIndex( cell ); |
598 |
533 |
|
return table.headerTable.getColumnIndex( row, column ) - table.getHeaderOffset(); |
|
@@ -602,28 +537,23 @@ |
602 |
537 |
|
* Helper method that actually sets the column size. This method is called |
603 |
538 |
|
* periodically by a timer. |
604 |
539 |
|
*/ |
605 |
|
- |
private void resizeColumn() |
606 |
|
- |
{ |
607 |
|
- |
if ( mouseXLast != mouseXCurrent ) |
608 |
|
- |
{ |
|
540 |
+ |
private void resizeColumn() { |
|
541 |
+ |
if ( mouseXLast != mouseXCurrent ) { |
609 |
542 |
|
mouseXLast = mouseXCurrent; |
610 |
543 |
|
|
611 |
544 |
|
// Distribute to the cells being resized |
612 |
545 |
|
int totalDelta = mouseXCurrent - mouseXStart; |
613 |
|
- |
if ( LocaleInfo.getCurrentLocale().isRTL() ) |
614 |
|
- |
{ |
|
546 |
+ |
if ( LocaleInfo.getCurrentLocale().isRTL() ) { |
615 |
547 |
|
totalDelta *= -1; |
616 |
548 |
|
} |
617 |
549 |
|
totalDelta -= table.columnResizer.distributeWidth( curCells, totalDelta ); |
618 |
550 |
|
|
619 |
551 |
|
// Distribute to the sacrifice cells |
620 |
|
- |
if ( table.resizePolicy.isSacrificial() ) |
621 |
|
- |
{ |
|
552 |
+ |
if ( table.resizePolicy.isSacrificial() ) { |
622 |
553 |
|
int remaining = table.columnResizer.distributeWidth( sacrificeCells, -totalDelta ); |
623 |
554 |
|
|
624 |
555 |
|
// We don't have enough to sacrifice, redistribute the width |
625 |
|
- |
if ( remaining != 0 && table.resizePolicy.isFixedWidth() ) |
626 |
|
- |
{ |
|
556 |
+ |
if ( remaining != 0 && table.resizePolicy.isFixedWidth() ) { |
627 |
557 |
|
totalDelta += remaining; |
628 |
558 |
|
table.columnResizer.distributeWidth( curCells, totalDelta ); |
629 |
559 |
|
} |
|
@@ -647,8 +577,7 @@ |
647 |
577 |
|
* cursor style is changed. |
648 |
578 |
|
*/ |
649 |
579 |
|
@SuppressWarnings("unused") |
650 |
|
- |
private static class MouseResizeWorkerOpera extends MouseResizeWorker |
651 |
|
- |
{ |
|
580 |
+ |
private static class MouseResizeWorkerOpera extends MouseResizeWorker { |
652 |
581 |
|
/** |
653 |
582 |
|
* A div used to force the cursor to update. |
654 |
583 |
|
*/ |
|
@@ -657,8 +586,7 @@ |
657 |
586 |
|
/** |
658 |
587 |
|
* Constructor. |
659 |
588 |
|
*/ |
660 |
|
- |
public MouseResizeWorkerOpera() |
661 |
|
- |
{ |
|
589 |
+ |
public MouseResizeWorkerOpera() { |
662 |
590 |
|
cursorUpdateDiv = DOM.createDiv(); |
663 |
591 |
|
DOM.setStyleAttribute( cursorUpdateDiv, "position", "absolute" ); |
664 |
592 |
|
} |
|
@@ -671,11 +599,9 @@ |
671 |
599 |
|
* @return true if the cell was actually changed |
672 |
600 |
|
*/ |
673 |
601 |
|
@Override |
674 |
|
- |
public boolean setCurrentCell( Event event ) |
675 |
|
- |
{ |
|
602 |
+ |
public boolean setCurrentCell( Event event ) { |
676 |
603 |
|
// Check if cursor update div is active |
677 |
|
- |
if ( DOM.eventGetTarget( event ) == cursorUpdateDiv ) |
678 |
|
- |
{ |
|
604 |
+ |
if ( DOM.eventGetTarget( event ) == cursorUpdateDiv ) { |
679 |
605 |
|
removeCursorUpdateDiv(); |
680 |
606 |
|
return false; |
681 |
607 |
|
} |
|
@@ -684,8 +610,7 @@ |
684 |
610 |
|
boolean cellChanged = super.setCurrentCell( event ); |
685 |
611 |
|
|
686 |
612 |
|
// Position a div that forces a cursor redraw in Opera |
687 |
|
- |
if ( cellChanged ) |
688 |
|
- |
{ |
|
613 |
+ |
if ( cellChanged ) { |
689 |
614 |
|
DOM.setCapture( getScrollTable().headerWrapper ); |
690 |
615 |
|
DOM.setStyleAttribute( cursorUpdateDiv, "height", (Window.getClientHeight() - 1) + "px" ); |
691 |
616 |
|
DOM.setStyleAttribute( cursorUpdateDiv, "width", (Window.getClientWidth() - 1) + "px" ); |
|
@@ -702,8 +627,7 @@ |
702 |
627 |
|
* @param event the mouse event |
703 |
628 |
|
*/ |
704 |
629 |
|
@Override |
705 |
|
- |
public void startResizing( Event event ) |
706 |
|
- |
{ |
|
630 |
+ |
public void startResizing( Event event ) { |
707 |
631 |
|
removeCursorUpdateDiv(); |
708 |
632 |
|
super.startResizing( event ); |
709 |
633 |
|
} |
|
@@ -711,10 +635,8 @@ |
711 |
635 |
|
/** |
712 |
636 |
|
* Remove the cursor update div from the page. |
713 |
637 |
|
*/ |
714 |
|
- |
private void removeCursorUpdateDiv() |
715 |
|
- |
{ |
716 |
|
- |
if ( DOM.getCaptureElement() != null ) |
717 |
|
- |
{ |
|
638 |
+ |
private void removeCursorUpdateDiv() { |
|
639 |
+ |
if ( DOM.getCaptureElement() != null ) { |
718 |
640 |
|
DOM.removeChild( RootPanel.getBodyElement(), cursorUpdateDiv ); |
719 |
641 |
|
DOM.releaseCapture( getScrollTable().headerWrapper ); |
720 |
642 |
|
} |
|
@@ -724,8 +646,7 @@ |
724 |
646 |
|
/** |
725 |
647 |
|
* Information about the height of the inner tables. |
726 |
648 |
|
*/ |
727 |
|
- |
private class TableHeightInfo |
728 |
|
- |
{ |
|
649 |
+ |
private class TableHeightInfo { |
729 |
650 |
|
private int headerTableHeight; |
730 |
651 |
|
private int dataTableHeight; |
731 |
652 |
|
private int footerTableHeight; |
|
@@ -733,12 +654,10 @@ |
733 |
654 |
|
/** |
734 |
655 |
|
* Construct a new {@link TableHeightInfo}. |
735 |
656 |
|
*/ |
736 |
|
- |
public TableHeightInfo() |
737 |
|
- |
{ |
|
657 |
+ |
public TableHeightInfo() { |
738 |
658 |
|
int totalHeight = DOM.getElementPropertyInt( getElement(), "clientHeight" ); |
739 |
659 |
|
headerTableHeight = headerTable.getOffsetHeight(); |
740 |
|
- |
if ( footerTable != null ) |
741 |
|
- |
{ |
|
660 |
+ |
if ( footerTable != null ) { |
742 |
661 |
|
footerTableHeight = footerTable.getOffsetHeight(); |
743 |
662 |
|
} |
744 |
663 |
|
dataTableHeight = totalHeight - headerTableHeight - footerTableHeight; |
|
@@ -748,8 +667,7 @@ |
748 |
667 |
|
/** |
749 |
668 |
|
* Information about the width of the inner tables. |
750 |
669 |
|
*/ |
751 |
|
- |
private class TableWidthInfo |
752 |
|
- |
{ |
|
670 |
+ |
private class TableWidthInfo { |
753 |
671 |
|
private int headerTableWidth; |
754 |
672 |
|
private int dataTableWidth; |
755 |
673 |
|
private int footerTableWidth; |
|
@@ -760,13 +678,11 @@ |
760 |
678 |
|
* |
761 |
679 |
|
* @param includeSpacer true to include spacer in calculations |
762 |
680 |
|
*/ |
763 |
|
- |
public TableWidthInfo( boolean includeSpacer ) |
764 |
|
- |
{ |
|
681 |
+ |
public TableWidthInfo( boolean includeSpacer ) { |
765 |
682 |
|
availableWidth = getAvailableWidth(); |
766 |
683 |
|
headerTableWidth = impl.getTableWidth( headerTable, includeSpacer ); |
767 |
684 |
|
dataTableWidth = dataTable.getElement().getScrollWidth(); |
768 |
|
- |
if ( footerTable != null ) |
769 |
|
- |
{ |
|
685 |
+ |
if ( footerTable != null ) { |
770 |
686 |
|
footerTableWidth = impl.getTableWidth( footerTable, includeSpacer ); |
771 |
687 |
|
} |
772 |
688 |
|
} |
|
@@ -814,8 +730,7 @@ |
814 |
730 |
|
* <li>MULTI_CELL - All cells can be resized by the user</li> |
815 |
731 |
|
* </ul> |
816 |
732 |
|
*/ |
817 |
|
- |
public static enum ColumnResizePolicy |
818 |
|
- |
{ |
|
733 |
+ |
public static enum ColumnResizePolicy { |
819 |
734 |
|
DISABLED, SINGLE_CELL, MULTI_CELL |
820 |
735 |
|
} |
821 |
736 |
|
|
|
@@ -836,26 +751,22 @@ |
836 |
751 |
|
* available width, even if the widget is resized.</li> |
837 |
752 |
|
* </ul> |
838 |
753 |
|
*/ |
839 |
|
- |
public static enum ResizePolicy |
840 |
|
- |
{ |
|
754 |
+ |
public static enum ResizePolicy { |
841 |
755 |
|
UNCONSTRAINED( false, false ), FLOW( false, true ), FIXED_WIDTH( true, true ), FILL_WIDTH( true, true ); |
842 |
756 |
|
|
843 |
757 |
|
private boolean isSacrificial; |
844 |
758 |
|
private boolean isFixedWidth; |
845 |
759 |
|
|
846 |
|
- |
private ResizePolicy( boolean isFixedWidth, boolean isSacrificial ) |
847 |
|
- |
{ |
|
760 |
+ |
private ResizePolicy( boolean isFixedWidth, boolean isSacrificial ) { |
848 |
761 |
|
this.isFixedWidth = isFixedWidth; |
849 |
762 |
|
this.isSacrificial = isSacrificial; |
850 |
763 |
|
} |
851 |
764 |
|
|
852 |
|
- |
private boolean isFixedWidth() |
853 |
|
- |
{ |
|
765 |
+ |
private boolean isFixedWidth() { |
854 |
766 |
|
return isFixedWidth; |
855 |
767 |
|
} |
856 |
768 |
|
|
857 |
|
- |
private boolean isSacrificial() |
858 |
|
- |
{ |
|
769 |
+ |
private boolean isSacrificial() { |
859 |
770 |
|
return isSacrificial; |
860 |
771 |
|
} |
861 |
772 |
|
} |
|
@@ -869,8 +780,7 @@ |
869 |
780 |
|
* <li>DISABLED - Scrollbars will not appear, even if content doesn't fit</li> |
870 |
781 |
|
* </ul> |
871 |
782 |
|
*/ |
872 |
|
- |
public static enum ScrollPolicy |
873 |
|
- |
{ |
|
783 |
+ |
public static enum ScrollPolicy { |
874 |
784 |
|
HORIZONTAL, BOTH, DISABLED |
875 |
785 |
|
} |
876 |
786 |
|
|
|
@@ -883,8 +793,7 @@ |
883 |
793 |
|
* <li>MULTI_CELL - All cells can be sorted by the user</li> |
884 |
794 |
|
* </ul> |
885 |
795 |
|
*/ |
886 |
|
- |
public static enum SortPolicy |
887 |
|
- |
{ |
|
796 |
+ |
public static enum SortPolicy { |
888 |
797 |
|
DISABLED, SINGLE_CELL, MULTI_CELL |
889 |
798 |
|
} |
890 |
799 |
|
|
|
@@ -1017,8 +926,7 @@ |
1017 |
926 |
|
* @param dataTable the data table |
1018 |
927 |
|
* @param headerTable the header table |
1019 |
928 |
|
*/ |
1020 |
|
- |
public AbstractScrollTable( FixedWidthGrid dataTable, final FixedWidthFlexTable headerTable ) |
1021 |
|
- |
{ |
|
929 |
+ |
public AbstractScrollTable( FixedWidthGrid dataTable, final FixedWidthFlexTable headerTable ) { |
1022 |
930 |
|
this.dataTable = dataTable; |
1023 |
931 |
|
this.headerTable = headerTable; |
1024 |
932 |
|
resizeWorker.setScrollTable( this ); |
|
@@ -1026,8 +934,7 @@ |
1026 |
934 |
|
// Prepare the header and data tables |
1027 |
935 |
|
prepareTable( dataTable, "dataTable" ); |
1028 |
936 |
|
prepareTable( headerTable, "headerTable" ); |
1029 |
|
- |
if ( dataTable.getSelectionPolicy().hasInputColumn() ) |
1030 |
|
- |
{ |
|
937 |
+ |
if ( dataTable.getSelectionPolicy().hasInputColumn() ) { |
1031 |
938 |
|
headerTable.setColumnWidth( 0, dataTable.getInputColumnWidth() ); |
1032 |
939 |
|
} |
1033 |
940 |
|
|
|
@@ -1069,14 +976,11 @@ |
1069 |
976 |
|
absoluteElem.appendChild( mockScrollable ); |
1070 |
977 |
|
|
1071 |
978 |
|
// Create image to fill width |
1072 |
|
- |
fillWidthImage = new Image() |
1073 |
|
- |
{ |
|
979 |
+ |
fillWidthImage = new Image() { |
1074 |
980 |
|
@Override |
1075 |
|
- |
public void onBrowserEvent( Event event ) |
1076 |
|
- |
{ |
|
981 |
+ |
public void onBrowserEvent( Event event ) { |
1077 |
982 |
|
super.onBrowserEvent( event ); |
1078 |
|
- |
if ( DOM.eventGetType( event ) == Event.ONCLICK ) |
1079 |
|
- |
{ |
|
983 |
+ |
if ( DOM.eventGetType( event ) == Event.ONCLICK ) { |
1080 |
984 |
|
fillWidth(); |
1081 |
985 |
|
} |
1082 |
986 |
|
} |
|
@@ -1106,37 +1010,30 @@ |
1106 |
1010 |
|
DOM.sinkEvents( headerWrapper, Event.ONMOUSEMOVE | Event.ONMOUSEDOWN | Event.ONMOUSEUP | Event.ONCLICK ); |
1107 |
1011 |
|
|
1108 |
1012 |
|
// Listen for sorting events in the data table |
1109 |
|
- |
dataTable.addColumnSortHandler( new ColumnSortHandler() |
1110 |
|
- |
{ |
1111 |
|
- |
public void onColumnSorted( ColumnSortEvent event ) |
1112 |
|
- |
{ |
|
1013 |
+ |
dataTable.addColumnSortHandler( new ColumnSortHandler() { |
|
1014 |
+ |
public void onColumnSorted( ColumnSortEvent event ) { |
1113 |
1015 |
|
// Get the primary column and sort order |
1114 |
1016 |
|
int column = -1; |
1115 |
1017 |
|
boolean ascending = true; |
1116 |
1018 |
|
ColumnSortList sortList = event.getColumnSortList(); |
1117 |
|
- |
if ( sortList != null ) |
1118 |
|
- |
{ |
|
1019 |
+ |
if ( sortList != null ) { |
1119 |
1020 |
|
column = sortList.getPrimaryColumn(); |
1120 |
1021 |
|
ascending = sortList.isPrimaryAscending(); |
1121 |
1022 |
|
} |
1122 |
1023 |
|
|
1123 |
1024 |
|
// Remove the sorted column indicator |
1124 |
|
- |
if ( isColumnSortable( column ) ) |
1125 |
|
- |
{ |
|
1025 |
+ |
if ( isColumnSortable( column ) ) { |
1126 |
1026 |
|
Element parent = DOM.getParent( sortedColumnWrapper ); |
1127 |
|
- |
if ( parent != null ) |
1128 |
|
- |
{ |
|
1027 |
+ |
if ( parent != null ) { |
1129 |
1028 |
|
parent.removeChild( sortedColumnWrapper ); |
1130 |
1029 |
|
} |
1131 |
1030 |
|
|
1132 |
1031 |
|
// Re-add the sorted column indicator |
1133 |
|
- |
if ( column < 0 ) |
1134 |
|
- |
{ |
|
1032 |
+ |
if ( column < 0 ) { |
1135 |
1033 |
|
sortedCellIndex = -1; |
1136 |
1034 |
|
sortedRowIndex = -1; |
1137 |
|
- |
} |
1138 |
|
- |
else if ( sortedCellIndex >= 0 && sortedRowIndex >= 0 && headerTable.getRowCount() > sortedRowIndex && headerTable.getCellCount( sortedRowIndex ) > sortedCellIndex ) |
1139 |
|
- |
{ |
|
1035 |
+ |
} else if ( sortedCellIndex >= 0 && sortedRowIndex >= 0 && headerTable.getRowCount() > sortedRowIndex && |
|
1036 |
+ |
headerTable.getCellCount( sortedRowIndex ) > sortedCellIndex ) { |
1140 |
1037 |
|
CellFormatter formatter = headerTable.getCellFormatter(); |
1141 |
1038 |
|
Element td = formatter.getElement( sortedRowIndex, sortedCellIndex ); |
1142 |
1039 |
|
applySortedColumnIndicator( td, ascending ); |
|
@@ -1146,8 +1043,7 @@ |
1146 |
1043 |
|
} ); |
1147 |
1044 |
|
} |
1148 |
1045 |
|
|
1149 |
|
- |
public HandlerRegistration addScrollHandler( ScrollHandler handler ) |
1150 |
|
- |
{ |
|
1046 |
+ |
public HandlerRegistration addScrollHandler( ScrollHandler handler ) { |
1151 |
1047 |
|
return addHandler( ScrollEvent.TYPE, handler ); |
1152 |
1048 |
|
} |
1153 |
1049 |
|
|
|
@@ -1159,8 +1055,7 @@ |
1159 |
1055 |
|
* The {@link AbstractScrollTable} must be visible on the page for this method |
1160 |
1056 |
|
* to work. |
1161 |
1057 |
|
*/ |
1162 |
|
- |
public void fillWidth() |
1163 |
|
- |
{ |
|
1058 |
+ |
public void fillWidth() { |
1164 |
1059 |
|
List<ColumnWidthInfo> colWidths = getFillColumnWidths( null ); |
1165 |
1060 |
|
applyNewColumnWidths( 0, colWidths, false ); |
1166 |
1061 |
|
scrollTables( false ); |
|
@@ -1169,24 +1064,21 @@ |
1169 |
1064 |
|
/** |
1170 |
1065 |
|
* @return the cell padding of the tables, in pixels |
1171 |
1066 |
|
*/ |
1172 |
|
- |
public int getCellPadding() |
1173 |
|
- |
{ |
|
1067 |
+ |
public int getCellPadding() { |
1174 |
1068 |
|
return dataTable.getCellPadding(); |
1175 |
1069 |
|
} |
1176 |
1070 |
|
|
1177 |
1071 |
|
/** |
1178 |
1072 |
|
* @return the cell spacing of the tables, in pixels |
1179 |
1073 |
|
*/ |
1180 |
|
- |
public int getCellSpacing() |
1181 |
|
- |
{ |
|
1074 |
+ |
public int getCellSpacing() { |
1182 |
1075 |
|
return dataTable.getCellSpacing(); |
1183 |
1076 |
|
} |
1184 |
1077 |
|
|
1185 |
1078 |
|
/** |
1186 |
1079 |
|
* @return the column resize policy |
1187 |
1080 |
|
*/ |
1188 |
|
- |
public ColumnResizePolicy getColumnResizePolicy() |
1189 |
|
- |
{ |
|
1081 |
+ |
public ColumnResizePolicy getColumnResizePolicy() { |
1190 |
1082 |
|
return columnResizePolicy; |
1191 |
1083 |
|
} |
1192 |
1084 |
|
|
|
@@ -1197,32 +1089,28 @@ |
1197 |
1089 |
|
* |
1198 |
1090 |
|
* @return the column width in pixels |
1199 |
1091 |
|
*/ |
1200 |
|
- |
public int getColumnWidth( int column ) |
1201 |
|
- |
{ |
|
1092 |
+ |
public int getColumnWidth( int column ) { |
1202 |
1093 |
|
return dataTable.getColumnWidth( column ); |
1203 |
1094 |
|
} |
1204 |
1095 |
|
|
1205 |
1096 |
|
/** |
1206 |
1097 |
|
* @return the data table |
1207 |
1098 |
|
*/ |
1208 |
|
- |
public FixedWidthGrid getDataTable() |
1209 |
|
- |
{ |
|
1099 |
+ |
public FixedWidthGrid getDataTable() { |
1210 |
1100 |
|
return dataTable; |
1211 |
1101 |
|
} |
1212 |
1102 |
|
|
1213 |
1103 |
|
/** |
1214 |
1104 |
|
* @return the footer table |
1215 |
1105 |
|
*/ |
1216 |
|
- |
public FixedWidthFlexTable getFooterTable() |
1217 |
|
- |
{ |
|
1106 |
+ |
public FixedWidthFlexTable getFooterTable() { |
1218 |
1107 |
|
return footerTable; |
1219 |
1108 |
|
} |
1220 |
1109 |
|
|
1221 |
1110 |
|
/** |
1222 |
1111 |
|
* @return the header table |
1223 |
1112 |
|
*/ |
1224 |
|
- |
public FixedWidthFlexTable getHeaderTable() |
1225 |
|
- |
{ |
|
1113 |
+ |
public FixedWidthFlexTable getHeaderTable() { |
1226 |
1114 |
|
return headerTable; |
1227 |
1115 |
|
} |
1228 |
1116 |
|
|
|
@@ -1251,18 +1139,15 @@ |
1251 |
1139 |
|
* |
1252 |
1140 |
|
* @return the tables minimum offset width, or -1 if it cannot be calculated |
1253 |
1141 |
|
*/ |
1254 |
|
- |
public int getMinimumOffsetWidth() |
1255 |
|
- |
{ |
1256 |
|
- |
if ( !isAttached() ) |
1257 |
|
- |
{ |
|
1142 |
+ |
public int getMinimumOffsetWidth() { |
|
1143 |
+ |
if ( !isAttached() ) { |
1258 |
1144 |
|
return -1; |
1259 |
1145 |
|
} |
1260 |
1146 |
|
|
1261 |
1147 |
|
// Determine the width and column count of the largest table |
1262 |
1148 |
|
TableWidthInfo redrawInfo = new TableWidthInfo( true ); |
1263 |
1149 |
|
maybeRecalculateIdealColumnWidths( null ); |
1264 |
|
- |
if ( redrawInfo.availableWidth < 1 ) |
1265 |
|
- |
{ |
|
1150 |
+ |
if ( redrawInfo.availableWidth < 1 ) { |
1266 |
1151 |
|
return -1; |
1267 |
1152 |
|
} |
1268 |
1153 |
|
|
|
@@ -1272,24 +1157,18 @@ |
1272 |
1157 |
|
int numHeaderCols = headerTable.getColumnCount() - getHeaderOffset(); |
1273 |
1158 |
|
int numDataCols = dataTable.getColumnCount(); |
1274 |
1159 |
|
int numFooterCols = (footerTable == null) ? -1 : footerTable.getColumnCount() - getHeaderOffset(); |
1275 |
|
- |
if ( numHeaderCols >= numDataCols && numHeaderCols >= numFooterCols ) |
1276 |
|
- |
{ |
|
1160 |
+ |
if ( numHeaderCols >= numDataCols && numHeaderCols >= numFooterCols ) { |
1277 |
1161 |
|
numColumns = numHeaderCols; |
1278 |
1162 |
|
scrollWidth = redrawInfo.headerTableWidth; |
1279 |
|
- |
} |
1280 |
|
- |
else if ( numFooterCols >= numDataCols && numFooterCols >= numHeaderCols ) |
1281 |
|
- |
{ |
|
1163 |
+ |
} else if ( numFooterCols >= numDataCols && numFooterCols >= numHeaderCols ) { |
1282 |
1164 |
|
numColumns = numFooterCols; |
1283 |
1165 |
|
scrollWidth = redrawInfo.footerTableWidth; |
1284 |
|
- |
} |
1285 |
|
- |
else if ( numDataCols > 0 ) |
1286 |
|
- |
{ |
|
1166 |
+ |
} else if ( numDataCols > 0 ) { |
1287 |
1167 |
|
numColumns = numDataCols; |
1288 |
1168 |
|
scrollWidth = redrawInfo.dataTableWidth; |
1289 |
1169 |
|
} |
1290 |
1170 |
|
} |
1291 |
|
- |
if ( numColumns <= 0 ) |
1292 |
|
- |
{ |
|
1171 |
+ |
if ( numColumns <= 0 ) { |
1293 |
1172 |
|
return -1; |
1294 |
1173 |
|
} |
1295 |
1174 |
|
|
|
@@ -1310,24 +1189,21 @@ |
1310 |
1189 |
|
/** |
1311 |
1190 |
|
* @return the resize policy |
1312 |
1191 |
|
*/ |
1313 |
|
- |
public ResizePolicy getResizePolicy() |
1314 |
|
- |
{ |
|
1192 |
+ |
public ResizePolicy getResizePolicy() { |
1315 |
1193 |
|
return resizePolicy; |
1316 |
1194 |
|
} |
1317 |
1195 |
|
|
1318 |
1196 |
|
/** |
1319 |
1197 |
|
* @return the current scroll policy |
1320 |
1198 |
|
*/ |
1321 |
|
- |
public ScrollPolicy getScrollPolicy() |
1322 |
|
- |
{ |
|
1199 |
+ |
public ScrollPolicy getScrollPolicy() { |
1323 |
1200 |
|
return scrollPolicy; |
1324 |
1201 |
|
} |
1325 |
1202 |
|
|
1326 |
1203 |
|
/** |
1327 |
1204 |
|
* @return the current sort policy |
1328 |
1205 |
|
*/ |
1329 |
|
- |
public SortPolicy getSortPolicy() |
1330 |
|
- |
{ |
|
1206 |
+ |
public SortPolicy getSortPolicy() { |
1331 |
1207 |
|
return sortPolicy; |
1332 |
1208 |
|
} |
1333 |
1209 |
|
|
|
@@ -1374,71 +1250,56 @@ |
1374 |
1250 |
|
public abstract boolean isHeaderColumnTruncatable( int column ); |
1375 |
1251 |
|
|
1376 |
1252 |
|
@Override |
1377 |
|
- |
public void onBrowserEvent( Event event ) |
1378 |
|
- |
{ |
|
1253 |
+ |
public void onBrowserEvent( Event event ) { |
1379 |
1254 |
|
super.onBrowserEvent( event ); |
1380 |
1255 |
|
Element target = DOM.eventGetTarget( event ); |
1381 |
|
- |
switch ( DOM.eventGetType( event ) ) |
1382 |
|
- |
{ |
|
1256 |
+ |
switch ( DOM.eventGetType( event ) ) { |
1383 |
1257 |
|
case Event.ONSCROLL: |
1384 |
1258 |
|
// Reposition the tables on scroll |
1385 |
1259 |
|
lastScrollLeft = dataWrapper.getScrollLeft(); |
1386 |
1260 |
|
scrollTables( false ); |
1387 |
|
- |
if ( dataWrapper.isOrHasChild( target ) ) |
1388 |
|
- |
{ |
|
1261 |
+ |
if ( dataWrapper.isOrHasChild( target ) ) { |
1389 |
1262 |
|
fireEvent( new ScrollEvent( event ) ); |
1390 |
1263 |
|
} |
1391 |
1264 |
|
break; |
1392 |
1265 |
|
|
1393 |
1266 |
|
case Event.ONMOUSEDOWN: |
1394 |
1267 |
|
// Start resizing a header column |
1395 |
|
- |
if ( DOM.eventGetButton( event ) != Event.BUTTON_LEFT ) |
1396 |
|
- |
{ |
|
1268 |
+ |
if ( DOM.eventGetButton( event ) != Event.BUTTON_LEFT ) { |
1397 |
1269 |
|
return; |
1398 |
1270 |
|
} |
1399 |
|
- |
if ( resizeWorker.getCurrentCell() != null ) |
1400 |
|
- |
{ |
|
1271 |
+ |
if ( resizeWorker.getCurrentCell() != null ) { |
1401 |
1272 |
|
DOM.eventPreventDefault( event ); |
1402 |
1273 |
|
DOM.eventCancelBubble( event, true ); |
1403 |
1274 |
|
resizeWorker.startResizing( event ); |
1404 |
1275 |
|
} |
1405 |
1276 |
|
break; |
1406 |
1277 |
|
case Event.ONMOUSEUP: |
1407 |
|
- |
if ( DOM.eventGetButton( event ) != Event.BUTTON_LEFT ) |
1408 |
|
- |
{ |
|
1278 |
+ |
if ( DOM.eventGetButton( event ) != Event.BUTTON_LEFT ) { |
1409 |
1279 |
|
return; |
1410 |
1280 |
|
} |
1411 |
1281 |
|
// Stop resizing the header column |
1412 |
|
- |
if ( resizeWorker.isResizing() ) |
1413 |
|
- |
{ |
|
1282 |
+ |
if ( resizeWorker.isResizing() ) { |
1414 |
1283 |
|
resizeWorker.stopResizing( event ); |
1415 |
|
- |
} |
1416 |
|
- |
else |
1417 |
|
- |
{ |
|
1284 |
+ |
} else { |
1418 |
1285 |
|
// Scroll tables if needed |
1419 |
|
- |
if ( DOM.isOrHasChild( headerWrapper, target ) ) |
1420 |
|
- |
{ |
|
1286 |
+ |
if ( DOM.isOrHasChild( headerWrapper, target ) ) { |
1421 |
1287 |
|
scrollTables( true ); |
1422 |
|
- |
} |
1423 |
|
- |
else |
1424 |
|
- |
{ |
|
1288 |
+ |
} else { |
1425 |
1289 |
|
scrollTables( false ); |
1426 |
1290 |
|
} |
1427 |
1291 |
|
|
1428 |
1292 |
|
// Get the actual column index |
1429 |
1293 |
|
Element cellElem = headerTable.getEventTargetCell( event ); |
1430 |
|
- |
if ( cellElem != null ) |
1431 |
|
- |
{ |
|
1294 |
+ |
if ( cellElem != null ) { |
1432 |
1295 |
|
// Sorting is disabled |
1433 |
|
- |
if ( sortPolicy == SortPolicy.DISABLED ) |
1434 |
|
- |
{ |
|
1296 |
+ |
if ( sortPolicy == SortPolicy.DISABLED ) { |
1435 |
1297 |
|
return; |
1436 |
1298 |
|
} |
1437 |
1299 |
|
|
1438 |
1300 |
|
// Check the colSpan |
1439 |
1301 |
|
int colSpan = cellElem.getPropertyInt( "colSpan" ); |
1440 |
|
- |
if ( colSpan > 1 && getSortPolicy() != SortPolicy.MULTI_CELL ) |
1441 |
|
- |
{ |
|
1302 |
+ |
if ( colSpan > 1 && getSortPolicy() != SortPolicy.MULTI_CELL ) { |
1442 |
1303 |
|
return; |
1443 |
1304 |
|
} |
1444 |
1305 |
|
|
|
@@ -1446,10 +1307,8 @@ |
1446 |
1307 |
|
sortedRowIndex = OverrideDOM.getRowIndex( DOM.getParent( cellElem ) ) - 1; |
1447 |
1308 |
|
sortedCellIndex = OverrideDOM.getCellIndex( cellElem ); |
1448 |
1309 |
|
int column = headerTable.getColumnIndex( sortedRowIndex, sortedCellIndex ) - getHeaderOffset(); |
1449 |
|
- |
if ( column >= 0 && isColumnSortable( column ) ) |
1450 |
|
- |
{ |
1451 |
|
- |
if ( dataTable.getColumnCount() > column && onHeaderSort( sortedRowIndex, column ) ) |
1452 |
|
- |
{ |
|
1310 |
+ |
if ( column >= 0 && isColumnSortable( column ) ) { |
|
1311 |
+ |
if ( dataTable.getColumnCount() > column && onHeaderSort( sortedRowIndex, column ) ) { |
1453 |
1312 |
|
dataTable.sortColumn( column ); |
1454 |
1313 |
|
} |
1455 |
1314 |
|
} |
|
@@ -1458,20 +1317,16 @@ |
1458 |
1317 |
|
break; |
1459 |
1318 |
|
case Event.ONMOUSEMOVE: |
1460 |
1319 |
|
// Resize the header column |
1461 |
|
- |
if ( resizeWorker.isResizing() ) |
1462 |
|
- |
{ |
|
1320 |
+ |
if ( resizeWorker.isResizing() ) { |
1463 |
1321 |
|
resizeWorker.resizeColumn( event ); |
1464 |
|
- |
} |
1465 |
|
- |
else |
1466 |
|
- |
{ |
|
1322 |
+ |
} else { |
1467 |
1323 |
|
resizeWorker.setCurrentCell( event ); |
1468 |
1324 |
|
} |
1469 |
1325 |
|
break; |
1470 |
1326 |
|
case Event.ONMOUSEOUT: |
1471 |
1327 |
|
// Unhighlight if the mouse leaves the table |
1472 |
1328 |
|
Element toElem = DOM.eventGetToElement( event ); |
1473 |
|
- |
if ( toElem == null || !dataWrapper.isOrHasChild( toElem ) ) |
1474 |
|
- |
{ |
|
1329 |
+ |
if ( toElem == null || !dataWrapper.isOrHasChild( toElem ) ) { |
1475 |
1330 |
|
// Check that the coordinates are not directly over the table |
1476 |
1331 |
|
int clientX = event.getClientX() + Window.getScrollLeft(); |
1477 |
1332 |
|
int clientY = event.getClientY() + Window.getScrollTop(); |
|
@@ -1481,8 +1336,7 @@ |
1481 |
1336 |
|
int tableHeight = dataWrapper.getOffsetHeight(); |
1482 |
1337 |
|
int tableBottom = tableTop + tableHeight; |
1483 |
1338 |
|
int tableRight = tableLeft + tableWidth; |
1484 |
|
- |
if ( clientX > tableLeft && clientX < tableRight && clientY > tableTop && clientY < tableBottom ) |
1485 |
|
- |
{ |
|
1339 |
+ |
if ( clientX > tableLeft && clientX < tableRight && clientY > tableTop && clientY < tableBottom ) { |
1486 |
1340 |
|
return; |
1487 |
1341 |
|
} |
1488 |
1342 |
|
|
|
@@ -1499,28 +1353,23 @@ |
1499 |
1353 |
|
* @param width the new client width of the element |
1500 |
1354 |
|
* @param height the new client height of the element |
1501 |
1355 |
|
*/ |
1502 |
|
- |
public void onResize( int width, int height ) |
1503 |
|
- |
{ |
|
1356 |
+ |
public void onResize( int width, int height ) { |
1504 |
1357 |
|
redraw(); |
1505 |
1358 |
|
} |
1506 |
1359 |
|
|
1507 |
1360 |
|
/** |
1508 |
1361 |
|
* Redraw the table. |
1509 |
1362 |
|
*/ |
1510 |
|
- |
public void redraw() |
1511 |
|
- |
{ |
1512 |
|
- |
if ( !isAttached() ) |
1513 |
|
- |
{ |
|
1363 |
+ |
public void redraw() { |
|
1364 |
+ |
if ( !isAttached() ) { |
1514 |
1365 |
|
return; |
1515 |
1366 |
|
} |
1516 |
1367 |
|
|
1517 |
1368 |
|
// Create a command to execute while recalculating widths. Using this |
1518 |
1369 |
|
// command prevents an extra browser layout by grouping read operations. |
1519 |
1370 |
|
TableWidthInfo redrawInfo = new TableWidthInfo( false ); |
1520 |
|
- |
Command command = new Command() |
1521 |
|
- |
{ |
1522 |
|
- |
public void execute() |
1523 |
|
- |
{ |
|
1371 |
+ |
Command command = new Command() { |
|
1372 |
+ |
public void execute() { |
1524 |
1373 |
|
// We update the ResizableWidgetCollection before changing the size of |
1525 |
1374 |
|
// the ScrollTable, because change the size of the scroll table could |
1526 |
1375 |
|
// require an additional layout (ex. if window scroll bars show up). |
|
@@ -1533,12 +1382,9 @@ |
1533 |
1382 |
|
|
1534 |
1383 |
|
// Calculate the new widths of the columns |
1535 |
1384 |
|
List<ColumnWidthInfo> colWidths = null; |
1536 |
|
- |
if ( resizePolicy == ResizePolicy.FILL_WIDTH ) |
1537 |
|
- |
{ |
|
1385 |
+ |
if ( resizePolicy == ResizePolicy.FILL_WIDTH ) { |
1538 |
1386 |
|
colWidths = getFillColumnWidths( redrawInfo ); |
1539 |
|
- |
} |
1540 |
|
- |
else |
1541 |
|
- |
{ |
|
1387 |
+ |
} else { |
1542 |
1388 |
|
colWidths = getBoundedColumnWidths( true ); |
1543 |
1389 |
|
} |
1544 |
1390 |
|
applyNewColumnWidths( 0, colWidths, true ); |
|
@@ -1562,16 +1408,14 @@ |
1562 |
1408 |
|
* @throws UnsupportedOperationException |
1563 |
1409 |
|
*/ |
1564 |
1410 |
|
@Override |
1565 |
|
- |
public boolean remove( Widget child ) |
1566 |
|
- |
{ |
|
1411 |
+ |
public boolean remove( Widget child ) { |
1567 |
1412 |
|
throw new UnsupportedOperationException( "This panel does not support remove()" ); |
1568 |
1413 |
|
} |
1569 |
1414 |
|
|
1570 |
1415 |
|
/** |
1571 |
1416 |
|
* Reset the widths of all columns to their preferred sizes. |
1572 |
1417 |
|
*/ |
1573 |
|
- |
public void resetColumnWidths() |
1574 |
|
- |
{ |
|
1418 |
+ |
public void resetColumnWidths() { |
1575 |
1419 |
|
applyNewColumnWidths( 0, getBoundedColumnWidths( false ), false ); |
1576 |
1420 |
|
scrollTables( false ); |
1577 |
1421 |
|
} |
|
@@ -1581,12 +1425,10 @@ |
1581 |
1425 |
|
* |
1582 |
1426 |
|
* @param padding the cell padding, in pixels |
1583 |
1427 |
|
*/ |
1584 |
|
- |
public void setCellPadding( int padding ) |
1585 |
|
- |
{ |
|
1428 |
+ |
public void setCellPadding( int padding ) { |
1586 |
1429 |
|
headerTable.setCellPadding( padding ); |
1587 |
1430 |
|
dataTable.setCellPadding( padding ); |
1588 |
|
- |
if ( footerTable != null ) |
1589 |
|
- |
{ |
|
1431 |
+ |
if ( footerTable != null ) { |
1590 |
1432 |
|
footerTable.setCellPadding( padding ); |
1591 |
1433 |
|
} |
1592 |
1434 |
|
redraw(); |
|
@@ -1597,12 +1439,10 @@ |
1597 |
1439 |
|
* |
1598 |
1440 |
|
* @param spacing the cell spacing, in pixels |
1599 |
1441 |
|
*/ |
1600 |
|
- |
public void setCellSpacing( int spacing ) |
1601 |
|
- |
{ |
|
1442 |
+ |
public void setCellSpacing( int spacing ) { |
1602 |
1443 |
|
headerTable.setCellSpacing( spacing ); |
1603 |
1444 |
|
dataTable.setCellSpacing( spacing ); |
1604 |
|
- |
if ( footerTable != null ) |
1605 |
|
- |
{ |
|
1445 |
+ |
if ( footerTable != null ) { |
1606 |
1446 |
|
footerTable.setCellSpacing( spacing ); |
1607 |
1447 |
|
} |
1608 |
1448 |
|
redraw(); |
|
@@ -1613,8 +1453,7 @@ |
1613 |
1453 |
|
* |
1614 |
1454 |
|
* @param columnResizePolicy the resize policy |
1615 |
1455 |
|
*/ |
1616 |
|
- |
public void setColumnResizePolicy( ColumnResizePolicy columnResizePolicy ) |
1617 |
|
- |
{ |
|
1456 |
+ |
public void setColumnResizePolicy( ColumnResizePolicy columnResizePolicy ) { |
1618 |
1457 |
|
this.columnResizePolicy = columnResizePolicy; |
1619 |
1458 |
|
updateFillWidthImage(); |
1620 |
1459 |
|
} |
|
@@ -1627,22 +1466,18 @@ |
1627 |
1466 |
|
* |
1628 |
1467 |
|
* @return the new column width |
1629 |
1468 |
|
*/ |
1630 |
|
- |
public int setColumnWidth( int column, int width ) |
1631 |
|
- |
{ |
|
1469 |
+ |
public int setColumnWidth( int column, int width ) { |
1632 |
1470 |
|
// Constrain the size of the column |
1633 |
1471 |
|
ColumnWidthInfo info = getColumnWidthInfo( column ); |
1634 |
|
- |
if ( info.hasMaximumWidth() ) |
1635 |
|
- |
{ |
|
1472 |
+ |
if ( info.hasMaximumWidth() ) { |
1636 |
1473 |
|
width = Math.min( width, info.getMaximumWidth() ); |
1637 |
1474 |
|
} |
1638 |
|
- |
if ( info.hasMinimumWidth() ) |
1639 |
|
- |
{ |
|
1475 |
+ |
if ( info.hasMinimumWidth() ) { |
1640 |
1476 |
|
width = Math.max( width, info.getMinimumWidth() ); |
1641 |
1477 |
|
} |
1642 |
1478 |
|
|
1643 |
1479 |
|
// Try to constrain the size of the grid |
1644 |
|
- |
if ( resizePolicy.isSacrificial() ) |
1645 |
|
- |
{ |
|
1480 |
+ |
if ( resizePolicy.isSacrificial() ) { |
1646 |
1481 |
|
// Get the sacrifice columns |
1647 |
1482 |
|
int sacrificeColumn = column + 1; |
1648 |
1483 |
|
int numColumns = dataTable.getColumnCount(); |
|
@@ -1657,8 +1492,7 @@ |
1657 |
1492 |
|
applyNewColumnWidths( sacrificeColumn, infos, false ); |
1658 |
1493 |
|
|
1659 |
1494 |
|
// Prevent over resizing |
1660 |
|
- |
if ( resizePolicy.isFixedWidth() ) |
1661 |
|
- |
{ |
|
1495 |
+ |
if ( resizePolicy.isFixedWidth() ) { |
1662 |
1496 |
|
width += undistributed; |
1663 |
1497 |
|
} |
1664 |
1498 |
|
} |
|
@@ -1667,8 +1501,7 @@ |
1667 |
1501 |
|
int offset = getHeaderOffset(); |
1668 |
1502 |
|
dataTable.setColumnWidth( column, width ); |
1669 |
1503 |
|
headerTable.setColumnWidth( column + offset, width ); |
1670 |
|
- |
if ( footerTable != null ) |
1671 |
|
- |
{ |
|
1504 |
+ |
if ( footerTable != null ) { |
1672 |
1505 |
|
footerTable.setColumnWidth( column + offset, width ); |
1673 |
1506 |
|
} |
1674 |
1507 |
|
|
|
@@ -1685,30 +1518,25 @@ |
1685 |
1518 |
|
* |
1686 |
1519 |
|
* @param footerTable the table to use in the footer |
1687 |
1520 |
|
*/ |
1688 |
|
- |
public void setFooterTable( FixedWidthFlexTable footerTable ) |
1689 |
|
- |
{ |
|
1521 |
+ |
public void setFooterTable( FixedWidthFlexTable footerTable ) { |
1690 |
1522 |
|
// Disown the old footer table |
1691 |
|
- |
if ( this.footerTable != null ) |
1692 |
|
- |
{ |
|
1523 |
+ |
if ( this.footerTable != null ) { |
1693 |
1524 |
|
super.remove( this.footerTable ); |
1694 |
1525 |
|
DOM.removeChild( absoluteElem, footerWrapper ); |
1695 |
1526 |
|
} |
1696 |
1527 |
|
|
1697 |
1528 |
|
// Set the new footer table |
1698 |
1529 |
|
this.footerTable = footerTable; |
1699 |
|
- |
if ( footerTable != null ) |
1700 |
|
- |
{ |
|
1530 |
+ |
if ( footerTable != null ) { |
1701 |
1531 |
|
footerTable.setCellSpacing( getCellSpacing() ); |
1702 |
1532 |
|
footerTable.setCellPadding( getCellPadding() ); |
1703 |
1533 |
|
prepareTable( footerTable, "footerTable" ); |
1704 |
|
- |
if ( dataTable.getSelectionPolicy().hasInputColumn() ) |
1705 |
|
- |
{ |
|
1534 |
+ |
if ( dataTable.getSelectionPolicy().hasInputColumn() ) { |
1706 |
1535 |
|
footerTable.setColumnWidth( 0, dataTable.getInputColumnWidth() ); |
1707 |
1536 |
|
} |
1708 |
1537 |
|
|
1709 |
1538 |
|
// Create the footer wrapper and spacer |
1710 |
|
- |
if ( footerWrapper == null ) |
1711 |
|
- |
{ |
|
1539 |
+ |
if ( footerWrapper == null ) { |
1712 |
1540 |
|
footerWrapper = createWrapper( "footerWrapper" ); |
1713 |
1541 |
|
footerSpacer = impl.createSpacer( footerTable, footerWrapper ); |
1714 |
1542 |
|
DOM.setEventListener( footerWrapper, this ); |
|
@@ -1722,8 +1550,7 @@ |
1722 |
1550 |
|
} |
1723 |
1551 |
|
|
1724 |
1552 |
|
@Override |
1725 |
|
- |
public void setHeight( String height ) |
1726 |
|
- |
{ |
|
1553 |
+ |
public void setHeight( String height ) { |
1727 |
1554 |
|
this.lastHeight = height; |
1728 |
1555 |
|
super.setHeight( height ); |
1729 |
1556 |
|
resizeTablesVertically(); |
|
@@ -1734,8 +1561,7 @@ |
1734 |
1561 |
|
* |
1735 |
1562 |
|
* @param resizePolicy the resize policy |
1736 |
1563 |
|
*/ |
1737 |
|
- |
public void setResizePolicy( ResizePolicy resizePolicy ) |
1738 |
|
- |
{ |
|
1564 |
+ |
public void setResizePolicy( ResizePolicy resizePolicy ) { |
1739 |
1565 |
|
this.resizePolicy = resizePolicy; |
1740 |
1566 |
|
updateFillWidthImage(); |
1741 |
1567 |
|
redraw(); |
|
@@ -1746,10 +1572,8 @@ |
1746 |
1572 |
|
* |
1747 |
1573 |
|
* @param scrollPolicy the new scroll policy |
1748 |
1574 |
|
*/ |
1749 |
|
- |
public void setScrollPolicy( ScrollPolicy scrollPolicy ) |
1750 |
|
- |
{ |
1751 |
|
- |
if ( scrollPolicy == this.scrollPolicy ) |
1752 |
|
- |
{ |
|
1575 |
+ |
public void setScrollPolicy( ScrollPolicy scrollPolicy ) { |
|
1576 |
+ |
if ( scrollPolicy == this.scrollPolicy ) { |
1753 |
1577 |
|
return; |
1754 |
1578 |
|
} |
1755 |
1579 |
|
this.scrollPolicy = scrollPolicy; |
|
@@ -1757,32 +1581,23 @@ |
1757 |
1581 |
|
// Clear the heights of the wrappers |
1758 |
1582 |
|
headerWrapper.getStyle().setProperty( "height", "" ); |
1759 |
1583 |
|
dataWrapper.getStyle().setProperty( "height", "" ); |
1760 |
|
- |
if ( footerWrapper != null ) |
1761 |
|
- |
{ |
|
1584 |
+ |
if ( footerWrapper != null ) { |
1762 |
1585 |
|
footerWrapper.getStyle().setProperty( "height", "" ); |
1763 |
1586 |
|
} |
1764 |
1587 |
|
|
1765 |
|
- |
if ( scrollPolicy == ScrollPolicy.DISABLED ) |
1766 |
|
- |
{ |
|
1588 |
+ |
if ( scrollPolicy == ScrollPolicy.DISABLED ) { |
1767 |
1589 |
|
// Disabled scroll bars |
1768 |
1590 |
|
dataWrapper.getStyle().setProperty( "height", "auto" ); |
1769 |
1591 |
|
dataWrapper.getStyle().setProperty( "overflow", "" ); |
1770 |
|
- |
} |
1771 |
|
- |
else if ( scrollPolicy == ScrollPolicy.HORIZONTAL ) |
1772 |
|
- |
{ |
|
1592 |
+ |
} else if ( scrollPolicy == ScrollPolicy.HORIZONTAL ) { |
1773 |
1593 |
|
// Only show horizontal scroll bar |
1774 |
1594 |
|
dataWrapper.getStyle().setProperty( "height", "auto" ); |
1775 |
1595 |
|
dataWrapper.getStyle().setProperty( "overflow", "auto" ); |
1776 |
|
- |
} |
1777 |
|
- |
else if ( scrollPolicy == ScrollPolicy.BOTH ) |
1778 |
|
- |
{ |
|
1596 |
+ |
} else if ( scrollPolicy == ScrollPolicy.BOTH ) { |
1779 |
1597 |
|
// Show both scroll bars |
1780 |
|
- |
if ( lastHeight != null ) |
1781 |
|
- |
{ |
|
1598 |
+ |
if ( lastHeight != null ) { |
1782 |
1599 |
|
super.setHeight( lastHeight ); |
1783 |
|
- |
} |
1784 |
|
- |
else |
1785 |
|
- |
{ |
|
1600 |
+ |
} else { |
1786 |
1601 |
|
super.setHeight( "" ); |
1787 |
1602 |
|
} |
1788 |
1603 |
|
dataWrapper.getStyle().setProperty( "overflow", "auto" ); |
|
@@ -1798,8 +1613,7 @@ |
1798 |
1613 |
|
* |
1799 |
1614 |
|
* @param sortPolicy the {@link SortPolicy} |
1800 |
1615 |
|
*/ |
1801 |
|
- |
public void setSortPolicy( SortPolicy sortPolicy ) |
1802 |
|
- |
{ |
|
1616 |
+ |
public void setSortPolicy( SortPolicy sortPolicy ) { |
1803 |
1617 |
|
this.sortPolicy = sortPolicy; |
1804 |
1618 |
|
|
1805 |
1619 |
|
// Remove the sorted indicator image |
|
@@ -1814,14 +1628,11 @@ |
1814 |
1628 |
|
* @param ascending true to apply the ascending indicator, false for |
1815 |
1629 |
|
* descending |
1816 |
1630 |
|
*/ |
1817 |
|
- |
protected void applySortedColumnIndicator( Element tdElem, boolean ascending ) |
1818 |
|
- |
{ |
|
1631 |
+ |
protected void applySortedColumnIndicator( Element tdElem, boolean ascending ) { |
1819 |
1632 |
|
// Remove the sort indicator |
1820 |
|
- |
if ( tdElem == null ) |
1821 |
|
- |
{ |
|
1633 |
+ |
if ( tdElem == null ) { |
1822 |
1634 |
|
Element parent = DOM.getParent( sortedColumnWrapper ); |
1823 |
|
- |
if ( parent != null ) |
1824 |
|
- |
{ |
|
1635 |
+ |
if ( parent != null ) { |
1825 |
1636 |
|
parent.removeChild( sortedColumnWrapper ); |
1826 |
1637 |
|
headerTable.clearIdealWidths(); |
1827 |
1638 |
|
} |
|
@@ -1829,12 +1640,9 @@ |
1829 |
1640 |
|
} |
1830 |
1641 |
|
|
1831 |
1642 |
|
tdElem.appendChild( sortedColumnWrapper ); |
1832 |
|
- |
if ( ascending ) |
1833 |
|
- |
{ |
|
1643 |
+ |
if ( ascending ) { |
1834 |
1644 |
|
sortedColumnWrapper.setInnerHTML( HTMLConstants.NBSP ); // TODO: + images.scrollTableAscending().getHTML() ); |
1835 |
|
- |
} |
1836 |
|
- |
else |
1837 |
|
- |
{ |
|
1645 |
+ |
} else { |
1838 |
1646 |
|
sortedColumnWrapper.setInnerHTML( HTMLConstants.NBSP ); // TODO: + images.scrollTableDescending().getHTML() ); |
1839 |
1647 |
|
} |
1840 |
1648 |
|
sortedRowIndex = -1; |
|
@@ -1852,16 +1660,14 @@ |
1852 |
1660 |
|
* |
1853 |
1661 |
|
* @return a new wrapper element |
1854 |
1662 |
|
*/ |
1855 |
|
- |
protected Element createWrapper( String cssName ) |
1856 |
|
- |
{ |
|
1663 |
+ |
protected Element createWrapper( String cssName ) { |
1857 |
1664 |
|
Element wrapper = DOM.createDiv(); |
1858 |
1665 |
|
wrapper.getStyle().setProperty( "width", "100%" ); |
1859 |
1666 |
|
wrapper.getStyle().setProperty( "overflow", "hidden" ); |
1860 |
1667 |
|
wrapper.getStyle().setPropertyPx( "padding", 0 ); |
1861 |
1668 |
|
wrapper.getStyle().setPropertyPx( "margin", 0 ); |
1862 |
1669 |
|
wrapper.getStyle().setPropertyPx( "border", 0 ); |
1863 |
|
- |
if ( cssName != null ) |
1864 |
|
- |
{ |
|
1670 |
+ |
if ( cssName != null ) { |
1865 |
1671 |
|
setStyleName( wrapper, cssName ); |
1866 |
1672 |
|
} |
1867 |
1673 |
|
return wrapper; |
|
@@ -1870,8 +1676,7 @@ |
1870 |
1676 |
|
/** |
1871 |
1677 |
|
* @return the wrapper element around the data table |
1872 |
1678 |
|
*/ |
1873 |
|
- |
protected Element getDataWrapper() |
1874 |
|
- |
{ |
|
1679 |
+ |
protected Element getDataWrapper() { |
1875 |
1680 |
|
return dataWrapper; |
1876 |
1681 |
|
} |
1877 |
1682 |
|
|
|
@@ -1882,8 +1687,7 @@ |
1882 |
1687 |
|
* @deprecated use {@link #redraw()} instead |
1883 |
1688 |
|
*/ |
1884 |
1689 |
|
@Deprecated |
1885 |
|
- |
protected void maybeFillWidth() |
1886 |
|
- |
{ |
|
1690 |
+ |
protected void maybeFillWidth() { |
1887 |
1691 |
|
redraw(); |
1888 |
1692 |
|
} |
1889 |
1693 |
|
|
|
@@ -1896,21 +1700,18 @@ |
1896 |
1700 |
|
* |
1897 |
1701 |
|
* @return true to sort, false to ignore |
1898 |
1702 |
|
*/ |
1899 |
|
- |
protected boolean onHeaderSort( int row, int column ) |
1900 |
|
- |
{ |
|
1703 |
+ |
protected boolean onHeaderSort( int row, int column ) { |
1901 |
1704 |
|
return true; |
1902 |
1705 |
|
} |
1903 |
1706 |
|
|
1904 |
1707 |
|
@Override |
1905 |
|
- |
protected void onLoad() |
1906 |
|
- |
{ |
|
1708 |
+ |
protected void onLoad() { |
1907 |
1709 |
|
ResizableWidgetCollection.get().add( this ); |
1908 |
1710 |
|
redraw(); |
1909 |
1711 |
|
} |
1910 |
1712 |
|
|
1911 |
1713 |
|
@Override |
1912 |
|
- |
protected void onUnload() |
1913 |
|
- |
{ |
|
1714 |
+ |
protected void onUnload() { |
1914 |
1715 |
|
ResizableWidgetCollection.get().remove( this ); |
1915 |
1716 |
|
} |
1916 |
1717 |
|
|
|
@@ -1918,24 +1719,18 @@ |
1918 |
1719 |
|
* Fixes the table heights so the header is visible and the data takes up the |
1919 |
1720 |
|
* remaining vertical space. |
1920 |
1721 |
|
*/ |
1921 |
|
- |
protected void resizeTablesVertically() |
1922 |
|
- |
{ |
1923 |
|
- |
if ( scrollPolicy == ScrollPolicy.DISABLED ) |
1924 |
|
- |
{ |
|
1722 |
+ |
protected void resizeTablesVertically() { |
|
1723 |
+ |
if ( scrollPolicy == ScrollPolicy.DISABLED ) { |
1925 |
1724 |
|
dataWrapper.getStyle().setProperty( "overflow", "auto" ); |
1926 |
1725 |
|
dataWrapper.getStyle().setProperty( "overflow", "" ); |
1927 |
1726 |
|
int height = Math.max( 1, absoluteElem.getOffsetHeight() ); |
1928 |
1727 |
|
super.setHeight( height + "px" ); |
1929 |
|
- |
} |
1930 |
|
- |
else if ( scrollPolicy == ScrollPolicy.HORIZONTAL ) |
1931 |
|
- |
{ |
|
1728 |
+ |
} else if ( scrollPolicy == ScrollPolicy.HORIZONTAL ) { |
1932 |
1729 |
|
dataWrapper.getStyle().setProperty( "overflow", "hidden" ); |
1933 |
1730 |
|
dataWrapper.getStyle().setProperty( "overflow", "auto" ); |
1934 |
1731 |
|
int height = Math.max( 1, absoluteElem.getOffsetHeight() ); |
1935 |
1732 |
|
super.setHeight( height + "px" ); |
1936 |
|
- |
} |
1937 |
|
- |
else |
1938 |
|
- |
{ |
|
1733 |
+ |
} else { |
1939 |
1734 |
|
applyTableWrapperSizes( getTableWrapperSizes() ); |
1940 |
1735 |
|
dataWrapper.getStyle().setProperty( "width", "100%" ); |
1941 |
1736 |
|
} |
|
@@ -1947,8 +1742,7 @@ |
1947 |
1742 |
|
* @deprecated use {@link #redraw()} instead |
1948 |
1743 |
|
*/ |
1949 |
1744 |
|
@Deprecated |
1950 |
|
- |
protected void resizeTablesVerticallyNow() |
1951 |
|
- |
{ |
|
1745 |
+ |
protected void resizeTablesVerticallyNow() { |
1952 |
1746 |
|
redraw(); |
1953 |
1747 |
|
} |
1954 |
1748 |
|
|
|
@@ -1958,22 +1752,17 @@ |
1958 |
1752 |
|
* |
1959 |
1753 |
|
* @param baseHeader true to scroll the data table as well |
1960 |
1754 |
|
*/ |
1961 |
|
- |
protected void scrollTables( boolean baseHeader ) |
1962 |
|
- |
{ |
1963 |
|
- |
if ( scrollPolicy == ScrollPolicy.DISABLED ) |
1964 |
|
- |
{ |
|
1755 |
+ |
protected void scrollTables( boolean baseHeader ) { |
|
1756 |
+ |
if ( scrollPolicy == ScrollPolicy.DISABLED ) { |
1965 |
1757 |
|
return; |
1966 |
1758 |
|
} |
1967 |
1759 |
|
|
1968 |
|
- |
if ( lastScrollLeft >= 0 ) |
1969 |
|
- |
{ |
|
1760 |
+ |
if ( lastScrollLeft >= 0 ) { |
1970 |
1761 |
|
headerWrapper.setScrollLeft( lastScrollLeft ); |
1971 |
|
- |
if ( baseHeader ) |
1972 |
|
- |
{ |
|
1762 |
+ |
if ( baseHeader ) { |
1973 |
1763 |
|
dataWrapper.setScrollLeft( lastScrollLeft ); |
1974 |
1764 |
|
} |
1975 |
|
- |
if ( footerWrapper != null ) |
1976 |
|
- |
{ |
|
1765 |
+ |
if ( footerWrapper != null ) { |
1977 |
1766 |
|
footerWrapper.setScrollLeft( lastScrollLeft ); |
1978 |
1767 |
|
} |
1979 |
1768 |
|
} |
|
@@ -1982,8 +1771,7 @@ |
1982 |
1771 |
|
/** |
1983 |
1772 |
|
* @return the absolutely positioned wrapper element |
1984 |
1773 |
|
*/ |
1985 |
|
- |
Element getAbsoluteElement() |
1986 |
|
- |
{ |
|
1774 |
+ |
Element getAbsoluteElement() { |
1987 |
1775 |
|
return absoluteElem; |
1988 |
1776 |
|
} |
1989 |
1777 |
|
|
|
@@ -1994,8 +1782,7 @@ |
1994 |
1782 |
|
* @param wrapper the wrapper element |
1995 |
1783 |
|
* @param index the index to insert the wrapper in the main element |
1996 |
1784 |
|
*/ |
1997 |
|
- |
private void adoptTable( Widget table, Element wrapper, int index ) |
1998 |
|
- |
{ |
|
1785 |
+ |
private void adoptTable( Widget table, Element wrapper, int index ) { |
1999 |
1786 |
|
DOM.insertChild( absoluteElem, wrapper, index ); |
2000 |
1787 |
|
add( table, wrapper ); |
2001 |
1788 |
|
} |
|
@@ -2007,26 +1794,21 @@ |
2007 |
1794 |
|
* @param infos the new column width info |
2008 |
1795 |
|
* @param forced if false, only set column widths that have changed |
2009 |
1796 |
|
*/ |
2010 |
|
- |
private void applyNewColumnWidths( int startIndex, List<ColumnWidthInfo> infos, boolean forced ) |
2011 |
|
- |
{ |
|
1797 |
+ |
private void applyNewColumnWidths( int startIndex, List<ColumnWidthInfo> infos, boolean forced ) { |
2012 |
1798 |
|
// Infos can be null if the widths cannot be calculated |
2013 |
|
- |
if ( infos == null ) |
2014 |
|
- |
{ |
|
1799 |
+ |
if ( infos == null ) { |
2015 |
1800 |
|
return; |
2016 |
1801 |
|
} |
2017 |
1802 |
|
|
2018 |
1803 |
|
int offset = getHeaderOffset(); |
2019 |
1804 |
|
int numColumns = infos.size(); |
2020 |
|
- |
for ( int i = 0; i < numColumns; i++ ) |
2021 |
|
- |
{ |
|
1805 |
+ |
for ( int i = 0; i < numColumns; i++ ) { |
2022 |
1806 |
|
ColumnWidthInfo info = infos.get( i ); |
2023 |
1807 |
|
int newWidth = info.getNewWidth(); |
2024 |
|
- |
if ( forced || info.getCurrentWidth() != newWidth ) |
2025 |
|
- |
{ |
|
1808 |
+ |
if ( forced || info.getCurrentWidth() != newWidth ) { |
2026 |
1809 |
|
dataTable.setColumnWidth( startIndex + i, newWidth ); |
2027 |
1810 |
|
headerTable.setColumnWidth( startIndex + i + offset, newWidth ); |
2028 |
|
- |
if ( footerTable != null ) |
2029 |
|
- |
{ |
|
1811 |
+ |
if ( footerTable != null ) { |
2030 |
1812 |
|
footerTable.setColumnWidth( startIndex + i + offset, newWidth ); |
2031 |
1813 |
|
} |
2032 |
1814 |
|
} |
|
@@ -2039,16 +1821,13 @@ |
2039 |
1821 |
|
* |
2040 |
1822 |
|
* @param sizes the sizes to apply |
2041 |
1823 |
|
*/ |
2042 |
|
- |
private void applyTableWrapperSizes( TableHeightInfo sizes ) |
2043 |
|
- |
{ |
2044 |
|
- |
if ( sizes == null ) |
2045 |
|
- |
{ |
|
1824 |
+ |
private void applyTableWrapperSizes( TableHeightInfo sizes ) { |
|
1825 |
+ |
if ( sizes == null ) { |
2046 |
1826 |
|
return; |
2047 |
1827 |
|
} |
2048 |
1828 |
|
|
2049 |
1829 |
|
headerWrapper.getStyle().setPropertyPx( "height", sizes.headerTableHeight ); |
2050 |
|
- |
if ( footerWrapper != null ) |
2051 |
|
- |
{ |
|
1830 |
+ |
if ( footerWrapper != null ) { |
2052 |
1831 |
|
footerWrapper.getStyle().setPropertyPx( "height", sizes.footerTableHeight ); |
2053 |
1832 |
|
} |
2054 |
1833 |
|
dataWrapper.getStyle().setPropertyPx( "height", Math.max( sizes.dataTableHeight, 0 ) ); |
|
@@ -2061,11 +1840,9 @@ |
2061 |
1840 |
|
* |
2062 |
1841 |
|
* @return the available width, or -1 if not defined |
2063 |
1842 |
|
*/ |
2064 |
|
- |
private int getAvailableWidth() |
2065 |
|
- |
{ |
|
1843 |
+ |
private int getAvailableWidth() { |
2066 |
1844 |
|
int clientWidth = absoluteElem.getPropertyInt( "clientWidth" ); |
2067 |
|
- |
if ( scrollPolicy == ScrollPolicy.BOTH ) |
2068 |
|
- |
{ |
|
1845 |
+ |
if ( scrollPolicy == ScrollPolicy.BOTH ) { |
2069 |
1846 |
|
int scrollbarWidth = mockScrollable.getOffsetWidth() - mockScrollable.getPropertyInt( "clientWidth" ); |
2070 |
1847 |
|
clientWidth = absoluteElem.getPropertyInt( "clientWidth" ) - scrollbarWidth - 1; |
2071 |
1848 |
|
} |
|
@@ -2080,10 +1857,8 @@ |
2080 |
1857 |
|
* |
2081 |
1858 |
|
* @return the column widths |
2082 |
1859 |
|
*/ |
2083 |
|
- |
private List<ColumnWidthInfo> getBoundedColumnWidths( boolean boundsOnly ) |
2084 |
|
- |
{ |
2085 |
|
- |
if ( !isAttached() ) |
2086 |
|
- |
{ |
|
1860 |
+ |
private List<ColumnWidthInfo> getBoundedColumnWidths( boolean boundsOnly ) { |
|
1861 |
+ |
if ( !isAttached() ) { |
2087 |
1862 |
|
return null; |
2088 |
1863 |
|
} |
2089 |
1864 |
|
|
|
@@ -2093,10 +1868,8 @@ |
2093 |
1868 |
|
List<ColumnWidthInfo> colWidthInfos = getColumnWidthInfo( 0, numColumns ); |
2094 |
1869 |
|
|
2095 |
1870 |
|
// If we are reseting to original widths, set all widths to 0 |
2096 |
|
- |
if ( !boundsOnly ) |
2097 |
|
- |
{ |
2098 |
|
- |
for ( ColumnWidthInfo info : colWidthInfos ) |
2099 |
|
- |
{ |
|
1871 |
+ |
if ( !boundsOnly ) { |
|
1872 |
+ |
for ( ColumnWidthInfo info : colWidthInfos ) { |
2100 |
1873 |
|
totalWidth += info.getCurrentWidth(); |
2101 |
1874 |
|
info.setCurrentWidth( 0 ); |
2102 |
1875 |
|
} |
|
@@ -2116,40 +1889,33 @@ |
2116 |
1889 |
|
* |
2117 |
1890 |
|
* @return the info about the column width |
2118 |
1891 |
|
*/ |
2119 |
|
- |
private ColumnWidthInfo getColumnWidthInfo( int column ) |
2120 |
|
- |
{ |
|
1892 |
+ |
private ColumnWidthInfo getColumnWidthInfo( int column ) { |
2121 |
1893 |
|
int minWidth = getMinimumColumnWidth( column ); |
2122 |
1894 |
|
int maxWidth = getMaximumColumnWidth( column ); |
2123 |
1895 |
|
int preferredWidth = getPreferredColumnWidth( column ); |
2124 |
1896 |
|
int curWidth = getColumnWidth( column ); |
2125 |
1897 |
|
|
2126 |
1898 |
|
// Adjust the widths if the columns are not truncatable, up to maxWidth |
2127 |
|
- |
if ( !isColumnTruncatable( column ) ) |
2128 |
|
- |
{ |
|
1899 |
+ |
if ( !isColumnTruncatable( column ) ) { |
2129 |
1900 |
|
maybeRecalculateIdealColumnWidths( null ); |
2130 |
1901 |
|
int idealWidth = getDataTable().getIdealColumnWidth( column ); |
2131 |
|
- |
if ( maxWidth != MaximumWidthProperty.NO_MAXIMUM_WIDTH ) |
2132 |
|
- |
{ |
|
1902 |
+ |
if ( maxWidth != MaximumWidthProperty.NO_MAXIMUM_WIDTH ) { |
2133 |
1903 |
|
idealWidth = Math.min( idealWidth, maxWidth ); |
2134 |
1904 |
|
} |
2135 |
1905 |
|
minWidth = Math.max( minWidth, idealWidth ); |
2136 |
1906 |
|
} |
2137 |
|
- |
if ( !isHeaderColumnTruncatable( column ) ) |
2138 |
|
- |
{ |
|
1907 |
+ |
if ( !isHeaderColumnTruncatable( column ) ) { |
2139 |
1908 |
|
maybeRecalculateIdealColumnWidths( null ); |
2140 |
1909 |
|
int idealWidth = getHeaderTable().getIdealColumnWidth( column + getHeaderOffset() ); |
2141 |
|
- |
if ( maxWidth != MaximumWidthProperty.NO_MAXIMUM_WIDTH ) |
2142 |
|
- |
{ |
|
1910 |
+ |
if ( maxWidth != MaximumWidthProperty.NO_MAXIMUM_WIDTH ) { |
2143 |
1911 |
|
idealWidth = Math.min( idealWidth, maxWidth ); |
2144 |
1912 |
|
} |
2145 |
1913 |
|
minWidth = Math.max( minWidth, idealWidth ); |
2146 |
1914 |
|
} |
2147 |
|
- |
if ( footerTable != null && !isFooterColumnTruncatable( column ) ) |
2148 |
|
- |
{ |
|
1915 |
+ |
if ( footerTable != null && !isFooterColumnTruncatable( column ) ) { |
2149 |
1916 |
|
maybeRecalculateIdealColumnWidths( null ); |
2150 |
1917 |
|
int idealWidth = getFooterTable().getIdealColumnWidth( column + getHeaderOffset() ); |
2151 |
|
- |
if ( maxWidth != MaximumWidthProperty.NO_MAXIMUM_WIDTH ) |
2152 |
|
- |
{ |
|
1918 |
+ |
if ( maxWidth != MaximumWidthProperty.NO_MAXIMUM_WIDTH ) { |
2153 |
1919 |
|
idealWidth = Math.min( idealWidth, maxWidth ); |
2154 |
1920 |
|
} |
2155 |
1921 |
|
minWidth = Math.max( minWidth, idealWidth ); |
|
@@ -2166,11 +1932,9 @@ |
2166 |
1932 |
|
* |
2167 |
1933 |
|
* @return the info about the column widths of the columns |
2168 |
1934 |
|
*/ |
2169 |
|
- |
private List<ColumnWidthInfo> getColumnWidthInfo( int column, int numColumns ) |
2170 |
|
- |
{ |
|
1935 |
+ |
private List<ColumnWidthInfo> getColumnWidthInfo( int column, int numColumns ) { |
2171 |
1936 |
|
List<ColumnWidthInfo> infos = new ArrayList<ColumnWidthInfo>(); |
2172 |
|
- |
for ( int i = 0; i < numColumns; i++ ) |
2173 |
|
- |
{ |
|
1937 |
+ |
for ( int i = 0; i < numColumns; i++ ) { |
2174 |
1938 |
|
infos.add( getColumnWidthInfo( column + i ) ); |
2175 |
1939 |
|
} |
2176 |
1940 |
|
return infos; |
|
@@ -2183,23 +1947,19 @@ |
2183 |
1947 |
|
* |
2184 |
1948 |
|
* @return the column widths |
2185 |
1949 |
|
*/ |
2186 |
|
- |
private List<ColumnWidthInfo> getFillColumnWidths( TableWidthInfo info ) |
2187 |
|
- |
{ |
2188 |
|
- |
if ( !isAttached() ) |
2189 |
|
- |
{ |
|
1950 |
+ |
private List<ColumnWidthInfo> getFillColumnWidths( TableWidthInfo info ) { |
|
1951 |
+ |
if ( !isAttached() ) { |
2190 |
1952 |
|
return null; |
2191 |
1953 |
|
} |
2192 |
1954 |
|
|
2193 |
1955 |
|
// Precompute some sizes |
2194 |
|
- |
if ( info == null ) |
2195 |
|
- |
{ |
|
1956 |
+ |
if ( info == null ) { |
2196 |
1957 |
|
info = new TableWidthInfo( false ); |
2197 |
1958 |
|
} |
2198 |
1959 |
|
|
2199 |
1960 |
|
// Calculate how much room we have to work with |
2200 |
1961 |
|
int clientWidth = info.availableWidth; |
2201 |
|
- |
if ( clientWidth <= 0 ) |
2202 |
|
- |
{ |
|
1962 |
+ |
if ( clientWidth <= 0 ) { |
2203 |
1963 |
|
return null; |
2204 |
1964 |
|
} |
2205 |
1965 |
|
|
|
@@ -2211,38 +1971,29 @@ |
2211 |
1971 |
|
int numHeaderCols = 0; |
2212 |
1972 |
|
int numDataCols = 0; |
2213 |
1973 |
|
int numFooterCols = 0; |
2214 |
|
- |
if ( info.headerTableWidth > 0 ) |
2215 |
|
- |
{ |
|
1974 |
+ |
if ( info.headerTableWidth > 0 ) { |
2216 |
1975 |
|
numHeaderCols = headerTable.getColumnCount() - getHeaderOffset(); |
2217 |
1976 |
|
} |
2218 |
|
- |
if ( info.dataTableWidth > 0 ) |
2219 |
|
- |
{ |
|
1977 |
+ |
if ( info.dataTableWidth > 0 ) { |
2220 |
1978 |
|
numDataCols = dataTable.getColumnCount(); |
2221 |
1979 |
|
} |
2222 |
|
- |
if ( footerTable != null && info.footerTableWidth > 0 ) |
2223 |
|
- |
{ |
|
1980 |
+ |
if ( footerTable != null && info.footerTableWidth > 0 ) { |
2224 |
1981 |
|
numFooterCols = footerTable.getColumnCount() - getHeaderOffset(); |
2225 |
1982 |
|
} |
2226 |
1983 |
|
|
2227 |
1984 |
|
// Determine the largest table |
2228 |
|
- |
if ( numHeaderCols >= numDataCols && numHeaderCols >= numFooterCols ) |
2229 |
|
- |
{ |
|
1985 |
+ |
if ( numHeaderCols >= numDataCols && numHeaderCols >= numFooterCols ) { |
2230 |
1986 |
|
numColumns = numHeaderCols; |
2231 |
1987 |
|
diff = clientWidth - info.headerTableWidth; |
2232 |
|
- |
} |
2233 |
|
- |
else if ( numFooterCols >= numDataCols && numFooterCols >= numHeaderCols ) |
2234 |
|
- |
{ |
|
1988 |
+ |
} else if ( numFooterCols >= numDataCols && numFooterCols >= numHeaderCols ) { |
2235 |
1989 |
|
numColumns = numFooterCols; |
2236 |
1990 |
|
diff = clientWidth - info.footerTableWidth; |
2237 |
|
- |
} |
2238 |
|
- |
else if ( numDataCols > 0 ) |
2239 |
|
- |
{ |
|
1991 |
+ |
} else if ( numDataCols > 0 ) { |
2240 |
1992 |
|
numColumns = numDataCols; |
2241 |
1993 |
|
diff = clientWidth - info.dataTableWidth; |
2242 |
1994 |
|
} |
2243 |
1995 |
|
} |
2244 |
|
- |
if ( numColumns <= 0 ) |
2245 |
|
- |
{ |
|
1996 |
+ |
if ( numColumns <= 0 ) { |
2246 |
1997 |
|
return null; |
2247 |
1998 |
|
} |
2248 |
1999 |
|
|
|
@@ -2260,10 +2011,8 @@ |
2260 |
2011 |
|
* |
2261 |
2012 |
|
* @return the offset |
2262 |
2013 |
|
*/ |
2263 |
|
- |
private int getHeaderOffset() |
2264 |
|
- |
{ |
2265 |
|
- |
if ( dataTable.getSelectionPolicy().hasInputColumn() ) |
2266 |
|
- |
{ |
|
2014 |
+ |
private int getHeaderOffset() { |
|
2015 |
+ |
if ( dataTable.getSelectionPolicy().hasInputColumn() ) { |
2267 |
2016 |
|
return 1; |
2268 |
2017 |
|
} |
2269 |
2018 |
|
return 0; |
|
@@ -2275,17 +2024,14 @@ |
2275 |
2024 |
|
* |
2276 |
2025 |
|
* @return the new table heights, or null |
2277 |
2026 |
|
*/ |
2278 |
|
- |
private TableHeightInfo getTableWrapperSizes() |
2279 |
|
- |
{ |
|
2027 |
+ |
private TableHeightInfo getTableWrapperSizes() { |
2280 |
2028 |
|
// If we aren't attached, return immediately |
2281 |
|
- |
if ( !isAttached() ) |
2282 |
|
- |
{ |
|
2029 |
+ |
if ( !isAttached() ) { |
2283 |
2030 |
|
return null; |
2284 |
2031 |
|
} |
2285 |
2032 |
|
|
2286 |
2033 |
|
// Heights only apply with vertical scrolling |
2287 |
|
- |
if ( scrollPolicy == ScrollPolicy.DISABLED || scrollPolicy == ScrollPolicy.HORIZONTAL ) |
2288 |
|
- |
{ |
|
2034 |
+ |
if ( scrollPolicy == ScrollPolicy.DISABLED || scrollPolicy == ScrollPolicy.HORIZONTAL ) { |
2289 |
2035 |
|
return null; |
2290 |
2036 |
|
} |
2291 |
2037 |
|
|
|
@@ -2298,19 +2044,16 @@ |
2298 |
2044 |
|
* |
2299 |
2045 |
|
* @param command an optional command to execute while recalculating |
2300 |
2046 |
|
*/ |
2301 |
|
- |
private void maybeRecalculateIdealColumnWidths( Command command ) |
2302 |
|
- |
{ |
|
2047 |
+ |
private void maybeRecalculateIdealColumnWidths( Command command ) { |
2303 |
2048 |
|
// Calculations require that we are attached |
2304 |
|
- |
if ( !isAttached() ) |
2305 |
|
- |
{ |
|
2049 |
+ |
if ( !isAttached() ) { |
2306 |
2050 |
|
return; |
2307 |
2051 |
|
} |
2308 |
2052 |
|
|
2309 |
2053 |
|
// Check if a recalculation is needed. |
2310 |
|
- |
if ( headerTable.isIdealColumnWidthsCalculated() && dataTable.isIdealColumnWidthsCalculated() && (footerTable == null || footerTable.isIdealColumnWidthsCalculated()) ) |
2311 |
|
- |
{ |
2312 |
|
- |
if ( command != null ) |
2313 |
|
- |
{ |
|
2054 |
+ |
if ( headerTable.isIdealColumnWidthsCalculated() && dataTable.isIdealColumnWidthsCalculated() && |
|
2055 |
+ |
(footerTable == null || footerTable.isIdealColumnWidthsCalculated()) ) { |
|
2056 |
+ |
if ( command != null ) { |
2314 |
2057 |
|
command.execute(); |
2315 |
2058 |
|
} |
2316 |
2059 |
|
return; |
|
@@ -2325,8 +2068,7 @@ |
2325 |
2068 |
|
* @param table the table to prepare |
2326 |
2069 |
|
* @param cssName the style name added to the base name |
2327 |
2070 |
|
*/ |
2328 |
|
- |
private void prepareTable( Widget table, String cssName ) |
2329 |
|
- |
{ |
|
2071 |
+ |
private void prepareTable( Widget table, String cssName ) { |
2330 |
2072 |
|
Element tableElem = table.getElement(); |
2331 |
2073 |
|
DOM.setStyleAttribute( tableElem, "margin", "0px" ); |
2332 |
2074 |
|
DOM.setStyleAttribute( tableElem, "border", "0px" ); |
|
@@ -2336,14 +2078,10 @@ |
2336 |
2078 |
|
/** |
2337 |
2079 |
|
* Show or hide to fillWidthImage depending on current policies. |
2338 |
2080 |
|
*/ |
2339 |
|
- |
private void updateFillWidthImage() |
2340 |
|
- |
{ |
2341 |
|
- |
if ( columnResizePolicy == ColumnResizePolicy.DISABLED || resizePolicy.isFixedWidth() ) |
2342 |
|
- |
{ |
|
2081 |
+ |
private void updateFillWidthImage() { |
|
2082 |
+ |
if ( columnResizePolicy == ColumnResizePolicy.DISABLED || resizePolicy.isFixedWidth() ) { |
2343 |
2083 |
|
fillWidthImage.setVisible( false ); |
2344 |
|
- |
} |
2345 |
|
- |
else |
2346 |
|
- |
{ |
|
2084 |
+ |
} else { |
2347 |
2085 |
|
fillWidthImage.setVisible( true ); |
2348 |
2086 |
|
} |
2349 |
2087 |
|
} |