|
@@ -9,8 +9,7 @@ |
9 |
9 |
|
import com.temp.shared.utils.*; |
10 |
10 |
|
|
11 |
11 |
|
@SuppressWarnings("deprecation") |
12 |
|
- |
public class CompleteInputFieldAccessor<T> extends InputFieldAccessor<T> |
13 |
|
- |
{ |
|
12 |
+ |
public class CompleteInputFieldAccessor<T> extends InputFieldAccessor<T> { |
14 |
13 |
|
private final E13nResolver e13nResolver; |
15 |
14 |
|
private final Widget labelLabel; |
16 |
15 |
|
private final Widget extendedLabel; |
|
@@ -22,9 +21,10 @@ |
22 |
21 |
|
private final boolean anyFocusTracking; |
23 |
22 |
|
private FocusChangedListener focusChangedListener; |
24 |
23 |
|
|
25 |
|
- |
public CompleteInputFieldAccessor( E13nResolver e13nResolver, TextLabel labelLabel, TextLabel extendedLabel, InputFieldAccessor<T> inputFieldAccessor, HelpWidget helpWidget, TextLabel exampleLabel, TextLabel errorLabel, Focusable... additionalFocusables ) |
26 |
|
- |
{ |
27 |
|
- |
super( inputFieldAccessor.getInput(), inputFieldAccessor.getValidator(), inputFieldAccessor.getValueAdapter(), inputFieldAccessor.getInputWidget(), append( inputFieldAccessor.getFocusables(), additionalFocusables ) ); |
|
24 |
+ |
public CompleteInputFieldAccessor( E13nResolver e13nResolver, TextLabel labelLabel, TextLabel extendedLabel, InputFieldAccessor<T> inputFieldAccessor, |
|
25 |
+ |
HelpWidget helpWidget, TextLabel exampleLabel, TextLabel errorLabel, Focusable... additionalFocusables ) { |
|
26 |
+ |
super( inputFieldAccessor.getInput(), inputFieldAccessor.getValidator(), inputFieldAccessor.getValueAdapter(), inputFieldAccessor.getInputWidget(), |
|
27 |
+ |
append( inputFieldAccessor.getFocusables(), additionalFocusables ) ); |
28 |
28 |
|
this.e13nResolver = e13nResolver; |
29 |
29 |
|
this.labelLabel = labelLabel; |
30 |
30 |
|
this.extendedLabel = extendedLabel; |
|
@@ -34,17 +34,13 @@ |
34 |
34 |
|
focusableFocused = new Boolean[focusables.length]; |
35 |
35 |
|
Focusable firstFocusable = null; |
36 |
36 |
|
boolean anyFocusTracking = false; |
37 |
|
- |
for ( int i = 0; i < focusables.length; i++ ) |
38 |
|
- |
{ |
|
37 |
+ |
for ( int i = 0; i < focusables.length; i++ ) { |
39 |
38 |
|
Focusable focusable = focusables[i]; |
40 |
|
- |
if ( focusable != null ) |
41 |
|
- |
{ |
42 |
|
- |
if ( firstFocusable == null ) |
43 |
|
- |
{ |
|
39 |
+ |
if ( focusable != null ) { |
|
40 |
+ |
if ( firstFocusable == null ) { |
44 |
41 |
|
firstFocusable = focusable; |
45 |
42 |
|
} |
46 |
|
- |
if ( registerFocusTracking( i, focusable ) ) |
47 |
|
- |
{ |
|
43 |
+ |
if ( registerFocusTracking( i, focusable ) ) { |
48 |
44 |
|
focusableFocused[i] = false; // Not currently Focused! |
49 |
45 |
|
anyFocusTracking = true; |
50 |
46 |
|
} |
|
@@ -54,53 +50,43 @@ |
54 |
50 |
|
this.anyFocusTracking = anyFocusTracking; |
55 |
51 |
|
} |
56 |
52 |
|
|
57 |
|
- |
private boolean registerFocusTracking( int index, Focusable focusable ) |
58 |
|
- |
{ |
59 |
|
- |
if ( focusable instanceof HasAllFocusHandlers ) |
60 |
|
- |
{ |
|
53 |
+ |
private boolean registerFocusTracking( int index, Focusable focusable ) { |
|
54 |
+ |
if ( focusable instanceof HasAllFocusHandlers ) { |
61 |
55 |
|
createFocusHandler( index, (HasAllFocusHandlers) focusable ); |
62 |
56 |
|
return true; |
63 |
57 |
|
} |
64 |
|
- |
if ( focusable instanceof SourcesFocusEvents ) |
65 |
|
- |
{ |
|
58 |
+ |
if ( focusable instanceof SourcesFocusEvents ) { |
66 |
59 |
|
createFocusListener( index, (SourcesFocusEvents) focusable ); |
67 |
60 |
|
return true; |
68 |
61 |
|
} |
69 |
62 |
|
return false; |
70 |
63 |
|
} |
71 |
64 |
|
|
72 |
|
- |
public E13nResolver getE13nResolver() |
73 |
|
- |
{ |
|
65 |
+ |
public E13nResolver getE13nResolver() { |
74 |
66 |
|
return e13nResolver; |
75 |
67 |
|
} |
76 |
68 |
|
|
77 |
|
- |
public Widget getLabelLabel() |
78 |
|
- |
{ |
|
69 |
+ |
public Widget getLabelLabel() { |
79 |
70 |
|
return labelLabel; |
80 |
71 |
|
} |
81 |
72 |
|
|
82 |
|
- |
public Widget getExtendedLabel() |
83 |
|
- |
{ |
|
73 |
+ |
public Widget getExtendedLabel() { |
84 |
74 |
|
return extendedLabel; |
85 |
75 |
|
} |
86 |
76 |
|
|
87 |
|
- |
public Widget getExampleLabel() |
88 |
|
- |
{ |
|
77 |
+ |
public Widget getExampleLabel() { |
89 |
78 |
|
return exampleLabel; |
90 |
79 |
|
} |
91 |
80 |
|
|
92 |
|
- |
public Widget getErrorLabel() |
93 |
|
- |
{ |
|
81 |
+ |
public Widget getErrorLabel() { |
94 |
82 |
|
return errorLabel; |
95 |
83 |
|
} |
96 |
84 |
|
|
97 |
|
- |
public HelpWidget getHelpWidget() |
98 |
|
- |
{ |
|
85 |
+ |
public HelpWidget getHelpWidget() { |
99 |
86 |
|
return helpWidget; |
100 |
87 |
|
} |
101 |
88 |
|
|
102 |
|
- |
public void init( boolean enabled, FocusChangedListener focusChangedListener ) |
103 |
|
- |
{ |
|
89 |
+ |
public void init( boolean enabled, FocusChangedListener focusChangedListener ) { |
104 |
90 |
|
setEnabled( enabled ); |
105 |
91 |
|
this.focusChangedListener = focusChangedListener; |
106 |
92 |
|
} |
|
@@ -108,18 +94,13 @@ |
108 |
94 |
|
/** |
109 |
95 |
|
* Return if the Field has Focus (or null indicating that the Focus state is not tracked) |
110 |
96 |
|
*/ |
111 |
|
- |
public Boolean isFocused() |
112 |
|
- |
{ |
113 |
|
- |
if ( !anyFocusTracking ) |
114 |
|
- |
{ |
|
97 |
+ |
public Boolean isFocused() { |
|
98 |
+ |
if ( !anyFocusTracking ) { |
115 |
99 |
|
return null; |
116 |
100 |
|
} |
117 |
|
- |
if ( isEnabled() ) |
118 |
|
- |
{ |
119 |
|
- |
for ( Boolean focused : focusableFocused ) |
120 |
|
- |
{ |
121 |
|
- |
if ( Boolean.TRUE.equals( focused ) ) |
122 |
|
- |
{ |
|
101 |
+ |
if ( isEnabled() ) { |
|
102 |
+ |
for ( Boolean focused : focusableFocused ) { |
|
103 |
+ |
if ( Boolean.TRUE.equals( focused ) ) { |
123 |
104 |
|
return true; |
124 |
105 |
|
} |
125 |
106 |
|
} |
|
@@ -130,10 +111,8 @@ |
130 |
111 |
|
/** |
131 |
112 |
|
* Pull the Focus to this Field (return false if the field is "thought" to be currently un-focusable, e.g. has no Focusable components or disabled) |
132 |
113 |
|
*/ |
133 |
|
- |
public boolean setFocused() |
134 |
|
- |
{ |
135 |
|
- |
if ( isEnabled() && (focusable != null) ) |
136 |
|
- |
{ |
|
114 |
+ |
public boolean setFocused() { |
|
115 |
+ |
if ( isEnabled() && (focusable != null) ) { |
137 |
116 |
|
focusable.setFocus( true ); |
138 |
117 |
|
// We "should" get the appropriate events... |
139 |
118 |
|
return true; |
|
@@ -141,74 +120,59 @@ |
141 |
120 |
|
return false; |
142 |
121 |
|
} |
143 |
122 |
|
|
144 |
|
- |
private void focusChange( int index, boolean focused ) |
145 |
|
- |
{ |
146 |
|
- |
if ( focusableFocused[index] != focused ) |
147 |
|
- |
{ |
|
123 |
+ |
private void focusChange( int index, boolean focused ) { |
|
124 |
+ |
if ( focusableFocused[index] != focused ) { |
148 |
125 |
|
focusableFocused[index] = focused; |
149 |
|
- |
if ( focusChangedListener != null ) |
150 |
|
- |
{ |
|
126 |
+ |
if ( focusChangedListener != null ) { |
151 |
127 |
|
focusChangedListener.focusChanged(); |
152 |
128 |
|
} |
153 |
129 |
|
} |
154 |
130 |
|
} |
155 |
131 |
|
|
156 |
|
- |
private void createFocusListener( final int index, SourcesFocusEvents focusable ) |
157 |
|
- |
{ |
158 |
|
- |
focusable.addFocusListener( new FocusListener() |
159 |
|
- |
{ |
|
132 |
+ |
private void createFocusListener( final int index, SourcesFocusEvents focusable ) { |
|
133 |
+ |
focusable.addFocusListener( new FocusListener() { |
160 |
134 |
|
@Override |
161 |
|
- |
public void onFocus( Widget sender ) |
162 |
|
- |
{ |
|
135 |
+ |
public void onFocus( Widget sender ) { |
163 |
136 |
|
focusChange( index, true ); |
164 |
137 |
|
} |
165 |
138 |
|
|
166 |
139 |
|
@Override |
167 |
|
- |
public void onLostFocus( Widget sender ) |
168 |
|
- |
{ |
|
140 |
+ |
public void onLostFocus( Widget sender ) { |
169 |
141 |
|
focusChange( index, false ); |
170 |
142 |
|
} |
171 |
143 |
|
} ); |
172 |
144 |
|
} |
173 |
145 |
|
|
174 |
|
- |
private void createFocusHandler( int index, HasAllFocusHandlers focusable ) |
175 |
|
- |
{ |
|
146 |
+ |
private void createFocusHandler( int index, HasAllFocusHandlers focusable ) { |
176 |
147 |
|
FocusBlurHandler handler = new FocusBlurHandler( index ); |
177 |
148 |
|
focusable.addFocusHandler( handler ); |
178 |
149 |
|
focusable.addBlurHandler( handler ); |
179 |
150 |
|
} |
180 |
151 |
|
|
181 |
152 |
|
private class FocusBlurHandler implements FocusHandler, |
182 |
|
- |
BlurHandler |
183 |
|
- |
{ |
|
153 |
+ |
BlurHandler { |
184 |
154 |
|
private final int index; |
185 |
155 |
|
|
186 |
|
- |
public FocusBlurHandler( int index ) |
187 |
|
- |
{ |
|
156 |
+ |
public FocusBlurHandler( int index ) { |
188 |
157 |
|
this.index = index; |
189 |
158 |
|
} |
190 |
159 |
|
|
191 |
160 |
|
@Override |
192 |
|
- |
public void onFocus( FocusEvent event ) |
193 |
|
- |
{ |
|
161 |
+ |
public void onFocus( FocusEvent event ) { |
194 |
162 |
|
focusChange( index, true ); |
195 |
163 |
|
} |
196 |
164 |
|
|
197 |
165 |
|
@Override |
198 |
|
- |
public void onBlur( BlurEvent event ) |
199 |
|
- |
{ |
|
166 |
+ |
public void onBlur( BlurEvent event ) { |
200 |
167 |
|
focusChange( index, false ); |
201 |
168 |
|
} |
202 |
169 |
|
} |
203 |
170 |
|
|
204 |
|
- |
private static Focusable[] append( Focusable[] focusables1, Focusable[] focusables2 ) |
205 |
|
- |
{ |
206 |
|
- |
if ( CollectionsUtils.isEmpty( focusables2 ) ) |
207 |
|
- |
{ |
|
171 |
+ |
private static Focusable[] append( Focusable[] focusables1, Focusable[] focusables2 ) { |
|
172 |
+ |
if ( CollectionsUtils.isEmpty( focusables2 ) ) { |
208 |
173 |
|
return focusables1; |
209 |
174 |
|
} |
210 |
|
- |
if ( CollectionsUtils.isEmpty( focusables1 ) ) |
211 |
|
- |
{ |
|
175 |
+ |
if ( CollectionsUtils.isEmpty( focusables1 ) ) { |
212 |
176 |
|
return focusables2; |
213 |
177 |
|
} |
214 |
178 |
|
Focusable[] merged = new Focusable[focusables1.length + focusables2.length]; |