|
@@ -8,10 +8,10 @@ |
8 |
8 |
|
|
9 |
9 |
|
/** |
10 |
10 |
|
* This class provides for creating a VerticalPanel "like" object that takes widgets as Pairs. |
11 |
|
- |
* |
|
11 |
+ |
* <p/> |
12 |
12 |
|
* These Widget Pairs are called the Prime Widget and the Subordinate Widget. All the Prime Widgets are |
13 |
13 |
|
* visible, but the Subordinate Widget attached to the Prime Widget is only visible if visibility is requested. |
14 |
|
- |
* |
|
14 |
+ |
* <p/> |
15 |
15 |
|
* The showing and hiding of the a Subordinate Widget is animated! |
16 |
16 |
|
* |
17 |
17 |
|
* @author georgs |
|
@@ -22,7 +22,7 @@ |
22 |
22 |
|
private boolean showing; |
23 |
23 |
|
private PairPanel pairPanel; |
24 |
24 |
|
|
25 |
|
- |
public WidgetPair(Widget prime, Widget subordinate) { |
|
25 |
+ |
public WidgetPair( Widget prime, Widget subordinate ) { |
26 |
26 |
|
this.prime = prime; |
27 |
27 |
|
this.mSubordinate = subordinate; |
28 |
28 |
|
} |
|
@@ -36,8 +36,8 @@ |
36 |
36 |
|
} |
37 |
37 |
|
|
38 |
38 |
|
public boolean isSubordinateShowing() { |
39 |
|
- |
if (showing) { |
40 |
|
- |
showing = checkPrimeAncestry(prime) && checkSubordinateAncestry(mSubordinate); |
|
39 |
+ |
if ( showing ) { |
|
40 |
+ |
showing = checkPrimeAncestry( prime ) && checkSubordinateAncestry( mSubordinate ); |
41 |
41 |
|
} |
42 |
42 |
|
return showing; |
43 |
43 |
|
} |
|
@@ -46,11 +46,11 @@ |
46 |
46 |
|
return showing; |
47 |
47 |
|
} |
48 |
48 |
|
|
49 |
|
- |
private void setShowing(boolean showing) { |
|
49 |
+ |
private void setShowing( boolean showing ) { |
50 |
50 |
|
this.showing = showing; |
51 |
51 |
|
} |
52 |
52 |
|
|
53 |
|
- |
private static boolean hasContent(WidgetPair pair) { |
|
53 |
+ |
private static boolean hasContent( WidgetPair pair ) { |
54 |
54 |
|
return (pair != null) && (pair.prime != null); |
55 |
55 |
|
} |
56 |
56 |
|
|
|
@@ -58,7 +58,7 @@ |
58 |
58 |
|
return pairPanel; |
59 |
59 |
|
} |
60 |
60 |
|
|
61 |
|
- |
private void setPairPanel(PairPanel pairPanel) { |
|
61 |
+ |
private void setPairPanel( PairPanel pairPanel ) { |
62 |
62 |
|
this.pairPanel = pairPanel; |
63 |
63 |
|
} |
64 |
64 |
|
} |
|
@@ -67,7 +67,7 @@ |
67 |
67 |
|
private List<WidgetPair> members = new ArrayList<WidgetPair>(); |
68 |
68 |
|
|
69 |
69 |
|
public AccordionVerticalPairPanel() { |
70 |
|
- |
initWidget(container); |
|
70 |
+ |
initWidget( container ); |
71 |
71 |
|
} |
72 |
72 |
|
|
73 |
73 |
|
public boolean isEmpty() { |
|
@@ -83,8 +83,8 @@ |
83 |
83 |
|
* |
84 |
84 |
|
* @return true if the widgets were actually added. |
85 |
85 |
|
*/ |
86 |
|
- |
public boolean add(Widget primeWidget, Widget subordinateWidget) { |
87 |
|
- |
return add(new WidgetPair(primeWidget, subordinateWidget)); |
|
86 |
+ |
public boolean add( Widget primeWidget, Widget subordinateWidget ) { |
|
87 |
+ |
return add( new WidgetPair( primeWidget, subordinateWidget ) ); |
88 |
88 |
|
} |
89 |
89 |
|
|
90 |
90 |
|
/** |
|
@@ -93,33 +93,33 @@ |
93 |
93 |
|
* |
94 |
94 |
|
* @return true if the WidgetPair was actually added. |
95 |
95 |
|
*/ |
96 |
|
- |
public boolean add(WidgetPair widgetPair) { |
97 |
|
- |
if (WidgetPair.hasContent(widgetPair)) { |
98 |
|
- |
members.add(widgetPair); |
99 |
|
- |
container.add(new PairPanel(this, widgetPair)); |
|
96 |
+ |
public boolean add( WidgetPair widgetPair ) { |
|
97 |
+ |
if ( WidgetPair.hasContent( widgetPair ) ) { |
|
98 |
+ |
members.add( widgetPair ); |
|
99 |
+ |
container.add( new PairPanel( this, widgetPair ) ); |
100 |
100 |
|
return true; |
101 |
101 |
|
} |
102 |
102 |
|
return false; |
103 |
103 |
|
} |
104 |
104 |
|
|
105 |
|
- |
public int indexOf(WidgetPair widgetPair) { |
106 |
|
- |
return members.indexOf(widgetPair); |
|
105 |
+ |
public int indexOf( WidgetPair widgetPair ) { |
|
106 |
+ |
return members.indexOf( widgetPair ); |
107 |
107 |
|
} |
108 |
108 |
|
|
109 |
|
- |
public int indexOfSubordinateWidget(Widget subordinateWidget) { |
110 |
|
- |
for (int i = 0; i < members.size(); i++) { |
111 |
|
- |
WidgetPair zMember = members.get(i); |
112 |
|
- |
if (subordinateWidget == zMember.getSubordinate()) { |
|
109 |
+ |
public int indexOfSubordinateWidget( Widget subordinateWidget ) { |
|
110 |
+ |
for ( int i = 0; i < members.size(); i++ ) { |
|
111 |
+ |
WidgetPair zMember = members.get( i ); |
|
112 |
+ |
if ( subordinateWidget == zMember.getSubordinate() ) { |
113 |
113 |
|
return i; |
114 |
114 |
|
} |
115 |
115 |
|
} |
116 |
116 |
|
return -1; |
117 |
117 |
|
} |
118 |
118 |
|
|
119 |
|
- |
public int indexOfPrimeWidget(Widget primeWidget) { |
120 |
|
- |
for (int i = 0; i < members.size(); i++) { |
121 |
|
- |
WidgetPair zMember = members.get(i); |
122 |
|
- |
if (primeWidget == zMember.getPrime()) { |
|
119 |
+ |
public int indexOfPrimeWidget( Widget primeWidget ) { |
|
120 |
+ |
for ( int i = 0; i < members.size(); i++ ) { |
|
121 |
+ |
WidgetPair zMember = members.get( i ); |
|
122 |
+ |
if ( primeWidget == zMember.getPrime() ) { |
123 |
123 |
|
return i; |
124 |
124 |
|
} |
125 |
125 |
|
} |
|
@@ -129,23 +129,24 @@ |
129 |
129 |
|
/** |
130 |
130 |
|
* @return true if contents changed (i.e. actually removed) |
131 |
131 |
|
*/ |
132 |
|
- |
public boolean remove(WidgetPair widgetPair) { |
133 |
|
- |
int zIndex = indexOf(widgetPair); |
134 |
|
- |
return (zIndex != -1) && (null != remove(zIndex)); |
|
132 |
+ |
public boolean remove( WidgetPair widgetPair ) { |
|
133 |
+ |
int zIndex = indexOf( widgetPair ); |
|
134 |
+ |
return (zIndex != -1) && (null != remove( zIndex )); |
135 |
135 |
|
} |
136 |
136 |
|
|
137 |
137 |
|
/** |
138 |
138 |
|
* @return WidgetPair that "was" at pIndex. |
139 |
139 |
|
*/ |
140 |
|
- |
public WidgetPair remove(int index) throws IndexOutOfBoundsException { |
141 |
|
- |
WidgetPair zRemoved = members.remove(index); |
142 |
|
- |
if (zRemoved != null) { |
|
140 |
+ |
public WidgetPair remove( int index ) |
|
141 |
+ |
throws IndexOutOfBoundsException { |
|
142 |
+ |
WidgetPair zRemoved = members.remove( index ); |
|
143 |
+ |
if ( zRemoved != null ) { |
143 |
144 |
|
PairPanel zPairPanel = zRemoved.getPairPanel(); |
144 |
|
- |
if (zPairPanel != null) { |
|
145 |
+ |
if ( zPairPanel != null ) { |
145 |
146 |
|
zPairPanel.clear(); |
146 |
147 |
|
} |
147 |
|
- |
zRemoved.setShowing(false); |
148 |
|
- |
container.remove(index); |
|
148 |
+ |
zRemoved.setShowing( false ); |
|
149 |
+ |
container.remove( index ); |
149 |
150 |
|
} |
150 |
151 |
|
return zRemoved; |
151 |
152 |
|
} |
|
@@ -155,23 +156,23 @@ |
155 |
156 |
|
*/ |
156 |
157 |
|
public void clear() { |
157 |
158 |
|
container.clear(); |
158 |
|
- |
for (WidgetPair zMember : members) { |
|
159 |
+ |
for ( WidgetPair zMember : members ) { |
159 |
160 |
|
PairPanel zPairPanel = zMember.getPairPanel(); |
160 |
|
- |
if (zPairPanel != null) { |
|
161 |
+ |
if ( zPairPanel != null ) { |
161 |
162 |
|
zPairPanel.clear(); |
162 |
163 |
|
} |
163 |
|
- |
zMember.setShowing(false); |
|
164 |
+ |
zMember.setShowing( false ); |
164 |
165 |
|
} |
165 |
166 |
|
members.clear(); |
166 |
167 |
|
} |
167 |
168 |
|
|
168 |
169 |
|
public void collapseAll() { |
169 |
|
- |
for (WidgetPair zMember : members) { |
|
170 |
+ |
for ( WidgetPair zMember : members ) { |
170 |
171 |
|
PairPanel zPairPanel = zMember.getPairPanel(); |
171 |
|
- |
if (zPairPanel != null) { |
|
172 |
+ |
if ( zPairPanel != null ) { |
172 |
173 |
|
zPairPanel.collapse(); |
173 |
174 |
|
} |
174 |
|
- |
zMember.setShowing(false); |
|
175 |
+ |
zMember.setShowing( false ); |
175 |
176 |
|
} |
176 |
177 |
|
} |
177 |
178 |
|
|
|
@@ -179,73 +180,69 @@ |
179 |
180 |
|
* Expand (show) or Collapse (!show) the pSubordinateWidget (if found) |
180 |
181 |
|
* according to the pShow value requested. |
181 |
182 |
|
* |
182 |
|
- |
* @param subordinateWidget |
183 |
|
- |
* the Subordinate Widget to locate |
184 |
|
- |
* @param show |
185 |
|
- |
* what to do with the Subordinate Widget if located |
|
183 |
+ |
* @param subordinateWidget the Subordinate Widget to locate |
|
184 |
+ |
* @param show what to do with the Subordinate Widget if located |
186 |
185 |
|
* |
187 |
186 |
|
* @return true if the Subordinate Widget was located |
188 |
187 |
|
*/ |
189 |
|
- |
public boolean show(Widget subordinateWidget, boolean show) { |
190 |
|
- |
return showSubordinateWidgetOf(getPairFor(subordinateWidget), show); |
|
188 |
+ |
public boolean show( Widget subordinateWidget, boolean show ) { |
|
189 |
+ |
return showSubordinateWidgetOf( getPairFor( subordinateWidget ), show ); |
191 |
190 |
|
} |
192 |
191 |
|
|
193 |
192 |
|
/** |
194 |
193 |
|
* Expand (show) or Collapse (!show) the Subordinate Widget (at pIndex) |
195 |
194 |
|
* according to the pShow value requested. |
196 |
195 |
|
* |
197 |
|
- |
* @param index |
198 |
|
- |
* Index of the the Subordinate Widget |
199 |
|
- |
* @param show |
200 |
|
- |
* what to do with the Subordinate Widget |
|
196 |
+ |
* @param index Index of the the Subordinate Widget |
|
197 |
+ |
* @param show what to do with the Subordinate Widget |
201 |
198 |
|
*/ |
202 |
|
- |
public void showSubordinateWidgetAt(int index, boolean show) throws IndexOutOfBoundsException { |
203 |
|
- |
showSubordinateWidgetOf(members.get(index), show); |
|
199 |
+ |
public void showSubordinateWidgetAt( int index, boolean show ) |
|
200 |
+ |
throws IndexOutOfBoundsException { |
|
201 |
+ |
showSubordinateWidgetOf( members.get( index ), show ); |
204 |
202 |
|
} |
205 |
203 |
|
|
206 |
204 |
|
/** |
207 |
205 |
|
* Expand (show) or Collapse (!show) the Subordinate Widget of the |
208 |
206 |
|
* WidgetPair (if found) according to the pShow value requested. |
209 |
207 |
|
* |
210 |
|
- |
* @param widgetPair |
211 |
|
- |
* the Widget Pair to locate |
212 |
|
- |
* @param show |
213 |
|
- |
* what to do with the Subordinate Widget of the Widget Pair if |
214 |
|
- |
* located |
|
208 |
+ |
* @param widgetPair the Widget Pair to locate |
|
209 |
+ |
* @param show what to do with the Subordinate Widget of the Widget Pair if |
|
210 |
+ |
* located |
215 |
211 |
|
* |
216 |
212 |
|
* @return true if the Widget Pair was located |
217 |
213 |
|
*/ |
218 |
|
- |
public boolean showSubordinateWidgetOf(WidgetPair widgetPair, boolean show) { |
219 |
|
- |
if (members.contains(widgetPair)) { |
|
214 |
+ |
public boolean showSubordinateWidgetOf( WidgetPair widgetPair, boolean show ) { |
|
215 |
+ |
if ( members.contains( widgetPair ) ) { |
220 |
216 |
|
PairPanel zPairPanel = widgetPair.getPairPanel(); |
221 |
|
- |
if (zPairPanel != null) { |
222 |
|
- |
if (show) { |
|
217 |
+ |
if ( zPairPanel != null ) { |
|
218 |
+ |
if ( show ) { |
223 |
219 |
|
zPairPanel.expand(); |
224 |
220 |
|
} else { |
225 |
221 |
|
zPairPanel.collapse(); |
226 |
222 |
|
} |
227 |
|
- |
widgetPair.setShowing(show); |
|
223 |
+ |
widgetPair.setShowing( show ); |
228 |
224 |
|
return true; |
229 |
225 |
|
} |
230 |
226 |
|
} |
231 |
227 |
|
return false; |
232 |
228 |
|
} |
233 |
229 |
|
|
234 |
|
- |
public boolean isShowing(Widget subordinateWidget) { |
235 |
|
- |
return isSubordinateWidgetShowing(getPairFor(subordinateWidget)); |
|
230 |
+ |
public boolean isShowing( Widget subordinateWidget ) { |
|
231 |
+ |
return isSubordinateWidgetShowing( getPairFor( subordinateWidget ) ); |
236 |
232 |
|
} |
237 |
233 |
|
|
238 |
|
- |
public boolean isSubordinateWidgetShowingAt(int index) throws IndexOutOfBoundsException { |
239 |
|
- |
return isSubordinateWidgetShowing(members.get(index)); |
|
234 |
+ |
public boolean isSubordinateWidgetShowingAt( int index ) |
|
235 |
+ |
throws IndexOutOfBoundsException { |
|
236 |
+ |
return isSubordinateWidgetShowing( members.get( index ) ); |
240 |
237 |
|
} |
241 |
238 |
|
|
242 |
|
- |
public boolean isSubordinateWidgetShowing(WidgetPair widgetPair) { |
243 |
|
- |
return members.contains(widgetPair) && widgetPair.isShowing(); |
|
239 |
+ |
public boolean isSubordinateWidgetShowing( WidgetPair widgetPair ) { |
|
240 |
+ |
return members.contains( widgetPair ) && widgetPair.isShowing(); |
244 |
241 |
|
} |
245 |
242 |
|
|
246 |
|
- |
private WidgetPair getPairFor(Widget pSubordinateWidget) { |
247 |
|
- |
for (WidgetPair zMember : members) { |
248 |
|
- |
if (pSubordinateWidget == zMember.getSubordinate()) { |
|
243 |
+ |
private WidgetPair getPairFor( Widget pSubordinateWidget ) { |
|
244 |
+ |
for ( WidgetPair zMember : members ) { |
|
245 |
+ |
if ( pSubordinateWidget == zMember.getSubordinate() ) { |
249 |
246 |
|
return zMember; |
250 |
247 |
|
} |
251 |
248 |
|
} |
|
@@ -256,33 +253,33 @@ |
256 |
253 |
|
* Only called by the PairPanel that should be removed because the PairPanel |
257 |
254 |
|
* has lost one of its widgets. |
258 |
255 |
|
*/ |
259 |
|
- |
private void removePair(PairPanel pairPanel) { |
260 |
|
- |
for (int i = 0; i < members.size(); i++) { |
261 |
|
- |
WidgetPair zMember = members.get(i); |
|
256 |
+ |
private void removePair( PairPanel pairPanel ) { |
|
257 |
+ |
for ( int i = 0; i < members.size(); i++ ) { |
|
258 |
+ |
WidgetPair zMember = members.get( i ); |
262 |
259 |
|
PairPanel zPairPanel = zMember.getPairPanel(); |
263 |
|
- |
if (pairPanel == zPairPanel) { |
264 |
|
- |
remove(i); |
|
260 |
+ |
if ( pairPanel == zPairPanel ) { |
|
261 |
+ |
remove( i ); |
265 |
262 |
|
return; |
266 |
263 |
|
} |
267 |
264 |
|
} |
268 |
265 |
|
} |
269 |
266 |
|
|
270 |
|
- |
private static boolean checkSubordinateAncestry(Widget widget) { |
|
267 |
+ |
private static boolean checkSubordinateAncestry( Widget widget ) { |
271 |
268 |
|
return (widget == null) || // |
272 |
|
- |
(null != parentClassIs(PairPanel.class, // |
273 |
|
- |
parentClassIs(ClippingPanel.class, // |
274 |
|
- |
parentClassIs(SubordinatePanel.class, // |
275 |
|
- |
widget)))); |
|
269 |
+ |
(null != parentClassIs( PairPanel.class, // |
|
270 |
+ |
parentClassIs( ClippingPanel.class, // |
|
271 |
+ |
parentClassIs( SubordinatePanel.class, // |
|
272 |
+ |
widget ) ) )); |
276 |
273 |
|
} |
277 |
274 |
|
|
278 |
|
- |
private static boolean checkPrimeAncestry(Widget widget) { |
279 |
|
- |
return (null != parentClassIs(PairPanel.class, widget)); |
|
275 |
+ |
private static boolean checkPrimeAncestry( Widget widget ) { |
|
276 |
+ |
return (null != parentClassIs( PairPanel.class, widget )); |
280 |
277 |
|
} |
281 |
278 |
|
|
282 |
|
- |
private static Widget parentClassIs(Class<?> klass, Widget widget) { |
283 |
|
- |
if (widget != null) { |
284 |
|
- |
if (null != (widget = widget.getParent())) { |
285 |
|
- |
if (widget.getClass() == klass) { |
|
279 |
+ |
private static Widget parentClassIs( Class<?> klass, Widget widget ) { |
|
280 |
+ |
if ( widget != null ) { |
|
281 |
+ |
if ( null != (widget = widget.getParent()) ) { |
|
282 |
+ |
if ( widget.getClass() == klass ) { |
286 |
283 |
|
return widget; |
287 |
284 |
|
} |
288 |
285 |
|
} |
|
@@ -294,11 +291,11 @@ |
294 |
291 |
|
private AccordionVerticalPairPanel parent; |
295 |
292 |
|
private ClippingPanel clippingPanel; |
296 |
293 |
|
|
297 |
|
- |
private PairPanel(AccordionVerticalPairPanel pParent, WidgetPair widgetPair) { |
|
294 |
+ |
private PairPanel( AccordionVerticalPairPanel pParent, WidgetPair widgetPair ) { |
298 |
295 |
|
this.parent = pParent; |
299 |
|
- |
add(widgetPair.getPrime()); |
300 |
|
- |
add(this.clippingPanel = new ClippingPanel(this, widgetPair.getSubordinate())); |
301 |
|
- |
widgetPair.setPairPanel(this); |
|
296 |
+ |
add( widgetPair.getPrime() ); |
|
297 |
+ |
add( this.clippingPanel = new ClippingPanel( this, widgetPair.getSubordinate() ) ); |
|
298 |
+ |
widgetPair.setPairPanel( this ); |
302 |
299 |
|
} |
303 |
300 |
|
|
304 |
301 |
|
public void collapse() { |
|
@@ -319,7 +316,7 @@ |
319 |
316 |
|
public void clear() { |
320 |
317 |
|
parent = null; // in case remove is called as part of the clear operation, then don't generate a potential infinite loop! |
321 |
318 |
|
super.clear(); |
322 |
|
- |
if (clippingPanel != null) { |
|
319 |
+ |
if ( clippingPanel != null ) { |
323 |
320 |
|
clippingPanel.clear(); |
324 |
321 |
|
clippingPanel = null; |
325 |
322 |
|
} |
|
@@ -333,12 +330,12 @@ |
333 |
330 |
|
* (AccordionVerticalPairPanel). |
334 |
331 |
|
*/ |
335 |
332 |
|
@Override |
336 |
|
- |
public boolean remove(Widget w) { |
337 |
|
- |
boolean zRemoved = super.remove(w); |
338 |
|
- |
if (zRemoved) { |
339 |
|
- |
if (parent != null) // in case remove is called as part of the clear operation, then don't generate a potential infinite loop! |
|
333 |
+ |
public boolean remove( Widget w ) { |
|
334 |
+ |
boolean zRemoved = super.remove( w ); |
|
335 |
+ |
if ( zRemoved ) { |
|
336 |
+ |
if ( parent != null ) // in case remove is called as part of the clear operation, then don't generate a potential infinite loop! |
340 |
337 |
|
{ |
341 |
|
- |
parent.removePair(this); |
|
338 |
+ |
parent.removePair( this ); |
342 |
339 |
|
clear(); |
343 |
340 |
|
} |
344 |
341 |
|
} |
|
@@ -347,11 +344,11 @@ |
347 |
344 |
|
} |
348 |
345 |
|
|
349 |
346 |
|
private enum AnimatedVisibility { |
350 |
|
- |
Collapsing(true), Collapsed(true), Expanding(false), Expanded(false); |
|
347 |
+ |
Collapsing( true ), Collapsed( true ), Expanding( false ), Expanded( false ); |
351 |
348 |
|
|
352 |
349 |
|
private boolean collapsingOrCollapsed; |
353 |
350 |
|
|
354 |
|
- |
AnimatedVisibility(boolean collapsingOrCollapsed) { |
|
351 |
+ |
AnimatedVisibility( boolean collapsingOrCollapsed ) { |
355 |
352 |
|
this.collapsingOrCollapsed = collapsingOrCollapsed; |
356 |
353 |
|
} |
357 |
354 |
|
|
|
@@ -373,11 +370,11 @@ |
373 |
370 |
|
private Integer maxHeight; |
374 |
371 |
|
private HeightAnimator animator; |
375 |
372 |
|
|
376 |
|
- |
private ClippingPanel(PairPanel parent, Widget subordinateWidget) { |
|
373 |
+ |
private ClippingPanel( PairPanel parent, Widget subordinateWidget ) { |
377 |
374 |
|
this.parent = parent; |
378 |
|
- |
setWidget(subordinatePanel = new SubordinatePanel(this, subordinateWidget)); |
379 |
|
- |
getStyleElement().getStyle().setOverflow(Style.Overflow.HIDDEN); |
380 |
|
- |
setHeight("1px"); |
|
375 |
+ |
setWidget( subordinatePanel = new SubordinatePanel( this, subordinateWidget ) ); |
|
376 |
+ |
getStyleElement().getStyle().setOverflow( Style.Overflow.HIDDEN ); |
|
377 |
+ |
setHeight( "1px" ); |
381 |
378 |
|
} |
382 |
379 |
|
|
383 |
380 |
|
/** |
|
@@ -390,7 +387,7 @@ |
390 |
387 |
|
public void clear() { |
391 |
388 |
|
parent = null; // in case remove is called as part of the clear operation, then don't generate a potential infinite loop! |
392 |
389 |
|
super.clear(); |
393 |
|
- |
if (subordinatePanel != null) { |
|
390 |
+ |
if ( subordinatePanel != null ) { |
394 |
391 |
|
subordinatePanel.clear(); |
395 |
392 |
|
subordinatePanel = null; |
396 |
393 |
|
} |
|
@@ -402,12 +399,12 @@ |
402 |
399 |
|
* We Automatically remove ourselves from our Parent (PairPanel). |
403 |
400 |
|
*/ |
404 |
401 |
|
@Override |
405 |
|
- |
public boolean remove(Widget w) { |
406 |
|
- |
boolean zRemoved = super.remove(w); |
407 |
|
- |
if (zRemoved) { |
408 |
|
- |
if (parent != null) // in case remove is called as part of the clear operation, then don't generate a potential infinite loop! |
|
402 |
+ |
public boolean remove( Widget w ) { |
|
403 |
+ |
boolean zRemoved = super.remove( w ); |
|
404 |
+ |
if ( zRemoved ) { |
|
405 |
+ |
if ( parent != null ) // in case remove is called as part of the clear operation, then don't generate a potential infinite loop! |
409 |
406 |
|
{ |
410 |
|
- |
parent.remove(this); |
|
407 |
+ |
parent.remove( this ); |
411 |
408 |
|
clear(); |
412 |
409 |
|
} |
413 |
410 |
|
} |
|
@@ -415,14 +412,14 @@ |
415 |
412 |
|
} |
416 |
413 |
|
|
417 |
414 |
|
public void collapse() { |
418 |
|
- |
if (sizingIsReadyWithNotReadyTarget(AnimatedVisibility.Collapsed) && visibility.isExpandingOrExpanded()) { |
419 |
|
- |
transition(AnimatedVisibility.Collapsing, 1); |
|
415 |
+ |
if ( sizingIsReadyWithNotReadyTarget( AnimatedVisibility.Collapsed ) && visibility.isExpandingOrExpanded() ) { |
|
416 |
+ |
transition( AnimatedVisibility.Collapsing, 1 ); |
420 |
417 |
|
} |
421 |
418 |
|
} |
422 |
419 |
|
|
423 |
420 |
|
public void expand() { |
424 |
|
- |
if (sizingIsReadyWithNotReadyTarget(AnimatedVisibility.Expanded) && visibility.isCollapsingOrCollapsed()) { |
425 |
|
- |
transition(AnimatedVisibility.Expanding, maxHeight); |
|
421 |
+ |
if ( sizingIsReadyWithNotReadyTarget( AnimatedVisibility.Expanded ) && visibility.isCollapsingOrCollapsed() ) { |
|
422 |
+ |
transition( AnimatedVisibility.Expanding, maxHeight ); |
426 |
423 |
|
} |
427 |
424 |
|
} |
428 |
425 |
|
|
|
@@ -433,8 +430,8 @@ |
433 |
430 |
|
* element along the path to the root is display=none, then a size might |
434 |
431 |
|
* NEVER arrive). |
435 |
432 |
|
*/ |
436 |
|
- |
private boolean sizingIsReadyWithNotReadyTarget(AnimatedVisibility targetVisibility) { |
437 |
|
- |
if (maxHeight == null) { |
|
433 |
+ |
private boolean sizingIsReadyWithNotReadyTarget( AnimatedVisibility targetVisibility ) { |
|
434 |
+ |
if ( maxHeight == null ) { |
438 |
435 |
|
this.targetVisibility = targetVisibility; |
439 |
436 |
|
return false; |
440 |
437 |
|
} |
|
@@ -445,37 +442,37 @@ |
445 |
442 |
|
/** |
446 |
443 |
|
* Called to indicate that Sizing is Ready! |
447 |
444 |
|
*/ |
448 |
|
- |
private void setMaxHeight(int height) { |
|
445 |
+ |
private void setMaxHeight( int height ) { |
449 |
446 |
|
maxHeight = height; |
450 |
447 |
|
// Now dispatch the last request (if any) that occured before Sizing was Ready! |
451 |
|
- |
if (AnimatedVisibility.Collapsed == targetVisibility) { |
|
448 |
+ |
if ( AnimatedVisibility.Collapsed == targetVisibility ) { |
452 |
449 |
|
collapse(); |
453 |
450 |
|
} |
454 |
|
- |
if (AnimatedVisibility.Expanded == targetVisibility) { |
|
451 |
+ |
if ( AnimatedVisibility.Expanded == targetVisibility ) { |
455 |
452 |
|
expand(); |
456 |
453 |
|
} |
457 |
454 |
|
} |
458 |
455 |
|
|
459 |
|
- |
private void setCurrentHeight(int height) { |
460 |
|
- |
if (height < 2) { |
|
456 |
+ |
private void setCurrentHeight( int height ) { |
|
457 |
+ |
if ( height < 2 ) { |
461 |
458 |
|
visibility = AnimatedVisibility.Collapsed; |
462 |
459 |
|
height = 1; |
463 |
460 |
|
} |
464 |
|
- |
if (maxHeight <= height) { |
|
461 |
+ |
if ( maxHeight <= height ) { |
465 |
462 |
|
visibility = AnimatedVisibility.Expanded; |
466 |
463 |
|
height = maxHeight; |
467 |
464 |
|
} |
468 |
465 |
|
currentHeight = height; |
469 |
|
- |
setHeight(height + "px"); |
|
466 |
+ |
setHeight( height + "px" ); |
470 |
467 |
|
} |
471 |
468 |
|
|
472 |
|
- |
private void transition(AnimatedVisibility newVisibility, int targetHeight) { |
473 |
|
- |
if (animator != null) { |
|
469 |
+ |
private void transition( AnimatedVisibility newVisibility, int targetHeight ) { |
|
470 |
+ |
if ( animator != null ) { |
474 |
471 |
|
animator.cancel(); |
475 |
472 |
|
animator = null; |
476 |
473 |
|
} |
477 |
474 |
|
visibility = newVisibility; |
478 |
|
- |
animator = new HeightAnimator(this, currentHeight, targetHeight); |
|
475 |
+ |
animator = new HeightAnimator( this, currentHeight, targetHeight ); |
479 |
476 |
|
animator.start(); |
480 |
477 |
|
} |
481 |
478 |
|
} |
|
@@ -484,10 +481,10 @@ |
484 |
481 |
|
private OurSizingDeterminer sizingDeterminer = new OurSizingDeterminer(); |
485 |
482 |
|
private ClippingPanel parent; |
486 |
483 |
|
|
487 |
|
- |
private SubordinatePanel(ClippingPanel parent, Widget subordinateWidget) { |
|
484 |
+ |
private SubordinatePanel( ClippingPanel parent, Widget subordinateWidget ) { |
488 |
485 |
|
this.parent = parent; |
489 |
|
- |
add(new Spacer().size("1px")); |
490 |
|
- |
add((null != subordinateWidget) ? subordinateWidget : new TransparentImage()); |
|
486 |
+ |
add( new Spacer().size( "1px" ) ); |
|
487 |
+ |
add( (null != subordinateWidget) ? subordinateWidget : new TransparentImage() ); |
491 |
488 |
|
} |
492 |
489 |
|
|
493 |
490 |
|
/** |
|
@@ -509,12 +506,12 @@ |
509 |
506 |
|
* We Automatically remove ourselves from our Parent (ClippingPanel). |
510 |
507 |
|
*/ |
511 |
508 |
|
@Override |
512 |
|
- |
public boolean remove(Widget w) { |
513 |
|
- |
boolean zRemoved = super.remove(w); |
514 |
|
- |
if (zRemoved) { |
515 |
|
- |
if (parent != null) // in case remove is called as part of the clear operation, then don't generate a potential infinite loop! |
|
509 |
+ |
public boolean remove( Widget w ) { |
|
510 |
+ |
boolean zRemoved = super.remove( w ); |
|
511 |
+ |
if ( zRemoved ) { |
|
512 |
+ |
if ( parent != null ) // in case remove is called as part of the clear operation, then don't generate a potential infinite loop! |
516 |
513 |
|
{ |
517 |
|
- |
parent.remove(this); |
|
514 |
+ |
parent.remove( this ); |
518 |
515 |
|
clear(); |
519 |
516 |
|
} |
520 |
517 |
|
} |
|
@@ -547,26 +544,26 @@ |
547 |
544 |
|
@Override |
548 |
545 |
|
public void run() { |
549 |
546 |
|
int zHeight = getOffsetHeight(); |
550 |
|
- |
if ((1 < zHeight) && (zHeight == height)) { |
551 |
|
- |
parent.setMaxHeight(zHeight); |
|
547 |
+ |
if ( (1 < zHeight) && (zHeight == height) ) { |
|
548 |
+ |
parent.setMaxHeight( zHeight ); |
552 |
549 |
|
sizingDetermined = true; |
553 |
550 |
|
return; |
554 |
551 |
|
} |
555 |
552 |
|
height = zHeight; |
556 |
|
- |
if (sizingDetermined != null) { |
557 |
|
- |
schedule(50); |
|
553 |
+ |
if ( sizingDetermined != null ) { |
|
554 |
+ |
schedule( 50 ); |
558 |
555 |
|
} |
559 |
556 |
|
} |
560 |
557 |
|
|
561 |
558 |
|
public void start() { |
562 |
|
- |
if (!Boolean.TRUE.equals(sizingDetermined)) { |
|
559 |
+ |
if ( !Boolean.TRUE.equals( sizingDetermined ) ) { |
563 |
560 |
|
sizingDetermined = false; |
564 |
|
- |
schedule(50); |
|
561 |
+ |
schedule( 50 ); |
565 |
562 |
|
} |
566 |
563 |
|
} |
567 |
564 |
|
|
568 |
565 |
|
public void stop() { |
569 |
|
- |
if (Boolean.FALSE.equals(sizingDetermined)) { |
|
566 |
+ |
if ( Boolean.FALSE.equals( sizingDetermined ) ) { |
570 |
567 |
|
sizingDetermined = null; |
571 |
568 |
|
cancel(); |
572 |
569 |
|
} |
|
@@ -581,7 +578,7 @@ |
581 |
578 |
|
private int delta; |
582 |
579 |
|
private boolean completed = true; |
583 |
580 |
|
|
584 |
|
- |
public HeightAnimator(ClippingPanel clippingPanel, int fromHeight, int toHeight) { |
|
581 |
+ |
public HeightAnimator( ClippingPanel clippingPanel, int fromHeight, int toHeight ) { |
585 |
582 |
|
this.clippingPanel = clippingPanel; |
586 |
583 |
|
this.fromHeight = fromHeight; |
587 |
584 |
|
this.toHeight = toHeight; |
|
@@ -590,13 +587,13 @@ |
590 |
587 |
|
|
591 |
588 |
|
public void start() { |
592 |
589 |
|
completed = false; |
593 |
|
- |
run(Math.min(700, Math.abs(7 * delta))); |
|
590 |
+ |
run( Math.min( 700, Math.abs( 7 * delta ) ) ); |
594 |
591 |
|
} |
595 |
592 |
|
|
596 |
593 |
|
@Override |
597 |
|
- |
protected void onUpdate(double progress) { |
598 |
|
- |
if (!completed) { |
599 |
|
- |
clippingPanel.setCurrentHeight(fromHeight + (int) (progress * delta)); |
|
594 |
+ |
protected void onUpdate( double progress ) { |
|
595 |
+ |
if ( !completed ) { |
|
596 |
+ |
clippingPanel.setCurrentHeight( fromHeight + (int) (progress * delta) ); |
600 |
597 |
|
} |
601 |
598 |
|
} |
602 |
599 |
|
|
|
@@ -604,7 +601,7 @@ |
604 |
601 |
|
protected void onComplete() { |
605 |
602 |
|
completed = true; |
606 |
603 |
|
super.onComplete(); |
607 |
|
- |
clippingPanel.setCurrentHeight(toHeight); |
|
604 |
+ |
clippingPanel.setCurrentHeight( toHeight ); |
608 |
605 |
|
} |
609 |
606 |
|
} |
610 |
607 |
|
} |