Revision 24759 branches/v2_0_0_prep/applications/appgvSIG/src/com/iver/cit/gvsig/gui/panels/FPanelCreateField.java

View differences:

FPanelCreateField.java
53 53
import javax.swing.JPanel;
54 54
import javax.swing.JTextField;
55 55

  
56
import org.gvsig.fmap.data.feature.AttributeDescriptor;
57
import org.gvsig.fmap.data.feature.FeatureAttributeDescriptor;
58
import org.gvsig.fmap.data.feature.IsNotAttributeSettingException;
56
import org.gvsig.fmap.dal.DataTypes;
57
import org.gvsig.fmap.dal.feature.EditableFeatureAttributeDescriptor;
59 58
import org.gvsig.gui.beans.AcceptCancelPanel;
60 59

  
61 60
import com.iver.andami.PluginServices;
......
173 172
		if (jCboFieldType == null) {
174 173
			jCboFieldType = new JComboBox();
175 174
			jCboFieldType.setBounds(new java.awt.Rectangle(147,52,138,22));
176
			jCboFieldType.addItem(FeatureAttributeDescriptor.TYPE_BOOLEAN);
177
			jCboFieldType.addItem(FeatureAttributeDescriptor.TYPE_DATE);
178
			jCboFieldType.addItem(FeatureAttributeDescriptor.TYPE_INT);
179
			jCboFieldType.addItem(FeatureAttributeDescriptor.TYPE_DOUBLE);
180
			jCboFieldType.addItem(FeatureAttributeDescriptor.TYPE_STRING);
175
			jCboFieldType.addItem(DataTypes.TYPE_NAMES[DataTypes.BOOLEAN]);
176
			jCboFieldType.addItem(DataTypes.TYPE_NAMES[DataTypes.DATE]);
177
			jCboFieldType.addItem(DataTypes.TYPE_NAMES[DataTypes.INT]);
178
			jCboFieldType.addItem(DataTypes.TYPE_NAMES[DataTypes.DOUBLE]);
179
			jCboFieldType.addItem(DataTypes.TYPE_NAMES[DataTypes.STRING]);
181 180

  
182 181
			jCboFieldType.setSelectedIndex(4);
183 182
			jCboFieldType.addActionListener(new java.awt.event.ActionListener() {
184 183
				public void actionPerformed(java.awt.event.ActionEvent e) {
185 184
					// System.out.println("actionPerformed()" + e.getActionCommand()); // TODO Auto-generated Event stub actionPerformed()
186 185
					String strType = (String) getJCboFieldType().getModel().getSelectedItem();
187
					if (strType == FeatureAttributeDescriptor.TYPE_DOUBLE) {
186
					if (strType == DataTypes.TYPE_NAMES[DataTypes.STRING]) {
188 187
						getJTxtFieldPrecision().setEnabled(true);
189 188
						if (getJTxtFieldPrecision().getText().equals("")){
190 189
							getJTxtFieldPrecision().setText("3");
......
198 197
					}else{
199 198
						getJTxtFieldPrecision().setEnabled(false);
200 199
					}
201
					if (strType == FeatureAttributeDescriptor.TYPE_BOOLEAN)
200
					if (strType == DataTypes.TYPE_NAMES[DataTypes.BOOLEAN])
202 201
					{
203 202
						getJTxtFieldLength().setText("0");
204 203
						getJTxtFieldLength().setEnabled(false);
......
256 255
		return jTxtDefaultValue;
257 256
	}
258 257

  
259
	public void loadFieldDescription(AttributeDescriptor attribute) throws ParseException, IsNotAttributeSettingException
260
	{
258
	public void loadFieldDescription(
259
			EditableFeatureAttributeDescriptor attribute)
260
			throws ParseException {
261 261
		attribute.setName(getJTxtFieldName().getText());
262 262
		String strType = (String) getJCboFieldType().getModel()
263 263
				.getSelectedItem();
264
		attribute.setType(strType);
264
		for (int type = 0; type < DataTypes.TYPE_NAMES.length; type++) {
265
			if (DataTypes.TYPE_NAMES[type] == strType) {
266
				attribute.setDataType(type);
267
				break;
268
			}
269
		}
270

  
265 271
		try {
266 272
			int fieldLength = Integer.parseInt(getJTxtFieldLength().getText());
267 273
			attribute.setSize(fieldLength);
......
269 275
			throw new ParseException(e.getMessage(), 0);
270 276
		}
271 277

  
272
		if (strType == FeatureAttributeDescriptor.TYPE_DOUBLE) {
278
		if (strType == DataTypes.TYPE_NAMES[DataTypes.DOUBLE]) {
273 279
			try {
274 280
				attribute.setPrecision(Integer.parseInt(getJTxtFieldPrecision()
275 281
						.getText()));

Also available in: Unified diff