Revision 6399
trunk/applications/appgvSIG/config/config.xml | ||
---|---|---|
413 | 413 |
active="true"> |
414 | 414 |
<menu text="Tabla/remove_row" action-command="REMOVEROW"/> |
415 | 415 |
</extension> |
416 |
<extension class-name="com.iver.cit.gvsig.TableEditChangeColumnsExtension" |
|
416 |
<!-- <extension class-name="com.iver.cit.gvsig.TableEditChangeColumnsExtension"
|
|
417 | 417 |
description="Extensi?n encargada de gestionar las operaciones de edici?n de columnas sobre las tablas." |
418 | 418 |
active="true"> |
419 | 419 |
<menu text="Tabla/add_column" action-command="ADDCOLUMN"/> |
420 | 420 |
<menu text="Tabla/rename_column" action-command="RENAMECOLUMN"/> |
421 | 421 |
<menu text="Tabla/remove_column" action-command="REMOVECOLUMN"/> |
422 |
</extension> |
|
422 |
</extension> -->
|
|
423 | 423 |
<extension class-name="com.iver.cit.gvsig.TableManageFields" |
424 | 424 |
description="Extensi?n encargada de gestionar los campos de las tablas." |
425 | 425 |
active="true"> |
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/dialogs/DlgFieldManager.java | ||
---|---|---|
41 | 41 |
package com.iver.cit.gvsig.gui.dialogs; |
42 | 42 |
|
43 | 43 |
import java.sql.Types; |
44 |
import java.util.ArrayList; |
|
45 | 44 |
|
46 | 45 |
import javax.swing.DefaultCellEditor; |
47 | 46 |
import javax.swing.JButton; |
48 | 47 |
import javax.swing.JComboBox; |
48 |
import javax.swing.JComponent; |
|
49 | 49 |
import javax.swing.JLabel; |
50 |
import javax.swing.JOptionPane; |
|
50 | 51 |
import javax.swing.JPanel; |
51 | 52 |
import javax.swing.JScrollPane; |
52 | 53 |
import javax.swing.JTable; |
... | ... | |
191 | 192 |
} |
192 | 193 |
|
193 | 194 |
public boolean isCellEditable(int rowIndex, int columnIndex) { |
194 |
// MyFieldDescription aux = (MyFieldDescription) |
|
195 |
// myFields.get(rowIndex); |
|
196 |
switch (columnIndex) { |
|
197 |
case 0: |
|
198 |
return true; |
|
199 |
// case 1: |
|
200 |
// case 2: |
|
201 |
// return !aux.isOriginal; |
|
202 |
} |
|
203 | 195 |
return false; |
204 | 196 |
|
205 | 197 |
} |
... | ... | |
369 | 361 |
jTableFields |
370 | 362 |
.setSelectionMode(javax.swing.ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); |
371 | 363 |
|
364 |
jTableFields.setColumnSelectionAllowed(false); |
|
372 | 365 |
// Ask to be notified of selection changes. |
373 | 366 |
ListSelectionModel rowSM = jTableFields.getSelectionModel(); |
374 | 367 |
rowSM.addListSelectionListener(new ListSelectionListener() { |
... | ... | |
384 | 377 |
} else { |
385 | 378 |
jBtnDeleteField.setEnabled(true); |
386 | 379 |
} |
380 |
if (jTableFields.getSelectedRows().length != 1) |
|
381 |
{ |
|
382 |
getJBtnRenameField().setEnabled(false); |
|
383 |
} |
|
384 |
else |
|
385 |
{ |
|
386 |
getJBtnRenameField().setEnabled(true); |
|
387 |
} |
|
388 |
|
|
387 | 389 |
} |
388 | 390 |
}); |
389 | 391 |
|
... | ... | |
467 | 469 |
jBtnRenameField |
468 | 470 |
.setBounds(new java.awt.Rectangle(255, 120, 118, 25)); |
469 | 471 |
jBtnRenameField.setText("Rename Field..."); |
472 |
jBtnRenameField.addActionListener(new java.awt.event.ActionListener() { |
|
473 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
|
474 |
int[] selecteds = jTableFields.getSelectedRows(); |
|
475 |
TableModel tm = jTableFields.getModel(); |
|
476 |
|
|
477 |
|
|
478 |
for (int i = selecteds.length - 1; i >= 0; i--) |
|
479 |
{ |
|
480 |
String fieldName = (String) tm.getValueAt(selecteds[i],0); |
|
481 |
try { |
|
482 |
String newName = JOptionPane.showInputDialog( |
|
483 |
(JComponent) PluginServices.getMDIManager().getActiveView(), |
|
484 |
PluginServices.getText(this, "please_insert_new_field_name"), |
|
485 |
fieldName |
|
486 |
); |
|
487 |
if (newName == null) return; |
|
488 |
|
|
489 |
edAdapter.renameField(fieldName, newName); |
|
490 |
} catch (EditionException e1) { |
|
491 |
// TODO Auto-generated catch block |
|
492 |
e1.printStackTrace(); |
|
493 |
} |
|
494 |
} |
|
495 |
jTableFields.repaint(); |
|
496 |
|
|
497 |
} |
|
498 |
}); |
|
470 | 499 |
} |
471 | 500 |
return jBtnRenameField; |
472 | 501 |
} |
... | ... | |
483 | 512 |
jBtnOK.setText("Aceptar"); |
484 | 513 |
jBtnOK.addActionListener(new java.awt.event.ActionListener() { |
485 | 514 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
486 |
System.out.println("actionPerformed()"); // TODO |
|
487 |
// Auto-generated |
|
488 |
// Event stub |
|
489 |
// actionPerformed() |
|
490 |
|
|
515 |
PluginServices.getMDIManager().closeView(DlgFieldManager.this); |
|
491 | 516 |
} |
492 | 517 |
}); |
493 | 518 |
} |
... | ... | |
504 | 529 |
jBtnCancel = new JButton(); |
505 | 530 |
jBtnCancel.setBounds(new java.awt.Rectangle(285, 285, 91, 23)); |
506 | 531 |
jBtnCancel.setText("Cancelar"); |
532 |
jBtnCancel.addActionListener(new java.awt.event.ActionListener() { |
|
533 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
|
534 |
PluginServices.getMDIManager().closeView(DlgFieldManager.this); |
|
535 |
} |
|
536 |
}); |
|
507 | 537 |
} |
508 | 538 |
return jBtnCancel; |
509 | 539 |
} |
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/TableNumericFieldOperations.java | ||
---|---|---|
106 | 106 |
return false; |
107 | 107 |
} |
108 | 108 |
|
109 |
if (v.getClass() == Table.class) {
|
|
109 |
if (v instanceof Table) {
|
|
110 | 110 |
Table table = (Table) v; |
111 | 111 |
return doIsEnabled(table); |
112 | 112 |
} |
... | ... | |
117 | 117 |
try{ |
118 | 118 |
BitSet indices = table.getSelectedFieldIndices(); |
119 | 119 |
|
120 |
System.out.println("TableNumericFieldOperations.isEnabled: Tabla: " + table.getModel().getModelo().getRecordset().getName() ); |
|
120 |
// System.out.println("TableNumericFieldOperations.isEnabled: Tabla: " + table.getModel().getModelo().getRecordset().getName() );
|
|
121 | 121 |
|
122 | 122 |
if (indices.cardinality() == 1){ |
123 | 123 |
try { |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/edition/commands/RenameFieldCommand.java | ||
---|---|---|
44 | 44 |
|
45 | 45 |
import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
46 | 46 |
import com.iver.cit.gvsig.fmap.edition.EditableAdapter; |
47 |
import com.iver.cit.gvsig.fmap.edition.EditionException; |
|
47 | 48 |
import com.iver.cit.gvsig.fmap.edition.InternalField; |
48 | 49 |
|
49 | 50 |
public class RenameFieldCommand extends AbstractCommand { |
... | ... | |
63 | 64 |
|
64 | 65 |
|
65 | 66 |
public void undo() throws DriverIOException, IOException { |
66 |
edAdapter.undoRenameField(field, antName); |
|
67 |
try { |
|
68 |
edAdapter.undoRenameField(field, antName); |
|
69 |
} catch (EditionException e) { |
|
70 |
// TODO Auto-generated catch block |
|
71 |
e.printStackTrace(); |
|
72 |
} |
|
67 | 73 |
} |
68 | 74 |
|
69 | 75 |
public void redo() throws DriverIOException, IOException { |
70 |
edAdapter.doRenameField(field, newName); |
|
76 |
try { |
|
77 |
edAdapter.doRenameField(field, newName); |
|
78 |
} catch (EditionException e) { |
|
79 |
// TODO Auto-generated catch block |
|
80 |
e.printStackTrace(); |
|
81 |
} |
|
71 | 82 |
|
72 | 83 |
} |
73 | 84 |
|
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/edition/EditableAdapter.java | ||
---|---|---|
1109 | 1109 |
} |
1110 | 1110 |
} |
1111 | 1111 |
|
1112 |
protected void fireAfterFieldModified(FieldDescription field) { |
|
1113 |
AfterFieldEditEvent event = new AfterFieldEditEvent(this,field, |
|
1114 |
EditionEvent.CHANGE_TYPE_MODIFY); |
|
1115 |
for (int i = 0; i < editionListeners.size(); i++) { |
|
1116 |
IEditionListener listener = (IEditionListener) editionListeners |
|
1117 |
.get(i); |
|
1118 |
listener.afterFieldEditEvent(event); |
|
1119 |
} |
|
1120 |
} |
|
1121 |
|
|
1122 |
|
|
1112 | 1123 |
protected boolean fireBeforeRowAdded(int sourceType) |
1113 | 1124 |
throws DriverIOException, IOException { |
1114 | 1125 |
Cancel cancel = new Cancel(); |
... | ... | |
1359 | 1370 |
Iterator it = aux.iterator(); |
1360 | 1371 |
while (it.hasNext()) { |
1361 | 1372 |
InternalField fld = (InternalField) it.next(); |
1362 |
if (fld.getFieldDesc().getFieldName().compareToIgnoreCase(fieldName) == 0)
|
|
1373 |
if (fld.getFieldDesc().getFieldAlias().compareToIgnoreCase(fieldName) == 0)
|
|
1363 | 1374 |
return fld; |
1364 | 1375 |
} |
1365 | 1376 |
|
... | ... | |
1396 | 1407 |
|
1397 | 1408 |
} |
1398 | 1409 |
|
1399 |
public void undoRenameField(InternalField field, String antName) { |
|
1410 |
public void undoRenameField(InternalField field, String antName) throws EditionException {
|
|
1400 | 1411 |
field.getFieldDesc().setFieldAlias(antName); |
1412 |
fieldsChanged(); |
|
1413 |
fireAfterFieldModified(field.getFieldDesc()); |
|
1414 |
|
|
1401 | 1415 |
} |
1402 | 1416 |
|
1403 |
public void doRenameField(InternalField field, String newName) { |
|
1417 |
public void doRenameField(InternalField field, String newName) throws EditionException {
|
|
1404 | 1418 |
field.getFieldDesc().setFieldAlias(newName); |
1419 |
fieldsChanged(); |
|
1420 |
fireAfterFieldModified(field.getFieldDesc()); |
|
1421 |
|
|
1405 | 1422 |
} |
1406 | 1423 |
|
1407 | 1424 |
|
Also available in: Unified diff