Revision 2487 org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.dynform/org.gvsig.tools.dynform.spi/src/main/java/org/gvsig/tools/dynform/spi/dynformfield/AbstractJDynFormField.java
AbstractJDynFormField.java | ||
---|---|---|
30 | 30 |
import java.util.HashSet; |
31 | 31 |
import java.util.Iterator; |
32 | 32 |
import java.util.List; |
33 |
import java.util.Objects; |
|
33 | 34 |
import java.util.Set; |
34 | 35 |
|
35 | 36 |
import javax.swing.Action; |
36 | 37 |
import javax.swing.JComboBox; |
37 | 38 |
import javax.swing.JComponent; |
38 | 39 |
import javax.swing.JLabel; |
39 |
import javax.swing.JList; |
|
40 | 40 |
import javax.swing.JPanel; |
41 | 41 |
import javax.swing.JScrollPane; |
42 |
import javax.swing.JSpinner; |
|
43 |
import javax.swing.JTextField; |
|
44 | 42 |
import javax.swing.JViewport; |
45 | 43 |
import javax.swing.text.JTextComponent; |
44 |
import org.apache.commons.lang3.StringUtils; |
|
46 | 45 |
import org.gvsig.tools.ToolsLocator; |
47 | 46 |
import org.gvsig.tools.dataTypes.CoercionException; |
48 | 47 |
import org.gvsig.tools.dataTypes.DataTypes; |
... | ... | |
356 | 355 |
if (!this.isReadOnly()) { |
357 | 356 |
Object value = this.getValue(); |
358 | 357 |
if (value == null) { |
359 |
if (value != this.getAssignedValue()) { |
|
358 |
Object x = this.getAssignedValue(); |
|
359 |
if (StringUtils.isNotBlank(Objects.toString(x,null))) { |
|
360 | 360 |
modified = true; |
361 | 361 |
} |
362 | 362 |
} else { |
363 |
if (!value.equals(this.getAssignedValue())) { |
|
363 |
Object x = this.getAssignedValue(); |
|
364 |
if (x instanceof CharSequence){ |
|
365 |
if (!StringUtils.equals((CharSequence) x, value.toString())){ |
|
366 |
modified = true; |
|
367 |
} |
|
368 |
}else if (!value.equals(this.getAssignedValue())) { |
|
364 | 369 |
modified = true; |
365 | 370 |
} |
366 | 371 |
} |
... | ... | |
432 | 437 |
if (this.contents == null) { |
433 | 438 |
return; |
434 | 439 |
} |
435 |
if (this.contents instanceof JTextField) {
|
|
436 |
Object value = this.getDefinition().getDefaultValue();
|
|
437 |
if (value != null) {
|
|
438 |
value = value.toString();
|
|
439 |
} else {
|
|
440 |
value = "";
|
|
441 |
}
|
|
442 |
((JTextField) this.contents).setText((String) value);
|
|
443 |
return;
|
|
444 |
}
|
|
445 |
if (this.contents instanceof JSpinner) {
|
|
446 |
Object value = this.getDefinition().getDefaultValue();
|
|
447 |
if (value==null) { |
|
448 |
((JSpinner) this.contents).setValue(0); |
|
449 |
return; |
|
450 |
} |
|
451 |
((JSpinner) this.contents).setValue(value); |
|
452 |
return; |
|
453 |
} |
|
454 |
if (this.contents instanceof JList) { |
|
455 |
((JList) this.contents).setSelectedIndex(-1); |
|
456 |
return; |
|
457 |
} |
|
458 |
if (this.contents instanceof JComboBox) { |
|
459 |
((JComboBox) this.contents).setSelectedIndex(-1); |
|
460 |
return; |
|
461 |
} |
|
440 |
Object value = this.getDefinition().getDefaultValue();
|
|
441 |
this.setValue(value);
|
|
442 |
// if (this.contents instanceof JTextField) {
|
|
443 |
// if (value != null) {
|
|
444 |
// value = value.toString();
|
|
445 |
// } else {
|
|
446 |
// value = "";
|
|
447 |
// }
|
|
448 |
// ((JTextField) this.contents).setText((String) value);
|
|
449 |
// return;
|
|
450 |
// }
|
|
451 |
// if (this.contents instanceof JSpinner) {
|
|
452 |
// if (value==null) {
|
|
453 |
// ((JSpinner) this.contents).setValue(0);
|
|
454 |
// return;
|
|
455 |
// }
|
|
456 |
// ((JSpinner) this.contents).setValue(value);
|
|
457 |
// return;
|
|
458 |
// }
|
|
459 |
// if (this.contents instanceof JList) {
|
|
460 |
// ((JList) this.contents).setSelectedIndex(-1);
|
|
461 |
// return;
|
|
462 |
// }
|
|
463 |
// if (this.contents instanceof JComboBox) {
|
|
464 |
// ((JComboBox) this.contents).setSelectedIndex(-1);
|
|
465 |
// return;
|
|
466 |
// }
|
|
462 | 467 |
} |
463 | 468 |
|
464 | 469 |
public void setForm(JDynForm form) { |
Also available in: Unified diff