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
package com.temp.client.foundation.widget.input;

import com.google.gwt.user.client.ui.*;
import com.temp.client.foundation.widget.input.fieldsupport.*;
import com.temp.client.foundation.widget.input.support.*;
import com.temp.shared.*;
import com.temp.shared.utils.*;

/**
 * An interface for an Input Field.
 * <p/>
 * Implementation should be able to be used directly or as a widget in a UI Binding file.
 * <p/>
 * It operates in two distinct states:
 * <p/>
 * <li>Builder Mode - Where properties of the final widget are specified (and parts of the widget are NOT accessable)</li>
 * <li>Run Mode - Where the parts of the Widget are accessable (and the specification properties are NOT changeable)</li>
 * <p/>
 * The transition between the states is one way ('Builder' to 'Run') and is a result of the call to 'init'.
 * <p/>
 * An Input Field has the following:
 * <p/>
 * <ul>
 * <li>Name</li>
 * <li>Base Value **,</li>
 * <li>Current Value **,</li>
 * <li>Changed State,</li>
 * <li>Errored State,</li>
 * <li>Enabled State,</li>
 * <li>Visibility State, and</li>
 * <li>Following Widgets:</li>
 * <ol>
 * <li>InputWidget</li>
 * <li>LabelLabel</li>
 * <li>ExtendedLabel</li>
 * <li>ExampleLabel</li>
 * <li>ErrorLabel</li>
 * <li>HelpWidget</li>
 * </ol>
 * </ul>
 * <p/>
 * ** - These values are "normalized" in both directions (to & from the underlying Input Widget(s)).
 * This means that a value set and then fetched may be different (however a value fetched, then set,
 * then fetched should match the original value fetched)! For String based input fields the normalization
 * is that leading and trailing whitespace is ignored and empty strings and nulls are substituted based
 * on direction ("" -> null when fetching from the underlying input widget, and null -> "" when setting
 * into the underlying input widget).  For non-String based input fields the normalization could appear
 * a bit strange, for example: CheckBox input fields will interpret null as false.
 *
 * @param <T> the data type returned by this InputField
 */
public interface InputField<T> extends FormEngineMember, HasName, Visible {
    interface ChangeListener<T2> {
        void changed(InputField<T2> field);
    }

    // Only callable in Builder Mode:

    // For HasName - The Name MUST be set before the call to init (transition to run mode)

    InputField<T> name(String name);

    // Callable anytime:

    InputField<T> add(ChangeListener<T> changeListener);

    boolean remove(ChangeListener<T> changeListener);

    void removeAllChangeListeners();

    ValueValidator<T>[] getValidators();

    InputField<T> add(ValueValidator<T> validator);

    InputField<T> add(ValueValidator<T>... additionalValidators);

    // For Enableable

    InputField<T> enable();

    InputField<T> disable();

    // For Visible

    InputField<T> visible();

    InputField<T> cloak();

    InputField<T> invisible();

    // Only callable in Run Mode:

    /**
     * set the Current value and the "Base" value (the "Base" value is what "change" is determined from).
     * <p/>
     * Note: The value is "normalized" before giving it to the actual Input Widget
     *
     * @param value null OK
     * @return "normalized" round-tripped value (null possible) as if <code>getCurrentValue()</code> was called.
     */
    T setCurrentValue(T value);

    /**
     * Returned the "normalized" Current value.
     *
     * @return null possible
     */
    T getCurrentValue();

    /**
     * Returned the "normalized" Base value.
     *
     * @return null possible
     */
    T getBaseValue();

    Widget getInputWidget();

    InputWidgetChangeFilter<T> getInput();

    InputWidgetValidator<T> getValidator();

    Widget getLabelLabel();

    Widget getExtendedLabel();

    Widget getExampleLabel();

    Widget getErrorLabel();

    Widget getHelpWidget();
}

Commits for litesoft/trunk/GWT_Sandbox/FormEngine/src/com/temp/client/foundation/widget/input/InputField.java

Diff revisions: vs.
Revision Author Commited Message
632 Diff Diff GeorgeS picture GeorgeS Wed 18 Apr, 2012 18:11:29 +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
628 Diff Diff GeorgeS picture GeorgeS Fri 13 Apr, 2012 03:53:33 +0000
626 GeorgeS picture GeorgeS Wed 11 Apr, 2012 19:39:41 +0000