litesoft
@ 628
litesoft / trunk / GWT_Sandbox / FormEngine / src / com / temp / client / foundation / widget / input / InputField.java
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 |
package com.temp.client.foundation.widget.input; import com.google.gwt.user.client.ui.*; import com.temp.client.foundation.widget.*; import com.temp.client.foundation.widget.input.fieldsupport.*; import com.temp.shared.*; import com.temp.shared.externalization.*; 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: * * <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> * * ** - 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 HasName, Enableable, 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 ); /** * The 'Builder' to 'Run' state transition method fully constructs/populates the InputField's Widget / container. * <p/> * Only callable ONCE and only in Builder Mode! * * @return this for method chaining */ InputField<T> init( E13nResolver resolver ); // Callable anytime boolean isRunMode(); 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 /** * Reset the value as if <code>setCurrentValue( null )</code> has been called. */ void reset(); /** * 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(); /** * revert to the "Base" value */ void revert(); /** * Return if the Current Value is different than the Base Value */ boolean isChanged(); /** * Return if the Current Value is rejected by any of the ValueValidator(s) */ boolean isErrored(); /** * Validate the Current Value, and "manage" the Error Label appropriately. * <p/> * Error Labels are set to a NBSP & Cloaked when the field is not in Error, and Visible w/ the appropriate E13n data when the field is in Error. * * @return true if <code>isErrored() == false</code>. */ boolean validate(); E13nResolver getE13nResolver(); Widget getInputWidget(); InputWidgetChangeFilter<T> getInput(); InputWidgetValidator<T> getValidator(); Widget getLabelLabel(); Widget getExtendedLabel(); Widget getExampleLabel(); Widget getErrorLabel(); Widget getHelpWidget(); } |