Revision 39125
branches/v2_0_0_prep/extensions/org.gvsig.app.document.table.app/org.gvsig.app.document.table.app.mainplugin/src/main/java/org/gvsig/app/project/documents/table/gui/FeatureTypeEditingPanel.java | ||
---|---|---|
56 | 56 |
import org.gvsig.fmap.dal.feature.EditableFeatureType; |
57 | 57 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
58 | 58 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
59 |
import org.gvsig.i18n.Messages; |
|
59 | 60 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
60 | 61 |
import org.slf4j.Logger; |
61 | 62 |
import org.slf4j.LoggerFactory; |
... | ... | |
507 | 508 |
(Component) PluginServices.getMDIManager() |
508 | 509 |
.getActiveWindow(), PluginServices |
509 | 510 |
.getText(this, |
510 |
"please_insert_new_field_name"),
|
|
511 |
"_Please_insert_new_field_name_Cannot_be_undone"),
|
|
511 | 512 |
fieldName); |
512 | 513 |
if (newName == null) { |
513 | 514 |
return; |
... | ... | |
518 | 519 |
"field_already_exists"), null); |
519 | 520 |
return; |
520 | 521 |
} |
521 |
FeatureAttributeDescriptor ad = |
|
522 |
(FeatureAttributeDescriptor) editableType |
|
523 |
.get(fieldName); |
|
524 |
editableType.remove(ad.getName()); |
|
525 |
EditableFeatureAttributeDescriptor ead = |
|
526 |
editableType.add(newName, ad.getType(), |
|
527 |
ad.getSize()); |
|
528 |
ead.setPrecision(ad.getPrecision()); |
|
522 |
|
|
523 |
|
|
524 |
try { |
|
525 |
TableOperations.renameColumn( |
|
526 |
featureStore, fieldName, newName); |
|
527 |
} catch (DataException de) { |
|
528 |
JOptionPane.showMessageDialog( |
|
529 |
jTableFields, |
|
530 |
Messages.getText("_Unable_to_rename_field") |
|
531 |
+ ": " + de.getMessage(), |
|
532 |
Messages.getText("_Rename_column"), |
|
533 |
JOptionPane.ERROR_MESSAGE); |
|
534 |
} |
|
535 |
|
|
536 |
/* |
|
537 |
* We need to close the dialog |
|
538 |
* to avoid another update of the |
|
539 |
* feature type |
|
540 |
*/ |
|
541 |
PluginServices.getMDIManager().closeWindow( |
|
542 |
FeatureTypeEditingPanel.this); |
|
543 |
|
|
544 |
|
|
529 | 545 |
} |
530 | 546 |
jTableFields.repaint(); |
531 | 547 |
} |
branches/v2_0_0_prep/extensions/org.gvsig.app.document.table.app/org.gvsig.app.document.table.app.mainplugin/src/main/java/org/gvsig/app/project/documents/table/TableOperations.java | ||
---|---|---|
49 | 49 |
import org.gvsig.fmap.dal.feature.FeatureSet; |
50 | 50 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
51 | 51 |
import org.gvsig.fmap.dal.feature.FeatureType; |
52 |
import org.gvsig.fmap.dal.feature.exception.StoreUpdateFeatureTypeException; |
|
52 | 53 |
import org.gvsig.fmap.mapcontrol.dal.feature.swing.FeatureTable; |
53 | 54 |
import org.gvsig.fmap.mapcontrol.dal.feature.swing.table.FeatureTableModel; |
54 | 55 |
import org.gvsig.i18n.Messages; |
... | ... | |
299 | 300 |
* @param name |
300 | 301 |
* @param newName |
301 | 302 |
*/ |
302 |
private void renameAttribute(FeatureStore fs, String name, String newName) { |
|
303 |
private static void renameAttribute(FeatureStore fs, String name, String newName) {
|
|
303 | 304 |
|
304 | 305 |
try { |
305 | 306 |
|
... | ... | |
337 | 338 |
} |
338 | 339 |
|
339 | 340 |
} |
341 |
|
|
342 |
/** |
|
343 |
* Renames field in feature store |
|
344 |
* |
|
345 |
* @param fs |
|
346 |
* @param oldname |
|
347 |
* @param newname |
|
348 |
* @return |
|
349 |
* @throws DataException |
|
350 |
*/ |
|
351 |
public static void renameColumn(FeatureStore fs, |
|
352 |
String oldname, String newname) throws DataException { |
|
353 |
|
|
354 |
FeatureType _ft = fs.getDefaultFeatureType(); |
|
355 |
if (_ft.getIndex(newname) != -1) { |
|
356 |
throw new StoreUpdateFeatureTypeException( |
|
357 |
new Exception("Attribute name already existed."), |
|
358 |
fs.getName()); |
|
359 |
} |
|
360 |
renameAttribute(fs, oldname, newname); |
|
361 |
fs.finishEditing(); |
|
362 |
} |
|
340 | 363 |
|
341 | 364 |
} |
branches/v2_0_0_prep/extensions/org.gvsig.app.document.table.app/org.gvsig.app.document.table.app.mainplugin/src/main/resources/text.properties | ||
---|---|---|
35 | 35 |
_Clear_selection=Deseleccionar todo |
36 | 36 |
_Column_manager=Gestor de columnas |
37 | 37 |
_Move_up_selection=Mover arriba la selecci?n |
38 |
_Unable_to_rename_field=No se pudo renombrar el campo |
|
38 | 39 |
|
branches/v2_0_0_prep/extensions/org.gvsig.app.document.table.app/org.gvsig.app.document.table.app.mainplugin/src/main/resources/text_en.properties | ||
---|---|---|
35 | 35 |
_Clear_selection=Clear selection |
36 | 36 |
_Column_manager=Column manager |
37 | 37 |
_Move_up_selection=Move up selection |
38 |
_Unable_to_rename_field=Unable to rename field |
|
38 | 39 |
|
39 | 40 |
|
40 | 41 |
|
Also available in: Unified diff