Subversion Repository Public Repository

litesoft

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
package com.test.uidesign.client;

import java.util.*;

import org.litesoft.GWT.client.*;
import org.litesoft.GWT.client.widgets.*;
import org.litesoft.GWT.forms.client.components.*;
import org.litesoft.GWT.forms.client.components.impls.input.*;
import org.litesoft.core.simpletypes.*;
import org.litesoft.core.simpletypes.temporal.*;
import org.litesoft.core.typeutils.Objects;
import org.litesoft.core.util.*;

import com.google.gwt.i18n.client.*;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.*;

public class OrigFormComponents extends SizeableHorizontalPanel
{
    private static final ResourceKeyNameURL ERROR_RESOURCE = new ResourceKeyNameURL( "VW2", "Volkswagen2", "common/images/misc/tmp/vw.jpg" );

    public OrigFormComponents()
    {
        stretchable();

        add( createPanel( "First Name", "My New Tooltip", // TextField
                          "Password", "A Tooltip 4 Password Field", // PasswordField
                          "Pick a color", // ComboBox ToolTip
                          "Checkbox tooltip", // CheckBox ToolTip
                          "Group Uno", "Radio Tooltip", // Radio Group
                          new String[]{"Option One", "Option Two is a really long, long option", "Option Three",} ) );

//        add( createPanel( "Last Name", null, // TextField
//                                  null, // ComboBox ToolTip
//                                  null, // CheckBox ToolTip
//                                  "Group Dos", null, // Radio Group
//                                  new String[]{"Option 1", "Option 2",} ) );
    }

