Revision 1998 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 | ||
---|---|---|
35 | 35 |
import javax.swing.JComboBox; |
36 | 36 |
import javax.swing.JComponent; |
37 | 37 |
import javax.swing.JLabel; |
38 |
import javax.swing.JSpinner; |
|
38 | 39 |
import javax.swing.JTextField; |
39 | 40 |
import javax.swing.UIManager; |
40 | 41 |
import javax.swing.text.JTextComponent; |
... | ... | |
80 | 81 |
return null; |
81 | 82 |
} |
82 | 83 |
|
84 |
protected JSpinner getJSpinnerField() { |
|
85 |
if (this.contents instanceof JSpinner) { |
|
86 |
return (JSpinner) this.contents; |
|
87 |
} |
|
88 |
return null; |
|
89 |
} |
|
90 |
|
|
83 | 91 |
protected DropDown getDropDown() { |
84 | 92 |
return this.dropDown; |
85 | 93 |
} |
... | ... | |
103 | 111 |
this.dropDown.setModel(new DefaultComboBoxModel(availableValues)); |
104 | 112 |
this.dropDown.setVisibleDropdownArrow(true); |
105 | 113 |
this.contents = label; |
114 |
} else if (theFactory.containsJSpinner(this.getDefinition(), null)) { |
|
115 |
this.contents = this.getComponentsFactory().getJSpinner(this.getDefinition(), null); |
|
116 |
this.dropDown = null; |
|
106 | 117 |
} else if (theFactory.containsJTextField(this.getDefinition(), null)) { |
107 | 118 |
this.contents = theFactory.getJTextField(this.getDefinition(), null); |
108 | 119 |
this.dropDown = null; |
... | ... | |
140 | 151 |
} |
141 | 152 |
this.contents.addFocusListener(this); |
142 | 153 |
this.setReadOnly(readOnly); // Forzamos a actualiza rel estado del component |
143 |
this.setValue(this.assignedValue); |
|
154 |
//component dont have support to set null values |
|
155 |
if (theFactory.containsJSpinner(this.getDefinition(), null) && this.assignedValue==null) { |
|
156 |
this.setValue(0); |
|
157 |
} else { |
|
158 |
this.setValue(this.assignedValue); |
|
159 |
} |
|
144 | 160 |
} |
145 | 161 |
|
146 | 162 |
@Override |
... | ... | |
207 | 223 |
} |
208 | 224 |
} |
209 | 225 |
jtext.setText(s); |
226 |
} else if (this.contents instanceof JSpinner) { |
|
227 |
JSpinner jspinner = this.getJSpinnerField(); |
|
228 |
if (value == null) { |
|
229 |
this.setTranslateEmptyToNull(true); |
|
230 |
value = this.getDefinition().getDefaultValue(); |
|
231 |
if (value != null) { |
|
232 |
jspinner.setValue(value); |
|
233 |
} else { |
|
234 |
jspinner.setValue(121); |
|
235 |
} |
|
236 |
} else { |
|
237 |
this.setTranslateEmptyToNull(false); |
|
238 |
} |
|
239 |
jspinner.setValue(value); |
|
210 | 240 |
} |
211 | 241 |
} else { |
212 |
if( value == null ) {
|
|
242 |
if (value == null) {
|
|
213 | 243 |
this.dropDown.setSelectedIndex(-1); |
214 | 244 |
} else { |
215 | 245 |
ComboBoxModel model = this.dropDown.getModel(); |
Also available in: Unified diff