|
@@ -1,525 +1,524 @@ |
1 |
|
- |
package com.test.uidesign.client; |
2 |
|
- |
|
3 |
|
- |
import org.litesoft.GWT.client.*; |
4 |
|
- |
import org.litesoft.GWT.client.widgets.*; |
5 |
|
- |
import org.litesoft.GWT.forms.client.components.*; |
6 |
|
- |
import org.litesoft.GWT.forms.client.components.impls.input.*; |
7 |
|
- |
import org.litesoft.commonfoundation.base.*; |
8 |
|
- |
import org.litesoft.commonfoundation.typeutils.*; |
9 |
|
- |
|
10 |
|
- |
import com.google.gwt.user.client.ui.*; |
11 |
|
- |
|
12 |
|
- |
public class PersonalInfoForm extends SizeableVerticalPanel { |
13 |
|
- |
// private static final ResourceKeyNameURL ERROR_RESOURCE = new ResourceKeyNameURL( "VW2", "Volkswagen2", "common/images/misc/tmp/vw.jpg" ); |
14 |
|
- |
|
15 |
|
- |
// private final List<Enableable> mFormComponents = new ArrayList<Enableable>(); |
16 |
|
- |
// private Button mEnable, mDisable, mDialog; |
17 |
|
- |
|
18 |
|
- |
public PersonalInfoForm() { |
19 |
|
- |
stretchable(); |
20 |
|
- |
|
21 |
|
- |
HorizontalPanel zHPanel; |
22 |
|
- |
|
23 |
|
- |
// add( TestTable.create() ); |
24 |
|
- |
// |
25 |
|
- |
// FormTextarea zFrmTA = new FormTextarea( "Comments are really long", null, "My New Tooltip", false, // |
26 |
|
- |
// null, false, // |
27 |
|
- |
// null, false ); |
28 |
|
- |
// zFrmTA.addFormComponentListener( new MyListener( "ERROR" ) ); |
29 |
|
- |
// add( zFrmTA ); |
30 |
|
- |
|
31 |
|
- |
add( zHPanel = new HorizontalPanel() ); |
32 |
|
- |
|
33 |
|
- |
// FormTimestampPicker zTimestampPicker = new FormTimestampPicker( "Timestamp", null, "My New Tooltip", TimeRes.ToMIN, "Cancel", "OK" ); |
34 |
|
- |
// zTimestampPicker.addFormComponentListener( new MyListener( new SimpleTimestamp( 1960, 1, 2, 3, 4 ) ) ); |
35 |
|
- |
// zHPanel.add( zTimestampPicker ); |
36 |
|
- |
// |
37 |
|
- |
// FormDatePicker zCalendar = new FormDatePicker( "Calendar", null, "Pick-a-Date", "Cancel", "Today", |
38 |
|
- |
// new DateFormatControl( DateFormatControl.DEFAULT_DATE_FORMAT ) ); |
39 |
|
- |
// zCalendar.addFormComponentListener( new MyListener( new SimpleDate( 1957, 1, 4 ) ) ); |
40 |
|
- |
// zHPanel.add( zCalendar ); |
41 |
|
- |
// |
42 |
|
- |
// FormTimePicker zTime = new FormTimePicker( "Time", null, "Pick-a-Time", TimeRes.ToMIN, "Cancel", "OK" ); |
43 |
|
- |
// zTime.addFormComponentListener( new MyListener( new SimpleTime( 1, 2 ) ) ); |
44 |
|
- |
// zHPanel.add( zTime ); |
45 |
|
- |
// |
46 |
|
- |
FormComboBox zOptions = new FormComboBox( "Colors *", null, "Pick-a-color", "Red" ); |
47 |
|
- |
zOptions.addFormComponentListener( new MyListener( "-Select-" ) ); |
48 |
|
- |
zOptions.addItems( "-Select-", // |
49 |
|
- |
"Red", // |
50 |
|
- |
"Green", // |
51 |
|
- |
"Blue" ); |
52 |
|
- |
zHPanel.add( zOptions ); |
53 |
|
- |
|
54 |
|
- |
// add( zHPanel = new HorizontalPanel() ); |
55 |
|
- |
// |
56 |
|
- |
// FormSuggestBox zSuggest = new FormSuggestBox( "Suggestions", null, "Type to filter content", null, null, createSuggestions() ); |
57 |
|
- |
// zSuggest.addFormComponentListener( new MyListener( "ERROR" ) ); |
58 |
|
- |
// |
59 |
|
- |
// String[] zRadioGroupOptions = new String[]{"Option One", "Option Two is a really long, long option", "Option Three",}; |
60 |
|
- |
// |
61 |
|
- |
// FormTextField zTFfc = new FormTextField( "First Name", null, "My New Tooltip", null, null ); |
62 |
|
- |
// zTFfc.addFormComponentListener( new MyListener( "ERROR" ) ); |
63 |
|
- |
// |
64 |
|
- |
// FormPasswordField zPFfc = new FormPasswordField( "Password", null, "A Tooltip 4 Password Field", null, null ); |
65 |
|
- |
// zPFfc.addFormComponentListener( new MyListener( "ERROR" ) ); |
66 |
|
- |
// |
67 |
|
- |
// final FormRightAlignTextField zTFnumeric = new FormRightAlignTextField( "Security Code", null, "My New Tooltip", null, null ); |
68 |
|
- |
// zTFnumeric.addFormComponentListener( new MyListener( "999" ) ); |
69 |
|
- |
// |
70 |
|
- |
// zHPanel.add( zSuggest ); |
71 |
|
- |
// zHPanel.add( new Spacer( 10 ) ); |
72 |
|
- |
// zHPanel.add( zTFfc ); |
73 |
|
- |
// zHPanel.add( new Spacer( 10 ) ); |
74 |
|
- |
// zHPanel.add( zPFfc ); |
75 |
|
- |
// zHPanel.add( new Spacer( 10 ) ); |
76 |
|
- |
// zHPanel.add( zTFnumeric ); |
77 |
|
- |
// |
78 |
|
- |
// FormRadioGroup zRGfc = new FormRadioGroup( "Group Uno", null, "Radio Tooltip", zRadioGroupOptions ); |
79 |
|
- |
// zRGfc.addFormComponentListener( new MyListener( "N/A" ) ); |
80 |
|
- |
// add( zRGfc ); |
81 |
|
- |
// |
82 |
|
- |
// FormCheckBox zCheck = new FormCheckBox( "Option1", null, "Options Tooltip", false ); |
83 |
|
- |
// zCheck.addFormComponentListener( new MyListener( null ) ); |
84 |
|
- |
// add( zCheck ); |
85 |
|
- |
// |
86 |
|
- |
// SizeableBorderedHorizontalSplitPairPanel zHSP2 = new SizeableBorderedHorizontalSplitPairPanel().stretchable(); |
87 |
|
- |
// zHSP2.add( createCurrentTasks() ); |
88 |
|
- |
// zHSP2.add( createTree() ); |
89 |
|
- |
// add( zHSP2 ); |
90 |
|
- |
// |
91 |
|
- |
//// SizeableHorizontalSplitPairPanel zHSP = new SizeableHorizontalSplitPairPanel().stretchable(); |
92 |
|
- |
//// add( zHSP ); |
93 |
|
- |
//// |
94 |
|
- |
//// zHSP.add( zFrmTA ); |
95 |
|
- |
//// zHSP.add( zHSP2 ); |
96 |
|
- |
// |
97 |
|
- |
// collectEnableables( mFormComponents, this ); |
98 |
|
- |
// |
99 |
|
- |
// SizeableHorizontalPanel hBtnPanel = new SizeableHorizontalPanel().stretchableHorizontally(); |
100 |
|
- |
// hBtnPanel.add( mEnable = Button.named( "Enable" ).green().text().add( new ClickHandler() |
101 |
|
- |
// { |
102 |
|
- |
// @Override |
103 |
|
- |
// public void onClick( ClickEvent event ) |
104 |
|
- |
// { |
105 |
|
- |
// enableDisable( true, mDisable, mEnable ); |
106 |
|
- |
// } |
107 |
|
- |
// } ).create() ); |
108 |
|
- |
// mEnable.disable(); |
109 |
|
- |
// |
110 |
|
- |
// hBtnPanel.add( mDisable = Button.named( "Disable" ).red().text().add( new ClickHandler() |
111 |
|
- |
// { |
112 |
|
- |
// @Override |
113 |
|
- |
// public void onClick( ClickEvent event ) |
114 |
|
- |
// { |
115 |
|
- |
// enableDisable( false, mEnable, mDisable ); |
116 |
|
- |
// } |
117 |
|
- |
// } ).create() ); |
118 |
|
- |
// hBtnPanel.add( new SizeableSpacer().stretchableHorizontally() ); |
119 |
|
- |
//// hBtnPanel.add( mDialog = ScreenBigButton.factory( "Dialog" ).add( new ClickHandler() |
120 |
|
- |
//// { |
121 |
|
- |
//// @Override |
122 |
|
- |
//// public void onClick( ClickEvent event ) |
123 |
|
- |
//// { |
124 |
|
- |
//// AlertManager.alert( "Test", "A Dialog", "The Body" ); |
125 |
|
- |
//// } |
126 |
|
- |
//// } ).create() ); |
127 |
|
- |
// add( hBtnPanel ); |
128 |
|
- |
} |
129 |
|
- |
|
130 |
|
- |
// private void enableDisable( boolean pEnable, Enableable pButtonToEnable, Enableable pButtonToDisable ) |
131 |
|
- |
// { |
132 |
|
- |
// pButtonToDisable.setEnabled( false ); |
133 |
|
- |
// mDialog.setEnabled( pEnable ); |
134 |
|
- |
// for ( Enableable zEnableable : mFormComponents ) |
135 |
|
- |
// { |
136 |
|
- |
// zEnableable.setEnabled( pEnable ); |
137 |
|
- |
// } |
138 |
|
- |
// pButtonToEnable.setEnabled( true ); |
139 |
|
- |
// } |
140 |
|
- |
|
141 |
|
- |
// private void collectEnableables( List<Enableable> pFormComponents, HasWidgets pWidget ) |
142 |
|
- |
// { |
143 |
|
- |
// for ( Widget zWidget : pWidget ) |
144 |
|
- |
// { |
145 |
|
- |
// if ( (zWidget instanceof Enableable) && !(zWidget instanceof Button) ) |
146 |
|
- |
// { |
147 |
|
- |
// pFormComponents.add( (Enableable) zWidget ); |
148 |
|
- |
// } |
149 |
|
- |
// if ( zWidget instanceof HasWidgets ) |
150 |
|
- |
// { |
151 |
|
- |
// collectEnableables( pFormComponents, (HasWidgets) zWidget ); |
152 |
|
- |
// } |
153 |
|
- |
// } |
154 |
|
- |
// } |
155 |
|
- |
|
156 |
|
- |
private static class MyListener implements IFormComponent.Listener { |
157 |
|
- |
protected IFormComponent mComponent; |
158 |
|
- |
private Object mErrorValue; |
159 |
|
- |
protected Object mOrigValue, mCurValue; |
160 |
|
- |
private String mWhat; |
161 |
|
- |
|
162 |
|
- |
public MyListener( Object pErrorValue ) { |
163 |
|
- |
mErrorValue = pErrorValue; |
164 |
|
- |
} |
165 |
|
- |
|
166 |
|
- |
@Override |
167 |
|
- |
public void add( IFormComponent pComponent ) { |
168 |
|
- |
mComponent = pComponent; |
169 |
|
- |
mOrigValue = mCurValue = mComponent.getCurrentValue(); |
170 |
|
- |
mWhat = ClassName.simple( mComponent ); |
171 |
|
- |
} |
172 |
|
- |
|
173 |
|
- |
@Override |
174 |
|
- |
public void remove( IFormComponent pComponent ) { |
175 |
|
- |
} |
176 |
|
- |
|
177 |
|
- |
@Override |
178 |
|
- |
public void changeOccurred() { |
179 |
|
- |
mCurValue = mComponent.getCurrentValue(); |
180 |
|
- |
// System.out.println( mWhat + " Change: '" + mCurValue + "'" ); |
181 |
|
- |
printToStatusbar( mWhat + " Change: '" + mCurValue + "'" ); |
182 |
|
- |
mComponent.setValueChanged( !Objects.areNonArraysEqual( mOrigValue, mCurValue ) ); |
183 |
|
- |
mComponent.setError( null ); |
184 |
|
- |
} |
185 |
|
- |
|
186 |
|
- |
@Override |
187 |
|
- |
public void blurOccurred() { |
188 |
|
- |
// System.out.println( mWhat + " Blur" ); |
189 |
|
- |
printToStatusbar( mWhat + " Blur" ); |
190 |
|
- |
mComponent.setFocused( false ); |
191 |
|
- |
mComponent.setError( Objects.areNonArraysEqual( mErrorValue, mCurValue ) ? "Error!" : null ); |
192 |
|
- |
} |
193 |
|
- |
|
194 |
|
- |
@Override |
195 |
|
- |
public void focusOccured() { |
196 |
|
- |
mComponent.setFocused( true ); |
197 |
|
- |
// System.out.println( mWhat + " Focus" ); |
198 |
|
- |
printToStatusbar( mWhat + " Focus" ); |
199 |
|
- |
} |
200 |
|
- |
|
201 |
|
- |
public void setCurrentValue( String pNewValue ) { |
202 |
|
- |
mComponent.setCurrentValue( pNewValue ); |
203 |
|
- |
mCurValue = mOrigValue = mComponent.getCurrentValue(); |
204 |
|
- |
mComponent.setValueChanged( false ); |
205 |
|
- |
mComponent.setError( null ); |
206 |
|
- |
} |
207 |
|
- |
|
208 |
|
- |
@Override |
209 |
|
- |
public void enterPressed( KeyboardKeyModifier pModifiers ) { |
210 |
|
- |
} |
211 |
|
- |
} |
212 |
|
- |
|
213 |
|
- |
// private static class MyDecimalFormatListener implements IFormComponent.Listener |
214 |
|
- |
// { |
215 |
|
- |
// private IFormComponent mComponent; |
216 |
|
- |
// private Object mErrorValue; |
217 |
|
- |
// private Object mOrigValue, mCurValue; |
218 |
|
- |
// private String mWhat; |
219 |
|
- |
// |
220 |
|
- |
// public MyDecimalFormatListener( Object pErrorValue ) |
221 |
|
- |
// { |
222 |
|
- |
// mErrorValue = pErrorValue; |
223 |
|
- |
// } |
224 |
|
- |
// |
225 |
|
- |
// @Override |
226 |
|
- |
// public void add( IFormComponent pComponent ) |
227 |
|
- |
// { |
228 |
|
- |
// mComponent = pComponent; |
229 |
|
- |
// mOrigValue = mComponent.getCurrentValue(); |
230 |
|
- |
// mWhat = UtilsCommon.simple( mComponent ); |
231 |
|
- |
// } |
232 |
|
- |
// |
233 |
|
- |
// @Override |
234 |
|
- |
// public void remove( IFormComponent pComponent ) |
235 |
|
- |
// { |
236 |
|
- |
// } |
237 |
|
- |
// |
238 |
|
- |
// @Override |
239 |
|
- |
// public void changeOccurred() |
240 |
|
- |
// { |
241 |
|
- |
// mCurValue = mComponent.getCurrentValue(); |
242 |
|
- |
//// System.out.println( mWhat + " Change: '" + mCurValue + "'" ); |
243 |
|
- |
// printToStatusbar( mWhat + " Change: '" + mCurValue + "'" ); |
244 |
|
- |
// mComponent.setValueChanged( !UtilsGwt.areNonArraysEqual( mOrigValue, mCurValue ) ); |
245 |
|
- |
// mComponent.setError( null ); |
246 |
|
- |
// } |
247 |
|
- |
// |
248 |
|
- |
// @Override |
249 |
|
- |
// public void blurOccurred() |
250 |
|
- |
// { |
251 |
|
- |
// mComponent.setFocused( false ); |
252 |
|
- |
// |
253 |
|
- |
// mCurValue = mComponent.getCurrentValue(); |
254 |
|
- |
// String zStrVal = mCurValue.toString(); |
255 |
|
- |
// NumberFormat zFormat = NumberFormat.getDecimalFormat(); |
256 |
|
- |
// |
257 |
|
- |
//// double zDouble = Double.parseDouble( zStrVal ); |
258 |
|
- |
//// String zFormattedValue = zFormat.format( zDouble ); |
259 |
|
- |
//// mComponent.setCurrentValue( zFormattedValue ); |
260 |
|
- |
//// mComponent.setError( UtilsGwt.areNonArraysEqual( mErrorValue, mCurValue ) ? "Error!" : null ); |
261 |
|
- |
// } |
262 |
|
- |
// |
263 |
|
- |
// @Override |
264 |
|
- |
// public void focusOccured() |
265 |
|
- |
// { |
266 |
|
- |
// mComponent.setFocused( true ); |
267 |
|
- |
//// System.out.println( mWhat + " Focus" ); |
268 |
|
- |
// printToStatusbar( mWhat + " Focus" ); |
269 |
|
- |
// } |
270 |
|
- |
// |
271 |
|
- |
// public void setCurrentValue( String pNewValue ) |
272 |
|
- |
// { |
273 |
|
- |
// mComponent.setCurrentValue( pNewValue ); |
274 |
|
- |
// mCurValue = mOrigValue = mComponent.getCurrentValue(); |
275 |
|
- |
// mComponent.setValueChanged( false ); |
276 |
|
- |
// mComponent.setError( null ); |
277 |
|
- |
// } |
278 |
|
- |
// |
279 |
|
- |
// @Override |
280 |
|
- |
// public void enterPressed( KeyboardKeyModifier pModifiers ) |
281 |
|
- |
// { |
282 |
|
- |
// } |
283 |
|
- |
// } |
284 |
|
- |
|
285 |
|
- |
// private static class MyCurrencyFormatListener implements IFormComponent.Listener |
286 |
|
- |
// { |
287 |
|
- |
// private IFormComponent mComponent; |
288 |
|
- |
// private Object mErrorValue; |
289 |
|
- |
// private Object mOrigValue, mCurValue; |
290 |
|
- |
// private String mWhat; |
291 |
|
- |
// |
292 |
|
- |
// public MyCurrencyFormatListener( Object pErrorValue ) |
293 |
|
- |
// { |
294 |
|
- |
// mErrorValue = pErrorValue; |
295 |
|
- |
// } |
296 |
|
- |
// |
297 |
|
- |
// @Override |
298 |
|
- |
// public void add( IFormComponent pComponent ) |
299 |
|
- |
// { |
300 |
|
- |
// mComponent = pComponent; |
301 |
|
- |
// mOrigValue = mComponent.getCurrentValue(); |
302 |
|
- |
// mWhat = UtilsCommon.simple( mComponent ); |
303 |
|
- |
// } |
304 |
|
- |
// |
305 |
|
- |
// @Override |
306 |
|
- |
// public void remove( IFormComponent pComponent ) |
307 |
|
- |
// { |
308 |
|
- |
// } |
309 |
|
- |
// |
310 |
|
- |
// @Override |
311 |
|
- |
// public void changeOccurred() |
312 |
|
- |
// { |
313 |
|
- |
// mCurValue = mComponent.getCurrentValue(); |
314 |
|
- |
//// System.out.println( mWhat + " Change: '" + mCurValue + "'" ); |
315 |
|
- |
// printToStatusbar( mWhat + " Change: '" + mCurValue + "'" ); |
316 |
|
- |
// mComponent.setValueChanged( !UtilsGwt.areNonArraysEqual( mOrigValue, mCurValue ) ); |
317 |
|
- |
// mComponent.setError( null ); |
318 |
|
- |
// } |
319 |
|
- |
// |
320 |
|
- |
// @Override |
321 |
|
- |
// public void blurOccurred() |
322 |
|
- |
// { |
323 |
|
- |
// mComponent.setFocused( false ); |
324 |
|
- |
// |
325 |
|
- |
// mCurValue = mComponent.getCurrentValue(); |
326 |
|
- |
// String zStrVal = mCurValue.toString(); |
327 |
|
- |
// NumberFormat zFormat = NumberFormat.getCurrencyFormat(); |
328 |
|
- |
// |
329 |
|
- |
// Double zDouble = Double.valueOf( zStrVal ); |
330 |
|
- |
// String zFormattedValue = zFormat.format( zDouble.doubleValue() ); |
331 |
|
- |
// mComponent.setCurrentValue( zFormattedValue ); |
332 |
|
- |
//// mComponent.setError( UtilsGwt.areNonArraysEqual( mErrorValue, mCurValue ) ? "Error!" : null ); |
333 |
|
- |
// } |
334 |
|
- |
// |
335 |
|
- |
// @Override |
336 |
|
- |
// public void focusOccured() |
337 |
|
- |
// { |
338 |
|
- |
// mComponent.setFocused( true ); |
339 |
|
- |
//// System.out.println( mWhat + " Focus" ); |
340 |
|
- |
// printToStatusbar( mWhat + " Focus" ); |
341 |
|
- |
// } |
342 |
|
- |
// |
343 |
|
- |
// public void setCurrentValue( String pNewValue ) |
344 |
|
- |
// { |
345 |
|
- |
// mComponent.setCurrentValue( pNewValue ); |
346 |
|
- |
// mCurValue = mOrigValue = mComponent.getCurrentValue(); |
347 |
|
- |
// mComponent.setValueChanged( false ); |
348 |
|
- |
// mComponent.setError( null ); |
349 |
|
- |
// } |
350 |
|
- |
// |
351 |
|
- |
// @Override |
352 |
|
- |
// public void enterPressed( KeyboardKeyModifier pModifiers ) |
353 |
|
- |
// { |
354 |
|
- |
// } |
355 |
|
- |
// } |
356 |
|
- |
|
357 |
|
- |
// private static class MyResourceProvider implements ResourceKeyNameURLprovider |
358 |
|
- |
// { |
359 |
|
- |
// @Override |
360 |
|
- |
// public ResourceKeyNameURL[] getLocalResourceKeyNameURLs() |
361 |
|
- |
// { |
362 |
|
- |
// return new ResourceKeyNameURL[]{new ResourceKeyNameURL( "AU", "Audi", "common/images/misc/tmp/audi.jpg" ),// |
363 |
|
- |
// new ResourceKeyNameURL( "BM", "BMW", "common/images/misc/tmp/bmw.jpg" ),// |
364 |
|
- |
// new ResourceKeyNameURL( "CH", "Chevrolet", "common/images/misc/tmp/chevy.jpg" ),// |
365 |
|
- |
// new ResourceKeyNameURL( "FD", "Ford", "common/images/misc/tmp/ford.jpg" ),// |
366 |
|
- |
// new ResourceKeyNameURL( "JA", "Jaguar", "common/images/misc/tmp/jag.jpg" ),// |
367 |
|
- |
// new ResourceKeyNameURL( "MZ", "Mazda", "common/images/misc/tmp/mazda.jpg" ),// |
368 |
|
- |
// new ResourceKeyNameURL( "MB", "Mercedes-Benz", "common/images/misc/tmp/mbenz.jpg" ),// |
369 |
|
- |
// new ResourceKeyNameURL( "NS", "Nissan", "common/images/misc/tmp/nissan.jpg" ),// |
370 |
|
- |
// new ResourceKeyNameURL( "TT", "Tata", "common/images/misc/tmp/tata.jpg" ),// |
371 |
|
- |
// new ResourceKeyNameURL( "VW", "Volkswagen", "common/images/misc/tmp/vw.jpg" ),// |
372 |
|
- |
// ERROR_RESOURCE,// |
373 |
|
- |
// }; |
374 |
|
- |
// } |
375 |
|
- |
// |
376 |
|
- |
// @Override |
377 |
|
- |
// public void requestResourceKeyNameURLs( ResourceKeyNameURLsAvailableCallback pCallback ) |
378 |
|
- |
// throws UnsupportedOperationException |
379 |
|
- |
// { |
380 |
|
- |
// //To change body of implemented methods use File | Settings | File Templates. |
381 |
|
- |
// } |
382 |
|
- |
// } |
383 |
|
- |
|
384 |
|
- |
private static void printToStatusbar( String pMessage ) { |
385 |
|
- |
System.out.println( pMessage ); |
386 |
|
- |
String current = StatusBar.get(); |
387 |
|
- |
StatusBar.set( pMessage + " | " + current ); |
388 |
|
- |
} |
389 |
|
- |
|
390 |
|
- |
// private TreeNode mTI2, mTI; |
391 |
|
- |
// private int mAddIndex = 0; |
392 |
|
- |
// |
393 |
|
- |
// private void addTo( SizeableTree zTree ) |
394 |
|
- |
// { |
395 |
|
- |
// switch ( (mAddIndex++ & 7) ) |
396 |
|
- |
// { |
397 |
|
- |
// case 0: |
398 |
|
- |
// mTI = zTree.addChild( augment( "One" ) ); |
399 |
|
- |
// break; |
400 |
|
- |
// case 1: |
401 |
|
- |
// mTI2 = mTI.addChild( augment( "A" ) ); |
402 |
|
- |
// mTI.addChild( augment( "B" ) ); |
403 |
|
- |
// mTI.addChild( augment( "C" ) ); |
404 |
|
- |
// break; |
405 |
|
- |
// case 2: |
406 |
|
- |
// mTI2.addChild( augment( "I" ) ); |
407 |
|
- |
// mTI2.addChild( augment( "II" ) ); |
408 |
|
- |
// mTI2.addChild( augment( "III" ) ); |
409 |
|
- |
// mTI2.addChild( augment( "IV" ) ); |
410 |
|
- |
// mTI2.addChild( augment( "V" ) ); |
411 |
|
- |
// break; |
412 |
|
- |
// case 3: |
413 |
|
- |
// mTI = zTree.addChild( augment( "Two" ) ); |
414 |
|
- |
// break; |
415 |
|
- |
// case 4: |
416 |
|
- |
// mTI.addChild( augment( "A" ) ); |
417 |
|
- |
// mTI2 = mTI.addChild( augment( "B" ) ); |
418 |
|
- |
// mTI.addChild( augment( "C" ) ); |
419 |
|
- |
// break; |
420 |
|
- |
// case 5: |
421 |
|
- |
// mTI2.addChild( augment( "I" ) ); |
422 |
|
- |
// mTI2.addChild( augment( "II" ) ); |
423 |
|
- |
// mTI2.addChild( augment( "III" ) ); |
424 |
|
- |
// mTI2.addChild( augment( "IV" ) ); |
425 |
|
- |
// mTI2.addChild( augment( "V" ) ); |
426 |
|
- |
// break; |
427 |
|
- |
// case 6: |
428 |
|
- |
// mTI = zTree.addChild( augment( "Three" ) ); |
429 |
|
- |
// break; |
430 |
|
- |
// case 7: |
431 |
|
- |
// mTI.addChild( augment( "A" ) ); |
432 |
|
- |
// mTI.addChild( augment( "B" ) ); |
433 |
|
- |
// mTI2 = mTI.addChild( augment( "C" ) ); |
434 |
|
- |
// mTI2.addChild( augment( "I" ) ); |
435 |
|
- |
// mTI2.addChild( augment( "II" ) ); |
436 |
|
- |
// mTI2.addChild( augment( "III" ) ); |
437 |
|
- |
// mTI2.addChild( augment( "IV" ) ); |
438 |
|
- |
// mTI2.addChild( augment( "V" ) ); |
439 |
|
- |
// break; |
440 |
|
- |
// } |
441 |
|
- |
// } |
442 |
|
- |
// |
443 |
|
- |
// private String augment( String pBaseName ) |
444 |
|
- |
// { |
445 |
|
- |
// return pBaseName + "-" + mAddIndex; |
446 |
|
- |
// } |
447 |
|
- |
// |
448 |
|
- |
// private Widget createTree() |
449 |
|
- |
// { |
450 |
|
- |
// Button zOpenAll = FolderOpenButton.factory().create(); |
451 |
|
- |
// Button zCloseAll = FolderClosedButton.factory().create(); |
452 |
|
- |
// final SizeableTree zTree = SizeableTree.withFolders(); |
453 |
|
- |
// zTree.connectOpenCloseButtons( zOpenAll, zCloseAll ); |
454 |
|
- |
// zTree.setAnimationEnabled( true ); |
455 |
|
- |
// zTree.addTreeSelectionListener( new TreeSelectionListener() |
456 |
|
- |
// { |
457 |
|
- |
// @Override |
458 |
|
- |
// public void selected( Object pSelected ) |
459 |
|
- |
// { |
460 |
|
- |
// System.out.println( "Tree Selected: " + pSelected ); |
461 |
|
- |
// } |
462 |
|
- |
// } ); |
463 |
|
- |
// zTree.addTreeOpenCloseListener( new TreeOpenCloseListener() |
464 |
|
- |
// { |
465 |
|
- |
// @Override |
466 |
|
- |
// public void openStateChanged( Boolean pOpened ) |
467 |
|
- |
// { |
468 |
|
- |
// System.out.println( "Tree Opened: " + pOpened + " - " + zTree.areAnyOpen() ); |
469 |
|
- |
// } |
470 |
|
- |
// } ); |
471 |
|
- |
// |
472 |
|
- |
// SizeableHorizontalPanel hPanel = new SizeableHorizontalPanel().stretchableHorizontally(); |
473 |
|
- |
// hPanel.add( zOpenAll ); |
474 |
|
- |
// hPanel.add( zCloseAll ); |
475 |
|
- |
// hPanel.add( new Spacer( 10 ) ); |
476 |
|
- |
// hPanel.add( new Label( "Some Text" ) ); |
477 |
|
- |
// hPanel.add( Button.named( "Add" ).blue().text().add( new ClickHandler() |
478 |
|
- |
// { |
479 |
|
- |
// @Override |
480 |
|
- |
// public void onClick( ClickEvent event ) |
481 |
|
- |
// { |
482 |
|
- |
// addTo( zTree ); |
483 |
|
- |
// } |
484 |
|
- |
// } ).create() ); |
485 |
|
- |
// hPanel.add( Button.named( "Remove" ).blue().text().add( new ClickHandler() |
486 |
|
- |
// { |
487 |
|
- |
// @Override |
488 |
|
- |
// public void onClick( ClickEvent event ) |
489 |
|
- |
// { |
490 |
|
- |
// if ( !zTree.isEmpty() ) |
491 |
|
- |
// { |
492 |
|
- |
// Object zUserObject = zTree.getSelected(); |
493 |
|
- |
// if ( zUserObject == null ) |
494 |
|
- |
// { |
495 |
|
- |
// zUserObject = zTree.iterator().next(); |
496 |
|
- |
// } |
497 |
|
- |
// zTree.removeDescendant( zUserObject ); |
498 |
|
- |
// } |
499 |
|
- |
// } |
500 |
|
- |
// } ).create() ); |
501 |
|
- |
// hPanel.add( Button.named( "Remove1st" ).blue().text().add( new ClickHandler() |
502 |
|
- |
// { |
503 |
|
- |
// @Override |
504 |
|
- |
// public void onClick( ClickEvent event ) |
505 |
|
- |
// { |
506 |
|
- |
// if ( !zTree.isEmpty() ) |
507 |
|
- |
// { |
508 |
|
- |
// Object zUserObject = zTree.iterator().next(); |
509 |
|
- |
// zTree.removeChild( zUserObject ); |
510 |
|
- |
// } |
511 |
|
- |
// } |
512 |
|
- |
// } ).create() ); |
513 |
|
- |
// |
514 |
|
- |
// SizeableVerticalPanel vPanel = new SizeableVerticalPanel().stretchable(); |
515 |
|
- |
// vPanel.add( hPanel ); |
516 |
|
- |
// vPanel.add( zTree ); |
517 |
|
- |
// |
518 |
|
- |
// return vPanel; |
519 |
|
- |
// } |
520 |
|
- |
|
521 |
|
- |
// private Widget createCurrentTasks() |
522 |
|
- |
// { |
523 |
|
- |
// return new CurrentTasks(); |
524 |
|
- |
// } |
525 |
|
- |
} |
|
1 |
+ |
package com.test.uidesign.client; |
|
2 |
+ |
|
|
3 |
+ |
import org.litesoft.GWT.client.*; |
|
4 |
+ |
import org.litesoft.GWT.client.widgets.*; |
|
5 |
+ |
import org.litesoft.GWT.forms.client.components.*; |
|
6 |
+ |
import org.litesoft.GWT.forms.client.components.impls.input.*; |
|
7 |
+ |
import org.litesoft.commonfoundation.base.*; |
|
8 |
+ |
|
|
9 |
+ |
import com.google.gwt.user.client.ui.*; |
|
10 |
+ |
|
|
11 |
+ |
public class PersonalInfoForm extends SizeableVerticalPanel { |
|
12 |
+ |
// private static final ResourceKeyNameURL ERROR_RESOURCE = new ResourceKeyNameURL( "VW2", "Volkswagen2", "common/images/misc/tmp/vw.jpg" ); |
|
13 |
+ |
|
|
14 |
+ |
// private final List<Enableable> mFormComponents = new ArrayList<Enableable>(); |
|
15 |
+ |
// private Button mEnable, mDisable, mDialog; |
|
16 |
+ |
|
|
17 |
+ |
public PersonalInfoForm() { |
|
18 |
+ |
stretchable(); |
|
19 |
+ |
|
|
20 |
+ |
HorizontalPanel zHPanel; |
|
21 |
+ |
|
|
22 |
+ |
// add( TestTable.create() ); |
|
23 |
+ |
// |
|
24 |
+ |
// FormTextarea zFrmTA = new FormTextarea( "Comments are really long", null, "My New Tooltip", false, // |
|
25 |
+ |
// null, false, // |
|
26 |
+ |
// null, false ); |
|
27 |
+ |
// zFrmTA.addFormComponentListener( new MyListener( "ERROR" ) ); |
|
28 |
+ |
// add( zFrmTA ); |
|
29 |
+ |
|
|
30 |
+ |
add( zHPanel = new HorizontalPanel() ); |
|
31 |
+ |
|
|
32 |
+ |
// FormTimestampPicker zTimestampPicker = new FormTimestampPicker( "Timestamp", null, "My New Tooltip", TimeRes.ToMIN, "Cancel", "OK" ); |
|
33 |
+ |
// zTimestampPicker.addFormComponentListener( new MyListener( new SimpleTimestamp( 1960, 1, 2, 3, 4 ) ) ); |
|
34 |
+ |
// zHPanel.add( zTimestampPicker ); |
|
35 |
+ |
// |
|
36 |
+ |
// FormDatePicker zCalendar = new FormDatePicker( "Calendar", null, "Pick-a-Date", "Cancel", "Today", |
|
37 |
+ |
// new DateFormatControl( DateFormatControl.DEFAULT_DATE_FORMAT ) ); |
|
38 |
+ |
// zCalendar.addFormComponentListener( new MyListener( new SimpleDate( 1957, 1, 4 ) ) ); |
|
39 |
+ |
// zHPanel.add( zCalendar ); |
|
40 |
+ |
// |
|
41 |
+ |
// FormTimePicker zTime = new FormTimePicker( "Time", null, "Pick-a-Time", TimeRes.ToMIN, "Cancel", "OK" ); |
|
42 |
+ |
// zTime.addFormComponentListener( new MyListener( new SimpleTime( 1, 2 ) ) ); |
|
43 |
+ |
// zHPanel.add( zTime ); |
|
44 |
+ |
// |
|
45 |
+ |
FormComboBox zOptions = new FormComboBox( "Colors *", null, "Pick-a-color", "Red" ); |
|
46 |
+ |
zOptions.addFormComponentListener( new MyListener( "-Select-" ) ); |
|
47 |
+ |
zOptions.addItems( "-Select-", // |
|
48 |
+ |
"Red", // |
|
49 |
+ |
"Green", // |
|
50 |
+ |
"Blue" ); |
|
51 |
+ |
zHPanel.add( zOptions ); |
|
52 |
+ |
|
|
53 |
+ |
// add( zHPanel = new HorizontalPanel() ); |
|
54 |
+ |
// |
|
55 |
+ |
// FormSuggestBox zSuggest = new FormSuggestBox( "Suggestions", null, "Type to filter content", null, null, createSuggestions() ); |
|
56 |
+ |
// zSuggest.addFormComponentListener( new MyListener( "ERROR" ) ); |
|
57 |
+ |
// |
|
58 |
+ |
// String[] zRadioGroupOptions = new String[]{"Option One", "Option Two is a really long, long option", "Option Three",}; |
|
59 |
+ |
// |
|
60 |
+ |
// FormTextField zTFfc = new FormTextField( "First Name", null, "My New Tooltip", null, null ); |
|
61 |
+ |
// zTFfc.addFormComponentListener( new MyListener( "ERROR" ) ); |
|
62 |
+ |
// |
|
63 |
+ |
// FormPasswordField zPFfc = new FormPasswordField( "Password", null, "A Tooltip 4 Password Field", null, null ); |
|
64 |
+ |
// zPFfc.addFormComponentListener( new MyListener( "ERROR" ) ); |
|
65 |
+ |
// |
|
66 |
+ |
// final FormRightAlignTextField zTFnumeric = new FormRightAlignTextField( "Security Code", null, "My New Tooltip", null, null ); |
|
67 |
+ |
// zTFnumeric.addFormComponentListener( new MyListener( "999" ) ); |
|
68 |
+ |
// |
|
69 |
+ |
// zHPanel.add( zSuggest ); |
|
70 |
+ |
// zHPanel.add( new Spacer( 10 ) ); |
|
71 |
+ |
// zHPanel.add( zTFfc ); |
|
72 |
+ |
// zHPanel.add( new Spacer( 10 ) ); |
|
73 |
+ |
// zHPanel.add( zPFfc ); |
|
74 |
+ |
// zHPanel.add( new Spacer( 10 ) ); |
|
75 |
+ |
// zHPanel.add( zTFnumeric ); |
|
76 |
+ |
// |
|
77 |
+ |
// FormRadioGroup zRGfc = new FormRadioGroup( "Group Uno", null, "Radio Tooltip", zRadioGroupOptions ); |
|
78 |
+ |
// zRGfc.addFormComponentListener( new MyListener( "N/A" ) ); |
|
79 |
+ |
// add( zRGfc ); |
|
80 |
+ |
// |
|
81 |
+ |
// FormCheckBox zCheck = new FormCheckBox( "Option1", null, "Options Tooltip", false ); |
|
82 |
+ |
// zCheck.addFormComponentListener( new MyListener( null ) ); |
|
83 |
+ |
// add( zCheck ); |
|
84 |
+ |
// |
|
85 |
+ |
// SizeableBorderedHorizontalSplitPairPanel zHSP2 = new SizeableBorderedHorizontalSplitPairPanel().stretchable(); |
|
86 |
+ |
// zHSP2.add( createCurrentTasks() ); |
|
87 |
+ |
// zHSP2.add( createTree() ); |
|
88 |
+ |
// add( zHSP2 ); |
|
89 |
+ |
// |
|
90 |
+ |
//// SizeableHorizontalSplitPairPanel zHSP = new SizeableHorizontalSplitPairPanel().stretchable(); |
|
91 |
+ |
//// add( zHSP ); |
|
92 |
+ |
//// |
|
93 |
+ |
//// zHSP.add( zFrmTA ); |
|
94 |
+ |
//// zHSP.add( zHSP2 ); |
|
95 |
+ |
// |
|
96 |
+ |
// collectEnableables( mFormComponents, this ); |
|
97 |
+ |
// |
|
98 |
+ |
// SizeableHorizontalPanel hBtnPanel = new SizeableHorizontalPanel().stretchableHorizontally(); |
|
99 |
+ |
// hBtnPanel.add( mEnable = Button.named( "Enable" ).green().text().add( new ClickHandler() |
|
100 |
+ |
// { |
|
101 |
+ |
// @Override |
|
102 |
+ |
// public void onClick( ClickEvent event ) |
|
103 |
+ |
// { |
|
104 |
+ |
// enableDisable( true, mDisable, mEnable ); |
|
105 |
+ |
// } |
|
106 |
+ |
// } ).create() ); |
|
107 |
+ |
// mEnable.disable(); |
|
108 |
+ |
// |
|
109 |
+ |
// hBtnPanel.add( mDisable = Button.named( "Disable" ).red().text().add( new ClickHandler() |
|
110 |
+ |
// { |
|
111 |
+ |
// @Override |
|
112 |
+ |
// public void onClick( ClickEvent event ) |
|
113 |
+ |
// { |
|
114 |
+ |
// enableDisable( false, mEnable, mDisable ); |
|
115 |
+ |
// } |
|
116 |
+ |
// } ).create() ); |
|
117 |
+ |
// hBtnPanel.add( new SizeableSpacer().stretchableHorizontally() ); |
|
118 |
+ |
//// hBtnPanel.add( mDialog = ScreenBigButton.factory( "Dialog" ).add( new ClickHandler() |
|
119 |
+ |
//// { |
|
120 |
+ |
//// @Override |
|
121 |
+ |
//// public void onClick( ClickEvent event ) |
|
122 |
+ |
//// { |
|
123 |
+ |
//// AlertManager.alert( "Test", "A Dialog", "The Body" ); |
|
124 |
+ |
//// } |
|
125 |
+ |
//// } ).create() ); |
|
126 |
+ |
// add( hBtnPanel ); |
|
127 |
+ |
} |
|
128 |
+ |
|
|
129 |
+ |
// private void enableDisable( boolean pEnable, Enableable pButtonToEnable, Enableable pButtonToDisable ) |
|
130 |
+ |
// { |
|
131 |
+ |
// pButtonToDisable.setEnabled( false ); |
|
132 |
+ |
// mDialog.setEnabled( pEnable ); |
|
133 |
+ |
// for ( Enableable zEnableable : mFormComponents ) |
|
134 |
+ |
// { |
|
135 |
+ |
// zEnableable.setEnabled( pEnable ); |
|
136 |
+ |
// } |
|
137 |
+ |
// pButtonToEnable.setEnabled( true ); |
|
138 |
+ |
// } |
|
139 |
+ |
|
|
140 |
+ |
// private void collectEnableables( List<Enableable> pFormComponents, HasWidgets pWidget ) |
|
141 |
+ |
// { |
|
142 |
+ |
// for ( Widget zWidget : pWidget ) |
|
143 |
+ |
// { |
|
144 |
+ |
// if ( (zWidget instanceof Enableable) && !(zWidget instanceof Button) ) |
|
145 |
+ |
// { |
|
146 |
+ |
// pFormComponents.add( (Enableable) zWidget ); |
|
147 |
+ |
// } |
|
148 |
+ |
// if ( zWidget instanceof HasWidgets ) |
|
149 |
+ |
// { |
|
150 |
+ |
// collectEnableables( pFormComponents, (HasWidgets) zWidget ); |
|
151 |
+ |
// } |
|
152 |
+ |
// } |
|
153 |
+ |
// } |
|
154 |
+ |
|
|
155 |
+ |
private static class MyListener implements IFormComponent.Listener { |
|
156 |
+ |
protected IFormComponent mComponent; |
|
157 |
+ |
private Object mErrorValue; |
|
158 |
+ |
protected Object mOrigValue, mCurValue; |
|
159 |
+ |
private String mWhat; |
|
160 |
+ |
|
|
161 |
+ |
public MyListener( Object pErrorValue ) { |
|
162 |
+ |
mErrorValue = pErrorValue; |
|
163 |
+ |
} |
|
164 |
+ |
|
|
165 |
+ |
@Override |
|
166 |
+ |
public void add( IFormComponent pComponent ) { |
|
167 |
+ |
mComponent = pComponent; |
|
168 |
+ |
mOrigValue = mCurValue = mComponent.getCurrentValue(); |
|
169 |
+ |
mWhat = ClassName.simple( mComponent ); |
|
170 |
+ |
} |
|
171 |
+ |
|
|
172 |
+ |
@Override |
|
173 |
+ |
public void remove( IFormComponent pComponent ) { |
|
174 |
+ |
} |
|
175 |
+ |
|
|
176 |
+ |
@Override |
|
177 |
+ |
public void changeOccurred() { |
|
178 |
+ |
mCurValue = mComponent.getCurrentValue(); |
|
179 |
+ |
// System.out.println( mWhat + " Change: '" + mCurValue + "'" ); |
|
180 |
+ |
printToStatusbar( mWhat + " Change: '" + mCurValue + "'" ); |
|
181 |
+ |
mComponent.setValueChanged( !Currently.areEqual( mOrigValue, mCurValue ) ); |
|
182 |
+ |
mComponent.setError( null ); |
|
183 |
+ |
} |
|
184 |
+ |
|
|
185 |
+ |
@Override |
|
186 |
+ |
public void blurOccurred() { |
|
187 |
+ |
// System.out.println( mWhat + " Blur" ); |
|
188 |
+ |
printToStatusbar( mWhat + " Blur" ); |
|
189 |
+ |
mComponent.setFocused( false ); |
|
190 |
+ |
mComponent.setError( Currently.areEqual( mErrorValue, mCurValue ) ? "Error!" : null ); |
|
191 |
+ |
} |
|
192 |
+ |
|
|
193 |
+ |
@Override |
|
194 |
+ |
public void focusOccured() { |
|
195 |
+ |
mComponent.setFocused( true ); |
|
196 |
+ |
// System.out.println( mWhat + " Focus" ); |
|
197 |
+ |
printToStatusbar( mWhat + " Focus" ); |
|
198 |
+ |
} |
|
199 |
+ |
|
|
200 |
+ |
public void setCurrentValue( String pNewValue ) { |
|
201 |
+ |
mComponent.setCurrentValue( pNewValue ); |
|
202 |
+ |
mCurValue = mOrigValue = mComponent.getCurrentValue(); |
|
203 |
+ |
mComponent.setValueChanged( false ); |
|
204 |
+ |
mComponent.setError( null ); |
|
205 |
+ |
} |
|
206 |
+ |
|
|
207 |
+ |
@Override |
|
208 |
+ |
public void enterPressed( KeyboardKeyModifier pModifiers ) { |
|
209 |
+ |
} |
|
210 |
+ |
} |
|
211 |
+ |
|
|
212 |
+ |
// private static class MyDecimalFormatListener implements IFormComponent.Listener |
|
213 |
+ |
// { |
|
214 |
+ |
// private IFormComponent mComponent; |
|
215 |
+ |
// private Object mErrorValue; |
|
216 |
+ |
// private Object mOrigValue, mCurValue; |
|
217 |
+ |
// private String mWhat; |
|
218 |
+ |
// |
|
219 |
+ |
// public MyDecimalFormatListener( Object pErrorValue ) |
|
220 |
+ |
// { |
|
221 |
+ |
// mErrorValue = pErrorValue; |
|
222 |
+ |
// } |
|
223 |
+ |
// |
|
224 |
+ |
// @Override |
|
225 |
+ |
// public void add( IFormComponent pComponent ) |
|
226 |
+ |
// { |
|
227 |
+ |
// mComponent = pComponent; |
|
228 |
+ |
// mOrigValue = mComponent.getCurrentValue(); |
|
229 |
+ |
// mWhat = UtilsCommon.simple( mComponent ); |
|
230 |
+ |
// } |
|
231 |
+ |
// |
|
232 |
+ |
// @Override |
|
233 |
+ |
// public void remove( IFormComponent pComponent ) |
|
234 |
+ |
// { |
|
235 |
+ |
// } |
|
236 |
+ |
// |
|
237 |
+ |
// @Override |
|
238 |
+ |
// public void changeOccurred() |
|
239 |
+ |
// { |
|
240 |
+ |
// mCurValue = mComponent.getCurrentValue(); |
|
241 |
+ |
//// System.out.println( mWhat + " Change: '" + mCurValue + "'" ); |
|
242 |
+ |
// printToStatusbar( mWhat + " Change: '" + mCurValue + "'" ); |
|
243 |
+ |
// mComponent.setValueChanged( !UtilsGwt.areEqual( mOrigValue, mCurValue ) ); |
|
244 |
+ |
// mComponent.setError( null ); |
|
245 |
+ |
// } |
|
246 |
+ |
// |
|
247 |
+ |
// @Override |
|
248 |
+ |
// public void blurOccurred() |
|
249 |
+ |
// { |
|
250 |
+ |
// mComponent.setFocused( false ); |
|
251 |
+ |
// |
|
252 |
+ |
// mCurValue = mComponent.getCurrentValue(); |
|
253 |
+ |
// String zStrVal = mCurValue.toString(); |
|
254 |
+ |
// NumberFormat zFormat = NumberFormat.getDecimalFormat(); |
|
255 |
+ |
// |
|
256 |
+ |
//// double zDouble = Double.parseDouble( zStrVal ); |
|
257 |
+ |
//// String zFormattedValue = zFormat.format( zDouble ); |
|
258 |
+ |
//// mComponent.setCurrentValue( zFormattedValue ); |
|
259 |
+ |
//// mComponent.setError( UtilsGwt.areEqual( mErrorValue, mCurValue ) ? "Error!" : null ); |
|
260 |
+ |
// } |
|
261 |
+ |
// |
|
262 |
+ |
// @Override |
|
263 |
+ |
// public void focusOccured() |
|
264 |
+ |
// { |
|
265 |
+ |
// mComponent.setFocused( true ); |
|
266 |
+ |
//// System.out.println( mWhat + " Focus" ); |
|
267 |
+ |
// printToStatusbar( mWhat + " Focus" ); |
|
268 |
+ |
// } |
|
269 |
+ |
// |
|
270 |
+ |
// public void setCurrentValue( String pNewValue ) |
|
271 |
+ |
// { |
|
272 |
+ |
// mComponent.setCurrentValue( pNewValue ); |
|
273 |
+ |
// mCurValue = mOrigValue = mComponent.getCurrentValue(); |
|
274 |
+ |
// mComponent.setValueChanged( false ); |
|
275 |
+ |
// mComponent.setError( null ); |
|
276 |
+ |
// } |
|
277 |
+ |
// |
|
278 |
+ |
// @Override |
|
279 |
+ |
// public void enterPressed( KeyboardKeyModifier pModifiers ) |
|
280 |
+ |
// { |
|
281 |
+ |
// } |
|
282 |
+ |
// } |
|
283 |
+ |
|
|
284 |
+ |
// private static class MyCurrencyFormatListener implements IFormComponent.Listener |
|
285 |
+ |
// { |
|
286 |
+ |
// private IFormComponent mComponent; |
|
287 |
+ |
// private Object mErrorValue; |
|
288 |
+ |
// private Object mOrigValue, mCurValue; |
|
289 |
+ |
// private String mWhat; |
|
290 |
+ |
// |
|
291 |
+ |
// public MyCurrencyFormatListener( Object pErrorValue ) |
|
292 |
+ |
// { |
|
293 |
+ |
// mErrorValue = pErrorValue; |
|
294 |
+ |
// } |
|
295 |
+ |
// |
|
296 |
+ |
// @Override |
|
297 |
+ |
// public void add( IFormComponent pComponent ) |
|
298 |
+ |
// { |
|
299 |
+ |
// mComponent = pComponent; |
|
300 |
+ |
// mOrigValue = mComponent.getCurrentValue(); |
|
301 |
+ |
// mWhat = UtilsCommon.simple( mComponent ); |
|
302 |
+ |
// } |
|
303 |
+ |
// |
|
304 |
+ |
// @Override |
|
305 |
+ |
// public void remove( IFormComponent pComponent ) |
|
306 |
+ |
// { |
|
307 |
+ |
// } |
|
308 |
+ |
// |
|
309 |
+ |
// @Override |
|
310 |
+ |
// public void changeOccurred() |
|
311 |
+ |
// { |
|
312 |
+ |
// mCurValue = mComponent.getCurrentValue(); |
|
313 |
+ |
//// System.out.println( mWhat + " Change: '" + mCurValue + "'" ); |
|
314 |
+ |
// printToStatusbar( mWhat + " Change: '" + mCurValue + "'" ); |
|
315 |
+ |
// mComponent.setValueChanged( !UtilsGwt.areEqual( mOrigValue, mCurValue ) ); |
|
316 |
+ |
// mComponent.setError( null ); |
|
317 |
+ |
// } |
|
318 |
+ |
// |
|
319 |
+ |
// @Override |
|
320 |
+ |
// public void blurOccurred() |
|
321 |
+ |
// { |
|
322 |
+ |
// mComponent.setFocused( false ); |
|
323 |
+ |
// |
|
324 |
+ |
// mCurValue = mComponent.getCurrentValue(); |
|
325 |
+ |
// String zStrVal = mCurValue.toString(); |
|
326 |
+ |
// NumberFormat zFormat = NumberFormat.getCurrencyFormat(); |
|
327 |
+ |
// |
|
328 |
+ |
// Double zDouble = Double.valueOf( zStrVal ); |
|
329 |
+ |
// String zFormattedValue = zFormat.format( zDouble.doubleValue() ); |
|
330 |
+ |
// mComponent.setCurrentValue( zFormattedValue ); |
|
331 |
+ |
//// mComponent.setError( UtilsGwt.areEqual( mErrorValue, mCurValue ) ? "Error!" : null ); |
|
332 |
+ |
// } |
|
333 |
+ |
// |
|
334 |
+ |
// @Override |
|
335 |
+ |
// public void focusOccured() |
|
336 |
+ |
// { |
|
337 |
+ |
// mComponent.setFocused( true ); |
|
338 |
+ |
//// System.out.println( mWhat + " Focus" ); |
|
339 |
+ |
// printToStatusbar( mWhat + " Focus" ); |
|
340 |
+ |
// } |
|
341 |
+ |
// |
|
342 |
+ |
// public void setCurrentValue( String pNewValue ) |
|
343 |
+ |
// { |
|
344 |
+ |
// mComponent.setCurrentValue( pNewValue ); |
|
345 |
+ |
// mCurValue = mOrigValue = mComponent.getCurrentValue(); |
|
346 |
+ |
// mComponent.setValueChanged( false ); |
|
347 |
+ |
// mComponent.setError( null ); |
|
348 |
+ |
// } |
|
349 |
+ |
// |
|
350 |
+ |
// @Override |
|
351 |
+ |
// public void enterPressed( KeyboardKeyModifier pModifiers ) |
|
352 |
+ |
// { |
|
353 |
+ |
// } |
|
354 |
+ |
// } |
|
355 |
+ |
|
|
356 |
+ |
// private static class MyResourceProvider implements ResourceKeyNameURLprovider |
|
357 |
+ |
// { |
|
358 |
+ |
// @Override |
|
359 |
+ |
// public ResourceKeyNameURL[] getLocalResourceKeyNameURLs() |
|
360 |
+ |
// { |
|
361 |
+ |
// return new ResourceKeyNameURL[]{new ResourceKeyNameURL( "AU", "Audi", "common/images/misc/tmp/audi.jpg" ),// |
|
362 |
+ |
// new ResourceKeyNameURL( "BM", "BMW", "common/images/misc/tmp/bmw.jpg" ),// |
|
363 |
+ |
// new ResourceKeyNameURL( "CH", "Chevrolet", "common/images/misc/tmp/chevy.jpg" ),// |
|
364 |
+ |
// new ResourceKeyNameURL( "FD", "Ford", "common/images/misc/tmp/ford.jpg" ),// |
|
365 |
+ |
// new ResourceKeyNameURL( "JA", "Jaguar", "common/images/misc/tmp/jag.jpg" ),// |
|
366 |
+ |
// new ResourceKeyNameURL( "MZ", "Mazda", "common/images/misc/tmp/mazda.jpg" ),// |
|
367 |
+ |
// new ResourceKeyNameURL( "MB", "Mercedes-Benz", "common/images/misc/tmp/mbenz.jpg" ),// |
|
368 |
+ |
// new ResourceKeyNameURL( "NS", "Nissan", "common/images/misc/tmp/nissan.jpg" ),// |
|
369 |
+ |
// new ResourceKeyNameURL( "TT", "Tata", "common/images/misc/tmp/tata.jpg" ),// |
|
370 |
+ |
// new ResourceKeyNameURL( "VW", "Volkswagen", "common/images/misc/tmp/vw.jpg" ),// |
|
371 |
+ |
// ERROR_RESOURCE,// |
|
372 |
+ |
// }; |
|
373 |
+ |
// } |
|
374 |
+ |
// |
|
375 |
+ |
// @Override |
|
376 |
+ |
// public void requestResourceKeyNameURLs( ResourceKeyNameURLsAvailableCallback pCallback ) |
|
377 |
+ |
// throws UnsupportedOperationException |
|
378 |
+ |
// { |
|
379 |
+ |
// //To change body of implemented methods use File | Settings | File Templates. |
|
380 |
+ |
// } |
|
381 |
+ |
// } |
|
382 |
+ |
|
|
383 |
+ |
private static void printToStatusbar( String pMessage ) { |
|
384 |
+ |
System.out.println( pMessage ); |
|
385 |
+ |
String current = StatusBar.get(); |
|
386 |
+ |
StatusBar.set( pMessage + " | " + current ); |
|
387 |
+ |
} |
|
388 |
+ |
|
|
389 |
+ |
// private TreeNode mTI2, mTI; |
|
390 |
+ |
// private int mAddIndex = 0; |
|
391 |
+ |
// |
|
392 |
+ |
// private void addTo( SizeableTree zTree ) |
|
393 |
+ |
// { |
|
394 |
+ |
// switch ( (mAddIndex++ & 7) ) |
|
395 |
+ |
// { |
|
396 |
+ |
// case 0: |
|
397 |
+ |
// mTI = zTree.addChild( augment( "One" ) ); |
|
398 |
+ |
// break; |
|
399 |
+ |
// case 1: |
|
400 |
+ |
// mTI2 = mTI.addChild( augment( "A" ) ); |
|
401 |
+ |
// mTI.addChild( augment( "B" ) ); |
|
402 |
+ |
// mTI.addChild( augment( "C" ) ); |
|
403 |
+ |
// break; |
|
404 |
+ |
// case 2: |
|
405 |
+ |
// mTI2.addChild( augment( "I" ) ); |
|
406 |
+ |
// mTI2.addChild( augment( "II" ) ); |
|
407 |
+ |
// mTI2.addChild( augment( "III" ) ); |
|
408 |
+ |
// mTI2.addChild( augment( "IV" ) ); |
|
409 |
+ |
// mTI2.addChild( augment( "V" ) ); |
|
410 |
+ |
// break; |
|
411 |
+ |
// case 3: |
|
412 |
+ |
// mTI = zTree.addChild( augment( "Two" ) ); |
|
413 |
+ |
// break; |
|
414 |
+ |
// case 4: |
|
415 |
+ |
// mTI.addChild( augment( "A" ) ); |
|
416 |
+ |
// mTI2 = mTI.addChild( augment( "B" ) ); |
|
417 |
+ |
// mTI.addChild( augment( "C" ) ); |
|
418 |
+ |
// break; |
|
419 |
+ |
// case 5: |
|
420 |
+ |
// mTI2.addChild( augment( "I" ) ); |
|
421 |
+ |
// mTI2.addChild( augment( "II" ) ); |
|
422 |
+ |
// mTI2.addChild( augment( "III" ) ); |
|
423 |
+ |
// mTI2.addChild( augment( "IV" ) ); |
|
424 |
+ |
// mTI2.addChild( augment( "V" ) ); |
|
425 |
+ |
// break; |
|
426 |
+ |
// case 6: |
|
427 |
+ |
// mTI = zTree.addChild( augment( "Three" ) ); |
|
428 |
+ |
// break; |
|
429 |
+ |
// case 7: |
|
430 |
+ |
// mTI.addChild( augment( "A" ) ); |
|
431 |
+ |
// mTI.addChild( augment( "B" ) ); |
|
432 |
+ |
// mTI2 = mTI.addChild( augment( "C" ) ); |
|
433 |
+ |
// mTI2.addChild( augment( "I" ) ); |
|
434 |
+ |
// mTI2.addChild( augment( "II" ) ); |
|
435 |
+ |
// mTI2.addChild( augment( "III" ) ); |
|
436 |
+ |
// mTI2.addChild( augment( "IV" ) ); |
|
437 |
+ |
// mTI2.addChild( augment( "V" ) ); |
|
438 |
+ |
// break; |
|
439 |
+ |
// } |
|
440 |
+ |
// } |
|
441 |
+ |
// |
|
442 |
+ |
// private String augment( String pBaseName ) |
|
443 |
+ |
// { |
|
444 |
+ |
// return pBaseName + "-" + mAddIndex; |
|
445 |
+ |
// } |
|
446 |
+ |
// |
|
447 |
+ |
// private Widget createTree() |
|
448 |
+ |
// { |
|
449 |
+ |
// Button zOpenAll = FolderOpenButton.factory().create(); |
|
450 |
+ |
// Button zCloseAll = FolderClosedButton.factory().create(); |
|
451 |
+ |
// final SizeableTree zTree = SizeableTree.withFolders(); |
|
452 |
+ |
// zTree.connectOpenCloseButtons( zOpenAll, zCloseAll ); |
|
453 |
+ |
// zTree.setAnimationEnabled( true ); |
|
454 |
+ |
// zTree.addTreeSelectionListener( new TreeSelectionListener() |
|
455 |
+ |
// { |
|
456 |
+ |
// @Override |
|
457 |
+ |
// public void selected( Object pSelected ) |
|
458 |
+ |
// { |
|
459 |
+ |
// System.out.println( "Tree Selected: " + pSelected ); |
|
460 |
+ |
// } |
|
461 |
+ |
// } ); |
|
462 |
+ |
// zTree.addTreeOpenCloseListener( new TreeOpenCloseListener() |
|
463 |
+ |
// { |
|
464 |
+ |
// @Override |
|
465 |
+ |
// public void openStateChanged( Boolean pOpened ) |
|
466 |
+ |
// { |
|
467 |
+ |
// System.out.println( "Tree Opened: " + pOpened + " - " + zTree.areAnyOpen() ); |
|
468 |
+ |
// } |
|
469 |
+ |
// } ); |
|
470 |
+ |
// |
|
471 |
+ |
// SizeableHorizontalPanel hPanel = new SizeableHorizontalPanel().stretchableHorizontally(); |
|
472 |
+ |
// hPanel.add( zOpenAll ); |
|
473 |
+ |
// hPanel.add( zCloseAll ); |
|
474 |
+ |
// hPanel.add( new Spacer( 10 ) ); |
|
475 |
+ |
// hPanel.add( new Label( "Some Text" ) ); |
|
476 |
+ |
// hPanel.add( Button.named( "Add" ).blue().text().add( new ClickHandler() |
|
477 |
+ |
// { |
|
478 |
+ |
// @Override |
|
479 |
+ |
// public void onClick( ClickEvent event ) |
|
480 |
+ |
// { |
|
481 |
+ |
// addTo( zTree ); |
|
482 |
+ |
// } |
|
483 |
+ |
// } ).create() ); |
|
484 |
+ |
// hPanel.add( Button.named( "Remove" ).blue().text().add( new ClickHandler() |
|
485 |
+ |
// { |
|
486 |
+ |
// @Override |
|
487 |
+ |
// public void onClick( ClickEvent event ) |
|
488 |
+ |
// { |
|
489 |
+ |
// if ( !zTree.isNullOrEmpty() ) |
|
490 |
+ |
// { |
|
491 |
+ |
// Object zUserObject = zTree.getSelected(); |
|
492 |
+ |
// if ( zUserObject == null ) |
|
493 |
+ |
// { |
|
494 |
+ |
// zUserObject = zTree.iterator().next(); |
|
495 |
+ |
// } |
|
496 |
+ |
// zTree.removeDescendant( zUserObject ); |
|
497 |
+ |
// } |
|
498 |
+ |
// } |
|
499 |
+ |
// } ).create() ); |
|
500 |
+ |
// hPanel.add( Button.named( "Remove1st" ).blue().text().add( new ClickHandler() |
|
501 |
+ |
// { |
|
502 |
+ |
// @Override |
|
503 |
+ |
// public void onClick( ClickEvent event ) |
|
504 |
+ |
// { |
|
505 |
+ |
// if ( !zTree.isNullOrEmpty() ) |
|
506 |
+ |
// { |
|
507 |
+ |
// Object zUserObject = zTree.iterator().next(); |
|
508 |
+ |
// zTree.removeChild( zUserObject ); |
|
509 |
+ |
// } |
|
510 |
+ |
// } |
|
511 |
+ |
// } ).create() ); |
|
512 |
+ |
// |
|
513 |
+ |
// SizeableVerticalPanel vPanel = new SizeableVerticalPanel().stretchable(); |
|
514 |
+ |
// vPanel.add( hPanel ); |
|
515 |
+ |
// vPanel.add( zTree ); |
|
516 |
+ |
// |
|
517 |
+ |
// return vPanel; |
|
518 |
+ |
// } |
|
519 |
+ |
|
|
520 |
+ |
// private Widget createCurrentTasks() |
|
521 |
+ |
// { |
|
522 |
+ |
// return new CurrentTasks(); |
|
523 |
+ |
// } |
|
524 |
+ |
} |