|
@@ -1,13 +1,11 @@ |
1 |
1 |
|
package com.temp.client.foundation.widget.input.fieldsupport; |
2 |
2 |
|
|
3 |
|
- |
import com.google.gwt.user.client.ui.HasEnabled; |
4 |
|
- |
import com.google.gwt.user.client.ui.Panel; |
5 |
|
- |
import com.temp.client.foundation.util.UtilsGwt; |
6 |
|
- |
import com.temp.client.foundation.widget.input.InputField; |
7 |
|
- |
import com.temp.shared.utils.ObjectUtils; |
|
3 |
+ |
import com.google.gwt.user.client.ui.*; |
|
4 |
+ |
import com.temp.client.foundation.util.*; |
|
5 |
+ |
import com.temp.client.foundation.widget.input.*; |
|
6 |
+ |
import com.temp.shared.utils.*; |
8 |
7 |
|
|
9 |
|
- |
import java.util.HashSet; |
10 |
|
- |
import java.util.Set; |
|
8 |
+ |
import java.util.*; |
11 |
9 |
|
|
12 |
10 |
|
/** |
13 |
11 |
|
* Common abstract helper for both the generated Widget and the Proxied versions of the InputField. |
|
@@ -28,30 +26,30 @@ |
28 |
26 |
|
} |
29 |
27 |
|
|
30 |
28 |
|
@Override |
31 |
|
- |
public final void setVisibility(State visibility) { |
32 |
|
- |
visibility = ObjectUtils.deNull(visibility, State.Visible); |
|
29 |
+ |
public final void setVisibility( State visibility ) { |
|
30 |
+ |
visibility = ObjectUtils.deNull( visibility, State.Visible ); |
33 |
31 |
|
Panel container = getContainer(); |
34 |
|
- |
if (container != null) { |
|
32 |
+ |
if ( container != null ) { |
35 |
33 |
|
this.visibility = visibility; |
36 |
|
- |
container.setVisible(visibility != State.Invisible); |
37 |
|
- |
UtilsGwt.setHidden(container, visibility == State.Cloaked); |
|
34 |
+ |
container.setVisible( visibility != State.Invisible ); |
|
35 |
+ |
UtilsGwt.setHidden( container, visibility == State.Cloaked ); |
38 |
36 |
|
} |
39 |
37 |
|
} |
40 |
38 |
|
|
41 |
39 |
|
// Configuration Methods |
42 |
40 |
|
|
43 |
41 |
|
@Override |
44 |
|
- |
public final InputField<T> add(FocusChangedListener focusChangedListener) { |
|
42 |
+ |
public final InputField<T> add( FocusChangedListener focusChangedListener ) { |
45 |
43 |
|
|
46 |
|
- |
if (focusChangedListener != null) { |
47 |
|
- |
focusChangeListeners.add(focusChangedListener); |
|
44 |
+ |
if ( focusChangedListener != null ) { |
|
45 |
+ |
focusChangeListeners.add( focusChangedListener ); |
48 |
46 |
|
} |
49 |
47 |
|
return this; |
50 |
48 |
|
} |
51 |
49 |
|
|
52 |
50 |
|
@Override |
53 |
|
- |
public final boolean remove(FocusChangedListener focusChangedListener) { |
54 |
|
- |
return (focusChangedListener == null) ? false : focusChangeListeners.remove(focusChangedListener); |
|
51 |
+ |
public final boolean remove( FocusChangedListener focusChangedListener ) { |
|
52 |
+ |
return (focusChangedListener == null) ? false : focusChangeListeners.remove( focusChangedListener ); |
55 |
53 |
|
} |
56 |
54 |
|
|
57 |
55 |
|
@Override |
|
@@ -60,16 +58,16 @@ |
60 |
58 |
|
} |
61 |
59 |
|
|
62 |
60 |
|
@Override |
63 |
|
- |
public final InputField<T> add(ChangeListener<T> changeListener) { |
64 |
|
- |
if (changeListener != null) { |
65 |
|
- |
changeListeners.add(changeListener); |
|
61 |
+ |
public final InputField<T> add( ChangeListener<T> changeListener ) { |
|
62 |
+ |
if ( changeListener != null ) { |
|
63 |
+ |
changeListeners.add( changeListener ); |
66 |
64 |
|
} |
67 |
65 |
|
return this; |
68 |
66 |
|
} |
69 |
67 |
|
|
70 |
68 |
|
@Override |
71 |
|
- |
public final boolean remove(ChangeListener<T> changeListener) { |
72 |
|
- |
return (changeListener == null) ? false : changeListeners.remove(changeListener); |
|
69 |
+ |
public final boolean remove( ChangeListener<T> changeListener ) { |
|
70 |
+ |
return (changeListener == null) ? false : changeListeners.remove( changeListener ); |
73 |
71 |
|
} |
74 |
72 |
|
|
75 |
73 |
|
@Override |
|
@@ -90,23 +88,23 @@ |
90 |
88 |
|
} |
91 |
89 |
|
|
92 |
90 |
|
@Override |
93 |
|
- |
public final void setEnabled(boolean enable) { |
|
91 |
+ |
public final void setEnabled( boolean enable ) { |
94 |
92 |
|
enabled = enable; |
95 |
93 |
|
HasEnabled enableable = getEnableable(); |
96 |
|
- |
if (enableable != null) { |
97 |
|
- |
enableable.setEnabled(enable); |
|
94 |
+ |
if ( enableable != null ) { |
|
95 |
+ |
enableable.setEnabled( enable ); |
98 |
96 |
|
} |
99 |
97 |
|
} |
100 |
98 |
|
|
101 |
99 |
|
@Override |
102 |
100 |
|
public final InputField<T> enable() { |
103 |
|
- |
setEnabled(true); |
|
101 |
+ |
setEnabled( true ); |
104 |
102 |
|
return this; |
105 |
103 |
|
} |
106 |
104 |
|
|
107 |
105 |
|
@Override |
108 |
106 |
|
public final InputField<T> disable() { |
109 |
|
- |
setEnabled(false); |
|
107 |
+ |
setEnabled( false ); |
110 |
108 |
|
return this; |
111 |
109 |
|
} |
112 |
110 |
|
|
|
@@ -129,67 +127,68 @@ |
129 |
127 |
|
|
130 |
128 |
|
@Override |
131 |
129 |
|
public final InputField<T> visible() { |
132 |
|
- |
setVisibility(State.Visible); |
|
130 |
+ |
setVisibility( State.Visible ); |
133 |
131 |
|
return this; |
134 |
132 |
|
} |
135 |
133 |
|
|
136 |
134 |
|
@Override |
137 |
135 |
|
public final InputField<T> cloak() { |
138 |
|
- |
setVisibility(State.Visible); |
|
136 |
+ |
setVisibility( State.Visible ); |
139 |
137 |
|
return this; |
140 |
138 |
|
} |
141 |
139 |
|
|
142 |
140 |
|
@Override |
143 |
141 |
|
public final InputField<T> invisible() { |
144 |
|
- |
setVisibility(State.Invisible); |
|
142 |
+ |
setVisibility( State.Invisible ); |
145 |
143 |
|
return this; |
146 |
144 |
|
} |
147 |
145 |
|
|
148 |
146 |
|
// Only callable in Run Mode |
149 |
147 |
|
|
150 |
|
- |
protected final void updateStyle(StateInputField state) { |
151 |
|
- |
state = ObjectUtils.deNull(state, StateInputField.BASE); |
152 |
|
- |
if (state != currentStyleState) { |
|
148 |
+ |
protected final void updateStyle( StateInputField state ) { |
|
149 |
+ |
state = ObjectUtils.deNull( state, StateInputField.BASE ); |
|
150 |
+ |
if ( state != currentStyleState ) { |
153 |
151 |
|
Panel panel = getContainer(); |
154 |
|
- |
if (panel != null) { |
155 |
|
- |
if (currentStyleState != null) { |
156 |
|
- |
panel.removeStyleName(currentStyleState.toCSS()); |
|
152 |
+ |
if ( panel != null ) { |
|
153 |
+ |
if ( currentStyleState != null ) { |
|
154 |
+ |
panel.removeStyleName( currentStyleState.toCSS() ); |
157 |
155 |
|
} |
158 |
|
- |
panel.addStyleName(state.toCSS()); |
|
156 |
+ |
panel.addStyleName( state.toCSS() ); |
159 |
157 |
|
} |
160 |
158 |
|
currentStyleState = state; |
161 |
159 |
|
} |
162 |
160 |
|
} |
163 |
161 |
|
|
164 |
162 |
|
protected final void notifyFocusChangeListeners() { |
165 |
|
- |
for (FocusChangedListener zListener : focusChangeListeners) { |
|
163 |
+ |
for ( FocusChangedListener zListener : focusChangeListeners ) { |
166 |
164 |
|
zListener.focusChanged(); |
167 |
165 |
|
} |
168 |
166 |
|
} |
169 |
167 |
|
|
170 |
168 |
|
protected final void notifyChangeListeners() { |
171 |
|
- |
for (ChangeListener<T> zListener : changeListeners) { |
172 |
|
- |
zListener.changed(this); |
|
169 |
+ |
for ( ChangeListener<T> zListener : changeListeners ) { |
|
170 |
+ |
zListener.changed( this ); |
173 |
171 |
|
} |
174 |
172 |
|
} |
175 |
173 |
|
|
176 |
|
- |
protected final void assertBuildMode(String method) { |
177 |
|
- |
assertMode(method, false); |
|
174 |
+ |
protected final void assertBuildMode( String method ) { |
|
175 |
+ |
assertMode( method, false ); |
178 |
176 |
|
} |
179 |
177 |
|
|
180 |
|
- |
protected final void assertRunMode(String method) { |
181 |
|
- |
assertMode(method, true); |
|
178 |
+ |
protected final void assertRunMode( String method ) { |
|
179 |
+ |
assertMode( method, true ); |
182 |
180 |
|
} |
183 |
181 |
|
|
184 |
|
- |
private void assertMode(String method, boolean expectedRunMode) { |
185 |
|
- |
if (isRunMode() != expectedRunMode) { |
186 |
|
- |
throw new IllegalStateException("Unable to access component/method '" + method + "' of InputField Named '" + getName() + // |
187 |
|
- |
(expectedRunMode ? "', because not in Run Mode (init NOT called)" : "', because no longer in Build Mode (init has already been called)")); |
|
182 |
+ |
private void assertMode( String method, boolean expectedRunMode ) { |
|
183 |
+ |
if ( isRunMode() != expectedRunMode ) { |
|
184 |
+ |
throw new IllegalStateException( "Unable to access component/method '" + method + "' of InputField Named '" + getName() + // |
|
185 |
+ |
(expectedRunMode ? "', because not in Run Mode (init NOT called)" : |
|
186 |
+ |
"', because no longer in Build Mode (init has already been called)") ); |
188 |
187 |
|
} |
189 |
188 |
|
} |
190 |
189 |
|
|
191 |
190 |
|
protected final C inheritanceLeaf() { |
192 |
|
- |
return ObjectUtils.cast(this); |
|
191 |
+ |
return ObjectUtils.cast( this ); |
193 |
192 |
|
} |
194 |
193 |
|
|
195 |
194 |
|
abstract protected Panel getContainer(); |