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 / TableEditAttributes.java @ 44103
History | View | Annotate | Download (3.67 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 | import org.gvsig.andami.plugins.Extension; |
||
30 | import org.gvsig.andami.ui.mdiManager.IWindow; |
||
31 | import org.gvsig.app.project.documents.table.TableDocument; |
||
32 | 40730 | jldominguez | import org.gvsig.app.project.documents.table.TableOperations; |
33 | 40435 | jjdelcerro | import org.gvsig.app.project.documents.table.gui.FeatureTableDocumentPanel; |
34 | import org.gvsig.app.project.documents.table.gui.FeatureTypeEditingPanel; |
||
35 | import org.gvsig.fmap.dal.exception.DataException; |
||
36 | import org.gvsig.fmap.dal.feature.FeatureStore; |
||
37 | 40730 | jldominguez | import org.gvsig.i18n.Messages; |
38 | 40435 | jjdelcerro | |
39 | /**
|
||
40 | * Extensi?n que abre la ventana para cambiar la configuraci?n de la estructura
|
||
41 | * de la tabla.
|
||
42 | *
|
||
43 | * @author Vicente Caballero Navarro
|
||
44 | */
|
||
45 | public class TableEditAttributes extends Extension { |
||
46 | |||
47 | private FeatureTableDocumentPanel table = null; |
||
48 | 40730 | jldominguez | private TableOperations featureTableOperations = null; |
49 | 40435 | jjdelcerro | |
50 | /**
|
||
51 | * @see com.iver.mdiApp.plugins.IExtension#updateUI(java.lang.String)
|
||
52 | */
|
||
53 | public void execute(String s) { |
||
54 | if( "table-column-manager".equalsIgnoreCase(s)) { |
||
55 | TableDocument pt = table.getModel(); |
||
56 | FeatureStore fs = pt.getStore(); |
||
57 | try {
|
||
58 | PluginServices.getMDIManager().addWindow( |
||
59 | new FeatureTypeEditingPanel(fs));
|
||
60 | } catch (DataException e) {
|
||
61 | NotificationManager.addError( |
||
62 | PluginServices.getText(this, "create_editabletype"), e); |
||
63 | } |
||
64 | 40730 | jldominguez | } else {
|
65 | |||
66 | try {
|
||
67 | if ("table-add-column".equals(s)) { |
||
68 | featureTableOperations.setTablePanel(table); |
||
69 | featureTableOperations.insertAttributes(table |
||
70 | .getTablePanel().getTable()); |
||
71 | } |
||
72 | } catch (DataException de) {
|
||
73 | NotificationManager.showMessageError( |
||
74 | Messages.getText("update_featuretype_error"), null); |
||
75 | } |
||
76 | |||
77 | 40435 | jjdelcerro | } |
78 | } |
||
79 | |||
80 | /**
|
||
81 | * @see org.gvsig.andami.plugins.IExtension#initialize()
|
||
82 | */
|
||
83 | public void initialize() { |
||
84 | IconThemeHelper.registerIcon("action", "table-column-manager", this); |
||
85 | 40730 | jldominguez | IconThemeHelper.registerIcon("action", "table-add-column", this); |
86 | featureTableOperations = TableOperations.getInstance(); |
||
87 | 40435 | jjdelcerro | } |
88 | |||
89 | public boolean isEnabled() { |
||
90 | FeatureStore fs = table.getModel().getStore(); |
||
91 | return fs.isEditing();
|
||
92 | } |
||
93 | |||
94 | /**
|
||
95 | * @see org.gvsig.andami.plugins.IExtension#isVisible()
|
||
96 | */
|
||
97 | public boolean isVisible() { |
||
98 | IWindow v = PluginServices.getMDIManager().getActiveWindow(); |
||
99 | if (v != null && v instanceof FeatureTableDocumentPanel) { |
||
100 | table = (FeatureTableDocumentPanel) v; |
||
101 | return true; |
||
102 | } |
||
103 | return false; |
||
104 | } |
||
105 | |||
106 | } |