    private Widget createPanel( String pTextFieldLabel, String pTextFieldTooltip, //
                                String pPasswordFieldLabel, String pPasswordFieldTooltip, //
                                String pComboBoxToolTip, //
                                String pCheckBoxToolTip, //
                                String pRadioGroupLabel, String pRadioGroupToolTip, String[] pRadioGroupOptions )
    {
        SizeableVerticalPanel panel = new SizeableVerticalPanel().stretchable();

        FormImageSelectBadDataType zBadDataType =
                new FormImageSelectBadDataType( "Bad Data Type", null, "reallyBadDataType", "BadDataType", 150, false, 150, false );
        panel.add( zBadDataType );

        FormImageSelectURL zUrlPicker = new FormImageSelectURL( "URL Picker", null, null, false, 150, false, 150, false );
        zUrlPicker.addFormComponentListener( new MyListener( "ERROR" )
        {

            public void changeOccurred()
            {
                super.changeOccurred();
                System.out.println( "'" + mCurValue + "'" );
                //To change body of overridden methods use File | Settings | File Templates.
            }
        } );
        panel.add( zUrlPicker );

        FormImageSelectOptions zOptPicker =
                new FormImageSelectOptions( "Image Options", null, "Select Image From List", false, new MyResourceProvider(), 150, false, 150, false );
        zOptPicker.addFormComponentListener( new MyListener( ERROR_RESOURCE ) );
        panel.add( zOptPicker );

        final FormTextField zDecimalField = new FormTextField( "Decimal", null, "Decimal Format ", 12, 12 );
        zDecimalField.addFormComponentListener( new MyDecimalFormatListener( "ERROR" ) );
        panel.add( zDecimalField );

//        final FormTextField zCurrencyField = new FormTextField( "Currency", null, "Currency Format ", 12, 12 );
//        final MyCurrencyFormatListener zCurrencyListener = new MyCurrencyFormatListener( zCurrencyField, "ERROR" );
//        zCurrencyField.addFormComponentListener( zCurrencyListener );
//        panel.add( zCurrencyField );

        final FormCheckBox zCkBXfc = new FormCheckBox( "Choice of One and ONLY One", null, pCheckBoxToolTip, true );
        zCkBXfc.addFormComponentListener( new MyListener( "ERROR" ) );
        panel.add( zCkBXfc );

        final FormCheckBox zCkBX_standalone = new FormCheckBox( "Choice Two", null, pCheckBoxToolTip, false );
        zCkBX_standalone.addFormComponentListener( new MyListener( "ERROR" ) );
        panel.add( zCkBX_standalone );

        final FormComboBox zCmBXfc = new FormComboBox( "Colors", null, pComboBoxToolTip ).addItems( new String[] //
                { //
                  "Red", //
                  "Green", //
                  "Blue", //
                } );
        zCmBXfc.addFormComponentListener( new MyListener( new StringKeyValuePair( "Green" ) ) );
        panel.add( zCmBXfc );

        final FormTextField zTFfc = new FormTextField( pTextFieldLabel, null, pTextFieldTooltip, null, null );
        zTFfc.addFormComponentListener( new MyListener( "ERROR" ) );

        final FormPasswordField zPFfc = new FormPasswordField( pPasswordFieldLabel, null, pPasswordFieldTooltip, null, null );
        zPFfc.addFormComponentListener( new MyListener( "ERROR" ) );

//        // Button & Field alignment
//        HorizontalPanel zHorizontalPanel2 = new HorizontalPanel();
//        DOM.setElementAttribute( zHorizontalPanel2.getElement(), "align", "right" );
//        zHorizontalPanel2.add( new Button( "Placeholder" ) );
//        zHorizontalPanel2.add( new Spacer( 24 ) );
//
//        VerticalPanel zVerticalPanel2 = new VerticalPanel();
//        DOM.setStyleAttribute( zVerticalPanel2.getElement(), "border", "1px solid red" );
//
//        zVerticalPanel2.add( zTFfc );
//        zVerticalPanel2.add( zHorizontalPanel2 );
//
//        panel.add( zVerticalPanel2 );
        panel.add( zTFfc );
        panel.add( zPFfc );

        final FormRightAlignTextField zTFnumeric = new FormRightAlignTextField( "Security Code", null, pTextFieldTooltip, null, null );
        final MyListener zTFnumericListener = new MyListener( "999" );
        zTFnumeric.addFormComponentListener( zTFnumericListener );
        panel.add( zTFnumeric );

        final FormTextarea zFrmTA = new FormTextarea( "Comments are really long", null, pTextFieldTooltip, false, null, false, null, false );
        final MyListener zTAlistener = new MyListener( "ERROR" );
        zFrmTA.addFormComponentListener( zTAlistener );
        panel.add( zFrmTA );

        final FormRadioGroup zRGfc = new FormRadioGroup( pRadioGroupLabel, null, pRadioGroupToolTip, //
                                                         pRadioGroupOptions );
        final MyListener zRGlistener = new MyListener( "N/A" );
        zRGfc.addFormComponentListener( zRGlistener );
        panel.add( zRGfc );

        FormTimestampPicker zTimestampPicker = new FormTimestampPicker( "Timestamp", null, pTextFieldTooltip, TimeRes.ToMIN, "Cancel", "OK" );
        MyListener zTimestampPickerListener = new MyListener( "ERROR" );
        zTimestampPicker.addFormComponentListener( zTimestampPickerListener );
//
//        HorizontalPanel zHorizontaPanel = new HorizontalPanel();
////        DOM.setStyleAttribute( zHorizontaPanel.getElement(), "border", "1px solid green");
//        DOM.setElementAttribute( zHorizontaPanel.getElement(), "align", "right" );
//        zHorizontaPanel.add( new Button( "Placeholder" ) );
//        zHorizontaPanel.add( new Spacer( 24 ) );
//
        panel.add( zTimestampPicker );
//        zVerticalPanel.add( zTimestampPicker );
//        zVerticalPanel.add( zHorizontaPanel );
//
//        panel.add( zVerticalPanel );
////        panel.add( zTimestampPicker );
//
//        FormTimePicker zTimePicker =
//                new FormTimePicker( "Pick-a-Time", null, pTextFieldTooltip, null, "Cancel", "OK" );
//        MyListener zTimePickerListener = new MyListener( zTimePicker, "ERROR" );
//        zTimePicker.addFormComponentListener( zTimePickerListener );
//        panel.add( zTimePicker );
//
//        FormDatePicker zDtPicker = new FormDatePicker( "Date", null, pTextFieldTooltip, "Cancel", "Today",
//                                                       new DateFormatControl( "dd MMM y" ) );
//        MyListener zDtPickerListener = new MyListener( zDtPicker, "9999" );
//        zDtPicker.addFormComponentListener( zDtPickerListener );
//        panel.add( zDtPicker );
//
//        FormTextarea dummyTA = new FormTextarea( "DummyField", null, pTextFieldTooltip, false, null, false, null, false );
//        final AbstractFormContainer zFrmContainer = new SizeableBorderedFormContainer( dummyTA );
//        // zFrmContainer.appendFormErrorText( "Error on Form, dude" );
//
//        panel.add( zFrmContainer );
//        panel.add( new Spacer( 3 ) );
//
        final List<Enableable> zFormComponents = new ArrayList<Enableable>();
        for ( Object o : panel )
        {
            if ( o instanceof Enableable )
            {
                zFormComponents.add( (Enableable) o );
            }
        }

        Button buttonSetEnabled = new Button( "Set Enabled" );
        Button buttonSetDisabled = new Button( "Set Disabled" );

        HorizontalPanel hBtnPanel = new HorizontalPanel();
        hBtnPanel.add( buttonSetEnabled );
        hBtnPanel.add( buttonSetDisabled );
        panel.add( hBtnPanel );

        panel.add( new Spacer( 3 ) );

//        MultiWordSuggestOracle oracle = new MultiWordSuggestOracle();
//        oracle.add( "Cat" );
//        oracle.add( "Dog" );
//        oracle.add( "Horse" );
//        oracle.add( "Canary" );
//
//        SuggestBox suggestBox = new SuggestBox( oracle );
//        panel.add( suggestBox );
//        panel.add( new Spacer( 3 ) );
//
        buttonSetEnabled.addClickListener( new ClickListener()
        {
            public void onClick( Widget sender )
            {
                for ( Enableable zEnableable : zFormComponents )
                {
                    zEnableable.setEnabled( true );
                }
            }
        } );
        buttonSetDisabled.addClickListener( new ClickListener()
        {
            public void onClick( Widget sender )
            {
                for ( Enableable zEnableable : zFormComponents )
                {
                    zEnableable.setEnabled( false );
                }
                // zFrmTA.disableTextArea();
            }
        } );

//        Button zError1 = new Button( "Error-1", new ClickListener()
//        {
//            public void onClick( Widget sender )
//            {
//                zFrmContainer.setError( "Houston, we have a problem" );
//            }
//        } );
//        Button zError2 = new Button( "Error-2", new ClickListener()
//        {
//            public void onClick( Widget sender )
//            {
//                zFrmContainer.setError( "We have more than\na problem" );
//            }
//        } );
//        Button zWarning1 = new Button( "Warning-1", new ClickListener()
//        {
//            public void onClick( Widget sender )
//            {
//                zFrmContainer.setWarning( "Warning, something else is going on" );
//            }
//        } );
//        Button zWarning2 = new Button( "Warning-2", new ClickListener()
//        {
//            public void onClick( Widget sender )
//            {
//                zFrmContainer.setWarning( "Something Special\n is going on" );
//            }
//        } );
//
//        Button clearFormErrors = new Button( "Clear Err or Warning", new ClickListener()
//        {
//            public void onClick( Widget sender )
//            {
//                zFrmContainer.clearErrorOrWarning();
//                StatusBar.set( "" );
//            }
//        } );
//
//        SizeableHorizontalPanel hErrBtns = new SizeableHorizontalPanel( true ).stretchableHorizontally();
//        hErrBtns.add( zError1 );
////        hErrBtns.add( zWarning1 );
////        hErrBtns.add( clearFormErrors );
////        hErrBtns.add( zWarning2 );
////        hErrBtns.add( zError2 );
//        hErrBtns.add( new SizeableSpacer().stretchableHorizontally() );
////        hErrBtns.add( new Button("test", new ClickListener()
////        {
////            public void onClick( Widget sender )
////            {
////                StatusBar.set( "Some Text: " + new BoxedString( "The Boxed String" ) );
////            }
////        } ) );
//        panel.add( hErrBtns );
//        panel.add( new Spacer( 3 ) );

        return panel;
    }

