Revision 11726

View differences:

branches/v10/applications/appgvSIG/src/com/iver/cit/gvsig/project/documents/table/gui/DlgFieldManager.java
68 68

  
69 69
import com.hardcode.driverManager.DriverLoadException;
70 70
import com.hardcode.gdbms.engine.data.driver.DriverException;
71
import com.hardcode.gdbms.engine.values.ValueFactory;
71 72
import com.iver.andami.PluginServices;
72 73
import com.iver.andami.messages.NotificationManager;
73 74
import com.iver.andami.ui.mdiManager.IWindow;
......
77 78
import com.iver.cit.gvsig.fmap.edition.EditionException;
78 79
import com.iver.cit.gvsig.fmap.edition.IEditableSource;
79 80
import com.iver.cit.gvsig.gui.panels.FPanelCreateField;
81
import com.iver.utiles.NumberUtilities;
80 82

  
81 83
public class DlgFieldManager extends JPanel implements IWindow {
82 84

  
......
463 465
									JOptionPane.showMessageDialog(DlgFieldManager.this, PluginServices.getText(this, "max_length_is") + ":" + MAX_FIELD_LENGTH);
464 466
									fld.setFieldLength(MAX_FIELD_LENGTH);
465 467
								}
468
								if (NumberUtilities.isNumeric(fld.getFieldType())){									
469
									try{
470
										Double.parseDouble(fld.getDefaultValue().toString().trim());
471
									} catch (NumberFormatException e1){
472
										if (fld.getDefaultValue().toString().trim().equals("")){
473
											fld.setDefaultValue(ValueFactory.createNullValue());
474
										} else {
475
											fld.setDefaultValue(ValueFactory.createValueByType("0",fld.getFieldType()));
476
										}
477
									}
478
								}
466 479

  
467 480
								if (edAdapter.getRecordset().getFieldIndexByName(fld.getFieldAlias()) != -1)
468 481
								{
branches/v10/applications/appgvSIG/src/com/iver/cit/gvsig/gui/panels/FPanelCreateField.java
185 185
					// System.out.println("actionPerformed()" + e.getActionCommand()); // TODO Auto-generated Event stub actionPerformed()
186 186
					String strType = (String) getJCboFieldType().getModel().getSelectedItem();
187 187
					int fieldType = FieldDescription.stringToType(strType);
188
					getJTxtFieldPrecision().setEnabled((fieldType == Types.DOUBLE));
188
					if (fieldType == Types.DOUBLE) {
189
						getJTxtFieldPrecision().setEnabled(true);
190
						if (getJTxtFieldPrecision().getText().equals("")){
191
							getJTxtFieldPrecision().setText("3");
192
						} else {
193
							try {
194
								Integer.parseInt(getJTxtFieldPrecision().getText());
195
							} catch (NumberFormatException e1){
196
								getJTxtFieldPrecision().setText("3");
197
							}
198
						}
199
					}else{
200
						getJTxtFieldPrecision().setEnabled(false);
201
					}
189 202
					if (fieldType == Types.BOOLEAN)
190 203
					{
191 204
						getJTxtFieldLength().setText("0");
......
260 273

  
261 274
		if (fieldType == Types.DOUBLE)
262 275
		{
263
			newField.setFieldDecimalCount(
264
					Integer.parseInt(
265
							getJTxtFieldPrecision().getText()));
276
			try {
277
				newField.setFieldDecimalCount(
278
						Integer.parseInt(
279
								getJTxtFieldPrecision().getText()));
280
			} catch (NumberFormatException e){
281
				newField.setFieldDecimalCount(3);
282
			}
266 283
		}
267 284
		else
268 285
			newField.setFieldDecimalCount(0);
......
363 380

  
364 381
	public void setCurrentFieldNames(String[] fieldNames) {
365 382
		currentFieldNames = fieldNames;
366
		String newField = PluginServices.getText(this, "new_field").replaceAll(" +", "_");
383
		String newField = PluginServices.getText(this, "field").replaceAll(" +", "_");
367 384
		int index=0;
368 385
		for (int i = 0; i < currentFieldNames.length; i++) {
369 386
			if (currentFieldNames[i].startsWith(newField)) {

Also available in: Unified diff