Revision 583
org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.swing/org.gvsig.tools.swing.serv/org.gvsig.tools.swing.serv.field/src/main/java/org/gvsig/tools/swing/serv/field/component/date/JNullValueMuttableTextFieldComponent.java | ||
---|---|---|
198 | 198 |
} |
199 | 199 |
|
200 | 200 |
public Object getTextFieldValue() { |
201 |
if (this.textField.isVisible()) { |
|
202 |
return null; |
|
203 |
} |
|
204 | 201 |
return this.editor.getTextFieldValue(); |
205 | 202 |
} |
206 | 203 |
|
... | ... | |
214 | 211 |
} |
215 | 212 |
|
216 | 213 |
/** |
214 |
* Sets the appropiate components properties for when the value is not null. |
|
215 |
*/ |
|
216 |
private void setNonEmptyValue(Object value) { |
|
217 |
|
|
218 |
this.editor.setTextFieldValue(value); |
|
219 |
getJSpinner().setValue(this.editor.getTextFieldValue()); |
|
220 |
getJSpinner().requestFocus(); |
|
221 |
getJSpinner().setVisible(true); |
|
222 |
|
|
223 |
fireValueChangedEvent(); |
|
224 |
|
|
225 |
} |
|
226 |
|
|
227 |
/** |
|
217 | 228 |
* Inits the main graphic user interface |
218 | 229 |
*/ |
219 | 230 |
private void initUI() { |
... | ... | |
263 | 274 |
// this.value = null; |
264 | 275 |
|
265 | 276 |
this.editor.setTextFieldValue(null); |
266 |
|
|
267 |
getJSpinner().setVisible(false); |
|
268 |
this.textField.setVisible(true); |
|
269 |
fireValueChangedEvent(); |
|
270 |
|
|
271 | 277 |
} |
272 | 278 |
|
273 | 279 |
/** |
274 |
* Sets the appropiate components properties for when the value is not null. |
|
275 |
*/ |
|
276 |
private void setNonEmptyValue(Object value) { |
|
277 |
// this.editor.setText(value); |
|
278 |
// this.value = editor.getValue(); |
|
279 |
getJSpinner().setValue(value); |
|
280 |
// this.value = getJSpinner().getValue(); |
|
281 |
|
|
282 |
this.textField.setVisible(false); |
|
283 |
getJSpinner().setVisible(true); |
|
284 |
getJSpinner().requestFocus(); |
|
285 |
|
|
286 |
fireValueChangedEvent(); |
|
287 |
|
|
288 |
} |
|
289 |
|
|
290 |
/** |
|
291 | 280 |
* Sets a value if it is not readonly. |
292 | 281 |
* |
293 | 282 |
* @param value |
... | ... | |
302 | 291 |
} else { |
303 | 292 |
setNonEmptyValue(value); |
304 | 293 |
} |
294 |
|
|
295 |
boolean hasValue = (this.getValue() != null); |
|
296 |
this.textField.setVisible(!hasValue); |
|
297 |
getJSpinner().setVisible(hasValue); |
|
298 |
|
|
299 |
fireValueChangedEvent(); |
|
305 | 300 |
} |
306 | 301 |
|
307 | 302 |
public JNullValueMuttableTextFieldComponent getModel() { |
... | ... | |
322 | 317 |
} |
323 | 318 |
|
324 | 319 |
public void focusGained(FocusEvent arg0) { |
320 |
Object value = getValue(); |
|
321 |
if (value == null) { |
|
322 |
this.setValue(null); |
|
323 |
} |
|
325 | 324 |
} |
326 | 325 |
|
327 | 326 |
public void focusLost(FocusEvent arg0) { |
327 |
setValue(getValue()); |
|
328 | 328 |
fireValueChangedEvent(); |
329 | 329 |
} |
330 | 330 |
|
Also available in: Unified diff