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
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
package com.test.uidesign.client;

import java.util.*;

import org.litesoft.GWT.client.*;
import org.litesoft.GWT.client.widgets.Button;
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.util.*;

import com.google.gwt.event.dom.client.*;
import com.google.gwt.i18n.client.*;
import com.google.gwt.user.client.ui.*;
import com.google.gwt.user.datepicker.client.*;

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

    private final List<Enableable> mFormComponents = new ArrayList<Enableable>();
    private Button mEnable, mDisable, mDialog;

    public PersonalInfoForm()
    {
        stretchable();

        FormSuggestBox zSuggest = new FormSuggestBox( "Suggestions", null, "Type to filter content", null, null, createSuggestions() );
        zSuggest.addFormComponentListener( new MyListener( "ERROR" ) );

        add( zSuggest );

//        DOM.setStyleAttribute( getElement(), "backgroundColor", "#00D000" );
        String[] zRadioGroupOptions = new String[]{"Option One", "Option Two is a really long, long option", "Option Three",};

//        final FormTextField zTFfc = new FormTextField( "First Name", null, "My New Tooltip", null, null ).setListener( new MyListener( "ERROR" ) );

        FormTextField zTFfc = new FormTextField( "First Name", null, "My New Tooltip", null, null );
        zTFfc.addFormComponentListener( new MyListener( "ERROR" ) );

        FormPasswordField zPFfc = new FormPasswordField( "Password", null, "A Tooltip 4 Password Field", null, null );
        zPFfc.addFormComponentListener( new MyListener( "ERROR" ) );

        add( zTFfc );
        add( zPFfc );

//        final FormRightAlignTextField zTFnumeric = new FormRightAlignTextField( "Security Code", null, "My New Tooltip", null, null );
//        final MyListener zTFnumericListener = new MyListener( zTFnumeric, "999" );
//        zTFnumeric.addFormComponentListener( zTFnumericListener );
//        add( zTFnumeric );

        SizeableBorderedHorizontalSplitPairPanel zHSP = new SizeableBorderedHorizontalSplitPairPanel().stretchable();
        add( zHSP );

        FormTextarea zFrmTA = new FormTextarea( "Comments are really long", null, "My New Tooltip", false, null, false, null, false );
        zFrmTA.addFormComponentListener( new MyListener( "ERROR" ) );
        zHSP.add( zFrmTA );

        SizeableBorderedHorizontalSplitPairPanel zHSP2 = new SizeableBorderedHorizontalSplitPairPanel().stretchable();
        zHSP.add( zHSP2 );
        zHSP2.add( createCurrentTasks() );
        zHSP2.add( createTree() );

        HorizontalPanel zHPanel = new HorizontalPanel();
        add( zHPanel );

        FormRadioGroup zRGfc = new FormRadioGroup( "Group Uno", null, "Radio Tooltip", //
                                                   zRadioGroupOptions );
        zRGfc.addFormComponentListener( new MyListener( "N/A" ) );
        zHPanel.add( zRGfc );

        zHPanel.add( new Spacer( 10 ) );

        zHPanel.add( new DatePicker() );

        add( zHPanel = new HorizontalPanel() );

        FormTimestampPicker zTimestampPicker = new FormTimestampPicker( "Timestamp", null, "My New Tooltip", TimeRes.ToMIN, "Cancel", "OK" );
        zTimestampPicker.addFormComponentListener( new MyListener( new SimpleTimestamp( 1960, 1, 2, 3, 4 ) ) );
        zHPanel.add( zTimestampPicker );

        FormDatePicker zCalendar = new FormDatePicker( "Calendar", null, "Pick-a-Date", "Cancel", "Today", new DateFormatControl( DateFormatControl.DEFAULT_DATE_FORMAT ) );
        zCalendar.addFormComponentListener( new MyListener( new SimpleDate( 1957, 1, 4 ) ) );
        zHPanel.add( zCalendar );

        FormTimePicker zTime = new FormTimePicker( "Time", null, "Pick-a-Time", TimeRes.ToMIN, "Cancel", "OK" );
        zTime.addFormComponentListener( new MyListener( new SimpleTime( 1, 2 ) ) );
        zHPanel.add( zTime );

        FormComboBox zOptions = new FormComboBox( "Colors *", null, "Pick-a-color", "Red" );
        zOptions.addFormComponentListener( new MyListener( "-Select-" ) );
        zOptions.addItems( "-Select-", //
                           "Red", //
                           "Green", //
                           "Blue" );
        zHPanel.add( zOptions );

//        final FormSuggestBox zSuggest3 = new FormSuggestBox( "Suggestions", null, "Type to filter content", null, null, mSuggestions );
//        add(zSuggest3);

        FormCheckBox zCheck = new FormCheckBox( "Option1", null, "Options Tooltip", false );
        zCheck.addFormComponentListener( new MyListener( null ) );
        add( zCheck );

//        FormComboBox zOptions = new FormComboBox( "Colors *", null, "Pick-a-color", "Red" );
//        zOptions.addFormComponentListener( new MyListener( "-Select-" ) );
//        zOptions.addItems( new String[] //
//                { //
//                  "-Select-", //
//                  "Red", //
//                  "Green", //
//                  "Blue", //
//                } );
//        add( zOptions );

        collectEnableables( mFormComponents, this );

        SizeableHorizontalPanel hBtnPanel = new SizeableHorizontalPanel().stretchableHorizontally();
        hBtnPanel.add( mEnable = Button.named( "Enable" ).green().text().add( new ClickHandler()
        {
            @Override
            public void onClick( ClickEvent event )
            {
                enableDisable( true, mDisable, mEnable );
            }
        } ).create() );
        mEnable.disable();

        //                        new RedButton( "Set Disabled",
        hBtnPanel.add( mDisable = Button.named( "Disable" ).red().text().add( new ClickHandler()
        {
            @Override
            public void onClick( ClickEvent event )
            {
                enableDisable( false, mEnable, mDisable );
            }
        } ).create() );
        hBtnPanel.add( new SizeableSpacer().stretchableHorizontally() );
        hBtnPanel.add( mDialog = ScreenBigButton.factory( "Dialog" ).add( new ClickHandler()
        {
            @Override
            public void onClick( ClickEvent event )
            {
                AlertManager.alert( "Test", "A Dialog", "The Body" );
            }
        } ).create() );
        add( hBtnPanel );

        add( new Spacer( 3 ) );

//        final OurSuggestBox zSuggest2 = new OurSuggestBox( zOracle );
//        zSuggest2.addFocusListener( new FocusListener()
//        {
//            @Override
//            public void onFocus( Widget sender )
//            {
//                if ( !zSuggest2.isSuggestionListShowing() )
//                {
//                    System.out.println( "About to show" );
//                    DeferredCommand.addCommand( new Command()
//                    {
//                        @Override public void execute()
//                        {
//                            if ( !zSuggest2.isSuggestionListShowing() )
//                            {
//                                if ( UtilsCommon.noEmpty( zSuggest2.getText() ) == null )
//                                {
//                                    zSuggest2.showSuggestionList();
//                                }
//                            }
//                        }
//                    } );
//                }
//            }
//
//            @Override
//            public void onLostFocus( Widget sender )
//            {
//                //To change body of implemented methods use File | Settings | File Templates.
//            }
//        } );
//
//        add( zSuggest2 );

    }

    private void enableDisable( boolean pEnable, Enableable pButtonToEnable, Enableable pButtonToDisable )
    {
        pButtonToDisable.setEnabled( false );
        mDialog.setEnabled( pEnable );
        for ( Enableable zEnableable : mFormComponents )
        {
            zEnableable.setEnabled( pEnable );
        }
        pButtonToEnable.setEnabled( true );
    }

    private List<String> createSuggestions()
    {
        return Arrays.asList(//
                             "Afghanistan", //
                             "Albania", //
                             "Algeria", //
                             "Argentina", //
                             "Armenia", //
                             "Australia", //
                             "Austria", //
                             "Azerbaijan", //
                             "Bahamas", //
                             "Bahrain", //
                             "Bangladesh", //
                             "Barbados", //
                             "Belarus", //
                             "Belgium", //
                             "Belize", //
                             "Benin", //
                             "Bhutan", //
                             "Bolivia", //
                             "Bosnia", //
                             "Brazil", //
                             "Bulgaria", //
                             "Cambodia", //
                             "Cameroon", //
                             "Canada", //
                             "Chad", //
                             "Chile", //
                             "China", //
                             "Colombia", //
                             "Comoros", //
                             "Congo", //
                             "Costa Rica", //
                             "Croatia", //
                             "Cuba", //
                             "Cyprus", //
                             "Denmark", //
                             "Dominica", //
                             "Ecuador", //
                             "Egypt", //
                             "Eritrea", //
                             "Estonia", //
                             "Ethiopia", //
                             "Fiji", //
                             "Finland", //
                             "France", //
                             "Gabon", //
                             "Gambia", //
                             "Germany", //
                             "Ghana", //
                             "Greece", //
                             "Grenada", //
                             "Guatemala", //
                             "Guinea", //
                             "Guyana", //
                             "Haiti", //
                             "Honduras", //
                             "Hungary", //
                             "Iceland", //
                             "India", //
                             "Indonesia", //
                             "Iran", //
                             "Iraq", //
                             "Ireland", //
                             "Israel", //
                             "Italy", //
                             "Jamaica", //
                             "Japan", //
                             "Jordan", //
                             "Kazakhstan", //
                             "Kenya", //
                             "Kiribati", //
                             "Korea, North", //
                             "Korea, South", //
                             "Kuwait", //
                             "Kyrgyzstan", //
                             "Laos", //
                             "Latvia", //
                             "Lebanon", //
                             "Lesotho", //
                             "Liberia", //
                             "Libya", //
                             "Liechtenstein", //
                             "Lithuania", //
                             "Luxembourg", //
                             "Madagascar", //
                             "Malawi", //
                             "Malaysia", //
                             "Maldives", //
                             "Mali", //
                             "Malta", //
                             "Mauritania", //
                             "Mauritius", //
                             "Mexico", //
                             "Moldova", //
                             "Monaco", //
                             "Mongolia", //
                             "Montenegro", //
                             "Morocco", //
                             "Mozambique", //
                             "Myanmar", //
                             "Namibia", //
                             "Nepal", //
                             "Netherlands", //
                             "New Zealand", //
                             "Nicaragua", //
                             "Niger", //
                             "Nigeria", //
                             "Norway", //
                             "Oman", //
                             "Pakistan", //
                             "Palau", //
                             "Panama", //
                             "Paraguay", //
                             "Peru", //
                             "Philippines", //
                             "Poland", //
                             "Portugal", //
                             "Qatar", //
                             "Romania", //
                             "Russia", //
                             "Rwanda", //
                             "Samoa", //
                             "Saudi Arabia", //
                             "Senegal", //
                             "Serbia", //
                             "Seychelles", //
                             "Singapore", //
                             "Slovakia", //
                             "Slovenia", //
                             "Somalia", //
                             "South Africa", //
                             "Spain", //
                             "Sudan", //
                             "Suriname", //
                             "Swaziland", //
                             "Sweden", //
                             "Switzerland", //
                             "Syria", //
                             "Taiwan", //
                             "Tajikistan", //
                             "Tanzania", //
                             "Thailand", //
                             "Togo", //
                             "Tonga", //
                             "Tunisia", //
                             "Turkey", //
                             "Turkmenistan", //
                             "Uganda", //
                             "Ukraine", //
                             "United Arab Emirates", //
                             "United Kingdom", //
                             "United States", //
                             "Uruguay", //
                             "Uzbekistan", //
                             "Vanuatu", //
                             "Venezuela", //
                             "Vietnam", //
                             "Yemen", //
                             "Zambia", //
                             "Zimbabwe" );
    }

    private void collectEnableables( List<Enableable> pFormComponents, HasWidgets pWidget )
    {
        for ( Widget zWidget : pWidget )
        {
            if ( (zWidget instanceof Enableable) && !(zWidget instanceof Button) )
            {
                pFormComponents.add( (Enableable) zWidget );
            }
            if ( zWidget instanceof HasWidgets )
            {
                collectEnableables( pFormComponents, (HasWidgets) zWidget );
            }
        }
    }

    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;
        }

        @Override
        public void add( IFormComponent pComponent )
        {
            mComponent = pComponent;
            mOrigValue = mCurValue = mComponent.getCurrentValue();
            mWhat = UtilsCommon.justClassNameOf( mComponent );
        }

        @Override
        public void remove( IFormComponent pComponent )
        {
        }

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

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

        @Override
        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 );
        }

        @Override
        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;
        }

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

        @Override
        public void remove( IFormComponent pComponent )
        {
        }

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

        @Override
        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 );
        }

        @Override
        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 );
        }

        @Override
        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;
        }

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

        @Override
        public void remove( IFormComponent pComponent )
        {
        }

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

        @Override
        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 );
        }

        @Override
        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 );
        }

        @Override
        public void enterPressed( KeyboardKeyModifier pModifiers )
        {
        }
    }

    private static class MyResourceProvider implements ResourceKeyNameURLprovider
    {
        @Override
        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,//
            };
        }

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

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

    private TreeNode mTI2, mTI;
    private int mAddIndex = 0;

    private void addTo( SizeableTree zTree )
    {
        switch ( (mAddIndex++ & 7) )
        {
            case 0:
                mTI = zTree.addChild( augment( "One" ) );
                break;
            case 1:
                mTI2 = mTI.addChild( augment( "A" ) );
                mTI.addChild( augment( "B" ) );
                mTI.addChild( augment( "C" ) );
                break;
            case 2:
                mTI2.addChild( augment( "I" ) );
                mTI2.addChild( augment( "II" ) );
                mTI2.addChild( augment( "III" ) );
                mTI2.addChild( augment( "IV" ) );
                mTI2.addChild( augment( "V" ) );
                break;
            case 3:
                mTI = zTree.addChild( augment( "Two" ) );
                break;
            case 4:
                mTI.addChild( augment( "A" ) );
                mTI2 = mTI.addChild( augment( "B" ) );
                mTI.addChild( augment( "C" ) );
                break;
            case 5:
                mTI2.addChild( augment( "I" ) );
                mTI2.addChild( augment( "II" ) );
                mTI2.addChild( augment( "III" ) );
                mTI2.addChild( augment( "IV" ) );
                mTI2.addChild( augment( "V" ) );
                break;
            case 6:
                mTI = zTree.addChild( augment( "Three" ) );
                break;
            case 7:
                mTI.addChild( augment( "A" ) );
                mTI.addChild( augment( "B" ) );
                mTI2 = mTI.addChild( augment( "C" ) );
                mTI2.addChild( augment( "I" ) );
                mTI2.addChild( augment( "II" ) );
                mTI2.addChild( augment( "III" ) );
                mTI2.addChild( augment( "IV" ) );
                mTI2.addChild( augment( "V" ) );
                break;
        }
    }

    private String augment( String pBaseName )
    {
        return pBaseName + "-" + mAddIndex;
    }

    private Widget createTree()
    {
        Button zOpenAll = FolderOpenButton.factory().create();
        Button zCloseAll = FolderClosedButton.factory().create();
        final SizeableTree zTree = SizeableTree.withFolders();
        zTree.connectOpenCloseButtons( zOpenAll, zCloseAll );
        zTree.setAnimationEnabled( true );
        zTree.addTreeSelectionListener( new TreeSelectionListener()
        {
            @Override public void selected( Object pSelected )
            {
                System.out.println( "Tree Selected: " + pSelected );
            }
        } );
        zTree.addTreeOpenCloseListener( new TreeOpenCloseListener()
        {
            @Override public void openStateChanged( Boolean pOpened )
            {
                System.out.println( "Tree Opened: " + pOpened + " - " + zTree.areAnyOpen() );
            }
        } );

        SizeableHorizontalPanel hPanel = new SizeableHorizontalPanel().stretchableHorizontally();
        hPanel.add( zOpenAll );
        hPanel.add( zCloseAll );
        hPanel.add( new Spacer( 10 ) );
        hPanel.add( new Label( "Some Text" ) );
        hPanel.add( Button.named( "Add" ).blue().text().add( new ClickHandler()
        {
            @Override public void onClick( ClickEvent event )
            {
                addTo( zTree );
            }
        } ).create() );
        hPanel.add( Button.named( "Remove" ).blue().text(  ).add( new ClickHandler()
        {
            @Override public void onClick( ClickEvent event )
            {
                if ( !zTree.isEmpty() )
                {
                    Object zUserObject = zTree.getSelected();
                    if ( zUserObject == null )
                    {
                        zUserObject = zTree.iterator().next();
                    }
                    zTree.removeDescendant( zUserObject );
                }
            }
        } ).create() );
        hPanel.add( Button.named( "Remove1st" ).blue().text(  ).add( new ClickHandler()
        {
            @Override public void onClick( ClickEvent event )
            {
                if ( !zTree.isEmpty() )
                {
                    Object zUserObject = zTree.iterator().next();
                    zTree.removeChild( zUserObject );
                }
            }
        } ).create() );

        SizeableVerticalPanel vPanel = new SizeableVerticalPanel().stretchable();
        vPanel.add( hPanel );
        vPanel.add( zTree );

        return vPanel;
    }

    private Widget createCurrentTasks()
    {
        return new CurrentTasks();
    }
}

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

Diff revisions: vs.
Revision Author Commited Message
162 GeorgeS picture GeorgeS Fri 01 Apr, 2011 19:58:40 +0000