Revision 931 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/AbstractJDynFormFieldWithValueList.java
AbstractJDynFormFieldWithValueList.java | ||
---|---|---|
9 | 9 |
import javax.swing.JTextField; |
10 | 10 |
import javax.swing.text.JTextComponent; |
11 | 11 |
|
12 |
import org.gvsig.tools.dynform.spi.JDynFormField; |
|
12 |
import org.gvsig.tools.dataTypes.CoercionException; |
|
13 |
import org.gvsig.tools.dynform.spi.dynformfield.AbstractJDynFormField.IllegalFieldValue; |
|
14 |
import org.gvsig.tools.dynforms.JDynFormField; |
|
13 | 15 |
import org.gvsig.tools.dynobject.DynObject; |
14 | 16 |
import org.gvsig.tools.dynobject.DynObjectValueItem; |
15 | 17 |
import org.gvsig.tools.dynobject.exception.DynFieldValidateException; |
... | ... | |
93 | 95 |
/* |
94 | 96 |
* M?todos espec?ficos de cada tipo de datos |
95 | 97 |
*/ |
96 |
protected abstract String getDefaultValue(); |
|
98 |
protected String getDefaultValue(){ |
|
99 |
return ""; |
|
100 |
} |
|
97 | 101 |
|
98 |
public abstract Object getValue(); |
|
99 |
|
|
102 |
public Object getValue() { |
|
103 |
Object value = null; |
|
104 |
String s = null; |
|
105 |
if( this.contents instanceof JTextField ) { |
|
106 |
s = this.getJTextField().getText(); |
|
107 |
} else { |
|
108 |
s = this.getJComboBox().getSelectedItem().toString(); |
|
109 |
} |
|
110 |
try { |
|
111 |
value = this.getDefinition().coerce(s); |
|
112 |
} catch (CoercionException e) { |
|
113 |
throw new IllegalFieldValue(this,"Can't convert value '"+s+"' to '"+this.getDefinition().getDataType().getName()+"'."); |
|
114 |
} |
|
115 |
this.problemIndicator().clear(); |
|
116 |
return value; |
|
117 |
} |
|
100 | 118 |
|
101 | 119 |
@SuppressWarnings("unused") |
102 | 120 |
public boolean hasValidValue() { |
Also available in: Unified diff