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 @ 40557
History | View | Annotate | Download (3.45 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 |
|
40 |
/**
|
41 |
* @author gvSIG Team
|
42 |
* @version $Id$
|
43 |
*
|
44 |
*/
|
45 |
public class ExporttoTableExtension extends Extension { |
46 |
|
47 |
private ExporttoSwingManager swingManager;
|
48 |
private static final ApplicationManager APPLICATION_MANAGER = |
49 |
ApplicationLocator.getManager(); |
50 |
|
51 |
public void initialize() { |
52 |
IconThemeHelper.registerIcon("action", "table-export", this); |
53 |
} |
54 |
|
55 |
@Override
|
56 |
public void postInitialize() { |
57 |
super.postInitialize();
|
58 |
swingManager = ExporttoSwingLocator.getSwingManager(); |
59 |
} |
60 |
|
61 |
public void execute(String actionCommand) { |
62 |
org.gvsig.andami.ui.mdiManager.IWindow f = |
63 |
PluginServices.getMDIManager().getActiveWindow(); |
64 |
|
65 |
if (f instanceof FeatureTableDocumentPanel) { |
66 |
FeatureTableDocumentPanel featureTableDocumentPanel = |
67 |
(FeatureTableDocumentPanel) f; |
68 |
TableDocument tableDocument = |
69 |
(TableDocument) featureTableDocumentPanel.getDocument(); |
70 |
showExportto(tableDocument.getStore()); |
71 |
} |
72 |
} |
73 |
|
74 |
private void showExportto(FeatureStore featureStore) { |
75 |
JExporttoServicePanel panel = |
76 |
swingManager |
77 |
.createExportto( |
78 |
featureStore, |
79 |
null,
|
80 |
new LoadTableAction(),
|
81 |
new int[] { ExporttoSwingManager.VECTORIAL_TABLE_WITHOUT_GEOMETRY }); |
82 |
|
83 |
swingManager.getWindowManager().showWindow(panel, "Exportto",
|
84 |
ExporttoWindowManager.MODE_WINDOW); |
85 |
|
86 |
} |
87 |
|
88 |
public boolean isEnabled() { |
89 |
return true; |
90 |
} |
91 |
|
92 |
public boolean isVisible() { |
93 |
IWindow window = APPLICATION_MANAGER.getUIManager().getActiveWindow(); |
94 |
|
95 |
if (window == null) { |
96 |
return false; |
97 |
} |
98 |
|
99 |
if (window instanceof FeatureTableDocumentPanel) { |
100 |
return true; |
101 |
} |
102 |
return false; |
103 |
} |
104 |
} |