Subversion Repository Public Repository

litesoft

Diff Revisions 947 vs 948 for /trunk/Java/GWT/OldClient/src/org/litesoft/GWT/client/widgets/SizeableFloatingPanel.java

Diff revisions: vs.
  @@ -1,22 +1,21 @@
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 org.litesoft.commonfoundation.typeutils.Objects;
5 - import java.util.*;
6 -
7 4 import org.litesoft.GWT.client.nonpublic.*;
8 5 import org.litesoft.GWT.client.widgets.nonpublic.*;
9 6 import org.litesoft.GWT.client.widgets.nonpublic.external.*;
7 + import org.litesoft.commonfoundation.typeutils.Objects;
10 8
11 - import com.google.gwt.user.client.ui.impl.*;
12 - import com.google.gwt.user.client.ui.*;
13 - import com.google.gwt.user.client.*;
14 9 import com.google.gwt.core.client.*;
15 10 import com.google.gwt.dom.client.Element;
11 + import com.google.gwt.user.client.*;
12 + import com.google.gwt.user.client.ui.*;
13 + import com.google.gwt.user.client.ui.impl.*;
14 +
15 + import java.util.*;
16 16
17 17 public class SizeableFloatingPanel extends AbstractFloaterPanel implements SizeableFloater,
18 - IFloaterPanelMoveAndSize
19 - {
18 + IFloaterPanelMoveAndSize {
20 19 protected static final int MIN_SHOWING_VERTICAL = 20;
21 20 protected static final int MIN_SHOWING_HORIZONTAL = 40;
22 21
  @@ -36,18 +35,15 @@
36 35
37 36 private boolean mHidden = false;
38 37
39 - private void LLsetActive( boolean pActive )
40 - {
38 + private void LLsetActive( boolean pActive ) {
41 39 mActive = stateStyle( pActive, getStyleElement(), "Active", "Inactive" );
42 40 }
43 41
44 - private void LLsetPinned( boolean pPinned )
45 - {
42 + private void LLsetPinned( boolean pPinned ) {
46 43 mPinned = stateStyle( pPinned, getTR_Pinning(), "Pinned", "UnPinned" );
47 44 }
48 45
49 - private class XYData
50 - {
46 + private class XYData {
51 47 private ISizeableDimensionHelper mDimensionHelper;
52 48 private Element mStyleElement;
53 49 private String mPrefixAnchorStyle;
  @@ -57,8 +53,7 @@
57 53 private int mPos = 0;
58 54
59 55 public XYData( ISizeableDimensionHelper pDimensionHelper, Element pStyleElement,
60 - String pPrefixAnchorStyle )
61 - {
56 + String pPrefixAnchorStyle ) {
62 57 mDimensionHelper = pDimensionHelper;
63 58 mStyleElement = pStyleElement;
64 59 mPrefixAnchorStyle = pPrefixAnchorStyle;
  @@ -66,11 +61,9 @@
66 61 setAnchored( false );
67 62 }
68 63
69 - private void determineAnchorOffset()
70 - {
64 + private void determineAnchorOffset() {
71 65 Integer zContainerSize = getContainerSize();
72 - if ( zContainerSize != null )
73 - {
66 + if ( zContainerSize != null ) {
74 67 int zOurSize = mDimensionHelper.getDimension( getElement() );
75 68 mAnchorOffset = zContainerSize - (getPos() + zOurSize);
76 69 return;
  @@ -78,36 +71,25 @@
78 71 mAnchorOffset = null;
79 72 }
80 73
81 - public void changedContainerSize()
82 - {
83 - if ( isAnchored() )
84 - {
85 - if ( mAnchorOffset == null )
86 - {
74 + public void changedContainerSize() {
75 + if ( isAnchored() ) {
76 + if ( mAnchorOffset == null ) {
87 77 determineAnchorOffset();
88 78 }
89 79 Integer zNewContainerSize = getCurrentContainerSize();
90 - if ( !Objects.areNonArraysEqual( mContainerSize, zNewContainerSize ) )
91 - {
80 + if ( !Objects.areNonArraysEqual( mContainerSize, zNewContainerSize ) ) {
92 81 Integer zOldContainerSize = mContainerSize;
93 82 mContainerSize = zNewContainerSize;
94 - if ( (zOldContainerSize != null) && (zNewContainerSize != null) )
95 - {
83 + if ( (zOldContainerSize != null) && (zNewContainerSize != null) ) {
96 84 int zDelta = zNewContainerSize - zOldContainerSize;
97 - if ( isPinned() )
98 - {
85 + if ( isPinned() ) {
99 86 // Change Size
100 87 mDimensionHelper.adjustSizeBy( zDelta );
101 - }
102 - else
103 - {
88 + } else {
104 89 // Change Position
105 - if ( "Width".equals( mDimensionHelper.getWhat() ) )
106 - {
90 + if ( "Width".equals( mDimensionHelper.getWhat() ) ) {
107 91 setPosLeft( getPos() + zDelta );
108 - }
109 - else
110 - {
92 + } else {
111 93 setPosTop( getPos() + zDelta );
112 94 }
113 95 }
  @@ -116,58 +98,46 @@
116 98 }
117 99 }
118 100
119 - private Integer getContainerSize()
120 - {
101 + private Integer getContainerSize() {
121 102 return (mContainerSize != null) ? mContainerSize : (mContainerSize = getCurrentContainerSize());
122 103 }
123 104
124 - private Integer getCurrentContainerSize()
125 - {
105 + private Integer getCurrentContainerSize() {
126 106 SizeableFloatableContainerPanel containerPanel = getContainerPanel();
127 - if ( containerPanel != null )
128 - {
129 - if ( containerPanel.getOffsetHeight() > 20 )
130 - {
107 + if ( containerPanel != null ) {
108 + if ( containerPanel.getOffsetHeight() > 20 ) {
131 109 return mDimensionHelper.getDimension( containerPanel );
132 110 }
133 111 }
134 112 return null;
135 113 }
136 114
137 - public void setAnchored( boolean pAnchored )
138 - {
115 + public void setAnchored( boolean pAnchored ) {
139 116 if ( mAnchored = stateStyle( pAnchored, mStyleElement, //
140 117 mPrefixAnchorStyle + "Anchor", //
141 - mPrefixAnchorStyle + "Free" ) )
142 - {
118 + mPrefixAnchorStyle + "Free" ) ) {
143 119 determineAnchorOffset();
144 120 }
145 121 }
146 122
147 - public int getPos()
148 - {
123 + public int getPos() {
149 124 return mPos;
150 125 }
151 126
152 - public boolean setPos( int pPos )
153 - {
154 - if ( mPos != pPos )
155 - {
127 + public boolean setPos( int pPos ) {
128 + if ( mPos != pPos ) {
156 129 mPos = pPos;
157 130 return true;
158 131 }
159 132 return false;
160 133 }
161 134
162 - public boolean isAnchored()
163 - {
135 + public boolean isAnchored() {
164 136 return mAnchored;
165 137 }
166 138
167 - public void possiblySetAnchored( boolean pAnchor )
168 - {
169 - if ( mAnchored != pAnchor )
170 - {
139 + public void possiblySetAnchored( boolean pAnchor ) {
140 + if ( mAnchored != pAnchor ) {
171 141 setAnchored( pAnchor );
172 142 }
173 143 }
  @@ -175,15 +145,13 @@
175 145
176 146 private XYData mXData, mYData;
177 147
178 - private boolean stateStyle( boolean pState, Element pElement, String pSuffixTrue, String pSuffixFalse )
179 - {
148 + private boolean stateStyle( boolean pState, Element pElement, String pSuffixTrue, String pSuffixFalse ) {
180 149 setStyleName( pElement, mBaseCSSclassname + "-" + pSuffixTrue, pState );
181 150 setStyleName( pElement, mBaseCSSclassname + "-" + pSuffixFalse, !pState );
182 151 return pState;
183 152 }
184 153
185 - public SizeableFloatingPanel()
186 - {
154 + public SizeableFloatingPanel() {
187 155 super( "Floater" );
188 156
189 157 finishContainerTable( this ); // This call must occur BEFORE the next 4 lines
  @@ -203,10 +171,8 @@
203 171 sinkEvents( Event.MOUSEEVENTS );
204 172 }
205 173
206 - public void onBrowserEvent( Event event )
207 - {
208 - switch ( DOM.eventGetType( event ) )
209 - {
174 + public void onBrowserEvent( Event event ) {
175 + switch ( DOM.eventGetType( event ) ) {
210 176 case Event.ONMOUSEDOWN:
211 177 forceToFront();
212 178 default:
  @@ -215,107 +181,87 @@
215 181 super.onBrowserEvent( event );
216 182 }
217 183
218 - protected boolean allowDragging()
219 - {
184 + protected boolean allowDragging() {
220 185 return isChromed();
221 186 }
222 187
223 - private DragController createTitleBarDragController( UiPositionable pUiPositionable )
224 - {
188 + private DragController createTitleBarDragController( UiPositionable pUiPositionable ) {
225 189 return createDragController( new BringToFrontGesture(
226 190 createThresholdFilter( createTitleBarDragGesture( pUiPositionable ) ) ) );
227 191 }
228 192
229 - protected DragController createBorderDragController( DragGesture pResizer )
230 - {
193 + protected DragController createBorderDragController( DragGesture pResizer ) {
231 194 return createDragController( new BringToFrontGesture( createThresholdFilter( pResizer ) ) );
232 195 }
233 196
234 - public boolean isVisible()
235 - {
197 + public boolean isVisible() {
236 198 return !"hidden".equals( DOM.getStyleAttribute( getElement(), "visibility" ) );
237 199 }
238 200
239 - public void setVisible( boolean visible )
240 - {
201 + public void setVisible( boolean visible ) {
241 202 DOM.setStyleAttribute( getElement(), "visibility", visible ? "visible" : "hidden" );
242 203 sImpl.setVisible( getElement(), visible );
243 204 }
244 205
245 - protected void onAttach()
246 - {
206 + protected void onAttach() {
247 207 super.onAttach();
248 208 sImpl.onShow( getElement() );
249 209 }
250 210
251 - protected void onDetach()
252 - {
211 + protected void onDetach() {
253 212 sImpl.onHide( getElement() );
254 213 super.onDetach();
255 214 }
256 215
257 - public int getArea()
258 - {
216 + public int getArea() {
259 217 return getOffsetHeight() * getOffsetWidth();
260 218 }
261 219
262 - public int minPosLeft()
263 - {
220 + public int minPosLeft() {
264 221 return MIN_SHOWING_HORIZONTAL - getOffsetWidth();
265 222 }
266 223
267 - public int minPosTop()
268 - {
224 + public int minPosTop() {
269 225 return 0 - (getTitleBarHeight() + BORDER_T_H - 3);
270 226 }
271 227
272 - public int maxPosLeft()
273 - {
228 + public int maxPosLeft() {
274 229 Widget zParent = getParent();
275 230 return ((zParent == null) ? 0 : zParent.getOffsetWidth()) - MIN_SHOWING_HORIZONTAL;
276 231 }
277 232
278 - public int maxPosTop()
279 - {
233 + public int maxPosTop() {
280 234 Widget zParent = getParent();
281 235 return ((zParent == null) ? 0 : zParent.getOffsetHeight()) - MIN_SHOWING_VERTICAL;
282 236 }
283 237
284 - public int getPosLeft()
285 - {
238 + public int getPosLeft() {
286 239 return mXData.getPos();
287 240 }
288 241
289 - public void setPosLeft( int pPosLeft )
290 - {
291 - if ( mXData.setPos( pPosLeft ) )
292 - {
242 + public void setPosLeft( int pPosLeft ) {
243 + if ( mXData.setPos( pPosLeft ) ) {
293 244 DOM.setIntStyleAttribute( getHelper().getOuterElement(), "left", pPosLeft );
294 245 }
295 246 }
296 247
297 - public int getPosTop()
298 - {
248 + public int getPosTop() {
299 249 return mYData.getPos();
300 250 }
301 251
302 - public void setPosTop( int pPosTop )
303 - {
304 - if ( mYData.setPos( pPosTop ) )
305 - {
252 + public void setPosTop( int pPosTop ) {
253 + if ( mYData.setPos( pPosTop ) ) {
306 254 DOM.setIntStyleAttribute( getHelper().getOuterElement(), "top", pPosTop );
307 255 }
308 256 }
309 257
310 - private void removePositionLock()
311 - {
258 + private void removePositionLock() {
312 259 setPinned( false );
313 260 setRightAnchor( false );
314 261 setBottomAnchor( false );
315 262 }
316 263
317 - public boolean isPositionLocked()
318 - {
264 + public boolean isPositionLocked() {
319 265 return isPinned() || isRightAnchor() || isBottomAnchor() || !isChromed();
320 266 }
321 267
  @@ -323,448 +269,359 @@
323 269
324 270 private int mCascadeUniqueID = ++sCascadeUniqueID;
325 271
326 - public int getCascadeUniqueID()
327 - {
272 + public int getCascadeUniqueID() {
328 273 return mCascadeUniqueID;
329 274 }
330 275
331 276 private int mZindex;
332 277
333 - public int getZindex()
334 - {
278 + public int getZindex() {
335 279 return mZindex;
336 280 }
337 281
338 - public void setZindex( int pZindex )
339 - {
340 - if ( mZindex != pZindex )
341 - {
282 + public void setZindex( int pZindex ) {
283 + if ( mZindex != pZindex ) {
342 284 mZindex = pZindex;
343 285 DOM.setIntStyleAttribute( getHelper().getOuterElement(), "zIndex", pZindex );
344 286 }
345 287 }
346 288
347 - public boolean isActive()
348 - {
289 + public boolean isActive() {
349 290 return mActive;
350 291 }
351 292
352 - public void setActive( boolean pActive )
353 - {
354 - if ( mActive != pActive )
355 - {
293 + public void setActive( boolean pActive ) {
294 + if ( mActive != pActive ) {
356 295 LLsetActive( pActive );
357 296 }
358 297 }
359 298
360 - public void maximizeVisibility()
361 - {
299 + public void maximizeVisibility() {
362 300 mHeightHandler.maximizeVisibility();
363 301 mWidthHandler.maximizeVisibility();
364 302 }
365 303
366 - public void changedContainerWidth()
367 - {
304 + public void changedContainerWidth() {
368 305 mXData.changedContainerSize();
369 306 }
370 307
371 - public void changedContainerHeight()
372 - {
308 + public void changedContainerHeight() {
373 309 mYData.changedContainerSize();
374 310 }
375 311
376 - public String getCurrentTitle()
377 - {
312 + public String getCurrentTitle() {
378 313 return getTitle();
379 314 }
380 315
381 - public IFloaterPanelMoveAndSize[] getAllFloaters()
382 - {
316 + public IFloaterPanelMoveAndSize[] getAllFloaters() {
383 317 SizeableFloater[] zFloaters = getContainerPanel().getFloatersSortedByTitle();
384 318 List<IFloaterPanelMoveAndSize> zList = new ArrayList<IFloaterPanelMoveAndSize>( zFloaters.length );
385 319
386 - for ( SizeableFloater zFloater : zFloaters )
387 - {
388 - if ( zFloater instanceof IFloaterPanelMoveAndSize )
389 - {
320 + for ( SizeableFloater zFloater : zFloaters ) {
321 + if ( zFloater instanceof IFloaterPanelMoveAndSize ) {
390 322 zList.add( (IFloaterPanelMoveAndSize) zFloater );
391 323 }
392 324 }
393 325 return zList.toArray( new IFloaterPanelMoveAndSize[zList.size()] );
394 326 }
395 327
396 - public void setActive()
397 - {
328 + public void setActive() {
398 329 getContainerPanel().makeTop( this );
399 330 }
400 331
401 - public String getRegisteredFactoryName()
402 - {
332 + public String getRegisteredFactoryName() {
403 333 return null;
404 334 }
405 335
406 - public boolean isChromed()
407 - {
336 + public boolean isChromed() {
408 337 return mChromed;
409 338 }
410 339
411 - public void setChromed( boolean pChromed )
412 - {
413 - if ( mChromed != pChromed )
414 - {
415 - if ( mChromed )
416 - {
340 + public void setChromed( boolean pChromed ) {
341 + if ( mChromed != pChromed ) {
342 + if ( mChromed ) {
417 343 hideBorder();
418 - }
419 - else
420 - {
344 + } else {
421 345 restoreBorder();
422 346 }
423 347 fireChromeChanged();
424 348 }
425 349 }
426 350
427 - public boolean isPinned()
428 - {
351 + public boolean isPinned() {
429 352 return mPinned;
430 353 }
431 354
432 - public void setPinned( boolean pPinned )
433 - {
434 - if ( mPinned != pPinned )
435 - {
355 + public void setPinned( boolean pPinned ) {
356 + if ( mPinned != pPinned ) {
436 357 LLsetPinned( pPinned );
437 358 }
438 359 }
439 360
440 - public boolean isRightAnchor()
441 - {
361 + public boolean isRightAnchor() {
442 362 return mXData.isAnchored();
443 363 }
444 364
445 - public void setRightAnchor( boolean pRightAnchor )
446 - {
365 + public void setRightAnchor( boolean pRightAnchor ) {
447 366 mXData.possiblySetAnchored( pRightAnchor );
448 367 }
449 368
450 - public boolean isBottomAnchor()
451 - {
369 + public boolean isBottomAnchor() {
452 370 return mYData.isAnchored();
453 371 }
454 372
455 - public void setBottomAnchor( boolean pBottomAnchor )
456 - {
373 + public void setBottomAnchor( boolean pBottomAnchor ) {
457 374 mYData.possiblySetAnchored( pBottomAnchor );
458 375 }
459 376
460 - public void moveN( int pPixels )
461 - {
377 + public void moveN( int pPixels ) {
462 378 chromeAwareAdjustPosTopBy( pPixels, -pPixels );
463 379 }
464 380
465 - public void moveE( int pPixels )
466 - {
381 + public void moveE( int pPixels ) {
467 382 chromeAwareAdjustPosLeftBy( pPixels, pPixels );
468 383 }
469 384
470 - public void moveW( int pPixels )
471 - {
385 + public void moveW( int pPixels ) {
472 386 chromeAwareAdjustPosLeftBy( pPixels, -pPixels );
473 387 }
474 388
475 - public void moveS( int pPixels )
476 - {
389 + public void moveS( int pPixels ) {
477 390 chromeAwareAdjustPosTopBy( pPixels, pPixels );
478 391 }
479 392
480 - public void moveNW( int pPixels )
481 - {
393 + public void moveNW( int pPixels ) {
482 394 moveN( pPixels );
483 395 moveW( pPixels );
484 396 }
485 397
486 - public void moveNE( int pPixels )
487 - {
398 + public void moveNE( int pPixels ) {
488 399 moveN( pPixels );
489 400 moveE( pPixels );
490 401 }
491 402
492 - public void moveSW( int pPixels )
493 - {
403 + public void moveSW( int pPixels ) {
494 404 moveS( pPixels );
495 405 moveW( pPixels );
496 406 }
497 407
498 - public void moveSE( int pPixels )
499 - {
408 + public void moveSE( int pPixels ) {
500 409 moveS( pPixels );
501 410 moveE( pPixels );
502 411 }
503 412
504 - public void moveToMaxN()
505 - {
413 + public void moveToMaxN() {
506 414 chromeAwareAdjustPosTopBy( -MAX_RESOLUTION_SUPPORTED );
507 415 }
508 416
509 - public void moveToMaxE()
510 - {
417 + public void moveToMaxE() {
511 418 chromeAwareAdjustPosLeftBy( MAX_RESOLUTION_SUPPORTED );
512 419 }
513 420
514 - public void moveToMaxW()
515 - {
421 + public void moveToMaxW() {
516 422 chromeAwareAdjustPosLeftBy( -MAX_RESOLUTION_SUPPORTED );
517 423 }
518 424
519 - public void moveToMaxS()
520 - {
425 + public void moveToMaxS() {
521 426 chromeAwareAdjustPosTopBy( MAX_RESOLUTION_SUPPORTED );
522 427 }
523 428
524 - public void moveToMaxNW()
525 - {
429 + public void moveToMaxNW() {
526 430 moveToMaxN();
527 431 moveToMaxW();
528 432 }
529 433
530 - public void moveToMaxNE()
531 - {
434 + public void moveToMaxNE() {
532 435 moveToMaxN();
533 436 moveToMaxE();
534 437 }
535 438
536 - public void moveToMaxSW()
537 - {
439 + public void moveToMaxSW() {
538 440 moveToMaxS();
539 441 moveToMaxW();
540 442 }
541 443
542 - public void moveToMaxSE()
543 - {
444 + public void moveToMaxSE() {
544 445 moveToMaxS();
545 446 moveToMaxE();
546 447 }
547 448
548 - public void increaseWidthBy( int pPixels )
549 - {
449 + public void increaseWidthBy( int pPixels ) {
550 450 chromeAwareAdjustWidthBy( pPixels, pPixels );
551 451 }
552 452
553 - public void decreaseWidthBy( int pPixels )
554 - {
453 + public void decreaseWidthBy( int pPixels ) {
555 454 chromeAwareAdjustWidthBy( pPixels, -pPixels );
556 455 }
557 456
558 - public void increaseHeightBy( int pPixels )
559 - {
457 + public void increaseHeightBy( int pPixels ) {
560 458 chromeAwareAdjustHeightBy( pPixels, pPixels );
561 459 }
562 460
563 - public void decreaseHeightBy( int pPixels )
564 - {
461 + public void decreaseHeightBy( int pPixels ) {
565 462 chromeAwareAdjustHeightBy( pPixels, -pPixels );
566 463 }
567 464
568 - public void expandToMaxWidth()
569 - {
465 + public void expandToMaxWidth() {
570 466 setWidth( MAX_RESOLUTION_SUPPORTED );
571 467 }
572 468
573 - public void expandToMaxHeight()
574 - {
469 + public void expandToMaxHeight() {
575 470 setHeight( MAX_RESOLUTION_SUPPORTED );
576 471 }
577 472
578 - public void setWidth( int pNewWidth )
579 - {
473 + public void setWidth( int pNewWidth ) {
580 474 removePositionLock();
581 475 setWidth( "" + chromeAwareConstrainWidth( pNewWidth ) );
582 476 }
583 477
584 - public void setHeight( int pNewHeight )
585 - {
478 + public void setHeight( int pNewHeight ) {
586 479 removePositionLock();
587 480 setHeight( "" + chromeAwareConstrainHeight( pNewHeight ) );
588 481 }
589 482
590 - private void chromeAwareAdjustPosTopBy( int pPixels, int pDirectionPixels )
591 - {
592 - if ( pPixels > 0 )
593 - {
483 + private void chromeAwareAdjustPosTopBy( int pPixels, int pDirectionPixels ) {
484 + if ( pPixels > 0 ) {
594 485 chromeAwareAdjustPosTopBy( pDirectionPixels );
595 486 }
596 487 }
597 488
598 - private void chromeAwareAdjustPosTopBy( int pDirectionPixels )
599 - {
489 + private void chromeAwareAdjustPosTopBy( int pDirectionPixels ) {
600 490 removePositionLock();
601 491 setPosTop( chromeAwareConstrainPosTop( getPosTop() + pDirectionPixels ) );
602 492 }
603 493
604 - private void chromeAwareAdjustPosLeftBy( int pPixels, int pDirectionPixels )
605 - {
606 - if ( pPixels > 0 )
607 - {
494 + private void chromeAwareAdjustPosLeftBy( int pPixels, int pDirectionPixels ) {
495 + if ( pPixels > 0 ) {
608 496 chromeAwareAdjustPosLeftBy( pDirectionPixels );
609 497 }
610 498 }
611 499
612 - private void chromeAwareAdjustPosLeftBy( int pDirectionPixels )
613 - {
500 + private void chromeAwareAdjustPosLeftBy( int pDirectionPixels ) {
614 501 removePositionLock();
615 502 setPosLeft( chromeAwareConstrainPosLeft( getPosLeft() + pDirectionPixels ) );
616 503 }
617 504
618 - private void chromeAwareAdjustWidthBy( int pPixels, int pDirectionPixels )
619 - {
620 - if ( pPixels > 0 )
621 - {
505 + private void chromeAwareAdjustWidthBy( int pPixels, int pDirectionPixels ) {
506 + if ( pPixels > 0 ) {
622 507 chromeAwareAdjustWidthBy( pDirectionPixels );
623 508 }
624 509 }
625 510
626 - private void chromeAwareAdjustWidthBy( int pDirectionPixels )
627 - {
511 + private void chromeAwareAdjustWidthBy( int pDirectionPixels ) {
628 512 setWidth( getOffsetWidth() + pDirectionPixels );
629 513 }
630 514
631 - private void chromeAwareAdjustHeightBy( int pPixels, int pDirectionPixels )
632 - {
633 - if ( pPixels > 0 )
634 - {
515 + private void chromeAwareAdjustHeightBy( int pPixels, int pDirectionPixels ) {
516 + if ( pPixels > 0 ) {
635 517 chromeAwareAdjustHeightBy( pDirectionPixels );
636 518 }
637 519 }
638 520
639 - private void chromeAwareAdjustHeightBy( int pDirectionPixels )
640 - {
521 + private void chromeAwareAdjustHeightBy( int pDirectionPixels ) {
641 522 setHeight( getOffsetHeight() + pDirectionPixels );
642 523 }
643 524
644 - private int getChromeAwareMaxPotentialWidth()
645 - {
525 + private int getChromeAwareMaxPotentialWidth() {
646 526 return getMaxPotentialWidth() + (isChromed() ? 0 : BORDER_R_W);
647 527 }
648 528
649 - private int chromeAwareConstrainPosLeft( int pPosLeft )
650 - {
529 + private int chromeAwareConstrainPosLeft( int pPosLeft ) {
651 530 int zMaxPosLeft = getChromeAwareMaxPotentialWidth() - getOffsetWidth();
652 - if ( pPosLeft > zMaxPosLeft )
653 - {
531 + if ( pPosLeft > zMaxPosLeft ) {
654 532 pPosLeft = zMaxPosLeft;
655 533 }
656 534
657 535 int zMinPosLeft = isChromed() ? 0 : -BORDER_L_W;
658 - if ( pPosLeft < zMinPosLeft )
659 - {
536 + if ( pPosLeft < zMinPosLeft ) {
660 537 pPosLeft = zMinPosLeft;
661 538 }
662 539
663 540 return pPosLeft;
664 541 }
665 542
666 - private int chromeAwareConstrainWidth( int pWidth )
667 - {
543 + private int chromeAwareConstrainWidth( int pWidth ) {
668 544 int zMaxWidth = getChromeAwareMaxPotentialWidth() - getPosLeft();
669 - if ( pWidth > zMaxWidth )
670 - {
545 + if ( pWidth > zMaxWidth ) {
671 546 pWidth = zMaxWidth;
672 547 }
673 548
674 549 int zMinWidth = getMinContentWidth() + (isChromed() ? 0 : BORDER_L_W + BORDER_R_W);
675 - if ( pWidth < zMinWidth )
676 - {
550 + if ( pWidth < zMinWidth ) {
677 551 pWidth = zMinWidth;
678 552 }
679 553
680 554 return pWidth;
681 555 }
682 556
683 - private int getChromeAwareMaxPotentialHeight()
684 - {
557 + private int getChromeAwareMaxPotentialHeight() {
685 558 return getMaxPotentialHeight() + (isChromed() ? 0 : BORDER_B_H);
686 559 }
687 560
688 - private int chromeAwareConstrainPosTop( int pPosTop )
689 - {
561 + private int chromeAwareConstrainPosTop( int pPosTop ) {
690 562 int zMaxPosTop = getChromeAwareMaxPotentialHeight() - getOffsetHeight();
691 - if ( pPosTop > zMaxPosTop )
692 - {
563 + if ( pPosTop > zMaxPosTop ) {
693 564 pPosTop = zMaxPosTop;
694 565 }
695 566
696 567 int zMinPosTop = isChromed() ? 0 : -(BORDER_T_H + getTitleBarHeight());
697 - if ( pPosTop < zMinPosTop )
698 - {
568 + if ( pPosTop < zMinPosTop ) {
699 569 pPosTop = zMinPosTop;
700 570 }
701 571
702 572 return pPosTop;
703 573 }
704 574
705 - private int chromeAwareConstrainHeight( int pHeight )
706 - {
575 + private int chromeAwareConstrainHeight( int pHeight ) {
707 576 int zMaxHeight = getChromeAwareMaxPotentialHeight() - getPosTop();
708 - if ( pHeight > zMaxHeight )
709 - {
577 + if ( pHeight > zMaxHeight ) {
710 578 pHeight = zMaxHeight;
711 579 }
712 580
713 581 int zMinHeight =
714 582 getMinContentHeight() + (isChromed() ? 0 : BORDER_T_H + getTitleBarHeight() + BORDER_B_H);
715 - if ( pHeight < zMinHeight )
716 - {
583 + if ( pHeight < zMinHeight ) {
717 584 pHeight = zMinHeight;
718 585 }
719 586
720 587 return pHeight;
721 588 }
722 589
723 - private int getMinContentWidth()
724 - {
590 + private int getMinContentWidth() {
725 591 return 60; // todo: Will need to dynamically determine
726 592 }
727 593
728 - private int getMinContentHeight()
729 - {
594 + private int getMinContentHeight() {
730 595 return 40; // todo: Will need to dynamically determine
731 596 }
732 597
733 - protected int getMaxPotentialWidth()
734 - {
598 + protected int getMaxPotentialWidth() {
735 599 SizeableFloatableContainerPanel containerPanel = getContainerPanel();
736 - if ( containerPanel != null )
737 - {
738 - if ( containerPanel.getOffsetHeight() > 20 )
739 - {
600 + if ( containerPanel != null ) {
601 + if ( containerPanel.getOffsetHeight() > 20 ) {
740 602 return containerPanel.getOffsetWidth();
741 603 }
742 604 }
743 605 return super.getMaxPotentialWidth();
744 606 }
745 607
746 - protected int getMaxPotentialHeight()
747 - {
608 + protected int getMaxPotentialHeight() {
748 609 SizeableFloatableContainerPanel containerPanel = getContainerPanel();
749 - if ( containerPanel != null )
750 - {
751 - if ( containerPanel.getOffsetHeight() > 20 )
752 - {
610 + if ( containerPanel != null ) {
611 + if ( containerPanel.getOffsetHeight() > 20 ) {
753 612 return containerPanel.getOffsetHeight();
754 613 }
755 614 }
756 615 return super.getMaxPotentialHeight();
757 616 }
758 617
759 - private SizeableFloatableContainerPanel getContainerPanel()
760 - {
618 + private SizeableFloatableContainerPanel getContainerPanel() {
761 619 Widget zParent = getParent();
762 620 return (zParent instanceof SizeableFloatableContainerPanel) ?
763 621 (SizeableFloatableContainerPanel) zParent : null;
764 622 }
765 623
766 - public void hideFloater()
767 - {
624 + public void hideFloater() {
768 625 Element zBorderElement = DOM.getParent( getStyleElement() );
769 626 setStyleName( zBorderElement, REGULAR_BORDER, false );
770 627 setStyleName( zBorderElement, CLEAR_BORDER, false );
  @@ -773,8 +630,7 @@
773 630 setVisible( false );
774 631 }
775 632
776 - public void showFloater()
777 - {
633 + public void showFloater() {
778 634 Element zBorderElement = DOM.getParent( getStyleElement() );
779 635 setStyleName( zBorderElement, HIDDEN_FLOATER, false );
780 636 setBorderStyle( mChromed );
  @@ -782,111 +638,88 @@
782 638 setVisible( true );
783 639 }
784 640
785 - public boolean isHidden()
786 - {
641 + public boolean isHidden() {
787 642 return mHidden;
788 643 }
789 644
790 - public void hideBorder()
791 - {
792 - if ( mChromed )
793 - {
645 + public void hideBorder() {
646 + if ( mChromed ) {
794 647 getTitleBar().hide();
795 648 teardownRegularBorder();
796 649 setupClearBorder();
797 650 }
798 651 }
799 652
800 - public void restoreBorder()
801 - {
802 - if ( !mChromed )
803 - {
653 + public void restoreBorder() {
654 + if ( !mChromed ) {
804 655 getTitleBar().unhide();
805 656 teardownClearBorder();
806 657 setupRegularBorder();
807 658 }
808 659 }
809 660
810 - private void setupClearBorder()
811 - {
661 + private void setupClearBorder() {
812 662 setBorderStyle( false );
813 663 }
814 664
815 - private void teardownClearBorder()
816 - {
665 + private void teardownClearBorder() {
817 666 }
818 667
819 - private void setupRegularBorder()
820 - {
668 + private void setupRegularBorder() {
821 669 setBorderStyle( true );
822 670 mTitleBarPanel.addController( mDragController );
823 671 }
824 672
825 - private void teardownRegularBorder()
826 - {
673 + private void teardownRegularBorder() {
827 674 mTitleBarPanel.removeController( mDragController );
828 675 }
829 676
830 - protected void setBorderStyle( boolean pNewState )
831 - {
677 + protected void setBorderStyle( boolean pNewState ) {
832 678 mChromed = pNewState;
833 679 Element zBorderElement = DOM.getParent( getStyleElement() );
834 680 setStyleName( zBorderElement, REGULAR_BORDER, mChromed );
835 681 setStyleName( zBorderElement, CLEAR_BORDER, !mChromed );
836 682 }
837 683
838 - private void forceToFront()
839 - {
840 - if ( isChromed() )
841 - {
684 + private void forceToFront() {
685 + if ( isChromed() ) {
842 686 SizeableFloatableContainerPanel containerPanel = getContainerPanel();
843 - if ( containerPanel != null )
844 - {
687 + if ( containerPanel != null ) {
845 688 containerPanel.makeTop( this );
846 689 }
847 690 }
848 691 }
849 692
850 - public void addListener( ChromeListener listener )
851 - {
852 - if ( mListeners == null )
853 - {
693 + public void addListener( ChromeListener listener ) {
694 + if ( mListeners == null ) {
854 695 mListeners = new ArrayList<ChromeListener>();
855 696 }
856 697 assert !mListeners.contains( listener );
857 698 mListeners.add( listener );
858 699 }
859 700
860 - public void removeListener( ChromeListener listener )
861 - {
862 - if ( mListeners != null )
863 - {
701 + public void removeListener( ChromeListener listener ) {
702 + if ( mListeners != null ) {
864 703 assert mListeners.contains( listener );
865 704 mListeners.remove( listener );
866 705 }
867 706 }
868 707
869 - protected void fireChromeChanged()
870 - {
871 - if ( mListeners != null && mListeners.size() > 0 )
872 - {
708 + protected void fireChromeChanged() {
709 + if ( mListeners != null && mListeners.size() > 0 ) {
873 710 ChromeListener[] listeners = mListeners.toArray( new ChromeListener[mListeners.size()] );
874 - for ( ChromeListener listener : listeners )
875 - {
711 + for ( ChromeListener listener : listeners ) {
876 712 listener.chromeChanged( this );
877 713 }
878 714 }
879 715 }
880 716
881 - private class BringToFrontGesture extends DragGestureWrapper
882 - {
883 - public BringToFrontGesture( DragGesture delegate )
884 - {
717 + private class BringToFrontGesture extends DragGestureWrapper {
718 + public BringToFrontGesture( DragGesture delegate ) {
885 719 super( delegate );
886 720 }
887 721
888 - public void start( MouseEvent e )
889 - {
722 + public void start( MouseEvent e ) {
890 723 forceToFront();
891 724 super.start( e );
892 725 }