|
@@ -5,17 +5,14 @@ |
5 |
5 |
|
|
6 |
6 |
|
import com.google.gwt.user.client.ui.*; |
7 |
7 |
|
|
8 |
|
- |
public class SizeableDeckPanel extends AbstractSizeableComplexPanel implements IndexedPanel |
9 |
|
- |
{ |
|
8 |
+ |
public class SizeableDeckPanel extends AbstractSizeableComplexPanel implements IndexedPanel { |
10 |
9 |
|
private Widget mVisibleWidget; |
11 |
10 |
|
|
12 |
|
- |
public SizeableDeckPanel() |
13 |
|
- |
{ |
|
11 |
+ |
public SizeableDeckPanel() { |
14 |
12 |
|
initializeElements( getHelper().create_OeTable_SeDiv_IeDiv( true ), "LayoutSizeableDeckPanel" ); |
15 |
13 |
|
} |
16 |
14 |
|
|
17 |
|
- |
public SizeableDeckPanel style( String pStyleName ) |
18 |
|
- |
{ |
|
15 |
+ |
public SizeableDeckPanel style( String pStyleName ) { |
19 |
16 |
|
addStyleName( pStyleName ); |
20 |
17 |
|
return this; |
21 |
18 |
|
} |
|
@@ -26,8 +23,7 @@ |
26 |
23 |
|
* @param w the widget to be added |
27 |
24 |
|
*/ |
28 |
25 |
|
@Override |
29 |
|
- |
public void add( Widget w ) |
30 |
|
- |
{ |
|
26 |
+ |
public void add( Widget w ) { |
31 |
27 |
|
insert( w, getWidgetCount() ); |
32 |
28 |
|
} |
33 |
29 |
|
|
|
@@ -36,26 +32,22 @@ |
36 |
32 |
|
* |
37 |
33 |
|
* @return the visible widget's index |
38 |
34 |
|
*/ |
39 |
|
- |
public int getVisibleWidget() |
40 |
|
- |
{ |
|
35 |
+ |
public int getVisibleWidget() { |
41 |
36 |
|
return getWidgetIndex( mVisibleWidget ); |
42 |
37 |
|
} |
43 |
38 |
|
|
44 |
39 |
|
@Override |
45 |
|
- |
public Widget getWidget( int index ) |
46 |
|
- |
{ |
|
40 |
+ |
public Widget getWidget( int index ) { |
47 |
41 |
|
return getChildren().get( index ); |
48 |
42 |
|
} |
49 |
43 |
|
|
50 |
44 |
|
@Override |
51 |
|
- |
public int getWidgetCount() |
52 |
|
- |
{ |
|
45 |
+ |
public int getWidgetCount() { |
53 |
46 |
|
return getChildren().size(); |
54 |
47 |
|
} |
55 |
48 |
|
|
56 |
49 |
|
@Override |
57 |
|
- |
public int getWidgetIndex( Widget child ) |
58 |
|
- |
{ |
|
50 |
+ |
public int getWidgetIndex( Widget child ) { |
59 |
51 |
|
return getChildren().indexOf( child ); |
60 |
52 |
|
} |
61 |
53 |
|
|
|
@@ -68,44 +60,34 @@ |
68 |
60 |
|
* @throws IndexOutOfBoundsException if <code>beforeIndex</code> is out of |
69 |
61 |
|
* range |
70 |
62 |
|
*/ |
71 |
|
- |
public void insert( Widget w, int beforeIndex ) |
72 |
|
- |
{ |
73 |
|
- |
if ( (beforeIndex < 0) || (beforeIndex > getWidgetCount()) ) |
74 |
|
- |
{ |
|
63 |
+ |
public void insert( Widget w, int beforeIndex ) { |
|
64 |
+ |
if ( (beforeIndex < 0) || (beforeIndex > getWidgetCount()) ) { |
75 |
65 |
|
throw new IndexOutOfBoundsException( String.valueOf( beforeIndex ) ); |
76 |
66 |
|
} |
77 |
67 |
|
|
78 |
68 |
|
super.insert( w, getContainerElement(), beforeIndex ); |
79 |
69 |
|
|
80 |
|
- |
if ( mVisibleWidget == null ) |
81 |
|
- |
{ |
|
70 |
+ |
if ( mVisibleWidget == null ) { |
82 |
71 |
|
showAwidget( 0 ); |
83 |
|
- |
} |
84 |
|
- |
else |
85 |
|
- |
{ |
|
72 |
+ |
} else { |
86 |
73 |
|
w.setVisible( false ); |
87 |
74 |
|
} |
88 |
75 |
|
} |
89 |
76 |
|
|
90 |
77 |
|
@Override |
91 |
|
- |
public boolean remove( int index ) |
92 |
|
- |
{ |
|
78 |
+ |
public boolean remove( int index ) { |
93 |
79 |
|
return remove( getWidget( index ) ); |
94 |
80 |
|
} |
95 |
81 |
|
|
96 |
82 |
|
@Override |
97 |
|
- |
public boolean remove( Widget w ) |
98 |
|
- |
{ |
99 |
|
- |
if ( !super.remove( w ) ) |
100 |
|
- |
{ |
|
83 |
+ |
public boolean remove( Widget w ) { |
|
84 |
+ |
if ( !super.remove( w ) ) { |
101 |
85 |
|
return false; |
102 |
86 |
|
} |
103 |
87 |
|
|
104 |
|
- |
if ( mVisibleWidget == w ) |
105 |
|
- |
{ |
|
88 |
+ |
if ( mVisibleWidget == w ) { |
106 |
89 |
|
mVisibleWidget = null; |
107 |
|
- |
if ( getWidgetCount() != 0 ) |
108 |
|
- |
{ |
|
90 |
+ |
if ( getWidgetCount() != 0 ) { |
109 |
91 |
|
showAwidget( 0 ); |
110 |
92 |
|
} |
111 |
93 |
|
} |
|
@@ -119,59 +101,49 @@ |
119 |
101 |
|
* |
120 |
102 |
|
* @param index the index of the widget to be shown |
121 |
103 |
|
*/ |
122 |
|
- |
public void showWidget( int index ) |
123 |
|
- |
{ |
|
104 |
+ |
public void showWidget( int index ) { |
124 |
105 |
|
checkIndex( index ); |
125 |
106 |
|
|
126 |
|
- |
if ( mVisibleWidget != null ) |
127 |
|
- |
{ |
|
107 |
+ |
if ( mVisibleWidget != null ) { |
128 |
108 |
|
mVisibleWidget.setVisible( false ); |
129 |
109 |
|
} |
130 |
110 |
|
showAwidget( index ); |
131 |
111 |
|
} |
132 |
112 |
|
|
133 |
|
- |
private void checkIndex( int index ) |
134 |
|
- |
{ |
135 |
|
- |
if ( (index < 0) || (index >= getWidgetCount()) ) |
136 |
|
- |
{ |
|
113 |
+ |
private void checkIndex( int index ) { |
|
114 |
+ |
if ( (index < 0) || (index >= getWidgetCount()) ) { |
137 |
115 |
|
throw new IndexOutOfBoundsException( String.valueOf( index ) ); |
138 |
116 |
|
} |
139 |
117 |
|
} |
140 |
118 |
|
|
141 |
119 |
|
//****** Implementation Code Block to support delegation to AbsoluteSizeHelper |
142 |
120 |
|
|
143 |
|
- |
public SizeableDeckPanel stretchable() |
144 |
|
- |
{ |
|
121 |
+ |
public SizeableDeckPanel stretchable() { |
145 |
122 |
|
LLstretchable(); |
146 |
123 |
|
return this; |
147 |
124 |
|
} |
148 |
125 |
|
|
149 |
|
- |
public SizeableDeckPanel stretchableVertically() |
150 |
|
- |
{ |
|
126 |
+ |
public SizeableDeckPanel stretchableVertically() { |
151 |
127 |
|
LLstretchableVertically(); |
152 |
128 |
|
return this; |
153 |
129 |
|
} |
154 |
130 |
|
|
155 |
|
- |
public SizeableDeckPanel stretchableHorizontally() |
156 |
|
- |
{ |
|
131 |
+ |
public SizeableDeckPanel stretchableHorizontally() { |
157 |
132 |
|
LLstretchableHorizontally(); |
158 |
133 |
|
return this; |
159 |
134 |
|
} |
160 |
135 |
|
|
161 |
136 |
|
@Override |
162 |
|
- |
public void setWidth( String width ) |
163 |
|
- |
{ |
|
137 |
+ |
public void setWidth( String width ) { |
164 |
138 |
|
super.setWidth( width ); // for stacktrace Debugging |
165 |
139 |
|
} |
166 |
140 |
|
|
167 |
141 |
|
@Override |
168 |
|
- |
public void setHeight( String height ) |
169 |
|
- |
{ |
|
142 |
+ |
public void setHeight( String height ) { |
170 |
143 |
|
super.setHeight( height ); // for stacktrace Debugging |
171 |
144 |
|
} |
172 |
145 |
|
|
173 |
|
- |
private void showAwidget( int index ) |
174 |
|
- |
{ |
|
146 |
+ |
private void showAwidget( int index ) { |
175 |
147 |
|
mVisibleWidget = getWidget( index ); |
176 |
148 |
|
mVisibleWidget.setVisible( true ); |
177 |
149 |
|
|
|
@@ -180,25 +152,20 @@ |
180 |
152 |
|
} |
181 |
153 |
|
|
182 |
154 |
|
@Override |
183 |
|
- |
protected void distributeToChildrenChangedWidth() |
184 |
|
- |
{ |
185 |
|
- |
if ( anyChildren() ) |
186 |
|
- |
{ |
|
155 |
+ |
protected void distributeToChildrenChangedWidth() { |
|
156 |
+ |
if ( anyChildren() ) { |
187 |
157 |
|
adjustSizeOnShownWidget( getWidthHelper() ); |
188 |
158 |
|
} |
189 |
159 |
|
} |
190 |
160 |
|
|
191 |
161 |
|
@Override |
192 |
|
- |
protected void distributeToChildrenChangedHeight() |
193 |
|
- |
{ |
194 |
|
- |
if ( anyChildren() ) |
195 |
|
- |
{ |
|
162 |
+ |
protected void distributeToChildrenChangedHeight() { |
|
163 |
+ |
if ( anyChildren() ) { |
196 |
164 |
|
adjustSizeOnShownWidget( getHeightHelper() ); |
197 |
165 |
|
} |
198 |
166 |
|
} |
199 |
167 |
|
|
200 |
|
- |
private void adjustSizeOnShownWidget( ISizeableDimensionHelper pDimensionHelper ) |
201 |
|
- |
{ |
|
168 |
+ |
private void adjustSizeOnShownWidget( ISizeableDimensionHelper pDimensionHelper ) { |
202 |
169 |
|
getHelper().applyChangedDimensionToChild( mVisibleWidget, pDimensionHelper ); |
203 |
170 |
|
} |
204 |
171 |
|
} |