    private static class MyListener implements IFormComponent.Listener
    {
        protected IFormComponent mComponent;
        private Object mErrorValue;
        protected Object mOrigValue, mCurValue;
        private String mWhat;

        public MyListener( Object pErrorValue )
        {
            mErrorValue = pErrorValue;
        }

        public void add( IFormComponent pComponent )
        {
            mComponent = pComponent;
            mOrigValue = mComponent.getCurrentValue();
            mWhat = Objects.justClassNameOf( mComponent );
        }

        public void remove( IFormComponent pComponent )
        {
        }

        public void changeOccurred()
        {
            mCurValue = mComponent.getCurrentValue();
//            System.out.println( mWhat + " Change: '" + mCurValue + "'" );
            printToStatusbar( mWhat + " Change: '" + mCurValue + "'" );
            mComponent.setValueChanged( !Objects.areNonArraysEqual( mOrigValue, mCurValue ) );
            mComponent.setError( null );
        }

        public void blurOccurred()
        {
//            System.out.println( mWhat + " Blur" );
            printToStatusbar( mWhat + " Blur" );
            mComponent.setFocused( false );
            mComponent.setError( Objects.areNonArraysEqual( mErrorValue, mCurValue ) ? "Error!" : null );
        }

        public void focusOccured()
        {
            mComponent.setFocused( true );
//            System.out.println( mWhat + " Focus" );
            printToStatusbar( mWhat + " Focus" );
        }

