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
package org.litesoft.sampleapplication.sampleApplication.client;

import com.google.gwt.core.client.*;
import com.google.gwt.event.dom.client.*;
import com.google.gwt.user.client.ui.*;
import com.temp.client.foundation.widget.NameToID;
import com.temp.client.foundation.widget.input.*;
import com.temp.shared.externalization.*;
import com.temp.shared.utils.*;
import com.temp.shared.validators.*;

public class SampleApplication implements EntryPoint
{
    private TemplateSourceE13nResolver resolver = new TemplateSourceE13nResolver(new TemplateSource() {
        @Override
        public String get(String key) {
            System.out.println("Template Get: " + key);
            return null;
        }

        @Override
        public String get(String key, String defaultValue) {
            return StringUtils.deNull(get(key), defaultValue);
        }
    });

    enum Options {Red, Green, Blue}

    public void onModuleLoad()
    {
        final TextInputField tif = new TextInputField().maxLength( 9 ).required().extendedLabel().example().errorLabel().helpLink( "XX#YY" ).name( "Fred" );
        tif.add( IdentifierValueValidator.INSTANCE );
        complete(tif);

        final OptionBoxInputField<Options> obif = new OptionBoxInputField<Options>().required().labelPosition(LabelPosition.Top).errorLabel().helpLink( "XX#YY" ).name( "Wilma" ).addNullOptional();
        complete(obif.addOptions(Options.values()));

        final CheckBoxInputField cbif = new CheckBoxInputField().helpLink( "XX#YY" ).labelPosition(LabelPosition.Right).name( "Pebbles" );
        complete(cbif);

        Button buttonSetValue = new Button( "Set Value", new ClickHandler()
        {
            public void onClick( ClickEvent event )
            {
                tif.setCurrentValue( tif.getCurrentValue() );
                System.out.println( "Set Value!" );
            }
        } );
        Button buttonSetValueAsUser = new Button( "User Set Value", new ClickHandler()
        {
            public void onClick( ClickEvent event )
            {
                tif.getInput().setValueAsUser( tif.getCurrentValue() + "!" );
                System.out.println( "User Set Value!" );
            }
        } );
        Button buttonValidate = new Button( "Validate", new ClickHandler()
        {
            public void onClick( ClickEvent event )
            {
                tif.validate();
                obif.validate();
                cbif.validate();
            }
        } );

        VerticalPanel zVPanel = new VerticalPanel();
        zVPanel.add( new HTML( "&nbsp;" ) );
        zVPanel.add( horizontalWithSpacers( tif, new HTML( "&nbsp;" ), obif , new HTML( "&nbsp;" ), cbif ) );
        zVPanel.add( new HTML( "&nbsp;" ) );
        zVPanel.add( horizontalWithSpacers( buttonSetValue, buttonSetValueAsUser, buttonValidate ) );

        RootPanel zRootPanel = RootPanel.get( "centeredWidget" );
        zRootPanel.add( zVPanel );
    }

    private <T> void complete(InputField<T> inputField) {
        inputField.init(resolver);

        inputField.addNamedWidgetsTo(new NameToID()).applyIDs();

        inputField.add(new InputField.ChangeListener<T>() {
            @Override
            public void changed(InputField<T> field) {
                T value = field.getCurrentValue();
                System.out.println("Change ("+field.getName()+"): " + field.isChanged() + " '" + value + "' | " + field.getValidator().getErrorData());
                if ("OK".equals(value)) {
                    field.setCurrentValue(value);
                }
            }
        });
    }

    private HorizontalPanel horizontalWithSpacers( IsWidget... widgets )
    {
        HorizontalPanel zPanel = new HorizontalPanel();
        zPanel.add( widgets[0] );
        for ( int i = 1; i < widgets.length; i++ )
        {
            zPanel.add( new HTML( "&nbsp;&nbsp;" ) );
            zPanel.add( widgets[i] );
        }
        return zPanel;
    }
}

Commits for litesoft/trunk/GWT_Sandbox/FormEngine/src/org/litesoft/sampleapplication/sampleApplication/client/SampleApplication.java

Diff revisions: vs.
Revision Author Commited Message
631 Diff Diff GeorgeS picture GeorgeS Tue 17 Apr, 2012 23:24:54 +0000
630 Diff Diff GeorgeS picture GeorgeS Tue 17 Apr, 2012 20:22:17 +0000
629 Diff Diff GeorgeS picture GeorgeS Tue 17 Apr, 2012 05:47:55 +0000
626 Diff Diff GeorgeS picture GeorgeS Wed 11 Apr, 2012 19:39:41 +0000
601 Diff Diff GeorgeS picture GeorgeS Wed 08 Feb, 2012 01:52:17 +0000
600 Diff Diff GeorgeS picture GeorgeS Sun 05 Feb, 2012 18:55:58 +0000

Sync-n

595 Diff Diff GeorgeS picture GeorgeS Sat 21 Jan, 2012 16:54:12 +0000
594 Diff Diff GeorgeS picture GeorgeS Sat 21 Jan, 2012 00:40:54 +0000
592 Diff Diff GeorgeS picture GeorgeS Fri 20 Jan, 2012 20:23:50 +0000
590 GeorgeS picture GeorgeS Thu 19 Jan, 2012 23:33:20 +0000

New FormEngine