svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / 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 @ 42533
History | View | Annotate | Download (24.1 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 3
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
* For any additional information, do not hesitate to contact us
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
*/
|
24 |
package org.gvsig.app.project.documents.table.gui; |
25 |
|
26 |
import java.awt.BorderLayout; |
27 |
import java.awt.Component; |
28 |
import java.awt.FlowLayout; |
29 |
import java.awt.GridLayout; |
30 |
import java.awt.event.ActionListener; |
31 |
import java.text.ParseException; |
32 |
import java.util.ArrayList; |
33 |
import java.util.List; |
34 |
|
35 |
import javax.swing.DefaultCellEditor; |
36 |
import javax.swing.JButton; |
37 |
import javax.swing.JComboBox; |
38 |
import javax.swing.JLabel; |
39 |
import javax.swing.JOptionPane; |
40 |
import javax.swing.JPanel; |
41 |
import javax.swing.JScrollPane; |
42 |
import javax.swing.JTable; |
43 |
import javax.swing.ListSelectionModel; |
44 |
import javax.swing.event.ListSelectionEvent; |
45 |
import javax.swing.event.ListSelectionListener; |
46 |
import javax.swing.table.AbstractTableModel; |
47 |
import javax.swing.table.TableColumn; |
48 |
import javax.swing.table.TableModel; |
49 |
|
50 |
import org.gvsig.andami.PluginServices; |
51 |
import org.gvsig.andami.messages.NotificationManager; |
52 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
53 |
import org.gvsig.andami.ui.mdiManager.WindowInfo; |
54 |
import org.gvsig.app.project.documents.table.TableOperations; |
55 |
import org.gvsig.fmap.dal.DALLocator; |
56 |
import org.gvsig.fmap.dal.DataManager; |
57 |
import org.gvsig.fmap.dal.DataTypes; |
58 |
import org.gvsig.fmap.dal.exception.DataException; |
59 |
import org.gvsig.fmap.dal.feature.EditableFeatureAttributeDescriptor; |
60 |
import org.gvsig.fmap.dal.feature.EditableFeatureType; |
61 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
62 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
63 |
import org.gvsig.fmap.dal.feature.FeatureStoreProviderFactory; |
64 |
import org.gvsig.i18n.Messages; |
65 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
66 |
import org.slf4j.Logger; |
67 |
import org.slf4j.LoggerFactory; |
68 |
|
69 |
/**
|
70 |
* To modify FeatureTypes from the interface.
|
71 |
*
|
72 |
* @author Vicente Caballero Navarro
|
73 |
*
|
74 |
*/
|
75 |
public class FeatureTypeEditingPanel extends JPanel implements IWindow { |
76 |
|
77 |
private static final long serialVersionUID = -4284879326692474318L; |
78 |
|
79 |
private static final Logger logger = LoggerFactory |
80 |
.getLogger(FeatureTypeEditingPanel.class); |
81 |
|
82 |
WindowInfo windowInfo = null;
|
83 |
|
84 |
private JLabel jLabel = null; |
85 |
|
86 |
private JScrollPane jScrollPane = null; |
87 |
|
88 |
private JTable jTableFields = null; |
89 |
|
90 |
private JButton jBtnNewField = null; |
91 |
|
92 |
private JButton jBtnDeleteField = null; |
93 |
|
94 |
private JButton jBtnRenameField = null; |
95 |
|
96 |
private JButton jBtnOK = null; |
97 |
|
98 |
private JButton jBtnCancel = null; |
99 |
|
100 |
private CreateNewAttributePanel panelNewField =
|
101 |
new CreateNewAttributePanel();
|
102 |
|
103 |
private FeatureStore featureStore = null; |
104 |
|
105 |
private JPanel jPanelButtons = null; |
106 |
|
107 |
private EditableFeatureType editableType = null; |
108 |
|
109 |
private class MyTableModel extends AbstractTableModel { |
110 |
|
111 |
/**
|
112 |
*
|
113 |
*/
|
114 |
private static final long serialVersionUID = -2847526298987536118L; |
115 |
|
116 |
public MyTableModel() {
|
117 |
|
118 |
} |
119 |
|
120 |
public int getColumnCount() { |
121 |
return 5; |
122 |
} |
123 |
|
124 |
public int getRowCount() { |
125 |
return editableType.size();
|
126 |
} |
127 |
|
128 |
public Object getValueAt(int rowIndex, int columnIndex) { |
129 |
FeatureAttributeDescriptor myField = null;
|
130 |
myField = (FeatureAttributeDescriptor) editableType.get(rowIndex); |
131 |
|
132 |
switch (columnIndex) {
|
133 |
case 0: |
134 |
return myField.getName();
|
135 |
case 1: |
136 |
return myField.getDataType().getName();
|
137 |
case 2: |
138 |
return new Integer(myField.getSize()); |
139 |
case 3: |
140 |
return new Integer(myField.getPrecision()); |
141 |
case 4: |
142 |
return myField.getDefaultValue();
|
143 |
|
144 |
} |
145 |
return null; |
146 |
} |
147 |
|
148 |
public Class<?> getColumnClass(int columnIndex) { |
149 |
return super.getColumnClass(columnIndex); |
150 |
} |
151 |
|
152 |
public String getColumnName(int column) { |
153 |
switch (column) {
|
154 |
case 0: |
155 |
return PluginServices.getText(this, "field_name"); |
156 |
case 1: |
157 |
return PluginServices.getText(this, "field_type"); |
158 |
case 2: |
159 |
return PluginServices.getText(this, "field_length"); |
160 |
case 3: |
161 |
return PluginServices.getText(this, "field_decimal_count"); |
162 |
case 4: |
163 |
return PluginServices.getText(this, "field_default_value"); |
164 |
|
165 |
} |
166 |
return super.getColumnName(column); |
167 |
} |
168 |
|
169 |
public boolean isCellEditable(int rowIndex, int columnIndex) { |
170 |
return false; |
171 |
|
172 |
} |
173 |
|
174 |
public void setValueAt(Object aValue, int rowIndex, int columnIndex) { |
175 |
if (columnIndex == 0) { |
176 |
editableType.remove(rowIndex); |
177 |
} |
178 |
String name = ""; |
179 |
int type = DataTypes.STRING;
|
180 |
int size = 0; |
181 |
int precision = 0; |
182 |
switch (columnIndex) {
|
183 |
case 0: |
184 |
name = (String) aValue;
|
185 |
break;
|
186 |
case 1: |
187 |
String strType = (String) aValue; |
188 |
if (strType.equals("String")) { |
189 |
type = DataTypes.STRING; |
190 |
} |
191 |
if (strType.equals("Double")) { |
192 |
type = DataTypes.DOUBLE; |
193 |
precision = 5;
|
194 |
} |
195 |
if (strType.equals("Integer")) { |
196 |
type = DataTypes.INT; |
197 |
} |
198 |
if (strType.equals("Boolean")) { |
199 |
type = DataTypes.BOOLEAN; |
200 |
} |
201 |
if (strType.equals("Date")) { |
202 |
type = DataTypes.DATE; |
203 |
} |
204 |
break;
|
205 |
case 2: |
206 |
size = ((Integer) aValue).intValue();
|
207 |
|
208 |
// TODO: HACERLO BIEN
|
209 |
// if (ead.getDataType()==DataTypes.STRING) {
|
210 |
// ead.setPrecision(5);
|
211 |
// }
|
212 |
} |
213 |
EditableFeatureAttributeDescriptor ead = |
214 |
editableType.add(name, type, size); |
215 |
ead.setPrecision(precision); |
216 |
} |
217 |
|
218 |
} |
219 |
|
220 |
/**
|
221 |
* This method initializes
|
222 |
*
|
223 |
* @throws DataException
|
224 |
*
|
225 |
*/
|
226 |
public FeatureTypeEditingPanel(FeatureStore fs) throws DataException { |
227 |
super();
|
228 |
this.featureStore = fs;
|
229 |
this.editableType = fs.getDefaultFeatureType().getEditable();
|
230 |
initialize(); |
231 |
// Add a new row
|
232 |
TableModel tm;
|
233 |
tm = new MyTableModel();
|
234 |
getJTableFields().setModel(tm); |
235 |
// Esto lo a?ado aqu? porque si no tiene registros, no hace caso.
|
236 |
// (Por eso no
|
237 |
// lo pongo en getJTable()
|
238 |
TableColumn typeColumn = jTableFields.getColumnModel().getColumn(1); |
239 |
JComboBox comboBox = new JComboBox(); |
240 |
comboBox.addItem("Boolean");
|
241 |
comboBox.addItem("Date");
|
242 |
comboBox.addItem("Integer");
|
243 |
comboBox.addItem("Double");
|
244 |
comboBox.addItem("String");
|
245 |
typeColumn.setCellEditor(new DefaultCellEditor(comboBox)); |
246 |
|
247 |
} |
248 |
|
249 |
/**
|
250 |
* This method initializes this
|
251 |
*
|
252 |
*/
|
253 |
private void initialize() { |
254 |
FlowLayout flowLayout = new FlowLayout(); |
255 |
flowLayout.setVgap(5);
|
256 |
flowLayout.setHgap(0);
|
257 |
BorderLayout borderLayout = new BorderLayout(); |
258 |
borderLayout.setHgap(15);
|
259 |
borderLayout.setVgap(15);
|
260 |
jLabel = new JLabel(); |
261 |
jLabel.setText(PluginServices.getText(this, "add_delete_edit_fields") |
262 |
+ ": ");
|
263 |
this.setLayout(borderLayout);
|
264 |
this.setSize(new java.awt.Dimension(663, 404)); |
265 |
this.setPreferredSize(new java.awt.Dimension(getWidth(), getHeight())); |
266 |
JPanel jPanelNorth = new JPanel(new FlowLayout(FlowLayout.LEFT)); |
267 |
jPanelNorth.add(jLabel); |
268 |
this.add(jPanelNorth, BorderLayout.NORTH); |
269 |
JPanel jPanelCenter =
|
270 |
new JPanel(new FlowLayout(FlowLayout.LEFT, 10, 0)); |
271 |
jPanelCenter.add(getJScrollPane()); |
272 |
this.add(jPanelCenter, BorderLayout.CENTER); |
273 |
|
274 |
this.add(getJPanelButtons(), BorderLayout.EAST); |
275 |
JPanel jPanelSouth = new JPanel(); |
276 |
jPanelSouth.setLayout(flowLayout); |
277 |
jPanelSouth.add(getJBtnOK(), null);
|
278 |
jPanelSouth.add(getJBtnCancel(), null);
|
279 |
this.add(jPanelSouth, BorderLayout.SOUTH); |
280 |
|
281 |
} |
282 |
|
283 |
public WindowInfo getWindowInfo() {
|
284 |
if (windowInfo == null) { |
285 |
windowInfo = |
286 |
new WindowInfo(WindowInfo.MODALDIALOG | WindowInfo.PALETTE
|
287 |
| WindowInfo.RESIZABLE); |
288 |
windowInfo.setTitle(PluginServices.getText(this, "field_manager")); |
289 |
windowInfo.setHeight(this.getHeight());
|
290 |
windowInfo.setWidth(this.getWidth());
|
291 |
} |
292 |
return windowInfo;
|
293 |
} |
294 |
|
295 |
// /**
|
296 |
// * Convierte lo que hay en la tabla en una definici?n de campos adecuada
|
297 |
// * para crear un LayerDefinition
|
298 |
// *
|
299 |
// * @return
|
300 |
// */
|
301 |
// public FieldDescription[] getFieldsDescription() {
|
302 |
// DefaultTableModel tm = (DefaultTableModel) jTableFields.getModel();
|
303 |
// FieldDescription[] fieldsDesc = new FieldDescription[tm.getRowCount()];
|
304 |
//
|
305 |
// for (int i = 0; i < tm.getRowCount(); i++) {
|
306 |
// fieldsDesc[i] = new FieldDescription();
|
307 |
// fieldsDesc[i].setFieldName((String) tm.getValueAt(i, 0));
|
308 |
// String strType = (String) tm.getValueAt(i, 1);
|
309 |
// if (strType.equals("String"))
|
310 |
// fieldsDesc[i].setFieldType(Types.VARCHAR);
|
311 |
// if (strType.equals("Double"))
|
312 |
// fieldsDesc[i].setFieldType(Types.DOUBLE);
|
313 |
// if (strType.equals("Integer"))
|
314 |
// fieldsDesc[i].setFieldType(Types.INTEGER);
|
315 |
// if (strType.equals("Boolean"))
|
316 |
// fieldsDesc[i].setFieldType(Types.BOOLEAN);
|
317 |
// if (strType.equals("Date"))
|
318 |
// fieldsDesc[i].setFieldType(Types.DATE);
|
319 |
// int fieldLength = Integer.parseInt((String) tm.getValueAt(i, 2));
|
320 |
// fieldsDesc[i].setFieldLength(fieldLength);
|
321 |
//
|
322 |
// // TODO: HACERLO BIEN
|
323 |
// if (strType.equals("Double"))
|
324 |
// fieldsDesc[i].setFieldDecimalCount(5);
|
325 |
//
|
326 |
// }
|
327 |
//
|
328 |
// return fieldsDesc;
|
329 |
// }
|
330 |
|
331 |
/**
|
332 |
* This method initializes jScrollPane
|
333 |
*
|
334 |
* @return javax.swing.JScrollPane
|
335 |
*/
|
336 |
private JScrollPane getJScrollPane() { |
337 |
if (jScrollPane == null) { |
338 |
jScrollPane = new JScrollPane(); |
339 |
jScrollPane.setPreferredSize(new java.awt.Dimension(482, 350)); |
340 |
jScrollPane.setViewportView(getJTableFields()); |
341 |
} |
342 |
return jScrollPane;
|
343 |
} |
344 |
|
345 |
/**
|
346 |
* This method initializes jTableFields
|
347 |
*
|
348 |
* @return javax.swing.JTable
|
349 |
*/
|
350 |
private JTable getJTableFields() { |
351 |
if (jTableFields == null) { |
352 |
jTableFields = new JTable(); |
353 |
jTableFields |
354 |
.setSelectionMode(javax.swing.ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); |
355 |
|
356 |
jTableFields.setColumnSelectionAllowed(false);
|
357 |
// Ask to be notified of selection changes.
|
358 |
ListSelectionModel rowSM = jTableFields.getSelectionModel();
|
359 |
rowSM.addListSelectionListener(new ListSelectionListener() { |
360 |
|
361 |
public void valueChanged(ListSelectionEvent e) { |
362 |
// Ignore extra messages.
|
363 |
if (e.getValueIsAdjusting()) {
|
364 |
return;
|
365 |
} |
366 |
|
367 |
ListSelectionModel lsm = (ListSelectionModel) e.getSource(); |
368 |
if (lsm.isSelectionEmpty()) {
|
369 |
// no rows are selected
|
370 |
jBtnDeleteField.setEnabled(false);
|
371 |
} else {
|
372 |
jBtnDeleteField.setEnabled(true);
|
373 |
} |
374 |
if (jTableFields.getSelectedRows().length != 1) { |
375 |
getJBtnRenameField().setEnabled(false);
|
376 |
} else {
|
377 |
getJBtnRenameField().setEnabled(true);
|
378 |
} |
379 |
|
380 |
} |
381 |
}); |
382 |
|
383 |
} |
384 |
return jTableFields;
|
385 |
} |
386 |
|
387 |
/**
|
388 |
* This method initializes jBtnNewField
|
389 |
*
|
390 |
* @return javax.swing.JButton
|
391 |
*/
|
392 |
private JButton getJBtnNewField() { |
393 |
if (jBtnNewField == null) { |
394 |
jBtnNewField = |
395 |
ToolsSwingLocator.getUsabilitySwingManager().createJButton(); |
396 |
jBtnNewField.setText(PluginServices.getText(this, "new_field")); |
397 |
jBtnNewField.addActionListener(new java.awt.event.ActionListener() {
|
398 |
|
399 |
private List<String> tempFieldNames = new ArrayList<String>(); |
400 |
|
401 |
{ |
402 |
try {
|
403 |
int size = editableType.size();
|
404 |
for (int i = 0; i < size; i++) { |
405 |
FeatureAttributeDescriptor ad = |
406 |
(FeatureAttributeDescriptor) editableType |
407 |
.get(i); |
408 |
tempFieldNames.add(ad.getName()); |
409 |
} |
410 |
} catch (Exception ex) { |
411 |
logger.warn("Can't initialize tempFieldNames", ex);
|
412 |
} |
413 |
} |
414 |
|
415 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
416 |
ActionListener okAction;
|
417 |
DataManager dataManager = DALLocator.getDataManager(); |
418 |
FeatureStoreProviderFactory factory = |
419 |
(FeatureStoreProviderFactory) dataManager. |
420 |
getStoreProviderFactory(featureStore.getProviderName()); |
421 |
panelNewField.setMaxAttributeNameSize(factory.getMaxAttributeNameSize()); |
422 |
okAction = new java.awt.event.ActionListener() {
|
423 |
|
424 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
425 |
try {
|
426 |
EditableFeatureAttributeDescriptor ead = |
427 |
panelNewField |
428 |
.loadFieldDescription(editableType); |
429 |
if (ead == null) { |
430 |
return;
|
431 |
} |
432 |
if (ead.getType() == DataTypes.STRING
|
433 |
&& ead.getSize() > TableOperations.MAX_FIELD_LENGTH) { |
434 |
NotificationManager.showMessageInfo( |
435 |
PluginServices.getText(this,
|
436 |
"max_length_is")
|
437 |
+ ":"
|
438 |
+ TableOperations.MAX_FIELD_LENGTH, |
439 |
null);
|
440 |
ead.setSize(TableOperations.MAX_FIELD_LENGTH); |
441 |
} |
442 |
tempFieldNames.add(ead.getName()); |
443 |
jTableFields.revalidate(); |
444 |
PluginServices.getMDIManager().closeWindow( |
445 |
panelNewField); |
446 |
} catch (ParseException e2) { |
447 |
NotificationManager.addError(e2); |
448 |
} |
449 |
|
450 |
} |
451 |
}; |
452 |
panelNewField.setOkAction(okAction); |
453 |
String[] names = |
454 |
(String[]) tempFieldNames.toArray(new String[0]); |
455 |
panelNewField.setCurrentFieldNames(names); |
456 |
panelNewField = |
457 |
(CreateNewAttributePanel) PluginServices |
458 |
.getMDIManager().addWindow(panelNewField); |
459 |
} |
460 |
}); |
461 |
} |
462 |
return jBtnNewField;
|
463 |
} |
464 |
|
465 |
/**
|
466 |
* This method initializes jButton
|
467 |
*
|
468 |
* @return javax.swing.JButton
|
469 |
*/
|
470 |
private JButton getJBtnDelete() { |
471 |
if (jBtnDeleteField == null) { |
472 |
jBtnDeleteField = |
473 |
ToolsSwingLocator.getUsabilitySwingManager().createJButton(); |
474 |
jBtnDeleteField.setText(PluginServices |
475 |
.getText(this, "delete_field")); |
476 |
jBtnDeleteField |
477 |
.addActionListener(new java.awt.event.ActionListener() {
|
478 |
|
479 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
480 |
int[] selecteds = jTableFields.getSelectedRows(); |
481 |
TableModel tm = jTableFields.getModel();
|
482 |
|
483 |
for (int i = selecteds.length - 1; i >= 0; i--) { |
484 |
String fieldName =
|
485 |
(String) tm.getValueAt(selecteds[i], 0); |
486 |
|
487 |
String old_geom_fld = editableType.getDefaultGeometryAttributeName();
|
488 |
if (old_geom_fld.compareTo(fieldName) == 0) { |
489 |
JOptionPane.showMessageDialog(
|
490 |
jTableFields, |
491 |
Messages.getText("_Cannot_delete_geometry_field"),
|
492 |
Messages.getText("_Remove_column"),
|
493 |
JOptionPane.WARNING_MESSAGE);
|
494 |
continue;
|
495 |
} |
496 |
|
497 |
editableType.remove(fieldName); |
498 |
} |
499 |
jTableFields.getSelectionModel().clearSelection(); |
500 |
jTableFields.revalidate(); |
501 |
} |
502 |
}); |
503 |
} |
504 |
return jBtnDeleteField;
|
505 |
} |
506 |
|
507 |
/**
|
508 |
* This method initializes jBtnRenameField
|
509 |
*
|
510 |
* @return javax.swing.JButton
|
511 |
*/
|
512 |
private JButton getJBtnRenameField() { |
513 |
if (jBtnRenameField == null) { |
514 |
jBtnRenameField = |
515 |
ToolsSwingLocator.getUsabilitySwingManager().createJButton(); |
516 |
jBtnRenameField.setText(PluginServices |
517 |
.getText(this, "rename_field")); |
518 |
jBtnRenameField |
519 |
.addActionListener(new java.awt.event.ActionListener() {
|
520 |
|
521 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
522 |
int[] selecteds = jTableFields.getSelectedRows(); |
523 |
TableModel tm = jTableFields.getModel();
|
524 |
|
525 |
for (int i = selecteds.length - 1; i >= 0; i--) { |
526 |
String fieldName =
|
527 |
(String) tm.getValueAt(selecteds[i], 0); |
528 |
|
529 |
String old_geom_fld = editableType.getDefaultGeometryAttributeName();
|
530 |
/*
|
531 |
* old_geom_fld is null if we are dealing with
|
532 |
* table (no geometry column)
|
533 |
*/
|
534 |
if (old_geom_fld != null && old_geom_fld.compareTo(fieldName) == 0) { |
535 |
JOptionPane.showMessageDialog(
|
536 |
jTableFields, |
537 |
Messages.getText("_Cannot_rename_geometry_field"),
|
538 |
Messages.getText("_Rename_column"),
|
539 |
JOptionPane.WARNING_MESSAGE);
|
540 |
continue;
|
541 |
} |
542 |
|
543 |
String newName =
|
544 |
JOptionPane.showInputDialog(
|
545 |
(Component) PluginServices.getMDIManager()
|
546 |
.getActiveWindow(), PluginServices |
547 |
.getText(this, "_Please_insert_new_field_name"), |
548 |
fieldName); |
549 |
if (newName == null) { |
550 |
continue;
|
551 |
} |
552 |
|
553 |
if (newName.length() == 0) { |
554 |
JOptionPane.showMessageDialog(
|
555 |
jTableFields, |
556 |
Messages.getText("_No_input_name"),
|
557 |
Messages.getText("_Rename_column"),
|
558 |
JOptionPane.ERROR_MESSAGE);
|
559 |
continue;
|
560 |
} |
561 |
|
562 |
if (editableType.getIndex(newName) != -1) { |
563 |
NotificationManager.showMessageInfo( |
564 |
PluginServices.getText(this,
|
565 |
"field_already_exists"), null); |
566 |
continue;
|
567 |
} |
568 |
|
569 |
try {
|
570 |
EditableFeatureAttributeDescriptor efad = |
571 |
(EditableFeatureAttributeDescriptor) |
572 |
editableType.getAttributeDescriptor(fieldName); |
573 |
efad.setName(newName); |
574 |
|
575 |
} catch (Exception de) { |
576 |
JOptionPane.showMessageDialog(
|
577 |
jTableFields, |
578 |
Messages.getText("_Unable_to_rename_field")
|
579 |
+ ": " + de.getMessage(),
|
580 |
Messages.getText("_Rename_column"),
|
581 |
JOptionPane.ERROR_MESSAGE);
|
582 |
} |
583 |
} |
584 |
jTableFields.repaint(); |
585 |
} |
586 |
}); |
587 |
} |
588 |
return jBtnRenameField;
|
589 |
} |
590 |
|
591 |
/**
|
592 |
* This method initializes jBtnOK
|
593 |
*
|
594 |
* @return javax.swing.JButton
|
595 |
*/
|
596 |
private JButton getJBtnOK() { |
597 |
if (jBtnOK == null) { |
598 |
jBtnOK = |
599 |
ToolsSwingLocator.getUsabilitySwingManager().createJButton(); |
600 |
jBtnOK.setText(PluginServices.getText(this, "aceptar")); |
601 |
jBtnOK.addActionListener(new java.awt.event.ActionListener() {
|
602 |
|
603 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
604 |
try {
|
605 |
featureStore.update(editableType); |
606 |
} catch (DataException e1) {
|
607 |
NotificationManager.showMessageError(PluginServices |
608 |
.getText(this, "update_featuretype_error"), e1); |
609 |
} |
610 |
PluginServices.getMDIManager().closeWindow( |
611 |
FeatureTypeEditingPanel.this); |
612 |
} |
613 |
}); |
614 |
} |
615 |
return jBtnOK;
|
616 |
} |
617 |
|
618 |
/**
|
619 |
* This method initializes jButton
|
620 |
*
|
621 |
* @return javax.swing.JButton
|
622 |
*/
|
623 |
private JButton getJBtnCancel() { |
624 |
if (jBtnCancel == null) { |
625 |
jBtnCancel = |
626 |
ToolsSwingLocator.getUsabilitySwingManager().createJButton(); |
627 |
jBtnCancel.setText(PluginServices.getText(this, "cancelar")); |
628 |
jBtnCancel.addActionListener(new java.awt.event.ActionListener() {
|
629 |
|
630 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
631 |
PluginServices.getMDIManager().closeWindow( |
632 |
FeatureTypeEditingPanel.this); |
633 |
} |
634 |
}); |
635 |
// jBtnCancel.setVisible(false);
|
636 |
} |
637 |
return jBtnCancel;
|
638 |
} |
639 |
|
640 |
/**
|
641 |
* This method initializes jPanelButtons
|
642 |
*
|
643 |
* @return javax.swing.JPanel
|
644 |
*/
|
645 |
private JPanel getJPanelButtons() { |
646 |
if (jPanelButtons == null) { |
647 |
jPanelButtons = new JPanel(); |
648 |
JPanel aux = new JPanel(new GridLayout(3, 1)); |
649 |
aux.add(getJBtnNewField()); |
650 |
aux.add(getJBtnRenameField()); |
651 |
aux.add(getJBtnDelete()); |
652 |
jPanelButtons.add(aux, BorderLayout.NORTH);
|
653 |
} |
654 |
return jPanelButtons;
|
655 |
} |
656 |
|
657 |
public Object getWindowProfile() { |
658 |
return WindowInfo.DIALOG_PROFILE;
|
659 |
} |
660 |
|
661 |
} |