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 / export / app / extension / ExportTableExtension.java @ 47422
History | View | Annotate | Download (3.65 KB)
1 | 40557 | jjdelcerro | /**
|
---|---|---|---|
2 | * gvSIG. Desktop Geographic Information System.
|
||
3 | 40435 | jjdelcerro | *
|
4 | 40557 | jjdelcerro | * Copyright (C) 2007-2013 gvSIG Association.
|
5 | 40435 | jjdelcerro | *
|
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 | 40557 | 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 | *
|
||
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 | 40557 | jjdelcerro | * 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 | 43926 | jjdelcerro | package org.gvsig.export.app.extension; |
25 | 40435 | jjdelcerro | |
26 | 44263 | jjdelcerro | import javax.swing.Action; |
27 | 40435 | jjdelcerro | import org.gvsig.andami.IconThemeHelper; |
28 | import org.gvsig.andami.plugins.Extension; |
||
29 | import org.gvsig.app.ApplicationLocator; |
||
30 | import org.gvsig.app.ApplicationManager; |
||
31 | import org.gvsig.app.project.documents.table.TableDocument; |
||
32 | 43926 | jjdelcerro | import org.gvsig.app.project.documents.table.TableManager; |
33 | 45076 | omartinez | import org.gvsig.app.project.documents.table.gui.FeatureTableDocumentPanel; |
34 | 44263 | jjdelcerro | import org.gvsig.export.app.extension.FeatureStoreSearchExportAction.FeatureStoreSearchExportActionFactory; |
35 | 45076 | omartinez | import org.gvsig.fmap.dal.feature.FeatureStore; |
36 | 44263 | jjdelcerro | import org.gvsig.fmap.dal.swing.DALSwingLocator; |
37 | import org.gvsig.fmap.dal.swing.DataSwingManager; |
||
38 | import org.gvsig.fmap.dal.swing.searchpanel.FeatureStoreSearchPanel; |
||
39 | 45627 | fdiaz | import org.gvsig.tools.dataTypes.DataTypes; |
40 | import org.gvsig.tools.swing.api.windowmanager.WindowManager; |
||
41 | import org.gvsig.tools.util.ArrayUtils; |
||
42 | 40435 | jjdelcerro | |
43 | /**
|
||
44 | * @author gvSIG Team
|
||
45 | * @version $Id$
|
||
46 | *
|
||
47 | */
|
||
48 | 43926 | jjdelcerro | public class ExportTableExtension extends Extension { |
49 | 40435 | jjdelcerro | |
50 | 43926 | jjdelcerro | @Override
|
51 | 40435 | jjdelcerro | public void initialize() { |
52 | IconThemeHelper.registerIcon("action", "table-export", this); |
||
53 | 47422 | jjdelcerro | IconThemeHelper.registerIcon("storeaction", "storeaction-export", this); |
54 | 40435 | jjdelcerro | } |
55 | |||
56 | @Override
|
||
57 | public void postInitialize() { |
||
58 | super.postInitialize();
|
||
59 | 44263 | jjdelcerro | FeatureStoreSearchExportActionFactory.selfRegister(); |
60 | 40435 | jjdelcerro | } |
61 | 44263 | jjdelcerro | |
62 | 43926 | jjdelcerro | @Override
|
63 | 40435 | jjdelcerro | public void execute(String actionCommand) { |
64 | 45627 | fdiaz | this.execute(actionCommand, null); |
65 | } |
||
66 | |||
67 | public void execute(String command, Object[] args) { |
||
68 | |||
69 | 43926 | jjdelcerro | ApplicationManager application = ApplicationLocator.getManager(); |
70 | 45627 | fdiaz | Object table = ArrayUtils.get(args, 0); |
71 | TableDocument tableDoc; |
||
72 | |||
73 | WindowManager.MODE mode = WindowManager.MODE.WINDOW; |
||
74 | if (table instanceof TableDocument) { |
||
75 | tableDoc = (TableDocument) table; |
||
76 | mode = WindowManager.MODE.fromInteger( |
||
77 | (Integer) ArrayUtils.get(args, 1, DataTypes.INT, 0) |
||
78 | ); |
||
79 | } else {
|
||
80 | tableDoc = (TableDocument) application.getActiveDocument(TableManager.TYPENAME); |
||
81 | |||
82 | } |
||
83 | 43926 | jjdelcerro | if( tableDoc == null ) { |
84 | return;
|
||
85 | 40435 | jjdelcerro | } |
86 | 45076 | omartinez | final FeatureTableDocumentPanel tablePanel = (FeatureTableDocumentPanel) tableDoc.getMainComponent();
|
87 | 44263 | jjdelcerro | ExportTable exportTable = new ExportTable();
|
88 | 45627 | fdiaz | exportTable.showExport(tablePanel.getFeatureStore(), null, mode);
|
89 | 40435 | jjdelcerro | } |
90 | |||
91 | 43926 | jjdelcerro | @Override
|
92 | 40435 | jjdelcerro | public boolean isEnabled() { |
93 | return true; |
||
94 | } |
||
95 | |||
96 | 43926 | jjdelcerro | @Override
|
97 | 40435 | jjdelcerro | public boolean isVisible() { |
98 | 43926 | jjdelcerro | ApplicationManager application = ApplicationLocator.getManager(); |
99 | TableDocument tableDoc = (TableDocument) application.getActiveDocument(TableManager.TYPENAME); |
||
100 | return tableDoc != null; |
||
101 | 40435 | jjdelcerro | } |
102 | } |