Revision 6356
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/TableManageFields.java | ||
---|---|---|
46 | 46 |
*/ |
47 | 47 |
package com.iver.cit.gvsig; |
48 | 48 |
|
49 |
import java.util.BitSet; |
|
50 |
|
|
51 | 49 |
import com.iver.andami.PluginServices; |
52 |
import com.iver.andami.messages.NotificationManager; |
|
53 | 50 |
import com.iver.andami.plugins.Extension; |
54 |
import com.iver.andami.preferences.DlgPreferences; |
|
55 | 51 |
import com.iver.andami.ui.mdiManager.View; |
56 |
import com.iver.cit.gvsig.fmap.DriverException;
|
|
57 |
import com.iver.cit.gvsig.fmap.edition.IFieldManager;
|
|
52 |
import com.iver.cit.gvsig.fmap.edition.EditableAdapter;
|
|
53 |
import com.iver.cit.gvsig.fmap.edition.IEditableSource;
|
|
58 | 54 |
import com.iver.cit.gvsig.fmap.edition.IWriteable; |
59 | 55 |
import com.iver.cit.gvsig.fmap.edition.IWriter; |
60 |
import com.iver.cit.gvsig.fmap.layers.SelectableDataSource; |
|
61 | 56 |
import com.iver.cit.gvsig.gui.Table; |
62 | 57 |
import com.iver.cit.gvsig.gui.dialogs.DlgFieldManager; |
63 | 58 |
import com.iver.cit.gvsig.project.ProjectTable; |
... | ... | |
78 | 73 |
|
79 | 74 |
Table t = (Table) v; |
80 | 75 |
ProjectTable pt = t.getModel(); |
81 |
SelectableDataSource dataSource; |
|
82 |
dataSource = pt.getModelo().getRecordset(); |
|
83 |
if (dataSource.getDriver() instanceof IWriteable) |
|
84 |
{ |
|
85 |
IWriteable aux = (IWriteable) dataSource.getDriver(); |
|
86 |
IWriter writer = aux.getWriter(); |
|
87 |
// No todos los writer pueden cambiar los campos (ejemplo: el dxf |
|
88 |
// o el dgn siempre tienen los mismos campos). |
|
89 |
if (writer instanceof IFieldManager) |
|
90 |
{ |
|
91 |
IFieldManager fieldManager = (IFieldManager) writer; |
|
92 |
DlgFieldManager dlg = new DlgFieldManager(fieldManager); |
|
93 |
PluginServices.getMDIManager().addView(dlg); |
|
94 |
} |
|
95 |
} |
|
76 |
IEditableSource ies = pt.getModelo(); |
|
77 |
if (ies.getDriver() instanceof IWriteable) |
|
78 |
{ |
|
79 |
IWriteable aux = (IWriteable) ies.getDriver(); |
|
80 |
IWriter writer = aux.getWriter(); |
|
81 |
// No todos los writer pueden cambiar los campos (ejemplo: el dxf |
|
82 |
// o el dgn siempre tienen los mismos campos). |
|
83 |
if (writer.canAlterTable()) |
|
84 |
{ |
|
85 |
// IFieldManager fieldManager = (IFieldManager) writer; |
|
86 |
DlgFieldManager dlg = new DlgFieldManager(ies); |
|
87 |
PluginServices.getMDIManager().addView(dlg); |
|
88 |
} |
|
89 |
} |
|
96 | 90 |
|
97 | 91 |
} |
98 | 92 |
|
... | ... | |
111 | 105 |
|
112 | 106 |
if (v instanceof Table) { |
113 | 107 |
Table t = (Table) v; |
114 |
ProjectTable pt = t.getModel(); |
|
115 |
SelectableDataSource dataSource; |
|
116 |
dataSource = pt.getModelo().getRecordset(); |
|
117 |
if (dataSource.getDriver() instanceof IWriteable) |
|
118 |
{ |
|
119 |
IWriteable aux = (IWriteable) dataSource.getDriver(); |
|
120 |
IWriter writer = aux.getWriter(); |
|
121 |
if (writer instanceof IFieldManager) |
|
122 |
return true; |
|
123 |
} |
|
124 |
|
|
125 |
|
|
108 |
IEditableSource ies = t.getModel().getModelo(); |
|
109 |
// ProjectTable pt = t.getModel(); |
|
110 |
if (ies.getDriver() instanceof IWriteable) |
|
111 |
{ |
|
112 |
IWriter writer = ((IWriteable) ies.getDriver()).getWriter(); |
|
113 |
if ((writer != null) && (writer.canAlterTable())) |
|
114 |
{ |
|
115 |
if (ies.isEditing()) |
|
116 |
{ |
|
117 |
return true; |
|
118 |
} |
|
119 |
} |
|
120 |
} |
|
126 | 121 |
} |
127 | 122 |
return false; |
128 | 123 |
} |
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/project/ProjectTable.java | ||
---|---|---|
502 | 502 |
} catch (Exception e) { |
503 | 503 |
throw new OpenException(e, this.getClass().getName()); |
504 | 504 |
} |
505 |
columns.clear(); |
|
505 |
|
|
506 | 506 |
// for (int i=1;i<xml.getNumChild();i++){ |
507 | 507 |
// columns.add(Column.createColumn(xml.getChild(i))); |
508 | 508 |
// } |
509 | 509 |
if (xml.contains("columns")) { |
510 |
columns.clear(); |
|
510 | 511 |
columns = Columns |
511 | 512 |
.createColumns(xml.getChild(xml.getNumChild() - 1)); |
512 | 513 |
} |
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/dialogs/DlgFieldManager.java | ||
---|---|---|
58 | 58 |
import javax.swing.table.TableColumn; |
59 | 59 |
import javax.swing.table.TableModel; |
60 | 60 |
|
61 |
import com.hardcode.driverManager.DriverLoadException; |
|
62 |
import com.hardcode.gdbms.engine.data.driver.DriverException; |
|
61 | 63 |
import com.iver.andami.PluginServices; |
62 | 64 |
import com.iver.andami.ui.mdiManager.View; |
63 | 65 |
import com.iver.andami.ui.mdiManager.ViewInfo; |
64 | 66 |
import com.iver.cit.gvsig.fmap.drivers.FieldDescription; |
65 |
import com.iver.cit.gvsig.fmap.edition.IFieldManager; |
|
67 |
import com.iver.cit.gvsig.fmap.edition.EditableAdapter; |
|
68 |
import com.iver.cit.gvsig.fmap.edition.IEditableSource; |
|
66 | 69 |
|
67 | 70 |
public class DlgFieldManager extends JPanel implements View { |
68 | 71 |
|
... | ... | |
79 | 82 |
private JButton jBtnRenameField = null; |
80 | 83 |
private JButton jBtnOK = null; |
81 | 84 |
private JButton jBtnCancel = null; |
82 |
private IFieldManager fieldManager;; |
|
85 |
// private IFieldManager fieldManager;; |
|
86 |
private EditableAdapter edAdapter = null; |
|
83 | 87 |
|
84 | 88 |
private class MyFieldDescription |
85 | 89 |
{ |
... | ... | |
218 | 222 |
* This method initializes |
219 | 223 |
* |
220 | 224 |
*/ |
221 |
public DlgFieldManager(IFieldManager fieldManager) {
|
|
225 |
public DlgFieldManager(IEditableSource ies) {
|
|
222 | 226 |
super(); |
223 |
this.fieldManager = fieldManager;
|
|
227 |
this.edAdapter = (EditableAdapter) ies;
|
|
224 | 228 |
initialize(); |
225 | 229 |
// Add a new row |
226 |
TableModel tm = new MyTableModel(fieldManager.getOriginalFields()); |
|
227 |
getJTableFields().setModel(tm); |
|
228 |
// Esto lo a?ado aqu? porque si no tiene registros, no hace caso. (Por eso no |
|
229 |
// lo pongo en getJTable() |
|
230 |
TableColumn typeColumn = jTableFields.getColumnModel().getColumn(1); |
|
231 |
JComboBox comboBox = new JComboBox(); |
|
232 |
comboBox.addItem("Boolean"); |
|
233 |
comboBox.addItem("Date"); |
|
234 |
comboBox.addItem("Integer"); |
|
235 |
comboBox.addItem("Double"); |
|
236 |
comboBox.addItem("String"); |
|
237 |
typeColumn.setCellEditor(new DefaultCellEditor(comboBox)); |
|
230 |
TableModel tm; |
|
231 |
try { |
|
232 |
tm = new MyTableModel(ies.getRecordset().getFieldsDescription()); |
|
233 |
getJTableFields().setModel(tm); |
|
234 |
// Esto lo a?ado aqu? porque si no tiene registros, no hace caso. (Por eso no |
|
235 |
// lo pongo en getJTable() |
|
236 |
TableColumn typeColumn = jTableFields.getColumnModel().getColumn(1); |
|
237 |
JComboBox comboBox = new JComboBox(); |
|
238 |
comboBox.addItem("Boolean"); |
|
239 |
comboBox.addItem("Date"); |
|
240 |
comboBox.addItem("Integer"); |
|
241 |
comboBox.addItem("Double"); |
|
242 |
comboBox.addItem("String"); |
|
243 |
typeColumn.setCellEditor(new DefaultCellEditor(comboBox)); |
|
244 |
|
|
245 |
TableColumn widthColumn = jTableFields.getColumnModel().getColumn(2); |
|
246 |
} catch (DriverLoadException e) { |
|
247 |
// TODO Auto-generated catch block |
|
248 |
e.printStackTrace(); |
|
249 |
} catch (DriverException e) { |
|
250 |
// TODO Auto-generated catch block |
|
251 |
e.printStackTrace(); |
|
252 |
} |
|
238 | 253 |
|
239 |
TableColumn widthColumn = jTableFields.getColumnModel().getColumn(2); |
|
240 |
|
|
241 | 254 |
} |
242 | 255 |
|
243 | 256 |
/** |
... | ... | |
386 | 399 |
|
387 | 400 |
} |
388 | 401 |
}); |
402 |
jBtnNewField.addActionListener(new java.awt.event.ActionListener() { |
|
403 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
|
404 |
// Add a new row |
|
405 |
DefaultTableModel tm = (DefaultTableModel) jTableFields.getModel(); |
|
406 |
Object[] newRow = new Object[tm.getColumnCount()]; |
|
407 |
newRow[0] = PluginServices.getText(this,"field"); |
|
408 |
newRow[1] = "String"; |
|
409 |
newRow[2] = "20"; |
|
410 |
tm.addRow(newRow); |
|
411 |
|
|
412 |
// Esto lo a?ado aqu? porque si no tiene registros, no hace caso. (Por eso no |
|
413 |
// lo pongo en getJTable() |
|
414 |
TableColumn typeColumn = jTableFields.getColumnModel().getColumn(1); |
|
415 |
JComboBox comboBox = new JComboBox(); |
|
416 |
comboBox.addItem("Boolean"); |
|
417 |
comboBox.addItem("Date"); |
|
418 |
comboBox.addItem("Integer"); |
|
419 |
comboBox.addItem("Double"); |
|
420 |
comboBox.addItem("String"); |
|
421 |
typeColumn.setCellEditor(new DefaultCellEditor(comboBox)); |
|
422 |
|
|
423 |
TableColumn widthColumn = jTableFields.getColumnModel().getColumn(2); |
|
424 |
|
|
425 |
// edAdapter.addField(fld); |
|
426 |
} |
|
427 |
}); |
|
389 | 428 |
} |
390 | 429 |
return jBtnNewField; |
391 | 430 |
} |
... | ... | |
400 | 439 |
jBtnDeleteField = new JButton(); |
401 | 440 |
jBtnDeleteField.setBounds(new java.awt.Rectangle(255,90,118,25)); |
402 | 441 |
jBtnDeleteField.setText("Delete Field"); |
442 |
jBtnDeleteField.addActionListener(new java.awt.event.ActionListener() { |
|
443 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
|
444 |
int[] selecteds = jTableFields.getSelectedRows(); |
|
445 |
DefaultTableModel tm = (DefaultTableModel) jTableFields.getModel(); |
|
446 |
|
|
447 |
for (int i=selecteds.length-1; i >=0; i--) |
|
448 |
tm.removeRow(selecteds[i]); |
|
449 |
|
|
450 |
} |
|
451 |
}); |
|
403 | 452 |
} |
404 | 453 |
return jBtnDeleteField; |
405 | 454 |
} |
... | ... | |
428 | 477 |
jBtnOK = new JButton(); |
429 | 478 |
jBtnOK.setBounds(new java.awt.Rectangle(180,285,91,23)); |
430 | 479 |
jBtnOK.setText("Aceptar"); |
480 |
jBtnOK.addActionListener(new java.awt.event.ActionListener() { |
|
481 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
|
482 |
System.out.println("actionPerformed()"); // TODO Auto-generated Event stub actionPerformed() |
|
483 |
|
|
484 |
} |
|
485 |
}); |
|
431 | 486 |
} |
432 | 487 |
return jBtnOK; |
433 | 488 |
} |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/drivers/dbf/DBFDriver.java | ||
---|---|---|
375 | 375 |
return dbfWriter.getTableDefinition(); |
376 | 376 |
} |
377 | 377 |
|
378 |
public boolean canAlterTable() { |
|
379 |
return true; |
|
380 |
} |
|
381 |
|
|
378 | 382 |
} |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/drivers/dxf/DXFMemoryDriver.java | ||
---|---|---|
892 | 892 |
return dxfWriter.getTableDefinition(); |
893 | 893 |
} |
894 | 894 |
|
895 |
public boolean canAlterTable() { |
|
896 |
return false; |
|
897 |
} |
|
898 |
|
|
895 | 899 |
} |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/drivers/shp/IndexedShpDriver.java | ||
---|---|---|
987 | 987 |
public ITableDefinition getTableDefinition() { |
988 | 988 |
return shpWriter.getTableDefinition(); |
989 | 989 |
} |
990 |
|
|
991 |
public boolean canAlterTable() { |
|
992 |
return true; |
|
993 |
} |
|
990 | 994 |
} |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/edition/EditableAdapter.java | ||
---|---|---|
21 | 21 |
import com.iver.cit.gvsig.fmap.drivers.FieldDescription; |
22 | 22 |
import com.iver.cit.gvsig.fmap.drivers.ITableDefinition; |
23 | 23 |
import com.iver.cit.gvsig.fmap.drivers.TableDefinition; |
24 |
import com.iver.cit.gvsig.fmap.drivers.dbf.DBFDriver; |
|
24 | 25 |
import com.iver.cit.gvsig.fmap.edition.commands.AddFieldCommand; |
25 | 26 |
import com.iver.cit.gvsig.fmap.edition.commands.AddRowCommand; |
26 | 27 |
import com.iver.cit.gvsig.fmap.edition.commands.Command; |
... | ... | |
231 | 232 |
|
232 | 233 |
saveEdits(writer, sourceType); |
233 | 234 |
isEditing = false; |
235 |
cr.clearAll(); |
|
234 | 236 |
fireStopEditionEvent(sourceType); |
235 | 237 |
} |
236 | 238 |
|
... | ... | |
308 | 310 |
try { |
309 | 311 |
ds= null; |
310 | 312 |
clean(); |
313 |
cr.clearAll(); |
|
311 | 314 |
} catch (DriverException e) { |
312 | 315 |
e.printStackTrace(); |
313 | 316 |
throw new IOException("Error: " + e.getMessage()); |
... | ... | |
1260 | 1263 |
* @see com.iver.cit.gvsig.fmap.edition.IEditableSource#getFieldManager() |
1261 | 1264 |
*/ |
1262 | 1265 |
public IFieldManager getFieldManager() { |
1263 |
if (ods.getDriver() instanceof IFieldManager) |
|
1264 |
return (IFieldManager) ods.getDriver(); |
|
1266 |
if (ods.getDriver() instanceof IWriteable) |
|
1267 |
{ |
|
1268 |
IWriter writer = ((IWriteable)ods.getDriver()).getWriter(); |
|
1269 |
if ((writer != null) && (writer instanceof IFieldManager)) |
|
1270 |
{ |
|
1271 |
return (IFieldManager) writer; |
|
1272 |
} |
|
1273 |
} |
|
1265 | 1274 |
return null; |
1266 | 1275 |
} |
1267 | 1276 |
|
... | ... | |
1332 | 1341 |
field.setFieldIndex(actualFields.size()); |
1333 | 1342 |
actualFields.put(field.getFieldId(), field); |
1334 | 1343 |
fieldsChanged(); |
1344 |
fireAfterFieldAdded(field.getFieldDesc()); |
|
1335 | 1345 |
} |
1336 | 1346 |
|
1337 | 1347 |
public void doRemoveField(InternalField field) throws EditionException { |
... | ... | |
1406 | 1416 |
return field.getFieldIndex(); |
1407 | 1417 |
} |
1408 | 1418 |
|
1419 |
public Driver getDriver() |
|
1420 |
{ |
|
1421 |
return ods.getDriver(); |
|
1422 |
} |
|
1423 |
|
|
1409 | 1424 |
} |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/edition/writers/shp/MultiShpWriter.java | ||
---|---|---|
264 | 264 |
public ITableDefinition getTableDefinition() { |
265 | 265 |
return layerDefinition; |
266 | 266 |
} |
267 |
|
|
268 |
public boolean canAlterTable() { |
|
269 |
return true; |
|
270 |
} |
|
267 | 271 |
} |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/edition/writers/AbstractWriter.java | ||
---|---|---|
34 | 34 |
// public abstract boolean canWriteGeometry(int gvSIGgeometryType); |
35 | 35 |
public abstract boolean canWriteAttribute(int sqlType); |
36 | 36 |
|
37 |
public boolean canAlterTable() |
|
38 |
{ |
|
39 |
return true; |
|
40 |
} |
|
41 |
|
|
37 | 42 |
public void initialize(ITableDefinition tableDefinition) throws EditionException { |
38 | 43 |
this.tableDef = tableDefinition; |
39 | 44 |
|
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/edition/writers/dxf/DxfWriter.java | ||
---|---|---|
63 | 63 |
return false; |
64 | 64 |
} |
65 | 65 |
|
66 |
public boolean canAlterTable() { |
|
67 |
return false; |
|
68 |
} |
|
69 |
|
|
66 | 70 |
public boolean canWriteGeometry(int gvSIGgeometryType) { |
67 | 71 |
return true; // I guess all geometries can be here... |
68 | 72 |
} |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/edition/IEditableSource.java | ||
---|---|---|
2 | 2 |
|
3 | 3 |
import java.io.IOException; |
4 | 4 |
|
5 |
import com.hardcode.driverManager.Driver; |
|
5 | 6 |
import com.hardcode.driverManager.DriverLoadException; |
6 | 7 |
import com.iver.cit.gvsig.fmap.DriverException; |
7 | 8 |
import com.iver.cit.gvsig.fmap.core.IRow; |
... | ... | |
195 | 196 |
public IFieldManager getFieldManager(); |
196 | 197 |
|
197 | 198 |
public void saveEdits(IWriter writer, int sourceType) throws EditionException; |
199 |
|
|
200 |
public Driver getDriver(); |
|
198 | 201 |
|
199 | 202 |
|
200 | 203 |
} |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/edition/commands/MemoryCommandRecord.java | ||
---|---|---|
194 | 194 |
public void removeCommandListener(CommandListener e) { |
195 | 195 |
commandsListener.remove(e); |
196 | 196 |
} |
197 |
|
|
198 |
public void clearAll() { |
|
199 |
redos.clear(); |
|
200 |
undos.clear(); |
|
201 |
|
|
202 |
} |
|
197 | 203 |
} |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/edition/commands/CommandRecord.java | ||
---|---|---|
102 | 102 |
public void removeCommandListener(CommandListener e); |
103 | 103 |
public void fireCommandsRepaint(CommandEvent e); |
104 | 104 |
public int getCommandCount(); |
105 |
/** |
|
106 |
* Removes all do's and undo's |
|
107 |
*/ |
|
108 |
public void clearAll(); |
|
105 | 109 |
|
106 | 110 |
} |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/edition/IWriter.java | ||
---|---|---|
26 | 26 |
|
27 | 27 |
|
28 | 28 |
public abstract boolean canWriteAttribute(int sqlType); |
29 |
public abstract boolean canAlterTable(); |
|
29 | 30 |
|
30 | 31 |
public void initialize(ITableDefinition tableDefinition) throws EditionException ; |
31 | 32 |
|
Also available in: Unified diff