        public void setCurrentValue( String pNewValue )
        {
            mComponent.setCurrentValue( pNewValue );
            mCurValue = mOrigValue = mComponent.getCurrentValue();
            mComponent.setValueChanged( false );
            mComponent.setError( null );
        }

        public void enterPressed( KeyboardKeyModifier pModifiers )
        {
        }
    }

    private static class MyDecimalFormatListener implements IFormComponent.Listener
    {
        private IFormComponent mComponent;
        private Object mErrorValue;
        private Object mOrigValue, mCurValue;
        private String mWhat;

        public MyDecimalFormatListener( Object pErrorValue )
        {
            mErrorValue = pErrorValue;
        }

        public void add( IFormComponent pComponent )
        {
            mComponent = pComponent;
            mOrigValue = mComponent.getCurrentValue();
            mWhat = Objects.justClassNameOf( mComponent );
        }

        public void remove( IFormComponent pComponent )
        {
        }

        public void changeOccurred()
        {
            mCurValue = mComponent.getCurrentValue();
//            System.out.println( mWhat + " Change: '" + mCurValue + "'" );
            printToStatusbar( mWhat + " Change: '" + mCurValue + "'" );
            mComponent.setValueChanged( !Objects.areNonArraysEqual( mOrigValue, mCurValue ) );
            mComponent.setError( null );
        }

        public void blurOccurred()
        {
            mComponent.setFocused( false );

            mCurValue = mComponent.getCurrentValue();
            String zStrVal = mCurValue.toString();
            NumberFormat zFormat = NumberFormat.getDecimalFormat();

//            double zDouble = Double.parseDouble( zStrVal );
//            String zFormattedValue = zFormat.format( zDouble );
//            mComponent.setCurrentValue( zFormattedValue );
//            mComponent.setError( UtilsGwt.areNonArraysEqual( mErrorValue, mCurValue ) ? "Error!" : null );
        }

        public void focusOccured()
        {
            mComponent.setFocused( true );
//            System.out.println( mWhat + " Focus" );
            printToStatusbar( mWhat + " Focus" );
        }

        public void setCurrentValue( String pNewValue )
        {
            mComponent.setCurrentValue( pNewValue );
            mCurValue = mOrigValue = mComponent.getCurrentValue();
            mComponent.setValueChanged( false );
            mComponent.setError( null );
        }

        public void enterPressed( KeyboardKeyModifier pModifiers )
        {
        }
    }

    private static class MyCurrencyFormatListener implements IFormComponent.Listener
    {
        private IFormComponent mComponent;
        private Object mErrorValue;
        private Object mOrigValue, mCurValue;
        private String mWhat;

        public MyCurrencyFormatListener( Object pErrorValue )
        {
            mErrorValue = pErrorValue;
        }

        public void add( IFormComponent pComponent )
        {
            mComponent = pComponent;
            mOrigValue = mComponent.getCurrentValue();
            mWhat = Objects.justClassNameOf( mComponent );
        }

        public void remove( IFormComponent pComponent )
        {
        }

