Subversion Repository Public Repository

litesoft

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

Diff revisions: vs.
  @@ -9,8 +9,7 @@
9 9 import com.google.gwt.dom.client.Element;
10 10 import com.google.gwt.user.client.*;
11 11
12 - public abstract class AbstractCssBackedButton extends Button
13 - {
12 + public abstract class AbstractCssBackedButton extends Button {
14 13 private static final State sREGULAR = new State( "Regular" );
15 14 private static final State sMOUSEOVER = new State( "Mouseover" );
16 15 private static final State sMOUSEDOWN = new State( "Mousedown" );
  @@ -26,12 +25,10 @@
26 25 protected State mCurrentState = null;
27 26 private com.google.gwt.user.client.Element mSavedCaptureElement = null;
28 27
29 - public AbstractCssBackedButton( String pName, CtrlElements pCtrlElements, String pEnabledToolTip, String pDisabledToolTip )
30 - {
28 + public AbstractCssBackedButton( String pName, CtrlElements pCtrlElements, String pEnabledToolTip, String pDisabledToolTip ) {
31 29 super( pName, pCtrlElements.getPrimary() );
32 30 mCtrlElements = pCtrlElements;
33 - if ( null != (mEnabledToolTip = Strings.noEmpty( pEnabledToolTip )) )
34 - {
31 + if ( null != (mEnabledToolTip = Strings.noEmpty( pEnabledToolTip )) ) {
35 32 setTitle( mEnabledToolTip );
36 33 mDisabledToolTip = pDisabledToolTip == null ? pDisabledToolTip : pDisabledToolTip.trim();
37 34 }
  @@ -39,82 +36,63 @@
39 36 updateForm();
40 37 }
41 38
42 - public String getEnabledToolTip()
43 - {
39 + public String getEnabledToolTip() {
44 40 return mEnabledToolTip;
45 41 }
46 42
47 - public void setEnabledToolTip( String pEnabledToolTip )
48 - {
43 + public void setEnabledToolTip( String pEnabledToolTip ) {
49 44 String zEnabledToolTip = Strings.noEmpty( pEnabledToolTip );
50 - if ( zEnabledToolTip != null )
51 - {
45 + if ( zEnabledToolTip != null ) {
52 46 mEnabledToolTip = pEnabledToolTip;
53 - if ( isEnabled() )
54 - {
47 + if ( isEnabled() ) {
55 48 setTitle( mEnabledToolTip );
56 49 }
57 50 }
58 51 }
59 52
60 53 @Override
61 - public void setColorStyleClass( String pNewColorStyleClassName )
62 - {
63 - if ( null != (pNewColorStyleClassName = Strings.noEmpty( pNewColorStyleClassName )) )
64 - {
54 + public void setColorStyleClass( String pNewColorStyleClassName ) {
55 + if ( null != (pNewColorStyleClassName = Strings.noEmpty( pNewColorStyleClassName )) ) {
65 56 Element zStyle = mCtrlElements.getSecondStyle();
66 - if ( zStyle != null )
67 - {
57 + if ( zStyle != null ) {
68 58 zStyle.setClassName( pNewColorStyleClassName ); // Don't think we need to remove the old value!
69 59 }
70 60 }
71 61 }
72 62
73 - private State determineNewForm()
74 - {
75 - if ( !isEnabled() )
76 - {
63 + private State determineNewForm() {
64 + if ( !isEnabled() ) {
77 65 return sDISABLED;
78 66 }
79 - if ( mMouseDown )
80 - {
67 + if ( mMouseDown ) {
81 68 return sMOUSEDOWN;
82 69 }
83 - if ( mMouseOver )
84 - {
70 + if ( mMouseOver ) {
85 71 return sMOUSEOVER;
86 72 }
87 73 return sREGULAR;
88 74 }
89 75
90 - public void updateForm()
91 - {
76 + public void updateForm() {
92 77 State zNewForm = determineNewForm();
93 - if ( mCurrentState != zNewForm )
94 - {
95 - if ( mCurrentState != null )
96 - {
78 + if ( mCurrentState != zNewForm ) {
79 + if ( mCurrentState != null ) {
97 80 removeCurrentState();
98 81
99 - if ( mCurrentState == sMOUSEDOWN )
100 - {
82 + if ( mCurrentState == sMOUSEDOWN ) {
101 83 DOM.releaseCapture( getElement() );
102 - if ( mSavedCaptureElement != null )
103 - {
84 + if ( mSavedCaptureElement != null ) {
104 85 DOM.setCapture( mSavedCaptureElement );
105 86 mSavedCaptureElement = null;
106 87 }
107 88 }
108 89 }
109 90 String zNewToolTip = mDisabledToolTip;
110 - if ( zNewForm != sDISABLED )
111 - {
91 + if ( zNewForm != sDISABLED ) {
112 92 zNewToolTip = mEnabledToolTip;
113 - if ( zNewForm == sMOUSEDOWN )
114 - {
93 + if ( zNewForm == sMOUSEDOWN ) {
115 94 mSavedCaptureElement = DOM.getCaptureElement();
116 - if ( mSavedCaptureElement != null )
117 - {
95 + if ( mSavedCaptureElement != null ) {
118 96 DOM.releaseCapture( mSavedCaptureElement );
119 97 }
120 98 DOM.setCapture( getElement() );
  @@ -122,35 +100,29 @@
122 100 }
123 101 mCurrentState = zNewForm;
124 102 applyCurrentState();
125 - if ( zNewToolTip != null )
126 - {
103 + if ( zNewToolTip != null ) {
127 104 setTitle( zNewToolTip );
128 105 }
129 106 }
130 107 }
131 108
132 - protected void applyCurrentState()
133 - {
109 + protected void applyCurrentState() {
134 110 addStyleName( "" + mCurrentState );
135 111 }
136 112
137 - protected void removeCurrentState()
138 - {
113 + protected void removeCurrentState() {
139 114 removeStyleName( "" + mCurrentState );
140 115 }
141 116
142 117 @Override
143 - public void setEnabled( boolean pEnabled )
144 - {
118 + public void setEnabled( boolean pEnabled ) {
145 119 super.setEnabled( pEnabled );
146 120 updateForm();
147 121 }
148 122
149 123 @Override
150 - public void onBrowserEvent( Event pEvent )
151 - {
152 - switch ( DOM.eventGetType( pEvent ) )
153 - {
124 + public void onBrowserEvent( Event pEvent ) {
125 + switch ( DOM.eventGetType( pEvent ) ) {
154 126 case Event.ONMOUSEDOWN:
155 127 UtilsGwt.eventPreventDefaultAndCancelBubble( pEvent );
156 128 onMouseDown( pEvent );
  @@ -174,47 +146,38 @@
174 146 }
175 147
176 148 @SuppressWarnings({"UnusedDeclaration"})
177 - protected void onMouseDown( Event pEvent )
178 - {
149 + protected void onMouseDown( Event pEvent ) {
179 150 mouseDown();
180 151 }
181 152
182 - protected void onMouseUp( Event pEvent )
183 - {
153 + protected void onMouseUp( Event pEvent ) {
184 154 mouseUp();
185 - if ( !mMouseOver )
186 - {
155 + if ( !mMouseOver ) {
187 156 simulateMouseMove( pEvent );
188 157 }
189 158 }
190 159
191 160 @SuppressWarnings({"UnusedDeclaration"})
192 - protected void onMouseEnter( Event pEvent )
193 - {
161 + protected void onMouseEnter( Event pEvent ) {
194 162 mouseEnter();
195 163 }
196 164
197 165 @SuppressWarnings({"UnusedDeclaration"})
198 - protected void onMouseLeave( Event pEvent )
199 - {
166 + protected void onMouseLeave( Event pEvent ) {
200 167 mouseLeave();
201 168 }
202 169
203 170 @SuppressWarnings({"UnusedDeclaration"})
204 - protected void onMouseMove( Event pEvent )
205 - {
171 + protected void onMouseMove( Event pEvent ) {
206 172 MyMouseMoveEvent zEvent = new MyMouseMoveEvent( pEvent );
207 173 com.google.gwt.user.client.Element e = getElement();
208 174 int zRelativeX = zEvent.getRelativeX( e );
209 175 int zOffsetWidth = e.getOffsetWidth();
210 176 int zRelativeY = zEvent.getRelativeY( e );
211 177 int zOffsetHeight = e.getOffsetHeight();
212 - if ( over( zRelativeX, zOffsetWidth ) && over( zRelativeY, zOffsetHeight ) )
213 - {
178 + if ( over( zRelativeX, zOffsetWidth ) && over( zRelativeY, zOffsetHeight ) ) {
214 179 mouseEnter();
215 - }
216 - else
217 - {
180 + } else {
218 181 mouseLeave();
219 182 }
220 183 // AbstractLogger zLogger = LOGGER.trace();
  @@ -232,105 +195,86 @@
232 195 // return " | " + pWhat + "(" + pX + "," + pY + ")";
233 196 }
234 197
235 - private boolean over( int pRelativeAt, int pOffsetSize )
236 - {
198 + private boolean over( int pRelativeAt, int pOffsetSize ) {
237 199 return (0 <= pRelativeAt) && (pRelativeAt < pOffsetSize);
238 200 }
239 201
240 - protected void mouseDown()
241 - {
202 + protected void mouseDown() {
242 203 mMouseDown = true;
243 204 updateForm();
244 205 }
245 206
246 - protected void mouseUp()
247 - {
207 + protected void mouseUp() {
248 208 mMouseDown = false;
249 209 updateForm();
250 210 }
251 211
252 - protected void mouseEnter()
253 - {
212 + protected void mouseEnter() {
254 213 mMouseOver = true;
255 214 updateForm();
256 215 }
257 216
258 - protected void mouseLeave()
259 - {
217 + protected void mouseLeave() {
260 218 mMouseOver = false;
261 219 updateForm();
262 220 }
263 221
264 - public static class State
265 - {
222 + public static class State {
266 223 private String mText;
267 224
268 - public State( String pText )
269 - {
225 + public State( String pText ) {
270 226 mText = pText;
271 227 }
272 228
273 229 @Override
274 - public String toString()
275 - {
230 + public String toString() {
276 231 return mText;
277 232 }
278 233
279 - public String getURL( String pURLBaseGifExtentionAssumed )
280 - {
234 + public String getURL( String pURLBaseGifExtentionAssumed ) {
281 235 return pURLBaseGifExtentionAssumed + "-" + mText + ".gif";
282 236 }
283 237
284 - public String[] getURLsFor9cell( String pURLBaseGifExtentionAssumed )
285 - {
238 + public String[] getURLsFor9cell( String pURLBaseGifExtentionAssumed ) {
286 239 return generateURLs( pURLBaseGifExtentionAssumed + "/" + mText + "/", CompassPoint.values() );
287 240 }
288 241
289 - private String[] generateURLs( String pLeader, CompassPoint[] pCells )
290 - {
242 + private String[] generateURLs( String pLeader, CompassPoint[] pCells ) {
291 243 String[] rv = new String[pCells.length];
292 - for ( int i = 0; i < pCells.length; i++ )
293 - {
244 + for ( int i = 0; i < pCells.length; i++ ) {
294 245 rv[i] = pLeader + pCells[i] + ".gif";
295 246 }
296 247 return rv;
297 248 }
298 249 }
299 250
300 - protected static class CtrlElements
301 - {
251 + protected static class CtrlElements {
302 252 private Element mPrimary, mSecondStyle, mWidth, mHeight;
303 253
304 - public CtrlElements( Element pPrimary, Element pSecondStyle, Element pWidth, Element pHeight )
305 - {
254 + public CtrlElements( Element pPrimary, Element pSecondStyle, Element pWidth, Element pHeight ) {
306 255 mPrimary = pPrimary;
307 256 mSecondStyle = pSecondStyle;
308 257 mWidth = pWidth;
309 258 mHeight = pHeight;
310 259 }
311 260
312 - public CtrlElements( Element pPrimary )
313 - {
261 + public CtrlElements( Element pPrimary ) {
314 262 this( pPrimary, null, null, null );
315 263 }
316 264
317 - public Element getPrimary()
318 - {
265 + public Element getPrimary() {
319 266 return mPrimary;
320 267 }
321 268
322 - public Element getSecondStyle()
323 - {
269 + public Element getSecondStyle() {
324 270 return mSecondStyle;
325 271 }
326 272
327 - public Element getWidth()
328 - {
273 + public Element getWidth() {
329 274 return mWidth;
330 275 }
331 276
332 - public Element getHeight()
333 - {
277 + public Element getHeight() {
334 278 return mHeight;
335 279 }
336 280 }