|
@@ -1,222 +1,222 @@ |
1 |
|
- |
// This Source Code is in the Public Domain per: http://unlicense.org |
2 |
|
- |
package org.litesoft.GWT.client.widgets.nonpublic; |
3 |
|
- |
|
4 |
|
- |
import com.google.gwt.user.client.ui.*; |
5 |
|
- |
|
6 |
|
- |
public abstract class AbstractSizeableTextBoxBase extends AbstractSizeableComposite implements SourcesChangeEvents, |
7 |
|
- |
SourcesClickEvents, |
8 |
|
- |
HasText, |
9 |
|
- |
HasFocus { |
10 |
|
- |
abstract protected TextBoxBase getTextBoxBase(); |
11 |
|
- |
|
12 |
|
- |
private DelegatingKeyboardListenerCollection mKeyboardListeners; |
13 |
|
- |
private DelegatingClickListenerCollection mClickListeners; |
14 |
|
- |
private DelegatingFocusListenerCollection mFocusListeners; |
15 |
|
- |
private DelegatingChangeListenerCollection mChangeListeners; |
16 |
|
- |
|
17 |
|
- |
@Override |
18 |
|
- |
public void addKeyboardListener( KeyboardListener listener ) { |
19 |
|
- |
if ( listener != null ) { |
20 |
|
- |
if ( mKeyboardListeners == null ) { |
21 |
|
- |
mKeyboardListeners = new DelegatingKeyboardListenerCollection( this, getTextBoxBase() ); |
22 |
|
- |
} |
23 |
|
- |
mKeyboardListeners.add( listener ); |
24 |
|
- |
} |
25 |
|
- |
} |
26 |
|
- |
|
27 |
|
- |
@Override |
28 |
|
- |
public void removeKeyboardListener( KeyboardListener listener ) { |
29 |
|
- |
if ( (listener != null) && (mKeyboardListeners != null) && // |
30 |
|
- |
mKeyboardListeners.remove( listener ) && mKeyboardListeners.isEmpty() ) { |
31 |
|
- |
getTextBoxBase().removeKeyboardListener( mKeyboardListeners ); |
32 |
|
- |
mKeyboardListeners = null; |
33 |
|
- |
} |
34 |
|
- |
} |
35 |
|
- |
|
36 |
|
- |
@Override |
37 |
|
- |
public void addClickListener( ClickListener listener ) { |
38 |
|
- |
if ( listener != null ) { |
39 |
|
- |
if ( mClickListeners == null ) { |
40 |
|
- |
mClickListeners = new DelegatingClickListenerCollection( this, getTextBoxBase() ); |
41 |
|
- |
} |
42 |
|
- |
mClickListeners.add( listener ); |
43 |
|
- |
} |
44 |
|
- |
} |
45 |
|
- |
|
46 |
|
- |
@Override |
47 |
|
- |
public void removeClickListener( ClickListener listener ) { |
48 |
|
- |
if ( (listener != null) && (mClickListeners != null) && // |
49 |
|
- |
mClickListeners.remove( listener ) && mClickListeners.isEmpty() ) { |
50 |
|
- |
getTextBoxBase().removeClickListener( mClickListeners ); |
51 |
|
- |
mClickListeners = null; |
52 |
|
- |
} |
53 |
|
- |
} |
54 |
|
- |
|
55 |
|
- |
@Override |
56 |
|
- |
public void addFocusListener( FocusListener listener ) { |
57 |
|
- |
if ( listener != null ) { |
58 |
|
- |
if ( mFocusListeners == null ) { |
59 |
|
- |
mFocusListeners = new DelegatingFocusListenerCollection( this, getTextBoxBase() ); |
60 |
|
- |
} |
61 |
|
- |
mFocusListeners.add( listener ); |
62 |
|
- |
} |
63 |
|
- |
} |
64 |
|
- |
|
65 |
|
- |
@Override |
66 |
|
- |
public void removeFocusListener( FocusListener listener ) { |
67 |
|
- |
if ( (listener != null) && (mFocusListeners != null) && // |
68 |
|
- |
mFocusListeners.remove( listener ) && mFocusListeners.isEmpty() ) { |
69 |
|
- |
getTextBoxBase().removeFocusListener( mFocusListeners ); |
70 |
|
- |
mFocusListeners = null; |
71 |
|
- |
} |
72 |
|
- |
} |
73 |
|
- |
|
74 |
|
- |
@Override |
75 |
|
- |
public void addChangeListener( ChangeListener listener ) { |
76 |
|
- |
if ( listener != null ) { |
77 |
|
- |
if ( mChangeListeners == null ) { |
78 |
|
- |
mChangeListeners = new DelegatingChangeListenerCollection( this, getTextBoxBase() ); |
79 |
|
- |
} |
80 |
|
- |
mChangeListeners.add( listener ); |
81 |
|
- |
} |
82 |
|
- |
} |
83 |
|
- |
|
84 |
|
- |
@Override |
85 |
|
- |
public void removeChangeListener( ChangeListener listener ) { |
86 |
|
- |
if ( (listener != null) && (mChangeListeners != null) && // |
87 |
|
- |
mChangeListeners.remove( listener ) && mChangeListeners.isEmpty() ) { |
88 |
|
- |
getTextBoxBase().removeChangeListener( mChangeListeners ); |
89 |
|
- |
mChangeListeners = null; |
90 |
|
- |
} |
91 |
|
- |
} |
92 |
|
- |
|
93 |
|
- |
/** |
94 |
|
- |
* Selects all of the text in the box. |
95 |
|
- |
*/ |
96 |
|
- |
public void selectAll() { |
97 |
|
- |
getTextBoxBase().selectAll(); |
98 |
|
- |
} |
99 |
|
- |
|
100 |
|
- |
/** |
101 |
|
- |
* Sets the cursor position. |
102 |
|
- |
* |
103 |
|
- |
* @param pos the new cursor position |
104 |
|
- |
*/ |
105 |
|
- |
public void setCursorPos( int pos ) { |
106 |
|
- |
getTextBoxBase().setCursorPos( pos ); |
107 |
|
- |
} |
108 |
|
- |
|
109 |
|
- |
/** |
110 |
|
- |
* If a keyboard event is currently being handled by the text box, this method |
111 |
|
- |
* replaces the unicode character or key code associated with it. This allows |
112 |
|
- |
* listeners to easily filter keyboard input. |
113 |
|
- |
* |
114 |
|
- |
* @param key the new key value |
115 |
|
- |
*/ |
116 |
|
- |
public void setKey( char key ) { |
117 |
|
- |
getTextBoxBase().setKey( key ); |
118 |
|
- |
} |
119 |
|
- |
|
120 |
|
- |
public void setName( String name ) { |
121 |
|
- |
getTextBoxBase().setName( name ); |
122 |
|
- |
} |
123 |
|
- |
|
124 |
|
- |
/** |
125 |
|
- |
* Sets the range of text to be selected. |
126 |
|
- |
* |
127 |
|
- |
* @param pos the position of the first character to be selected |
128 |
|
- |
* @param length the number of characters to be selected |
129 |
|
- |
*/ |
130 |
|
- |
public void setSelectionRange( int pos, int length ) { |
131 |
|
- |
getTextBoxBase().setSelectionRange( pos, length ); |
132 |
|
- |
} |
133 |
|
- |
|
134 |
|
- |
@Override |
135 |
|
- |
public void setText( String text ) { |
136 |
|
- |
getTextBoxBase().setText( text ); |
137 |
|
- |
} |
138 |
|
- |
|
139 |
|
- |
/** |
140 |
|
- |
* If a keyboard event is currently being handled on this text box, calling |
141 |
|
- |
* this method will suppress it. This allows listeners to easily filter |
142 |
|
- |
* keyboard input. |
143 |
|
- |
*/ |
144 |
|
- |
public void cancelKey() { |
145 |
|
- |
getTextBoxBase().cancelKey(); |
146 |
|
- |
} |
147 |
|
- |
|
148 |
|
- |
/** |
149 |
|
- |
* Gets the current position of the cursor (this also serves as the beginning |
150 |
|
- |
* of the text selection). |
151 |
|
- |
* |
152 |
|
- |
* @return the cursor's position |
153 |
|
- |
*/ |
154 |
|
- |
public int getCursorPos() { |
155 |
|
- |
return getTextBoxBase().getCursorPos(); |
156 |
|
- |
} |
157 |
|
- |
|
158 |
|
- |
public String getName() { |
159 |
|
- |
return getTextBoxBase().getName(); |
160 |
|
- |
} |
161 |
|
- |
|
162 |
|
- |
/** |
163 |
|
- |
* Gets the text currently selected within this text box. |
164 |
|
- |
* |
165 |
|
- |
* @return the selected text, or an empty string if none is selected |
166 |
|
- |
*/ |
167 |
|
- |
public String getSelectedText() { |
168 |
|
- |
return getTextBoxBase().getSelectedText(); |
169 |
|
- |
} |
170 |
|
- |
|
171 |
|
- |
/** |
172 |
|
- |
* Gets the length of the current text selection. |
173 |
|
- |
* |
174 |
|
- |
* @return the text selection length |
175 |
|
- |
*/ |
176 |
|
- |
public int getSelectionLength() { |
177 |
|
- |
return getTextBoxBase().getSelectionLength(); |
178 |
|
- |
} |
179 |
|
- |
|
180 |
|
- |
@Override |
181 |
|
- |
public String getText() { |
182 |
|
- |
return getTextBoxBase().getText(); |
183 |
|
- |
} |
184 |
|
- |
|
185 |
|
- |
public boolean isEnabled() { |
186 |
|
- |
return getTextBoxBase().isEnabled(); |
187 |
|
- |
} |
188 |
|
- |
|
189 |
|
- |
public void setEnabled( boolean enabled ) { |
190 |
|
- |
TextBoxBase zTextBox = getTextBoxBase(); |
191 |
|
- |
|
192 |
|
- |
if ( enabled ) { |
193 |
|
- |
zTextBox.removeStyleName( "DisabledTextArea" ); |
194 |
|
- |
zTextBox.addStyleName( "EnabledTextArea" ); |
195 |
|
- |
} else { |
196 |
|
- |
zTextBox.removeStyleName( "EnabledTextArea" ); |
197 |
|
- |
zTextBox.addStyleName( "DisabledTextArea" ); |
198 |
|
- |
} |
199 |
|
- |
|
200 |
|
- |
zTextBox.setEnabled( enabled ); |
201 |
|
- |
} |
202 |
|
- |
|
203 |
|
- |
@Override |
204 |
|
- |
public int getTabIndex() { |
205 |
|
- |
return getTextBoxBase().getTabIndex(); |
206 |
|
- |
} |
207 |
|
- |
|
208 |
|
- |
@Override |
209 |
|
- |
public void setTabIndex( int index ) { |
210 |
|
- |
getTextBoxBase().setTabIndex( index ); |
211 |
|
- |
} |
212 |
|
- |
|
213 |
|
- |
@Override |
214 |
|
- |
public void setAccessKey( char key ) { |
215 |
|
- |
getTextBoxBase().setAccessKey( key ); |
216 |
|
- |
} |
217 |
|
- |
|
218 |
|
- |
@Override |
219 |
|
- |
public void setFocus( boolean focused ) { |
220 |
|
- |
getTextBoxBase().setFocus( focused ); |
221 |
|
- |
} |
222 |
|
- |
} |
|
1 |
+ |
// This Source Code is in the Public Domain per: http://unlicense.org |
|
2 |
+ |
package org.litesoft.GWT.client.widgets.nonpublic; |
|
3 |
+ |
|
|
4 |
+ |
import com.google.gwt.user.client.ui.*; |
|
5 |
+ |
|
|
6 |
+ |
public abstract class AbstractSizeableTextBoxBase extends AbstractSizeableComposite implements SourcesChangeEvents, |
|
7 |
+ |
SourcesClickEvents, |
|
8 |
+ |
HasText, |
|
9 |
+ |
HasFocus { |
|
10 |
+ |
abstract protected TextBoxBase getTextBoxBase(); |
|
11 |
+ |
|
|
12 |
+ |
private DelegatingKeyboardListenerCollection mKeyboardListeners; |
|
13 |
+ |
private DelegatingClickListenerCollection mClickListeners; |
|
14 |
+ |
private DelegatingFocusListenerCollection mFocusListeners; |
|
15 |
+ |
private DelegatingChangeListenerCollection mChangeListeners; |
|
16 |
+ |
|
|
17 |
+ |
@Override |
|
18 |
+ |
public void addKeyboardListener( KeyboardListener listener ) { |
|
19 |
+ |
if ( listener != null ) { |
|
20 |
+ |
if ( mKeyboardListeners == null ) { |
|
21 |
+ |
mKeyboardListeners = new DelegatingKeyboardListenerCollection( this, getTextBoxBase() ); |
|
22 |
+ |
} |
|
23 |
+ |
mKeyboardListeners.add( listener ); |
|
24 |
+ |
} |
|
25 |
+ |
} |
|
26 |
+ |
|
|
27 |
+ |
@Override |
|
28 |
+ |
public void removeKeyboardListener( KeyboardListener listener ) { |
|
29 |
+ |
if ( (listener != null) && (mKeyboardListeners != null) && // |
|
30 |
+ |
mKeyboardListeners.remove( listener ) && mKeyboardListeners.isEmpty() ) { |
|
31 |
+ |
getTextBoxBase().removeKeyboardListener( mKeyboardListeners ); |
|
32 |
+ |
mKeyboardListeners = null; |
|
33 |
+ |
} |
|
34 |
+ |
} |
|
35 |
+ |
|
|
36 |
+ |
@Override |
|
37 |
+ |
public void addClickListener( ClickListener listener ) { |
|
38 |
+ |
if ( listener != null ) { |
|
39 |
+ |
if ( mClickListeners == null ) { |
|
40 |
+ |
mClickListeners = new DelegatingClickListenerCollection( this, getTextBoxBase() ); |
|
41 |
+ |
} |
|
42 |
+ |
mClickListeners.add( listener ); |
|
43 |
+ |
} |
|
44 |
+ |
} |
|
45 |
+ |
|
|
46 |
+ |
@Override |
|
47 |
+ |
public void removeClickListener( ClickListener listener ) { |
|
48 |
+ |
if ( (listener != null) && (mClickListeners != null) && // |
|
49 |
+ |
mClickListeners.remove( listener ) && mClickListeners.isEmpty() ) { |
|
50 |
+ |
getTextBoxBase().removeClickListener( mClickListeners ); |
|
51 |
+ |
mClickListeners = null; |
|
52 |
+ |
} |
|
53 |
+ |
} |
|
54 |
+ |
|
|
55 |
+ |
@Override |
|
56 |
+ |
public void addFocusListener( FocusListener listener ) { |
|
57 |
+ |
if ( listener != null ) { |
|
58 |
+ |
if ( mFocusListeners == null ) { |
|
59 |
+ |
mFocusListeners = new DelegatingFocusListenerCollection( this, getTextBoxBase() ); |
|
60 |
+ |
} |
|
61 |
+ |
mFocusListeners.add( listener ); |
|
62 |
+ |
} |
|
63 |
+ |
} |
|
64 |
+ |
|
|
65 |
+ |
@Override |
|
66 |
+ |
public void removeFocusListener( FocusListener listener ) { |
|
67 |
+ |
if ( (listener != null) && (mFocusListeners != null) && // |
|
68 |
+ |
mFocusListeners.remove( listener ) && mFocusListeners.isEmpty() ) { |
|
69 |
+ |
getTextBoxBase().removeFocusListener( mFocusListeners ); |
|
70 |
+ |
mFocusListeners = null; |
|
71 |
+ |
} |
|
72 |
+ |
} |
|
73 |
+ |
|
|
74 |
+ |
@Override |
|
75 |
+ |
public void addChangeListener( ChangeListener listener ) { |
|
76 |
+ |
if ( listener != null ) { |
|
77 |
+ |
if ( mChangeListeners == null ) { |
|
78 |
+ |
mChangeListeners = new DelegatingChangeListenerCollection( this, getTextBoxBase() ); |
|
79 |
+ |
} |
|
80 |
+ |
mChangeListeners.add( listener ); |
|
81 |
+ |
} |
|
82 |
+ |
} |
|
83 |
+ |
|
|
84 |
+ |
@Override |
|
85 |
+ |
public void removeChangeListener( ChangeListener listener ) { |
|
86 |
+ |
if ( (listener != null) && (mChangeListeners != null) && // |
|
87 |
+ |
mChangeListeners.remove( listener ) && mChangeListeners.isEmpty() ) { |
|
88 |
+ |
getTextBoxBase().removeChangeListener( mChangeListeners ); |
|
89 |
+ |
mChangeListeners = null; |
|
90 |
+ |
} |
|
91 |
+ |
} |
|
92 |
+ |
|
|
93 |
+ |
/** |
|
94 |
+ |
* Selects all of the text in the box. |
|
95 |
+ |
*/ |
|
96 |
+ |
public void selectAll() { |
|
97 |
+ |
getTextBoxBase().selectAll(); |
|
98 |
+ |
} |
|
99 |
+ |
|
|
100 |
+ |
/** |
|
101 |
+ |
* Sets the cursor position. |
|
102 |
+ |
* |
|
103 |
+ |
* @param pos the new cursor position |
|
104 |
+ |
*/ |
|
105 |
+ |
public void setCursorPos( int pos ) { |
|
106 |
+ |
getTextBoxBase().setCursorPos( pos ); |
|
107 |
+ |
} |
|
108 |
+ |
|
|
109 |
+ |
/** |
|
110 |
+ |
* If a keyboard event is currently being handled by the text box, this method |
|
111 |
+ |
* replaces the unicode character or key code associated with it. This allows |
|
112 |
+ |
* listeners to easily filter keyboard input. |
|
113 |
+ |
* |
|
114 |
+ |
* @param key the new key value |
|
115 |
+ |
*/ |
|
116 |
+ |
public void setKey( char key ) { |
|
117 |
+ |
getTextBoxBase().setKey( key ); |
|
118 |
+ |
} |
|
119 |
+ |
|
|
120 |
+ |
public void setName( String name ) { |
|
121 |
+ |
getTextBoxBase().setName( name ); |
|
122 |
+ |
} |
|
123 |
+ |
|
|
124 |
+ |
/** |
|
125 |
+ |
* Sets the range of text to be selected. |
|
126 |
+ |
* |
|
127 |
+ |
* @param pos the position of the first character to be selected |
|
128 |
+ |
* @param length the number of characters to be selected |
|
129 |
+ |
*/ |
|
130 |
+ |
public void setSelectionRange( int pos, int length ) { |
|
131 |
+ |
getTextBoxBase().setSelectionRange( pos, length ); |
|
132 |
+ |
} |
|
133 |
+ |
|
|
134 |
+ |
@Override |
|
135 |
+ |
public void setText( String text ) { |
|
136 |
+ |
getTextBoxBase().setText( text ); |
|
137 |
+ |
} |
|
138 |
+ |
|
|
139 |
+ |
/** |
|
140 |
+ |
* If a keyboard event is currently being handled on this text box, calling |
|
141 |
+ |
* this method will suppress it. This allows listeners to easily filter |
|
142 |
+ |
* keyboard input. |
|
143 |
+ |
*/ |
|
144 |
+ |
public void cancelKey() { |
|
145 |
+ |
getTextBoxBase().cancelKey(); |
|
146 |
+ |
} |
|
147 |
+ |
|
|
148 |
+ |
/** |
|
149 |
+ |
* Gets the current position of the cursor (this also serves as the beginning |
|
150 |
+ |
* of the text selection). |
|
151 |
+ |
* |
|
152 |
+ |
* @return the cursor's position |
|
153 |
+ |
*/ |
|
154 |
+ |
public int getCursorPos() { |
|
155 |
+ |
return getTextBoxBase().getCursorPos(); |
|
156 |
+ |
} |
|
157 |
+ |
|
|
158 |
+ |
public String getName() { |
|
159 |
+ |
return getTextBoxBase().getName(); |
|
160 |
+ |
} |
|
161 |
+ |
|
|
162 |
+ |
/** |
|
163 |
+ |
* Gets the text currently selected within this text box. |
|
164 |
+ |
* |
|
165 |
+ |
* @return the selected text, or an empty string if none is selected |
|
166 |
+ |
*/ |
|
167 |
+ |
public String getSelectedText() { |
|
168 |
+ |
return getTextBoxBase().getSelectedText(); |
|
169 |
+ |
} |
|
170 |
+ |
|
|
171 |
+ |
/** |
|
172 |
+ |
* Gets the length of the current text selection. |
|
173 |
+ |
* |
|
174 |
+ |
* @return the text selection length |
|
175 |
+ |
*/ |
|
176 |
+ |
public int getSelectionLength() { |
|
177 |
+ |
return getTextBoxBase().getSelectionLength(); |
|
178 |
+ |
} |
|
179 |
+ |
|
|
180 |
+ |
@Override |
|
181 |
+ |
public String getText() { |
|
182 |
+ |
return getTextBoxBase().getText(); |
|
183 |
+ |
} |
|
184 |
+ |
|
|
185 |
+ |
public boolean isEnabled() { |
|
186 |
+ |
return getTextBoxBase().isEnabled(); |
|
187 |
+ |
} |
|
188 |
+ |
|
|
189 |
+ |
public void setEnabled( boolean enabled ) { |
|
190 |
+ |
TextBoxBase zTextBox = getTextBoxBase(); |
|
191 |
+ |
|
|
192 |
+ |
if ( enabled ) { |
|
193 |
+ |
zTextBox.removeStyleName( "DisabledTextArea" ); |
|
194 |
+ |
zTextBox.addStyleName( "EnabledTextArea" ); |
|
195 |
+ |
} else { |
|
196 |
+ |
zTextBox.removeStyleName( "EnabledTextArea" ); |
|
197 |
+ |
zTextBox.addStyleName( "DisabledTextArea" ); |
|
198 |
+ |
} |
|
199 |
+ |
|
|
200 |
+ |
zTextBox.setEnabled( enabled ); |
|
201 |
+ |
} |
|
202 |
+ |
|
|
203 |
+ |
@Override |
|
204 |
+ |
public int getTabIndex() { |
|
205 |
+ |
return getTextBoxBase().getTabIndex(); |
|
206 |
+ |
} |
|
207 |
+ |
|
|
208 |
+ |
@Override |
|
209 |
+ |
public void setTabIndex( int index ) { |
|
210 |
+ |
getTextBoxBase().setTabIndex( index ); |
|
211 |
+ |
} |
|
212 |
+ |
|
|
213 |
+ |
@Override |
|
214 |
+ |
public void setAccessKey( char key ) { |
|
215 |
+ |
getTextBoxBase().setAccessKey( key ); |
|
216 |
+ |
} |
|
217 |
+ |
|
|
218 |
+ |
@Override |
|
219 |
+ |
public void setFocus( boolean focused ) { |
|
220 |
+ |
getTextBoxBase().setFocus( focused ); |
|
221 |
+ |
} |
|
222 |
+ |
} |