        public void changeOccurred()
        {
            mCurValue = mComponent.getCurrentValue();
//            System.out.println( mWhat + " Change: '" + mCurValue + "'" );
            printToStatusbar( mWhat + " Change: '" + mCurValue + "'" );
            mComponent.setValueChanged( !Objects.areNonArraysEqual( mOrigValue, mCurValue ) );
            mComponent.setError( null );
        }

        public void blurOccurred()
        {
            mComponent.setFocused( false );

            mCurValue = mComponent.getCurrentValue();
            String zStrVal = mCurValue.toString();
            NumberFormat zFormat = NumberFormat.getCurrencyFormat();

            Double zDouble = Double.valueOf( zStrVal );
            String zFormattedValue = zFormat.format( zDouble.doubleValue() );
            mComponent.setCurrentValue( zFormattedValue );
//            mComponent.setError( UtilsGwt.areNonArraysEqual( mErrorValue, mCurValue ) ? "Error!" : null );
        }

        public void focusOccured()
        {
            mComponent.setFocused( true );
//            System.out.println( mWhat + " Focus" );
            printToStatusbar( mWhat + " Focus" );
        }

        public void setCurrentValue( String pNewValue )
        {
            mComponent.setCurrentValue( pNewValue );
            mCurValue = mOrigValue = mComponent.getCurrentValue();
            mComponent.setValueChanged( false );
            mComponent.setError( null );
        }

        public void enterPressed( KeyboardKeyModifier pModifiers )
        {
        }
    }

    private static class MyResourceProvider implements ResourceKeyNameURLprovider
    {

        public ResourceKeyNameURL[] getLocalResourceKeyNameURLs()
        {
            return new ResourceKeyNameURL[]{new ResourceKeyNameURL( "AU", "Audi", "common/images/misc/tmp/audi.jpg" ),//
                                            new ResourceKeyNameURL( "BM", "BMW", "common/images/misc/tmp/bmw.jpg" ),//
                                            new ResourceKeyNameURL( "CH", "Chevrolet", "common/images/misc/tmp/chevy.jpg" ),//
                                            new ResourceKeyNameURL( "FD", "Ford", "common/images/misc/tmp/ford.jpg" ),//
                                            new ResourceKeyNameURL( "JA", "Jaguar", "common/images/misc/tmp/jag.jpg" ),//
                                            new ResourceKeyNameURL( "MZ", "Mazda", "common/images/misc/tmp/mazda.jpg" ),//
                                            new ResourceKeyNameURL( "MB", "Mercedes-Benz", "common/images/misc/tmp/mbenz.jpg" ),//
                                            new ResourceKeyNameURL( "NS", "Nissan", "common/images/misc/tmp/nissan.jpg" ),//
                                            new ResourceKeyNameURL( "TT", "Tata", "common/images/misc/tmp/tata.jpg" ),//
                                            new ResourceKeyNameURL( "VW", "Volkswagen", "common/images/misc/tmp/vw.jpg" ),//
                                            ERROR_RESOURCE,//
            };
        }

        public void requestResourceKeyNameURLs( ResourceKeyNameURLsAvailableCallback pCallback )
                throws UnsupportedOperationException
        {
            //To change body of implemented methods use File | Settings | File Templates.
        }
    }

    private static void printToStatusbar( String pMessage )
    {
        String current = StatusBar.get();
        StatusBar.set( pMessage + " | " + current );
    }
}

Commits for litesoft/trunk/GWT_Sandbox/UIdesign/src/com/test/uidesign/client/OrigFormComponents.java

Diff revisions: vs.
Revision Author Commited Message
937 Diff Diff markcmarkc Mon 02 Jun, 2014 00:08:18 +0000

Added property file loading for master unvalidated accessor

811 Diff Diff GeorgeS picture GeorgeS Sat 18 Aug, 2012 13:45:18 +0000
804 Diff Diff GeorgeS picture GeorgeS Wed 15 Aug, 2012 12:48:51 +0000
384 Diff Diff GeorgeS picture GeorgeS Sun 14 Aug, 2011 16:07:37 +0000
377 GeorgeS picture GeorgeS Sat 13 Aug, 2011 00:08:16 +0000