svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.exportto.app / org.gvsig.exportto.app.mainplugin / src / main / java / org / gvsig / exportto / app / extension / ExporttoTableExtension.java @ 43920
History | View | Annotate | Download (3.64 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.exportto.app.extension; |
25 |
|
26 |
import org.gvsig.andami.IconThemeHelper; |
27 |
import org.gvsig.andami.PluginServices; |
28 |
import org.gvsig.andami.plugins.Extension; |
29 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
30 |
import org.gvsig.app.ApplicationLocator; |
31 |
import org.gvsig.app.ApplicationManager; |
32 |
import org.gvsig.app.project.documents.table.TableDocument; |
33 |
import org.gvsig.app.project.documents.table.gui.FeatureTableDocumentPanel; |
34 |
import org.gvsig.exportto.swing.ExporttoSwingLocator; |
35 |
import org.gvsig.exportto.swing.ExporttoSwingManager; |
36 |
import org.gvsig.exportto.swing.ExporttoWindowManager; |
37 |
import org.gvsig.exportto.swing.JExporttoServicePanel; |
38 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
39 |
import org.gvsig.tools.ToolsLocator; |
40 |
import org.gvsig.tools.i18n.I18nManager; |
41 |
|
42 |
/**
|
43 |
* @author gvSIG Team
|
44 |
* @version $Id$
|
45 |
*
|
46 |
*/
|
47 |
public class ExporttoTableExtension extends Extension { |
48 |
|
49 |
private ExporttoSwingManager swingManager;
|
50 |
private static final ApplicationManager APPLICATION_MANAGER = |
51 |
ApplicationLocator.getManager(); |
52 |
|
53 |
public void initialize() { |
54 |
IconThemeHelper.registerIcon("action", "table-export", this); |
55 |
} |
56 |
|
57 |
@Override
|
58 |
public void postInitialize() { |
59 |
super.postInitialize();
|
60 |
swingManager = ExporttoSwingLocator.getSwingManager(); |
61 |
} |
62 |
|
63 |
public void execute(String actionCommand) { |
64 |
org.gvsig.andami.ui.mdiManager.IWindow f = |
65 |
PluginServices.getMDIManager().getActiveWindow(); |
66 |
|
67 |
if (f instanceof FeatureTableDocumentPanel) { |
68 |
FeatureTableDocumentPanel featureTableDocumentPanel = |
69 |
(FeatureTableDocumentPanel) f; |
70 |
TableDocument tableDocument = |
71 |
(TableDocument) featureTableDocumentPanel.getDocument(); |
72 |
showExportto(tableDocument.getStore()); |
73 |
} |
74 |
} |
75 |
|
76 |
private void showExportto(FeatureStore featureStore) { |
77 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
78 |
|
79 |
JExporttoServicePanel panel = swingManager.createExportto( |
80 |
featureStore, |
81 |
null,
|
82 |
new LoadTableAction(),
|
83 |
null //new int[] { ExporttoSwingManager.VECTORIAL_TABLE_WITHOUT_GEOMETRY, ExporttoSwingManager.VECTORIAL_TABLE_WITH_GEOMETRY } |
84 |
); |
85 |
|
86 |
swingManager.getWindowManager().showWindow(panel, i18nManager.getTranslation("_Export_to"),
|
87 |
ExporttoWindowManager.MODE_WINDOW); |
88 |
|
89 |
} |
90 |
|
91 |
public boolean isEnabled() { |
92 |
return true; |
93 |
} |
94 |
|
95 |
public boolean isVisible() { |
96 |
IWindow window = APPLICATION_MANAGER.getUIManager().getActiveWindow(); |
97 |
|
98 |
if (window == null) { |
99 |
return false; |
100 |
} |
101 |
|
102 |
if (window instanceof FeatureTableDocumentPanel) { |
103 |
return true; |
104 |
} |
105 |
return false; |
106 |
} |
107 |
} |