Subversion Repository Public Repository

litesoft

Diff Revisions 947 vs 948 for /trunk/Java/GWT/Client/src/org/litesoft/GWT/client/widgets/nonpublic/AbstractSizeableSimplePanel.java

Diff revisions: vs.
  @@ -1,20 +1,18 @@
1 1 // This Source Code is in the Public Domain per: http://unlicense.org
2 2 package org.litesoft.GWT.client.widgets.nonpublic;
3 3
4 - import java.util.*;
5 -
6 4 import org.litesoft.GWT.client.widgets.*;
7 5
8 6 import com.google.gwt.user.client.*;
9 7 import com.google.gwt.user.client.ui.*;
10 8
11 - public abstract class AbstractSizeableSimplePanel extends AbstractSizeablePanel implements SizeableSingleWidgetContainer
12 - {
9 + import java.util.*;
10 +
11 + public abstract class AbstractSizeableSimplePanel extends AbstractSizeablePanel implements SizeableSingleWidgetContainer {
13 12 private Widget mWidget;
14 13
15 14 @Override
16 - public boolean anyChildren()
17 - {
15 + public boolean anyChildren() {
18 16 return (mWidget != null);
19 17 }
20 18
  @@ -24,10 +22,8 @@
24 22 * Removes all child widgets.
25 23 */
26 24 @Override
27 - public void clear()
28 - {
29 - if ( anyChildren() )
30 - {
25 + public void clear() {
26 + if ( anyChildren() ) {
31 27 remove( mWidget );
32 28 }
33 29 }
  @@ -37,15 +33,12 @@
37 33 * implement {@link Iterator#remove()}.
38 34 */
39 35 @Override
40 - public Iterator<Widget> iterator()
41 - {
36 + public Iterator<Widget> iterator() {
42 37 // Return a simple iterator that enumerates the 0 or 1 elements in this
43 38 // panel.
44 - return new SingleWidgetIterator( mWidget )
45 - {
39 + return new SingleWidgetIterator( mWidget ) {
46 40 @Override
47 - public void remove()
48 - {
41 + public void remove() {
49 42 clear();
50 43 }
51 44 };
  @@ -57,11 +50,9 @@
57 50 * @param pWidget the child widget to be added
58 51 */
59 52 @Override
60 - public void add( Widget pWidget )
61 - {
53 + public void add( Widget pWidget ) {
62 54 // Can't add() more than one widget to a SimplePanel.
63 - if ( getWidget() != null )
64 - {
55 + if ( getWidget() != null ) {
65 56 throw new IllegalStateException( "SimplePanel can only contain one child widget" );
66 57 }
67 58 setWidget( pWidget );
  @@ -75,10 +66,8 @@
75 66 * @return <code>true</code> if the widget was present
76 67 */
77 68 @Override
78 - public boolean remove( Widget pWidget )
79 - {
80 - if ( mWidget == pWidget )
81 - {
69 + public boolean remove( Widget pWidget ) {
70 + if ( mWidget == pWidget ) {
82 71 disown( pWidget );
83 72 return true;
84 73 }
  @@ -95,8 +84,7 @@
95 84 * @return the child widget, or <code>null</code> if none is present
96 85 */
97 86 @Override
98 - public Widget getWidget()
99 - {
87 + public Widget getWidget() {
100 88 return mWidget;
101 89 }
102 90
  @@ -104,16 +92,13 @@
104 92 * Sets this panel's widget. Any existing child widget will be removed.
105 93 */
106 94 @Override
107 - public void setWidget( Widget pWidget )
108 - {
95 + public void setWidget( Widget pWidget ) {
109 96 // If there is already a widget attached, remove it.
110 - if ( mWidget != null )
111 - {
97 + if ( mWidget != null ) {
112 98 disown( mWidget );
113 99 }
114 100
115 - if ( pWidget != null )
116 - {
101 + if ( pWidget != null ) {
117 102 // Adopt the child.
118 103 adopt( pWidget );
119 104 }
  @@ -122,8 +107,7 @@
122 107 // ^^^^^^^^^^^ SingleWidgetContainer
123 108
124 109 @Override
125 - protected final Element adopt( Widget w, Element container )
126 - {
110 + protected final Element adopt( Widget w, Element container ) {
127 111 throw new IllegalStateException( "Inappropriate use of raw adopt( Widget w, Element container )" );
128 112 }
129 113
  @@ -132,10 +116,8 @@
132 116 *
133 117 * @param pWidget !null
134 118 */
135 - protected void adopt( Widget pWidget )
136 - {
137 - if ( aboutToAdopt( pWidget ) )
138 - {
119 + protected void adopt( Widget pWidget ) {
120 + if ( aboutToAdopt( pWidget ) ) {
139 121 LLadopt( pWidget );
140 122 justAdopted( pWidget );
141 123 }
  @@ -147,24 +129,20 @@
147 129 * @param pWidget !null
148 130 */
149 131 @Override
150 - protected Element disown( Widget pWidget )
151 - {
152 - if ( aboutToDisown( pWidget ) )
153 - {
132 + protected Element disown( Widget pWidget ) {
133 + if ( aboutToDisown( pWidget ) ) {
154 134 LLdisown( pWidget );
155 135 justDisowned( pWidget );
156 136 }
157 137 return null; // Don't care
158 138 }
159 139
160 - protected void LLdisown( Widget pWidget )
161 - {
140 + protected void LLdisown( Widget pWidget ) {
162 141 super.disown( pWidget ); // remove Widget from td
163 142 mWidget = null;
164 143 }
165 144
166 - protected void LLadopt( Widget pWidget )
167 - {
145 + protected void LLadopt( Widget pWidget ) {
168 146 pWidget.removeFromParent();
169 147 super.adopt( pWidget, getContainerElement() ); // put Widget in TD
170 148 mWidget = pWidget;
  @@ -177,8 +155,7 @@
177 155 * @return true if OK to add
178 156 */
179 157 @SuppressWarnings({"UnusedDeclaration"})
180 - protected boolean aboutToAdopt( Widget pWidget )
181 - {
158 + protected boolean aboutToAdopt( Widget pWidget ) {
182 159 return true;
183 160 }
184 161
  @@ -187,8 +164,7 @@
187 164 * Should not throw an exception!
188 165 */
189 166 @SuppressWarnings({"UnusedDeclaration"})
190 - protected void justAdopted( Widget pWidget )
191 - {
167 + protected void justAdopted( Widget pWidget ) {
192 168 }
193 169
194 170 /**
  @@ -198,8 +174,7 @@
198 174 * @return true if OK to add
199 175 */
200 176 @SuppressWarnings({"UnusedDeclaration"})
201 - protected boolean aboutToDisown( Widget pWidget )
202 - {
177 + protected boolean aboutToDisown( Widget pWidget ) {
203 178 return true;
204 179 }
205 180
  @@ -208,31 +183,26 @@
208 183 * Should not throw an exception!
209 184 */
210 185 @SuppressWarnings({"UnusedDeclaration"})
211 - protected void justDisowned( Widget pWidget )
212 - {
186 + protected void justDisowned( Widget pWidget ) {
213 187 }
214 188
215 189 @Override
216 - public void setWidth( String width )
217 - {
190 + public void setWidth( String width ) {
218 191 super.setWidth( width ); // for stacktrace Debugging
219 192 }
220 193
221 194 @Override
222 - public void setHeight( String height )
223 - {
195 + public void setHeight( String height ) {
224 196 super.setHeight( height ); // for stacktrace Debugging
225 197 }
226 198
227 199 @Override
228 - protected void distributeToChildrenChangedWidth()
229 - {
200 + protected void distributeToChildrenChangedWidth() {
230 201 getHelper().applyChangedDimensionToChild( getWidget(), getWidthHelper() );
231 202 }
232 203
233 204 @Override
234 - protected void distributeToChildrenChangedHeight()
235 - {
205 + protected void distributeToChildrenChangedHeight() {
236 206 getHelper().applyChangedDimensionToChild( getWidget(), getHeightHelper() );
237 207 }
238 208 }