|
@@ -1,25 +1,23 @@ |
1 |
1 |
|
// This Source Code is in the Public Domain per: http://unlicense.org |
2 |
2 |
|
package org.litesoft.GWT.client.widgets; |
3 |
3 |
|
|
4 |
|
- |
import java.util.*; |
5 |
|
- |
|
6 |
4 |
|
import org.litesoft.GWT.client.widgets.nonpublic.*; |
7 |
5 |
|
import org.litesoft.commonfoundation.base.*; |
8 |
6 |
|
|
9 |
|
- |
import com.google.gwt.user.client.ui.*; |
10 |
7 |
|
import com.google.gwt.user.client.*; |
|
8 |
+ |
import com.google.gwt.user.client.ui.*; |
|
9 |
+ |
|
|
10 |
+ |
import java.util.*; |
11 |
11 |
|
|
12 |
12 |
|
public class SizeableFloatableContainerPanel extends AbstractSizeableComplexPanel implements IndexedPanel, |
13 |
|
- |
FloatablesCarrier |
14 |
|
- |
{ |
|
13 |
+ |
FloatablesCarrier { |
15 |
14 |
|
private static int INITIAL_Z_INDEX = 1000; |
16 |
15 |
|
private static int MAX_ALLOWED_Z_INDEX = 9999; |
17 |
16 |
|
private SizeableFloater mActive = null; |
18 |
17 |
|
|
19 |
18 |
|
private FloatableContainerListener mFloatableContainerListener; |
20 |
19 |
|
|
21 |
|
- |
public SizeableFloatableContainerPanel() |
22 |
|
- |
{ |
|
20 |
+ |
public SizeableFloatableContainerPanel() { |
23 |
21 |
|
initializeElements( getHelper().create_OeSeIeOverflowHiddenSingleDivSandwich(), |
24 |
22 |
|
"litesoft-NoSizeAffectingCSS-FloatablesCarrier" ); |
25 |
23 |
|
LLstretchable(); |
|
@@ -34,24 +32,18 @@ |
34 |
32 |
|
DOM.setIntStyleAttribute( containerElement, "zIndex", 0 ); |
35 |
33 |
|
} |
36 |
34 |
|
|
37 |
|
- |
private boolean setActive( SizeableFloater pActive ) |
38 |
|
- |
{ |
39 |
|
- |
if ( pActive != mActive ) |
40 |
|
- |
{ |
41 |
|
- |
if ( mActive != null ) |
42 |
|
- |
{ |
|
35 |
+ |
private boolean setActive( SizeableFloater pActive ) { |
|
36 |
+ |
if ( pActive != mActive ) { |
|
37 |
+ |
if ( mActive != null ) { |
43 |
38 |
|
mActive.setActive( false ); |
44 |
|
- |
if ( mFloatableContainerListener != null ) |
45 |
|
- |
{ |
|
39 |
+ |
if ( mFloatableContainerListener != null ) { |
46 |
40 |
|
mFloatableContainerListener.clearActive( mActive ); |
47 |
41 |
|
} |
48 |
42 |
|
} |
49 |
43 |
|
mActive = pActive; |
50 |
|
- |
if ( mActive != null ) |
51 |
|
- |
{ |
|
44 |
+ |
if ( mActive != null ) { |
52 |
45 |
|
mActive.setActive( true ); |
53 |
|
- |
if ( mFloatableContainerListener != null ) |
54 |
|
- |
{ |
|
46 |
+ |
if ( mFloatableContainerListener != null ) { |
55 |
47 |
|
mFloatableContainerListener.setActive( mActive ); |
56 |
48 |
|
} |
57 |
49 |
|
} |
|
@@ -60,18 +52,13 @@ |
60 |
52 |
|
return false; |
61 |
53 |
|
} |
62 |
54 |
|
|
63 |
|
- |
public void undoCascade() |
64 |
|
- |
{ |
65 |
|
- |
if ( !mStackOfFloatersPositionState.isEmpty() ) |
66 |
|
- |
{ |
|
55 |
+ |
public void undoCascade() { |
|
56 |
+ |
if ( !mStackOfFloatersPositionState.isEmpty() ) { |
67 |
57 |
|
SizeableFloater[] floaters = getFloatersSortedByZindex(); |
68 |
58 |
|
|
69 |
|
- |
if ( floaters.length == 0 ) |
70 |
|
- |
{ |
|
59 |
+ |
if ( floaters.length == 0 ) { |
71 |
60 |
|
mStackOfFloatersPositionState.clear(); |
72 |
|
- |
} |
73 |
|
- |
else |
74 |
|
- |
{ |
|
61 |
+ |
} else { |
75 |
62 |
|
FloatersPositionState zFPS = mStackOfFloatersPositionState.pop(); |
76 |
63 |
|
|
77 |
64 |
|
setActive( zFPS.restoreFloaters( floaters ) ); |
|
@@ -81,69 +68,55 @@ |
81 |
68 |
|
|
82 |
69 |
|
private Stack<FloatersPositionState> mStackOfFloatersPositionState = new Stack<FloatersPositionState>(); |
83 |
70 |
|
|
84 |
|
- |
public void cascade() |
85 |
|
- |
{ |
|
71 |
+ |
public void cascade() { |
86 |
72 |
|
SizeableFloater[] floaters = getFloatersSortedByZindex(); |
87 |
|
- |
if ( floaters.length == 0 ) |
88 |
|
- |
{ |
|
73 |
+ |
if ( floaters.length == 0 ) { |
89 |
74 |
|
mStackOfFloatersPositionState.clear(); |
90 |
|
- |
} |
91 |
|
- |
else |
92 |
|
- |
{ |
|
75 |
+ |
} else { |
93 |
76 |
|
FloatersPositionState zFPS = new FloatersPositionState(); |
94 |
77 |
|
|
95 |
78 |
|
SizeableFloater floater = zFPS.cascadeFloaters( floaters ); |
96 |
79 |
|
|
97 |
|
- |
if ( floater != null ) |
98 |
|
- |
{ |
|
80 |
+ |
if ( floater != null ) { |
99 |
81 |
|
setActive( floater ); |
100 |
82 |
|
|
101 |
|
- |
if ( floater.getZindex() > MAX_ALLOWED_Z_INDEX ) |
102 |
|
- |
{ |
|
83 |
+ |
if ( floater.getZindex() > MAX_ALLOWED_Z_INDEX ) { |
103 |
84 |
|
reZindex(); |
104 |
85 |
|
} |
105 |
86 |
|
|
106 |
|
- |
if ( zFPS.isChanged() ) |
107 |
|
- |
{ |
|
87 |
+ |
if ( zFPS.isChanged() ) { |
108 |
88 |
|
mStackOfFloatersPositionState.push( zFPS ); |
109 |
89 |
|
} |
110 |
90 |
|
} |
111 |
91 |
|
} |
112 |
92 |
|
} |
113 |
93 |
|
|
114 |
|
- |
private SizeableFloater[] getArrayOfChildren() |
115 |
|
- |
{ |
|
94 |
+ |
private SizeableFloater[] getArrayOfChildren() { |
116 |
95 |
|
WidgetCollection wc = getChildren(); |
117 |
96 |
|
int count = wc.size(); |
118 |
|
- |
if ( count == 0 ) |
119 |
|
- |
{ |
|
97 |
+ |
if ( count == 0 ) { |
120 |
98 |
|
return SizeableFloater.EMPTY_ARRAY; |
121 |
99 |
|
} |
122 |
100 |
|
SizeableFloater[] floaters = new SizeableFloater[count]; |
123 |
|
- |
for ( int i = 0; i < floaters.length; i++ ) |
124 |
|
- |
{ |
|
101 |
+ |
for ( int i = 0; i < floaters.length; i++ ) { |
125 |
102 |
|
floaters[i] = (SizeableFloater) wc.get( i ); |
126 |
103 |
|
} |
127 |
104 |
|
return floaters; |
128 |
105 |
|
} |
129 |
106 |
|
|
130 |
|
- |
public Widget getWidget( int index ) |
131 |
|
- |
{ |
|
107 |
+ |
public Widget getWidget( int index ) { |
132 |
108 |
|
return getChildren().get( index ); |
133 |
109 |
|
} |
134 |
110 |
|
|
135 |
|
- |
public int getWidgetCount() |
136 |
|
- |
{ |
|
111 |
+ |
public int getWidgetCount() { |
137 |
112 |
|
return getChildren().size(); |
138 |
113 |
|
} |
139 |
114 |
|
|
140 |
|
- |
public int getWidgetIndex( Widget child ) |
141 |
|
- |
{ |
|
115 |
+ |
public int getWidgetIndex( Widget child ) { |
142 |
116 |
|
return getChildren().indexOf( child ); |
143 |
117 |
|
} |
144 |
118 |
|
|
145 |
|
- |
public boolean remove( int index ) |
146 |
|
- |
{ |
|
119 |
+ |
public boolean remove( int index ) { |
147 |
120 |
|
return remove( getWidget( index ) ); |
148 |
121 |
|
} |
149 |
122 |
|
|
|
@@ -152,10 +125,8 @@ |
152 |
125 |
|
* |
153 |
126 |
|
* @param w the widget to be added |
154 |
127 |
|
*/ |
155 |
|
- |
public void add( Widget w ) |
156 |
|
- |
{ |
157 |
|
- |
if ( !(w instanceof SizeableFloater) ) |
158 |
|
- |
{ |
|
128 |
+ |
public void add( Widget w ) { |
|
129 |
+ |
if ( !(w instanceof SizeableFloater) ) { |
159 |
130 |
|
throw new IllegalArgumentException( "Only a 'SizeableFloater' can be added" ); |
160 |
131 |
|
} |
161 |
132 |
|
SizeableFloater floater = (SizeableFloater) w; |
|
@@ -168,8 +139,7 @@ |
168 |
139 |
|
|
169 |
140 |
|
SizeableFloater[] floaters = getArrayOfChildren(); |
170 |
141 |
|
|
171 |
|
- |
if ( floaters.length != 0 ) |
172 |
|
- |
{ |
|
142 |
+ |
if ( floaters.length != 0 ) { |
173 |
143 |
|
int delta = Math.max( floaters[0].getTitleBarHeight(), 25 ); |
174 |
144 |
|
|
175 |
145 |
|
int doubleDelta = (delta * 2); |
|
@@ -177,11 +147,9 @@ |
177 |
147 |
|
int maxHeight = getOffsetHeight() - doubleDelta; |
178 |
148 |
|
boolean checkOverflow = (maxWidth > doubleDelta && maxHeight > doubleDelta); |
179 |
149 |
|
|
180 |
|
- |
while ( anyAt( floaters, delta, zTop, zLeft ) ) |
181 |
|
- |
{ |
|
150 |
+ |
while ( anyAt( floaters, delta, zTop, zLeft ) ) { |
182 |
151 |
|
// safety valve -- if things get too jammed, just start plopping stuff at the top left |
183 |
|
- |
if ( count++ > 80 ) |
184 |
|
- |
{ |
|
152 |
+ |
if ( count++ > 80 ) { |
185 |
153 |
|
zTop = zLeft = 0; |
186 |
154 |
|
break; |
187 |
155 |
|
} |
|
@@ -190,11 +158,9 @@ |
190 |
158 |
|
zLeft += delta; |
191 |
159 |
|
|
192 |
160 |
|
// if we roll off the bottom or right, start over with a smaller delta |
193 |
|
- |
if ( checkOverflow && (zTop > maxHeight || zLeft > maxWidth) ) |
194 |
|
- |
{ |
|
161 |
+ |
if ( checkOverflow && (zTop > maxHeight || zLeft > maxWidth) ) { |
195 |
162 |
|
delta /= 2; |
196 |
|
- |
if ( delta < 2 ) |
197 |
|
- |
{ |
|
163 |
+ |
if ( delta < 2 ) { |
198 |
164 |
|
delta = 2; |
199 |
165 |
|
} |
200 |
166 |
|
zTop = delta; |
|
@@ -210,13 +176,10 @@ |
210 |
176 |
|
makeTop( floater ); |
211 |
177 |
|
} |
212 |
178 |
|
|
213 |
|
- |
public boolean remove( Widget w ) |
214 |
|
- |
{ |
215 |
|
- |
if ( super.remove( w ) ) |
216 |
|
- |
{ |
|
179 |
+ |
public boolean remove( Widget w ) { |
|
180 |
+ |
if ( super.remove( w ) ) { |
217 |
181 |
|
setActive( (getChildren().size() > 0) ? getCurrentMaxZindexChild() : null ); |
218 |
|
- |
if ( w instanceof SizeableFloater ) |
219 |
|
- |
{ |
|
182 |
+ |
if ( w instanceof SizeableFloater ) { |
220 |
183 |
|
floaterRemoved( (SizeableFloater) w ); |
221 |
184 |
|
} |
222 |
185 |
|
return true; |
|
@@ -224,85 +187,69 @@ |
224 |
187 |
|
return false; |
225 |
188 |
|
} |
226 |
189 |
|
|
227 |
|
- |
private boolean anyAt( SizeableFloater[] pFloaters, int pDelta, int pTop, int pLeft ) |
228 |
|
- |
{ |
|
190 |
+ |
private boolean anyAt( SizeableFloater[] pFloaters, int pDelta, int pTop, int pLeft ) { |
229 |
191 |
|
//noinspection ForLoopReplaceableByForEach |
230 |
|
- |
for ( int i = 0; i < pFloaters.length; i++ ) |
231 |
|
- |
{ |
|
192 |
+ |
for ( int i = 0; i < pFloaters.length; i++ ) { |
232 |
193 |
|
SizeableFloater floater = pFloaters[i]; |
233 |
194 |
|
if ( within( pDelta, pTop, floater.getPosTop() ) || |
234 |
|
- |
within( pDelta, pLeft, floater.getPosLeft() ) ) |
235 |
|
- |
{ |
|
195 |
+ |
within( pDelta, pLeft, floater.getPosLeft() ) ) { |
236 |
196 |
|
return true; |
237 |
197 |
|
} |
238 |
198 |
|
} |
239 |
199 |
|
return false; |
240 |
200 |
|
} |
241 |
201 |
|
|
242 |
|
- |
private boolean within( int pDelta, int pPos1, int pPos2 ) |
243 |
|
- |
{ |
|
202 |
+ |
private boolean within( int pDelta, int pPos1, int pPos2 ) { |
244 |
203 |
|
return Math.abs( pPos1 - pPos2 ) < pDelta; |
245 |
204 |
|
} |
246 |
205 |
|
|
247 |
|
- |
public SizeableFloater[] getFloatersSortedByTitle() |
248 |
|
- |
{ |
|
206 |
+ |
public SizeableFloater[] getFloatersSortedByTitle() { |
249 |
207 |
|
return getFloatersSortedBy( TitleComparator.INSTANCE ); |
250 |
208 |
|
} |
251 |
209 |
|
|
252 |
|
- |
public SizeableFloater[] getFloatersSortedByZindex() |
253 |
|
- |
{ |
|
210 |
+ |
public SizeableFloater[] getFloatersSortedByZindex() { |
254 |
211 |
|
return getFloatersSortedBy( ZindexComparator.INSTANCE ); |
255 |
212 |
|
} |
256 |
213 |
|
|
257 |
|
- |
private SizeableFloater[] getFloatersSortedBy( Comparator pComparator ) |
258 |
|
- |
{ |
|
214 |
+ |
private SizeableFloater[] getFloatersSortedBy( Comparator pComparator ) { |
259 |
215 |
|
SizeableFloater[] floaters = getArrayOfChildren(); |
260 |
216 |
|
return sort( floaters, pComparator ); |
261 |
217 |
|
} |
262 |
218 |
|
|
263 |
|
- |
private static SizeableFloater[] sort( SizeableFloater[] pFloaters, Comparator pComparator ) |
264 |
|
- |
{ |
265 |
|
- |
if ( pFloaters.length != 0 ) |
266 |
|
- |
{ |
|
219 |
+ |
private static SizeableFloater[] sort( SizeableFloater[] pFloaters, Comparator pComparator ) { |
|
220 |
+ |
if ( pFloaters.length != 0 ) { |
267 |
221 |
|
//noinspection unchecked |
268 |
222 |
|
Arrays.sort( pFloaters, pComparator ); |
269 |
223 |
|
} |
270 |
224 |
|
return pFloaters; |
271 |
225 |
|
} |
272 |
226 |
|
|
273 |
|
- |
private void reZindex() |
274 |
|
- |
{ |
|
227 |
+ |
private void reZindex() { |
275 |
228 |
|
reZindex( getFloatersSortedByZindex() ); |
276 |
229 |
|
} |
277 |
230 |
|
|
278 |
|
- |
private static void reZindex( SizeableFloater[] pFloaters ) |
279 |
|
- |
{ |
|
231 |
+ |
private static void reZindex( SizeableFloater[] pFloaters ) { |
280 |
232 |
|
int zIndex = INITIAL_Z_INDEX; |
281 |
233 |
|
//noinspection ForLoopReplaceableByForEach |
282 |
|
- |
for ( int i = 0; i < pFloaters.length; i++ ) |
283 |
|
- |
{ |
|
234 |
+ |
for ( int i = 0; i < pFloaters.length; i++ ) { |
284 |
235 |
|
pFloaters[i].setZindex( ++zIndex ); |
285 |
236 |
|
} |
286 |
237 |
|
} |
287 |
238 |
|
|
288 |
|
- |
private SizeableFloater getCurrentMaxZindexChild() |
289 |
|
- |
{ |
|
239 |
+ |
private SizeableFloater getCurrentMaxZindexChild() { |
290 |
240 |
|
WidgetCollection wc = getChildren(); |
291 |
241 |
|
int count = wc.size(); |
292 |
242 |
|
|
293 |
|
- |
if ( count == 0 ) |
294 |
|
- |
{ |
|
243 |
+ |
if ( count == 0 ) { |
295 |
244 |
|
return null; |
296 |
245 |
|
} |
297 |
246 |
|
SizeableFloater maxChild = (SizeableFloater) wc.get( 0 ); |
298 |
247 |
|
int maxZ = maxChild.getZindex(); |
299 |
248 |
|
|
300 |
|
- |
for ( int i = 1; i < count; i++ ) |
301 |
|
- |
{ |
|
249 |
+ |
for ( int i = 1; i < count; i++ ) { |
302 |
250 |
|
SizeableFloater floater = (SizeableFloater) wc.get( i ); |
303 |
251 |
|
int zindex = floater.getZindex(); |
304 |
|
- |
if ( zindex > maxZ ) |
305 |
|
- |
{ |
|
252 |
+ |
if ( zindex > maxZ ) { |
306 |
253 |
|
maxChild = floater; |
307 |
254 |
|
maxZ = zindex; |
308 |
255 |
|
} |
|
@@ -313,241 +260,197 @@ |
313 |
260 |
|
/** |
314 |
261 |
|
* ONLY called by a current child! |
315 |
262 |
|
*/ |
316 |
|
- |
public void makeTop( SizeableFloater pChild ) |
317 |
|
- |
{ |
|
263 |
+ |
public void makeTop( SizeableFloater pChild ) { |
318 |
264 |
|
SizeableFloatingPanel zFloater = ((SizeableFloatingPanel) pChild); |
319 |
265 |
|
|
320 |
|
- |
if(zFloater.isHidden()) |
321 |
|
- |
{ |
|
266 |
+ |
if ( zFloater.isHidden() ) { |
322 |
267 |
|
// zFloater.setActive( true ); |
323 |
|
- |
zFloater.showFloater( ); |
|
268 |
+ |
zFloater.showFloater(); |
324 |
269 |
|
} |
325 |
270 |
|
|
326 |
|
- |
if ( pChild != mActive ) |
327 |
|
- |
{ |
|
271 |
+ |
if ( pChild != mActive ) { |
328 |
272 |
|
int zindex = calcTemporaryNewZindex(); |
329 |
273 |
|
pChild.setZindex( zindex ); |
330 |
|
- |
if ( zindex > MAX_ALLOWED_Z_INDEX ) |
331 |
|
- |
{ |
|
274 |
+ |
if ( zindex > MAX_ALLOWED_Z_INDEX ) { |
332 |
275 |
|
reZindex(); |
333 |
276 |
|
} |
334 |
277 |
|
setActive( pChild ); |
335 |
278 |
|
} |
336 |
279 |
|
} |
337 |
280 |
|
|
338 |
|
- |
private int calcTemporaryNewZindex() |
339 |
|
- |
{ |
|
281 |
+ |
private int calcTemporaryNewZindex() { |
340 |
282 |
|
return 1 + ((mActive == null) ? INITIAL_Z_INDEX : mActive.getZindex()); |
341 |
283 |
|
} |
342 |
284 |
|
|
343 |
285 |
|
//****** Implementation Code Block to support delegation to AbsoluteSizeHelper |
344 |
286 |
|
|
345 |
|
- |
public SizeableFloatableContainerPanel width( int pPixels ) |
346 |
|
- |
{ |
|
287 |
+ |
public SizeableFloatableContainerPanel width( int pPixels ) { |
347 |
288 |
|
setWidth( "" + pPixels ); |
348 |
289 |
|
return this; |
349 |
290 |
|
} |
350 |
291 |
|
|
351 |
|
- |
public SizeableFloatableContainerPanel height( int pPixels ) |
352 |
|
- |
{ |
|
292 |
+ |
public SizeableFloatableContainerPanel height( int pPixels ) { |
353 |
293 |
|
setHeight( "" + pPixels ); |
354 |
294 |
|
return this; |
355 |
295 |
|
} |
356 |
296 |
|
|
357 |
|
- |
public void setRenderedDeferredCommand( Command pCommand ) |
358 |
|
- |
{ |
|
297 |
+ |
public void setRenderedDeferredCommand( Command pCommand ) { |
359 |
298 |
|
mRDCHelper.setRenderedDeferredCommand( pCommand ); |
360 |
299 |
|
} |
361 |
300 |
|
|
362 |
|
- |
public void setWidth( String width ) |
363 |
|
- |
{ |
|
301 |
+ |
public void setWidth( String width ) { |
364 |
302 |
|
super.setWidth( width ); |
365 |
303 |
|
mRDCHelper.chkWidth( width ); |
366 |
304 |
|
} |
367 |
305 |
|
|
368 |
|
- |
public void setHeight( String height ) |
369 |
|
- |
{ |
|
306 |
+ |
public void setHeight( String height ) { |
370 |
307 |
|
super.setHeight( height ); |
371 |
308 |
|
mRDCHelper.chkHeight( height ); |
372 |
309 |
|
} |
373 |
310 |
|
|
374 |
311 |
|
private RenderedDeferredCommandHelper mRDCHelper = new RenderedDeferredCommandHelper( this ); |
375 |
312 |
|
|
376 |
|
- |
protected void distributeToChildrenChangedWidth() |
377 |
|
- |
{ |
|
313 |
+ |
protected void distributeToChildrenChangedWidth() { |
378 |
314 |
|
getHelper().forceAdjustDimensionOnChild( getHelper().getInnerElement(), getWidthHelper() ); |
379 |
|
- |
for ( int i = 0; i < getWidgetCount(); i++ ) |
380 |
|
- |
{ |
|
315 |
+ |
for ( int i = 0; i < getWidgetCount(); i++ ) { |
381 |
316 |
|
SizeableFloater floater = (SizeableFloater) getWidget( i ); |
382 |
317 |
|
floater.initializeWidth(); |
383 |
|
- |
if ( floater.isPositionLocked() ) |
384 |
|
- |
{ |
|
318 |
+ |
if ( floater.isPositionLocked() ) { |
385 |
319 |
|
floater.changedContainerWidth(); |
386 |
320 |
|
} |
387 |
321 |
|
} |
388 |
322 |
|
} |
389 |
323 |
|
|
390 |
|
- |
protected void distributeToChildrenChangedHeight() |
391 |
|
- |
{ |
|
324 |
+ |
protected void distributeToChildrenChangedHeight() { |
392 |
325 |
|
getHelper().forceAdjustDimensionOnChild( getHelper().getInnerElement(), getHeightHelper() ); |
393 |
|
- |
for ( int i = 0; i < getWidgetCount(); i++ ) |
394 |
|
- |
{ |
|
326 |
+ |
for ( int i = 0; i < getWidgetCount(); i++ ) { |
395 |
327 |
|
SizeableFloater floater = (SizeableFloater) getWidget( i ); |
396 |
328 |
|
floater.initializeHeight(); |
397 |
|
- |
if ( floater.isPositionLocked() ) |
398 |
|
- |
{ |
|
329 |
+ |
if ( floater.isPositionLocked() ) { |
399 |
330 |
|
floater.changedContainerHeight(); |
400 |
331 |
|
} |
401 |
332 |
|
} |
402 |
333 |
|
} |
403 |
334 |
|
|
404 |
|
- |
public void setFloatableContainerListener( FloatableContainerListener pFloatableContainerListener ) |
405 |
|
- |
{ |
|
335 |
+ |
public void setFloatableContainerListener( FloatableContainerListener pFloatableContainerListener ) { |
406 |
336 |
|
mFloatableContainerListener = pFloatableContainerListener; |
407 |
337 |
|
} |
408 |
338 |
|
|
409 |
|
- |
private void floaterAdded( SizeableFloater pFloater ) |
410 |
|
- |
{ |
411 |
|
- |
if ( mFloatableContainerListener != null ) |
412 |
|
- |
{ |
|
339 |
+ |
private void floaterAdded( SizeableFloater pFloater ) { |
|
340 |
+ |
if ( mFloatableContainerListener != null ) { |
413 |
341 |
|
mFloatableContainerListener.floaterAdded( pFloater ); |
414 |
342 |
|
} |
415 |
343 |
|
} |
416 |
344 |
|
|
417 |
|
- |
private void floaterRemoved( SizeableFloater pFloater ) |
418 |
|
- |
{ |
419 |
|
- |
if ( mFloatableContainerListener != null ) |
420 |
|
- |
{ |
|
345 |
+ |
private void floaterRemoved( SizeableFloater pFloater ) { |
|
346 |
+ |
if ( mFloatableContainerListener != null ) { |
421 |
347 |
|
mFloatableContainerListener.floaterRemoved( pFloater ); |
422 |
348 |
|
} |
423 |
349 |
|
} |
424 |
350 |
|
|
425 |
|
- |
private static class ZindexComparator implements Comparator |
426 |
|
- |
{ |
|
351 |
+ |
private static class ZindexComparator implements Comparator { |
427 |
352 |
|
public static final Comparator INSTANCE = new ZindexComparator(); |
428 |
353 |
|
|
429 |
|
- |
public int compare( Object o1, Object o2 ) |
430 |
|
- |
{ |
|
354 |
+ |
public int compare( Object o1, Object o2 ) { |
431 |
355 |
|
return compare( (SizeableFloater) o1, (SizeableFloater) o2 ); |
432 |
356 |
|
} |
433 |
357 |
|
|
434 |
358 |
|
/** |
435 |
359 |
|
* @return a negative integer, zero, or a positive integer as pThis object |
436 |
|
- |
* is less than, equal to, or greater than the pThem object. |
|
360 |
+ |
* is less than, equal to, or greater than the pThem object. |
437 |
361 |
|
*/ |
438 |
|
- |
public int compare( SizeableFloater pThis, SizeableFloater pThem ) |
439 |
|
- |
{ |
|
362 |
+ |
public int compare( SizeableFloater pThis, SizeableFloater pThem ) { |
440 |
363 |
|
return pThis.getZindex() - pThem.getZindex(); |
441 |
364 |
|
} |
442 |
365 |
|
} |
443 |
366 |
|
|
444 |
|
- |
private static class AreaComparator implements Comparator<SizeableFloater> |
445 |
|
- |
{ |
|
367 |
+ |
private static class AreaComparator implements Comparator<SizeableFloater> { |
446 |
368 |
|
public static final AreaComparator INSTANCE = new AreaComparator(); |
447 |
369 |
|
|
448 |
370 |
|
/** |
449 |
371 |
|
* @return a negative integer, zero, or a positive integer as pThis object |
450 |
|
- |
* is less than, equal to, or greater than the pThem object. |
|
372 |
+ |
* is less than, equal to, or greater than the pThem object. |
451 |
373 |
|
*/ |
452 |
|
- |
public int compare( SizeableFloater pThis, SizeableFloater pThem ) |
453 |
|
- |
{ |
|
374 |
+ |
public int compare( SizeableFloater pThis, SizeableFloater pThem ) { |
454 |
375 |
|
// return pThis.getArea() - pThem.getArea(); |
455 |
376 |
|
return pThem.getArea() - pThis.getArea(); // reverse! (Bigger to Smaller) |
456 |
377 |
|
} |
457 |
378 |
|
} |
458 |
379 |
|
|
459 |
|
- |
private static class TitleComparator implements Comparator |
460 |
|
- |
{ |
|
380 |
+ |
private static class TitleComparator implements Comparator { |
461 |
381 |
|
public static final Comparator INSTANCE = new TitleComparator(); |
462 |
382 |
|
|
463 |
|
- |
public int compare( Object o1, Object o2 ) |
464 |
|
- |
{ |
|
383 |
+ |
public int compare( Object o1, Object o2 ) { |
465 |
384 |
|
return compare( (SizeableFloater) o1, (SizeableFloater) o2 ); |
466 |
385 |
|
} |
467 |
386 |
|
|
468 |
387 |
|
/** |
469 |
388 |
|
* @return a negative integer, zero, or a positive integer as pThis object |
470 |
|
- |
* is less than, equal to, or greater than the pThem object. |
|
389 |
+ |
* is less than, equal to, or greater than the pThem object. |
471 |
390 |
|
*/ |
472 |
|
- |
public int compare( SizeableFloater pThis, SizeableFloater pThem ) |
473 |
|
- |
{ |
|
391 |
+ |
public int compare( SizeableFloater pThis, SizeableFloater pThem ) { |
474 |
392 |
|
return Compare.nullsOK( pThem.getTitle(), pThis.getTitle() ); |
475 |
393 |
|
} |
476 |
394 |
|
} |
477 |
395 |
|
|
478 |
|
- |
private static class FloaterPosition implements Cascadable |
479 |
|
- |
{ |
|
396 |
+ |
private static class FloaterPosition implements Cascadable { |
480 |
397 |
|
private int mCascadeUniqueID, mPosLeft, mPosTop; |
481 |
398 |
|
|
482 |
|
- |
public FloaterPosition( SizeableFloater pFloater ) |
483 |
|
- |
{ |
|
399 |
+ |
public FloaterPosition( SizeableFloater pFloater ) { |
484 |
400 |
|
mCascadeUniqueID = pFloater.getCascadeUniqueID(); |
485 |
401 |
|
mPosLeft = pFloater.getPosLeft(); |
486 |
402 |
|
mPosTop = pFloater.getPosTop(); |
487 |
403 |
|
} |
488 |
404 |
|
|
489 |
|
- |
public boolean isPositionLocked() |
490 |
|
- |
{ |
|
405 |
+ |
public boolean isPositionLocked() { |
491 |
406 |
|
return true; |
492 |
407 |
|
} |
493 |
408 |
|
|
494 |
|
- |
public int getCascadeUniqueID() |
495 |
|
- |
{ |
|
409 |
+ |
public int getCascadeUniqueID() { |
496 |
410 |
|
return mCascadeUniqueID; |
497 |
411 |
|
} |
498 |
412 |
|
|
499 |
|
- |
public int getPosLeft() |
500 |
|
- |
{ |
|
413 |
+ |
public int getPosLeft() { |
501 |
414 |
|
return mPosLeft; |
502 |
415 |
|
} |
503 |
416 |
|
|
504 |
|
- |
public int getPosTop() |
505 |
|
- |
{ |
|
417 |
+ |
public int getPosTop() { |
506 |
418 |
|
return mPosTop; |
507 |
419 |
|
} |
508 |
420 |
|
|
509 |
|
- |
public int getOffsetWidth() |
510 |
|
- |
{ |
|
421 |
+ |
public int getOffsetWidth() { |
511 |
422 |
|
throw new UnsupportedOperationException(); |
512 |
423 |
|
} |
513 |
424 |
|
|
514 |
|
- |
public int getOffsetHeight() |
515 |
|
- |
{ |
|
425 |
+ |
public int getOffsetHeight() { |
516 |
426 |
|
throw new UnsupportedOperationException(); |
517 |
427 |
|
} |
518 |
428 |
|
|
519 |
|
- |
public int minPosLeft() |
520 |
|
- |
{ |
|
429 |
+ |
public int minPosLeft() { |
521 |
430 |
|
throw new UnsupportedOperationException(); |
522 |
431 |
|
} |
523 |
432 |
|
|
524 |
|
- |
public int minPosTop() |
525 |
|
- |
{ |
|
433 |
+ |
public int minPosTop() { |
526 |
434 |
|
throw new UnsupportedOperationException(); |
527 |
435 |
|
} |
528 |
436 |
|
|
529 |
|
- |
public int maxPosLeft() |
530 |
|
- |
{ |
|
437 |
+ |
public int maxPosLeft() { |
531 |
438 |
|
throw new UnsupportedOperationException(); |
532 |
439 |
|
} |
533 |
440 |
|
|
534 |
|
- |
public int maxPosTop() |
535 |
|
- |
{ |
|
441 |
+ |
public int maxPosTop() { |
536 |
442 |
|
throw new UnsupportedOperationException(); |
537 |
443 |
|
} |
538 |
444 |
|
|
539 |
|
- |
public void setPosition( int pLeft, int pTop ) |
540 |
|
- |
{ |
|
445 |
+ |
public void setPosition( int pLeft, int pTop ) { |
541 |
446 |
|
throw new UnsupportedOperationException(); |
542 |
447 |
|
} |
543 |
448 |
|
|
544 |
|
- |
public void setPosLeft( int pPosLeft ) |
545 |
|
- |
{ |
|
449 |
+ |
public void setPosLeft( int pPosLeft ) { |
546 |
450 |
|
throw new UnsupportedOperationException(); |
547 |
451 |
|
} |
548 |
452 |
|
|
549 |
|
- |
public void setPosTop( int pPosTop ) |
550 |
|
- |
{ |
|
453 |
+ |
public void setPosTop( int pPosTop ) { |
551 |
454 |
|
throw new UnsupportedOperationException(); |
552 |
455 |
|
} |
553 |
456 |
|
|
|
@@ -556,22 +459,19 @@ |
556 |
459 |
|
* |
557 |
460 |
|
* @param them !null |
558 |
461 |
|
*/ |
559 |
|
- |
public boolean isEquivalent( Cascadable them ) |
560 |
|
- |
{ |
|
462 |
+ |
public boolean isEquivalent( Cascadable them ) { |
561 |
463 |
|
return (this.getCascadeUniqueID() == them.getCascadeUniqueID()) // |
562 |
464 |
|
&& (this.getPosLeft() == them.getPosLeft()) // |
563 |
465 |
|
&& (this.getPosTop() == them.getPosTop()) // |
564 |
466 |
|
; |
565 |
467 |
|
} |
566 |
468 |
|
|
567 |
|
- |
public boolean shouldMove( int pDesiredLeft, int pDesiredTop ) |
568 |
|
- |
{ |
|
469 |
+ |
public boolean shouldMove( int pDesiredLeft, int pDesiredTop ) { |
569 |
470 |
|
return (mPosLeft != pDesiredLeft) || (mPosTop != pDesiredTop); |
570 |
471 |
|
} |
571 |
472 |
|
} |
572 |
473 |
|
|
573 |
|
- |
private static class FloatersPositionState |
574 |
|
- |
{ |
|
474 |
+ |
private static class FloatersPositionState { |
575 |
475 |
|
private boolean mChanged = false; |
576 |
476 |
|
private FloaterPosition[] mFloaterPositions; |
577 |
477 |
|
|
|
@@ -581,32 +481,26 @@ |
581 |
481 |
|
* |
582 |
482 |
|
* @return - Floater to make Active |
583 |
483 |
|
*/ |
584 |
|
- |
public SizeableFloater restoreFloaters( SizeableFloater[] pFloaters ) |
585 |
|
- |
{ |
|
484 |
+ |
public SizeableFloater restoreFloaters( SizeableFloater[] pFloaters ) { |
586 |
485 |
|
SizeableFloater floater = null; |
587 |
486 |
|
|
588 |
487 |
|
SizeableFloater[] zNewOrder = new SizeableFloater[pFloaters.length]; |
589 |
488 |
|
|
590 |
489 |
|
int ndxTo = 0; |
591 |
|
- |
for ( int ndxFrom = 0; ndxFrom < mFloaterPositions.length; ndxFrom++ ) |
592 |
|
- |
{ |
|
490 |
+ |
for ( int ndxFrom = 0; ndxFrom < mFloaterPositions.length; ndxFrom++ ) { |
593 |
491 |
|
FloaterPosition zPosition = mFloaterPositions[ndxFrom]; |
594 |
492 |
|
int zAt = locate( zPosition.getCascadeUniqueID(), pFloaters ); |
595 |
|
- |
if ( zAt != -1 ) |
596 |
|
- |
{ |
|
493 |
+ |
if ( zAt != -1 ) { |
597 |
494 |
|
floater = zNewOrder[ndxTo++] = pFloaters[zAt]; |
598 |
495 |
|
pFloaters[zAt] = null; |
599 |
|
- |
if ( !floater.isPositionLocked() ) |
600 |
|
- |
{ |
|
496 |
+ |
if ( !floater.isPositionLocked() ) { |
601 |
497 |
|
floater.setPosition( zPosition.getPosLeft(), zPosition.getPosTop() ); |
602 |
498 |
|
} |
603 |
499 |
|
} |
604 |
500 |
|
} |
605 |
|
- |
for ( int i = 0; i < pFloaters.length; i++ ) |
606 |
|
- |
{ |
|
501 |
+ |
for ( int i = 0; i < pFloaters.length; i++ ) { |
607 |
502 |
|
SizeableFloater zFloater = pFloaters[i]; |
608 |
|
- |
if ( zFloater != null ) |
609 |
|
- |
{ |
|
503 |
+ |
if ( zFloater != null ) { |
610 |
504 |
|
floater = zNewOrder[ndxTo++] = zFloater; |
611 |
505 |
|
} |
612 |
506 |
|
} |
|
@@ -616,14 +510,11 @@ |
616 |
510 |
|
return floater; |
617 |
511 |
|
} |
618 |
512 |
|
|
619 |
|
- |
private int locate( int pCascadeUniqueID, SizeableFloater[] pFloaters ) |
620 |
|
- |
{ |
|
513 |
+ |
private int locate( int pCascadeUniqueID, SizeableFloater[] pFloaters ) { |
621 |
514 |
|
int i = pFloaters.length; |
622 |
|
- |
while ( --i >= 0 ) |
623 |
|
- |
{ |
|
515 |
+ |
while ( --i >= 0 ) { |
624 |
516 |
|
SizeableFloater zFloater = pFloaters[i]; |
625 |
|
- |
if ( (zFloater != null) && (zFloater.getCascadeUniqueID() == pCascadeUniqueID) ) |
626 |
|
- |
{ |
|
517 |
+ |
if ( (zFloater != null) && (zFloater.getCascadeUniqueID() == pCascadeUniqueID) ) { |
627 |
518 |
|
return i; |
628 |
519 |
|
} |
629 |
520 |
|
} |
|
@@ -631,17 +522,14 @@ |
631 |
522 |
|
} |
632 |
523 |
|
|
633 |
524 |
|
private SizeableFloater populate( SizeableFloater[] pFloaters, |
634 |
|
- |
List<SizeableFloater> pNonLockedFloaters ) |
635 |
|
- |
{ |
|
525 |
+ |
List<SizeableFloater> pNonLockedFloaters ) { |
636 |
526 |
|
mFloaterPositions = new FloaterPosition[pFloaters.length]; |
637 |
527 |
|
|
638 |
528 |
|
SizeableFloater zFloater = null; |
639 |
|
- |
for ( int i = 0; i < pFloaters.length; i++ ) |
640 |
|
- |
{ |
|
529 |
+ |
for ( int i = 0; i < pFloaters.length; i++ ) { |
641 |
530 |
|
zFloater = pFloaters[i]; |
642 |
531 |
|
mFloaterPositions[i] = new FloaterPosition( zFloater ); |
643 |
|
- |
if ( !zFloater.isPositionLocked() ) |
644 |
|
- |
{ |
|
532 |
+ |
if ( !zFloater.isPositionLocked() ) { |
645 |
533 |
|
pNonLockedFloaters.add( zFloater ); |
646 |
534 |
|
} |
647 |
535 |
|
} |
|
@@ -654,14 +542,12 @@ |
654 |
542 |
|
* |
655 |
543 |
|
* @return - Floater to make Active |
656 |
544 |
|
*/ |
657 |
|
- |
public SizeableFloater cascadeFloaters( SizeableFloater[] pFloaters ) |
658 |
|
- |
{ |
|
545 |
+ |
public SizeableFloater cascadeFloaters( SizeableFloater[] pFloaters ) { |
659 |
546 |
|
List<SizeableFloater> zNonLockedFloaters = new ArrayList<SizeableFloater>( pFloaters.length ); |
660 |
547 |
|
|
661 |
548 |
|
SizeableFloater zFloater = populate( pFloaters, zNonLockedFloaters ); |
662 |
549 |
|
|
663 |
|
- |
if ( zFloater == null ) |
664 |
|
- |
{ |
|
550 |
+ |
if ( zFloater == null ) { |
665 |
551 |
|
return null; |
666 |
552 |
|
} |
667 |
553 |
|
Collections.sort( zNonLockedFloaters, AreaComparator.INSTANCE ); |
|
@@ -675,16 +561,14 @@ |
675 |
561 |
|
|
676 |
562 |
|
int delta = Math.max( floater.getTitleBarHeight(), 25 ); |
677 |
563 |
|
|
678 |
|
- |
for ( int i = 1; i < zNonLockedFloaters.size(); i++ ) |
679 |
|
- |
{ |
|
564 |
+ |
for ( int i = 1; i < zNonLockedFloaters.size(); i++ ) { |
680 |
565 |
|
floater = cascadeFloater( zNonLockedFloaters, pMaxZindex, i, zLeft += delta, zTop += delta ); |
681 |
566 |
|
} |
682 |
567 |
|
return floater; |
683 |
568 |
|
} |
684 |
569 |
|
|
685 |
570 |
|
private SizeableFloater cascadeFloater( List<SizeableFloater> pFloaters, int pMaxZindex, int pIndex, |
686 |
|
- |
int pTop, int pLeft ) |
687 |
|
- |
{ |
|
571 |
+ |
int pTop, int pLeft ) { |
688 |
572 |
|
SizeableFloater floater = pFloaters.get( pIndex ); |
689 |
573 |
|
|
690 |
574 |
|
floater.setPosition( pLeft, pTop ); |
|
@@ -695,30 +579,25 @@ |
695 |
579 |
|
return floater; |
696 |
580 |
|
} |
697 |
581 |
|
|
698 |
|
- |
public boolean isChanged() |
699 |
|
- |
{ |
|
582 |
+ |
public boolean isChanged() { |
700 |
583 |
|
return mChanged; |
701 |
584 |
|
} |
702 |
585 |
|
} |
703 |
586 |
|
|
704 |
587 |
|
// vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv No Additional Style Support vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv |
705 |
|
- |
public void setStylePrimaryName( String style ) |
706 |
|
- |
{ |
|
588 |
+ |
public void setStylePrimaryName( String style ) { |
707 |
589 |
|
throw new IllegalStateException( "No Style Support" ); |
708 |
590 |
|
} |
709 |
591 |
|
|
710 |
|
- |
public void addStyleDependentName( String styleSuffix ) |
711 |
|
- |
{ |
|
592 |
+ |
public void addStyleDependentName( String styleSuffix ) { |
712 |
593 |
|
throw new IllegalStateException( "No Style Support" ); |
713 |
594 |
|
} |
714 |
595 |
|
|
715 |
|
- |
public void addStyleName( String style ) |
716 |
|
- |
{ |
|
596 |
+ |
public void addStyleName( String style ) { |
717 |
597 |
|
throw new IllegalStateException( "No Style Support" ); |
718 |
598 |
|
} |
719 |
599 |
|
|
720 |
|
- |
protected Element getStyleElement() |
721 |
|
- |
{ |
|
600 |
+ |
protected Element getStyleElement() { |
722 |
601 |
|
throw new IllegalStateException( "No Style Support" ); |
723 |
602 |
|
} |
724 |
603 |
|
} |