|
@@ -5,78 +5,64 @@ |
5 |
5 |
|
|
6 |
6 |
|
import com.google.gwt.user.client.ui.*; |
7 |
7 |
|
|
8 |
|
- |
public abstract class AbstractSizeableVerticalSplitPairPanel extends AbstractSizeableVerticalPanel |
9 |
|
- |
{ |
|
8 |
+ |
public abstract class AbstractSizeableVerticalSplitPairPanel extends AbstractSizeableVerticalPanel { |
10 |
9 |
|
private VerticalSplitterDragger mDragger; |
11 |
10 |
|
|
12 |
11 |
|
@Override |
13 |
|
- |
protected void initialize() |
14 |
|
- |
{ |
|
12 |
+ |
protected void initialize() { |
15 |
13 |
|
super.initialize(); |
16 |
14 |
|
LLstretchableVertically(); |
17 |
15 |
|
} |
18 |
16 |
|
|
19 |
|
- |
public AbstractSizeableVerticalSplitPairPanel add( Widget pTopWidget, Widget pBottomWidget ) |
20 |
|
- |
{ |
|
17 |
+ |
public AbstractSizeableVerticalSplitPairPanel add( Widget pTopWidget, Widget pBottomWidget ) { |
21 |
18 |
|
add( pTopWidget ); |
22 |
19 |
|
add( pBottomWidget ); |
23 |
20 |
|
return this; |
24 |
21 |
|
} |
25 |
22 |
|
|
26 |
23 |
|
@Override |
27 |
|
- |
protected boolean aboutToAdopt( Widget pWidget, int pBeforeIndex ) |
28 |
|
- |
{ |
29 |
|
- |
if ( pWidget instanceof Splitter ) |
30 |
|
- |
{ |
|
24 |
+ |
protected boolean aboutToAdopt( Widget pWidget, int pBeforeIndex ) { |
|
25 |
+ |
if ( pWidget instanceof Splitter ) { |
31 |
26 |
|
throw new IllegalArgumentException( "Attempt to add Splitter directly" ); |
32 |
27 |
|
} |
33 |
|
- |
if ( !getSizeableWidget( pWidget ).getHeightHelper().isStretchable() ) |
34 |
|
- |
{ |
|
28 |
+ |
if ( !getSizeableWidget( pWidget ).getHeightHelper().isStretchable() ) { |
35 |
29 |
|
throw new IllegalArgumentException( "Attempt to add widget to Vertical Split Pair Panel that does NOT support Vertical Stretchability" ); |
36 |
30 |
|
} |
37 |
|
- |
if ( !isOur( pWidget ) && (getWidgetCount() == 3) ) |
38 |
|
- |
{ |
|
31 |
+ |
if ( !isOur( pWidget ) && (getWidgetCount() == 3) ) { |
39 |
32 |
|
throw new IllegalArgumentException( "Vertical Split Pair Panel only supports TWO Vertical Stretchables" ); |
40 |
33 |
|
} |
41 |
34 |
|
return super.aboutToAdopt( pWidget, pBeforeIndex ); |
42 |
35 |
|
} |
43 |
36 |
|
|
44 |
37 |
|
@Override |
45 |
|
- |
protected void justAdopted( Widget pWidget, int pWidgetIndex ) |
46 |
|
- |
{ |
|
38 |
+ |
protected void justAdopted( Widget pWidget, int pWidgetIndex ) { |
47 |
39 |
|
super.justAdopted( pWidget, pWidgetIndex ); |
48 |
40 |
|
|
49 |
41 |
|
// Since we only support 2 real widgets, they could be disordered in regards to the splitter |
50 |
42 |
|
dropSplitters(); |
51 |
|
- |
if ( getWidgetCount() == 2 ) |
52 |
|
- |
{ |
|
43 |
+ |
if ( getWidgetCount() == 2 ) { |
53 |
44 |
|
LLadopt( createSplitter( 1 ), 1 ); |
54 |
45 |
|
} |
55 |
46 |
|
} |
56 |
47 |
|
|
57 |
48 |
|
@Override |
58 |
|
- |
protected void justDisowned( Widget pWidget, int pWidgetIndex ) |
59 |
|
- |
{ |
|
49 |
+ |
protected void justDisowned( Widget pWidget, int pWidgetIndex ) { |
60 |
50 |
|
super.justDisowned( pWidget, pWidgetIndex ); |
61 |
51 |
|
|
62 |
52 |
|
// Since we only support 2 real widgets, any disowned should remove the splitter |
63 |
53 |
|
dropSplitters(); |
64 |
54 |
|
} |
65 |
55 |
|
|
66 |
|
- |
private void dropSplitters() |
67 |
|
- |
{ |
68 |
|
- |
for ( int i = getWidgetCount(); --i >= 0; ) |
69 |
|
- |
{ |
|
56 |
+ |
private void dropSplitters() { |
|
57 |
+ |
for ( int i = getWidgetCount(); --i >= 0; ) { |
70 |
58 |
|
Widget widget = getWidget( i ); |
71 |
|
- |
if ( widget instanceof Splitter ) |
72 |
|
- |
{ |
|
59 |
+ |
if ( widget instanceof Splitter ) { |
73 |
60 |
|
LLdisown( widget, i ); |
74 |
61 |
|
} |
75 |
62 |
|
} |
76 |
63 |
|
} |
77 |
64 |
|
|
78 |
|
- |
protected Widget createSplitter( int pIndex ) |
79 |
|
- |
{ |
|
65 |
+ |
protected Widget createSplitter( int pIndex ) { |
80 |
66 |
|
Splitter result = new Splitter( "litesoft-SplitterForVerticalPair" ); |
81 |
67 |
|
result.stretchableHorizontally(); |
82 |
68 |
|
mDragger = new VerticalSplitterDragger( this, pIndex ); |
|
@@ -84,16 +70,13 @@ |
84 |
70 |
|
return result; |
85 |
71 |
|
} |
86 |
72 |
|
|
87 |
|
- |
private class VerticalSplitterDragger extends AbstractSplitterDragger |
88 |
|
- |
{ |
89 |
|
- |
public VerticalSplitterDragger( AbstractSizeableOneDimensionalPanel panel, int pIndex ) |
90 |
|
- |
{ |
|
73 |
+ |
private class VerticalSplitterDragger extends AbstractSplitterDragger { |
|
74 |
+ |
public VerticalSplitterDragger( AbstractSizeableOneDimensionalPanel panel, int pIndex ) { |
91 |
75 |
|
super( panel, pIndex ); |
92 |
76 |
|
} |
93 |
77 |
|
|
94 |
78 |
|
@Override |
95 |
|
- |
protected boolean dragBy( int pDeltaX, int pDeltaY ) |
96 |
|
- |
{ |
|
79 |
+ |
protected boolean dragBy( int pDeltaX, int pDeltaY ) { |
97 |
80 |
|
return adjustSizesBy( getSizeableAt( mIndex - 1 ).getHeightHelper(), // |
98 |
81 |
|
getSizeableAt( mIndex + 1 ).getHeightHelper(), // |
99 |
82 |
|
pDeltaY ); |
|
@@ -101,31 +84,25 @@ |
101 |
84 |
|
} |
102 |
85 |
|
|
103 |
86 |
|
@Override |
104 |
|
- |
public void setWidth( String width ) |
105 |
|
- |
{ |
|
87 |
+ |
public void setWidth( String width ) { |
106 |
88 |
|
super.setWidth( width ); // for stacktrace Debugging |
107 |
89 |
|
} |
108 |
90 |
|
|
109 |
91 |
|
@Override |
110 |
|
- |
public void setHeight( String height ) |
111 |
|
- |
{ |
|
92 |
+ |
public void setHeight( String height ) { |
112 |
93 |
|
super.setHeight( height ); // for stacktrace Debugging |
113 |
94 |
|
} |
114 |
95 |
|
|
115 |
96 |
|
private boolean mFavorFirstWidget; |
116 |
97 |
|
|
117 |
|
- |
protected void setFavorFirstWidget() |
118 |
|
- |
{ |
|
98 |
+ |
protected void setFavorFirstWidget() { |
119 |
99 |
|
mFavorFirstWidget = true; |
120 |
100 |
|
} |
121 |
101 |
|
|
122 |
|
- |
public boolean setFirstWidgetHeight( int pPixels ) |
123 |
|
- |
{ |
124 |
|
- |
if ( (pPixels > 20) && anyChildren() ) |
125 |
|
- |
{ |
|
102 |
+ |
public boolean setFirstWidgetHeight( int pPixels ) { |
|
103 |
+ |
if ( (pPixels > 20) && anyChildren() ) { |
126 |
104 |
|
int zDimension = getHeightHelper().getDimension(); |
127 |
|
- |
if ( (zDimension > 20) && (zDimension != pPixels) ) |
128 |
|
- |
{ |
|
105 |
+ |
if ( (zDimension > 20) && (zDimension != pPixels) ) { |
129 |
106 |
|
mDragger.dragBy( 0, pPixels - zDimension ); |
130 |
107 |
|
return true; |
131 |
108 |
|
} |
|
@@ -134,10 +111,8 @@ |
134 |
111 |
|
} |
135 |
112 |
|
|
136 |
113 |
|
@Override |
137 |
|
- |
protected void distributeToChildrenChangedHeight() |
138 |
|
- |
{ |
139 |
|
- |
if ( anyChildren() ) |
140 |
|
- |
{ |
|
114 |
+ |
protected void distributeToChildrenChangedHeight() { |
|
115 |
+ |
if ( anyChildren() ) { |
141 |
116 |
|
getHelper().distributeDimensionToChild( this, getHeightHelper(), mFavorFirstWidget ? getFirstWidget() : getLastWidget() ); |
142 |
117 |
|
} |
143 |
118 |
|
} |