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