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 / extension / TableEditChangeColumnsExtension.java @ 44259
History | View | Annotate | Download (3.23 KB)
1 | 40558 | jjdelcerro | /**
|
---|---|---|---|
2 | * gvSIG. Desktop Geographic Information System.
|
||
3 | 40435 | jjdelcerro | *
|
4 | 40558 | jjdelcerro | * Copyright (C) 2007-2013 gvSIG Association.
|
5 | *
|
||
6 | 40435 | jjdelcerro | * This program is free software; you can redistribute it and/or
|
7 | * modify it under the terms of the GNU General Public License
|
||
8 | 40558 | jjdelcerro | * as published by the Free Software Foundation; either version 3
|
9 | 40435 | jjdelcerro | * of the License, or (at your option) any later version.
|
10 | 40558 | jjdelcerro | *
|
11 | 40435 | jjdelcerro | * 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 | 40558 | jjdelcerro | *
|
16 | 40435 | jjdelcerro | * 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 | 40558 | jjdelcerro | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 | 40435 | jjdelcerro | * MA 02110-1301, USA.
|
20 | 40558 | jjdelcerro | *
|
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 | 40435 | jjdelcerro | */
|
24 | package org.gvsig.app.extension; |
||
25 | |||
26 | import org.gvsig.andami.IconThemeHelper; |
||
27 | import org.gvsig.andami.PluginServices; |
||
28 | import org.gvsig.andami.messages.NotificationManager; |
||
29 | 44199 | jjdelcerro | import org.gvsig.app.ApplicationLocator; |
30 | import org.gvsig.app.ApplicationManager; |
||
31 | import org.gvsig.app.project.documents.table.TableDocument; |
||
32 | import org.gvsig.app.project.documents.table.TableManager; |
||
33 | import org.gvsig.app.project.documents.table.gui.FeatureTableDocumentPanel; |
||
34 | 40435 | jjdelcerro | import org.gvsig.fmap.dal.exception.DataException; |
35 | |||
36 | /**
|
||
37 | * DOCUMENT ME!
|
||
38 | *
|
||
39 | * @author Vicente Caballero Navarro
|
||
40 | */
|
||
41 | public class TableEditChangeColumnsExtension extends AbstractTableEditExtension { |
||
42 | |||
43 | public void initialize() { |
||
44 | super.initialize();
|
||
45 | IconThemeHelper.registerIcon("action", "table-rename-column", this); |
||
46 | IconThemeHelper.registerIcon("action", "table-remove-column", this); |
||
47 | } |
||
48 | /**
|
||
49 | * @see org.gvsig.andami.plugins.IExtension#execute(java.lang.String)
|
||
50 | */
|
||
51 | public void execute(String actionCommand) { |
||
52 | try {
|
||
53 | featureTableOperations.setTablePanel(table); |
||
54 | if ("table-remove-column".equals(actionCommand)) { |
||
55 | featureTableOperations.deleteAttributes(table.getTablePanel() |
||
56 | .getTable()); |
||
57 | } else
|
||
58 | if ("table-rename-column".equals(actionCommand)) { |
||
59 | featureTableOperations.renameAttributes(table |
||
60 | .getTablePanel().getTable()); |
||
61 | } |
||
62 | } catch (DataException e) {
|
||
63 | NotificationManager.showMessageError( |
||
64 | PluginServices.getText(this, "update_featuretype_error"), null); |
||
65 | } |
||
66 | |||
67 | } |
||
68 | |||
69 | 44199 | jjdelcerro | @Override
|
70 | 40435 | jjdelcerro | public boolean isEnabled() { |
71 | try {
|
||
72 | if (table.getTablePanel().getTable().getSelectedColumnCount() > 0) { |
||
73 | return true; |
||
74 | } |
||
75 | } catch (DataException e) {
|
||
76 | return false; |
||
77 | } |
||
78 | return false; |
||
79 | } |
||
80 | 44199 | jjdelcerro | |
81 | @Override
|
||
82 | public boolean isVisible() { |
||
83 | ApplicationManager application = ApplicationLocator.getManager(); |
||
84 | TableDocument tableDoc = (TableDocument) application.getActiveDocument(TableManager.TYPENAME); |
||
85 | if( tableDoc == null ) { |
||
86 | return false; |
||
87 | } |
||
88 | this.table = (FeatureTableDocumentPanel) tableDoc.getMainComponent();
|
||
89 | return true; |
||
90 | } |
||
91 | |||
92 | |||
93 | 40435 | jjdelcerro | } |