|
@@ -1,13 +1,12 @@ |
1 |
1 |
|
// This Source Code is in the Public Domain per: http://unlicense.org |
2 |
2 |
|
package org.litesoft.GWT.client.widgets.nonpublic; |
3 |
3 |
|
|
4 |
|
- |
import java.util.*; |
5 |
|
- |
|
6 |
4 |
|
import com.google.gwt.user.client.*; |
7 |
5 |
|
import com.google.gwt.user.client.ui.*; |
8 |
6 |
|
|
9 |
|
- |
public abstract class AbstractSizeableTwoDimensionalPanel extends AbstractSizeableHasAlignmentPanel implements IndexedPanel |
10 |
|
- |
{ |
|
7 |
+ |
import java.util.*; |
|
8 |
+ |
|
|
9 |
+ |
public abstract class AbstractSizeableTwoDimensionalPanel extends AbstractSizeableHasAlignmentPanel implements IndexedPanel { |
11 |
10 |
|
/** |
12 |
11 |
|
* Table element. |
13 |
12 |
|
*/ |
|
@@ -20,8 +19,7 @@ |
20 |
19 |
|
|
21 |
20 |
|
private WidgetCollection mChildren = new WidgetCollection( this ); |
22 |
21 |
|
|
23 |
|
- |
protected AbstractSizeableTwoDimensionalPanel() |
24 |
|
- |
{ |
|
22 |
+ |
protected AbstractSizeableTwoDimensionalPanel() { |
25 |
23 |
|
tableElem = DOM.createTable(); |
26 |
24 |
|
bodyElem = DOM.createTBody(); |
27 |
25 |
|
DOM.appendChild( tableElem, bodyElem ); |
|
@@ -29,8 +27,7 @@ |
29 |
27 |
|
} |
30 |
28 |
|
|
31 |
29 |
|
@Override |
32 |
|
- |
public boolean anyChildren() |
33 |
|
- |
{ |
|
30 |
+ |
public boolean anyChildren() { |
34 |
31 |
|
return (mChildren.size() != 0); |
35 |
32 |
|
} |
36 |
33 |
|
|
|
@@ -40,10 +37,8 @@ |
40 |
37 |
|
* Removes all child widgets. |
41 |
38 |
|
*/ |
42 |
39 |
|
@Override |
43 |
|
- |
public void clear() |
44 |
|
- |
{ |
45 |
|
- |
if ( anyChildren() ) |
46 |
|
- |
{ |
|
40 |
+ |
public void clear() { |
|
41 |
+ |
if ( anyChildren() ) { |
47 |
42 |
|
// todo: ... |
48 |
43 |
|
} |
49 |
44 |
|
} |
|
@@ -52,9 +47,9 @@ |
52 |
47 |
|
* Gets an iterator for the contained widgets. This iterator is required to |
53 |
48 |
|
* implement {@link Iterator#remove()}. |
54 |
49 |
|
*/ |
55 |
|
- |
@SuppressWarnings({"unchecked"}) @Override |
56 |
|
- |
public Iterator iterator() |
57 |
|
- |
{ |
|
50 |
+ |
@SuppressWarnings({"unchecked"}) |
|
51 |
+ |
@Override |
|
52 |
+ |
public Iterator iterator() { |
58 |
53 |
|
return mChildren.iterator(); |
59 |
54 |
|
} |
60 |
55 |
|
|
|
@@ -67,8 +62,7 @@ |
67 |
62 |
|
* often this means that a specific overload must be called) |
68 |
63 |
|
*/ |
69 |
64 |
|
@Override |
70 |
|
- |
public void add( Widget pWidget ) |
71 |
|
- |
{ |
|
65 |
+ |
public void add( Widget pWidget ) { |
72 |
66 |
|
// todo: ... |
73 |
67 |
|
} |
74 |
68 |
|
|
|
@@ -80,11 +74,9 @@ |
80 |
74 |
|
* @return <code>true</code> if the widget was present |
81 |
75 |
|
*/ |
82 |
76 |
|
@Override |
83 |
|
- |
public boolean remove( Widget pWidget ) |
84 |
|
- |
{ |
|
77 |
+ |
public boolean remove( Widget pWidget ) { |
85 |
78 |
|
// Make sure this panel actually contains the child widget. |
86 |
|
- |
if ( !mChildren.contains( pWidget ) ) |
87 |
|
- |
{ |
|
79 |
+ |
if ( !mChildren.contains( pWidget ) ) { |
88 |
80 |
|
return false; |
89 |
81 |
|
} |
90 |
82 |
|
|
|
@@ -98,26 +90,22 @@ |
98 |
90 |
|
// vvvvvvvvvvv IndexedPanel |
99 |
91 |
|
|
100 |
92 |
|
@Override |
101 |
|
- |
public Widget getWidget( int pIndex ) |
102 |
|
- |
{ |
|
93 |
+ |
public Widget getWidget( int pIndex ) { |
103 |
94 |
|
return null; // todo: getChildren().get( pIndex ); |
104 |
95 |
|
} |
105 |
96 |
|
|
106 |
97 |
|
@Override |
107 |
|
- |
public int getWidgetCount() |
108 |
|
- |
{ |
|
98 |
+ |
public int getWidgetCount() { |
109 |
99 |
|
return 0; // todo: getChildren().size(); |
110 |
100 |
|
} |
111 |
101 |
|
|
112 |
102 |
|
@Override |
113 |
|
- |
public int getWidgetIndex( Widget pChild ) |
114 |
|
- |
{ |
|
103 |
+ |
public int getWidgetIndex( Widget pChild ) { |
115 |
104 |
|
return 0; // todo: getChildren().indexOf( pChild ); |
116 |
105 |
|
} |
117 |
106 |
|
|
118 |
107 |
|
@Override |
119 |
|
- |
public boolean remove( int pIndex ) |
120 |
|
- |
{ |
|
108 |
+ |
public boolean remove( int pIndex ) { |
121 |
109 |
|
return remove( getWidget( pIndex ) ); |
122 |
110 |
|
} |
123 |
111 |
|
|
|
@@ -130,8 +118,7 @@ |
130 |
118 |
|
* |
131 |
119 |
|
* @see HasAlignment |
132 |
120 |
|
*/ |
133 |
|
- |
public void setCellHorizontalAlignment( HorizontalAlignmentConstant hAlign ) |
134 |
|
- |
{ |
|
121 |
+ |
public void setCellHorizontalAlignment( HorizontalAlignmentConstant hAlign ) { |
135 |
122 |
|
// if ( m_cellMap.size() == 0 ) |
136 |
123 |
|
// { |
137 |
124 |
|
// throw new IllegalStateException(); |
|
@@ -147,8 +134,7 @@ |
147 |
134 |
|
* |
148 |
135 |
|
* @see HasAlignment |
149 |
136 |
|
*/ |
150 |
|
- |
public void setCellVerticalAlignment( VerticalAlignmentConstant vAlign ) |
151 |
|
- |
{ |
|
137 |
+ |
public void setCellVerticalAlignment( VerticalAlignmentConstant vAlign ) { |
152 |
138 |
|
// if ( m_cellMap.size() == 0 ) |
153 |
139 |
|
// { |
154 |
140 |
|
// throw new IllegalStateException(); |
|
@@ -157,13 +143,11 @@ |
157 |
143 |
|
// setCellVerticalAlignment( getCellCount() - 1, vAlign ); |
158 |
144 |
|
} |
159 |
145 |
|
|
160 |
|
- |
public static void setTdHorizontalAlignment( Element td, HorizontalAlignmentConstant hAlign ) |
161 |
|
- |
{ |
|
146 |
+ |
public static void setTdHorizontalAlignment( Element td, HorizontalAlignmentConstant hAlign ) { |
162 |
147 |
|
CommonElementHelper.setTDalign( td, hAlign ); |
163 |
148 |
|
} |
164 |
149 |
|
|
165 |
|
- |
public static void setTdVerticalAlignment( Element td, VerticalAlignmentConstant vAlign ) |
166 |
|
- |
{ |
|
150 |
+ |
public static void setTdVerticalAlignment( Element td, VerticalAlignmentConstant vAlign ) { |
167 |
151 |
|
CommonElementHelper.setTDvAlign( td, vAlign ); |
168 |
152 |
|
} |
169 |
153 |
|
|
|
@@ -178,8 +162,7 @@ |
178 |
162 |
|
* |
179 |
163 |
|
* @throws IndexOutOfBoundsException |
180 |
164 |
|
*/ |
181 |
|
- |
public int getColSpan( int row, int column ) |
182 |
|
- |
{ |
|
165 |
+ |
public int getColSpan( int row, int column ) { |
183 |
166 |
|
return DOM.getElementPropertyInt( getElement( row, column ), "colSpan" ); |
184 |
167 |
|
} |
185 |
168 |
|
|
|
@@ -194,8 +177,7 @@ |
194 |
177 |
|
* |
195 |
178 |
|
* @throws IndexOutOfBoundsException |
196 |
179 |
|
*/ |
197 |
|
- |
public int getRowSpan( int row, int column ) |
198 |
|
- |
{ |
|
180 |
+ |
public int getRowSpan( int row, int column ) { |
199 |
181 |
|
return DOM.getElementPropertyInt( getElement( row, column ), "rowSpan" ); |
200 |
182 |
|
} |
201 |
183 |
|
|
|
@@ -209,8 +191,7 @@ |
209 |
191 |
|
* |
210 |
192 |
|
* @throws IndexOutOfBoundsException |
211 |
193 |
|
*/ |
212 |
|
- |
public Element getElement( int row, int column ) |
213 |
|
- |
{ |
|
194 |
+ |
public Element getElement( int row, int column ) { |
214 |
195 |
|
checkCellBounds( row, column ); |
215 |
196 |
|
return getCellElement( bodyElem, row, column ); |
216 |
197 |
|
} |
|
@@ -223,16 +204,13 @@ |
223 |
204 |
|
* |
224 |
205 |
|
* @throws IndexOutOfBoundsException |
225 |
206 |
|
*/ |
226 |
|
- |
protected void checkCellBounds( int row, int column ) |
227 |
|
- |
{ |
|
207 |
+ |
protected void checkCellBounds( int row, int column ) { |
228 |
208 |
|
checkRowBounds( row ); |
229 |
|
- |
if ( column < 0 ) |
230 |
|
- |
{ |
|
209 |
+ |
if ( column < 0 ) { |
231 |
210 |
|
throw new IndexOutOfBoundsException( "Column " + column + " must be non-negative: " + column ); |
232 |
211 |
|
} |
233 |
212 |
|
int cellSize = getCellCount( row ); |
234 |
|
- |
if ( cellSize <= column ) |
235 |
|
- |
{ |
|
213 |
+ |
if ( cellSize <= column ) { |
236 |
214 |
|
throw new IndexOutOfBoundsException( "Column index: " + column + ", Column size: " + getCellCount( row ) ); |
237 |
215 |
|
} |
238 |
216 |
|
} |
|
@@ -244,11 +222,9 @@ |
244 |
222 |
|
* |
245 |
223 |
|
* @throws IndexOutOfBoundsException |
246 |
224 |
|
*/ |
247 |
|
- |
protected void checkRowBounds( int row ) |
248 |
|
- |
{ |
|
225 |
+ |
protected void checkRowBounds( int row ) { |
249 |
226 |
|
int rowSize = getRowCount(); |
250 |
|
- |
if ( (row >= rowSize) || (row < 0) ) |
251 |
|
- |
{ |
|
227 |
+ |
if ( (row >= rowSize) || (row < 0) ) { |
252 |
228 |
|
throw new IndexOutOfBoundsException( "Row index: " + row + ", Row size: " + rowSize ); |
253 |
229 |
|
} |
254 |
230 |
|
} |
|
@@ -284,8 +260,7 @@ |
284 |
260 |
|
}-*/; |
285 |
261 |
|
|
286 |
262 |
|
@Override |
287 |
|
- |
protected final Element adopt( Widget w, Element container ) |
288 |
|
- |
{ |
|
263 |
+ |
protected final Element adopt( Widget w, Element container ) { |
289 |
264 |
|
throw new IllegalStateException( "Inappropriate use of raw adopt( Widget w, Element container )" ); |
290 |
265 |
|
} |
291 |
266 |
|
|
|
@@ -294,10 +269,8 @@ |
294 |
269 |
|
* |
295 |
270 |
|
* @param pWidget !null |
296 |
271 |
|
*/ |
297 |
|
- |
protected void adopt( Widget pWidget, int pBeforeIndex ) |
298 |
|
- |
{ |
299 |
|
- |
if ( aboutToAdopt( pWidget, pBeforeIndex ) ) |
300 |
|
- |
{ |
|
272 |
+ |
protected void adopt( Widget pWidget, int pBeforeIndex ) { |
|
273 |
+ |
if ( aboutToAdopt( pWidget, pBeforeIndex ) ) { |
301 |
274 |
|
LLadopt( pWidget, pBeforeIndex ); |
302 |
275 |
|
justAdopted( pWidget, pBeforeIndex ); |
303 |
276 |
|
} |
|
@@ -309,30 +282,25 @@ |
309 |
282 |
|
* @param pWidget !null |
310 |
283 |
|
*/ |
311 |
284 |
|
@Override |
312 |
|
- |
protected Element disown( Widget pWidget ) |
313 |
|
- |
{ |
|
285 |
+ |
protected Element disown( Widget pWidget ) { |
314 |
286 |
|
int index = mChildren.indexOf( pWidget ); |
315 |
|
- |
if ( index == -1 ) |
316 |
|
- |
{ |
|
287 |
+ |
if ( index == -1 ) { |
317 |
288 |
|
throw new IllegalStateException( "Attempt to 'disown' widget (" + pWidget + ") not owned by: " + this ); |
318 |
289 |
|
} |
319 |
|
- |
if ( aboutToDisown( pWidget, index ) ) |
320 |
|
- |
{ |
|
290 |
+ |
if ( aboutToDisown( pWidget, index ) ) { |
321 |
291 |
|
LLdisown( pWidget, index ); |
322 |
292 |
|
justDisowned( pWidget, index ); |
323 |
293 |
|
} |
324 |
294 |
|
return null; // We Don't Care |
325 |
295 |
|
} |
326 |
296 |
|
|
327 |
|
- |
protected void LLdisown( Widget pWidget, int pIndex ) |
328 |
|
- |
{ |
|
297 |
+ |
protected void LLdisown( Widget pWidget, int pIndex ) { |
329 |
298 |
|
Element td = abstractSizeablePanel_disown( pWidget ); // remove Widget from td |
330 |
299 |
|
DOM.removeChild( getContainerElement(), unwrap( td ) ); |
331 |
300 |
|
mChildren.remove( pIndex ); |
332 |
301 |
|
} |
333 |
302 |
|
|
334 |
|
- |
protected void LLadopt( Widget pWidget, int pBeforeIndex ) |
335 |
|
- |
{ |
|
303 |
+ |
protected void LLadopt( Widget pWidget, int pBeforeIndex ) { |
336 |
304 |
|
pWidget.removeFromParent(); |
337 |
305 |
|
Element td = DOM.createTD(); |
338 |
306 |
|
abstractSizeablePanel_adopt( pWidget, td ); // put Widget in TD |
|
@@ -340,13 +308,11 @@ |
340 |
308 |
|
mChildren.insert( pWidget, pBeforeIndex ); |
341 |
309 |
|
} |
342 |
310 |
|
|
343 |
|
- |
protected Element abstractSizeablePanel_disown( Widget pWidget ) |
344 |
|
- |
{ |
|
311 |
+ |
protected Element abstractSizeablePanel_disown( Widget pWidget ) { |
345 |
312 |
|
return super.disown( pWidget ); |
346 |
313 |
|
} |
347 |
314 |
|
|
348 |
|
- |
protected void abstractSizeablePanel_adopt( Widget pWidget, Element pContainer ) |
349 |
|
- |
{ |
|
315 |
+ |
protected void abstractSizeablePanel_adopt( Widget pWidget, Element pContainer ) { |
350 |
316 |
|
super.adopt( pWidget, pContainer ); |
351 |
317 |
|
} |
352 |
318 |
|
|
|
@@ -357,8 +323,7 @@ |
357 |
323 |
|
* @return true if OK to add |
358 |
324 |
|
*/ |
359 |
325 |
|
@SuppressWarnings({"UnusedParameters"}) |
360 |
|
- |
protected boolean aboutToAdopt( Widget pWidget, int pBeforeIndex ) |
361 |
|
- |
{ |
|
326 |
+ |
protected boolean aboutToAdopt( Widget pWidget, int pBeforeIndex ) { |
362 |
327 |
|
return true; |
363 |
328 |
|
} |
364 |
329 |
|
|
|
@@ -367,8 +332,7 @@ |
367 |
332 |
|
* Should not throw an exception! |
368 |
333 |
|
*/ |
369 |
334 |
|
@SuppressWarnings({"UnusedParameters"}) |
370 |
|
- |
protected void justAdopted( Widget pWidget, int pWidgetIndex ) |
371 |
|
- |
{ |
|
335 |
+ |
protected void justAdopted( Widget pWidget, int pWidgetIndex ) { |
372 |
336 |
|
} |
373 |
337 |
|
|
374 |
338 |
|
/** |
|
@@ -378,8 +342,7 @@ |
378 |
342 |
|
* @return true if OK to add |
379 |
343 |
|
*/ |
380 |
344 |
|
@SuppressWarnings({"UnusedParameters"}) |
381 |
|
- |
protected boolean aboutToDisown( Widget pWidget, int pBeforeIndex ) |
382 |
|
- |
{ |
|
345 |
+ |
protected boolean aboutToDisown( Widget pWidget, int pBeforeIndex ) { |
383 |
346 |
|
return true; |
384 |
347 |
|
} |
385 |
348 |
|
|
|
@@ -388,8 +351,7 @@ |
388 |
351 |
|
* Should not throw an exception! |
389 |
352 |
|
*/ |
390 |
353 |
|
@SuppressWarnings({"UnusedParameters"}) |
391 |
|
- |
protected void justDisowned( Widget pWidget, int pWidgetIndex ) |
392 |
|
- |
{ |
|
354 |
+ |
protected void justDisowned( Widget pWidget, int pWidgetIndex ) { |
393 |
355 |
|
} |
394 |
356 |
|
|
395 |
357 |
|
abstract protected Element unwrap( Element pTD ); |