Statistics
| Revision:

svn-gvsig-desktop / tags / v2_0_0_Build_2059 / extensions / org.gvsig.exportto.app / org.gvsig.exportto.app.extension / src / main / java / org / gvsig / exportto / app / extension / ExporttoTableExtension.java @ 39325

History | View | Annotate | Download (3.4 KB)

1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
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 2
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
 */
22
package org.gvsig.exportto.app.extension;
23

    
24
import org.gvsig.andami.IconThemeHelper;
25
import org.gvsig.andami.PluginServices;
26
import org.gvsig.andami.plugins.Extension;
27
import org.gvsig.andami.ui.mdiManager.IWindow;
28
import org.gvsig.app.ApplicationLocator;
29
import org.gvsig.app.ApplicationManager;
30
import org.gvsig.app.project.documents.table.TableDocument;
31
import org.gvsig.app.project.documents.table.gui.FeatureTableDocumentPanel;
32
import org.gvsig.exportto.swing.ExporttoSwingLocator;
33
import org.gvsig.exportto.swing.ExporttoSwingManager;
34
import org.gvsig.exportto.swing.ExporttoWindowManager;
35
import org.gvsig.exportto.swing.JExporttoServicePanel;
36
import org.gvsig.fmap.dal.feature.FeatureStore;
37

    
38
/**
39
 * @author gvSIG Team
40
 * @version $Id$
41
 * 
42
 */
43
public class ExporttoTableExtension extends Extension {
44

    
45
    private ExporttoSwingManager swingManager;
46
    private static final ApplicationManager APPLICATION_MANAGER =
47
        ApplicationLocator.getManager();
48

    
49
    public void initialize() {
50
        IconThemeHelper.registerIcon("action", "table-export", this);
51
    }
52

    
53
    @Override
54
    public void postInitialize() {
55
        super.postInitialize();
56
        swingManager = ExporttoSwingLocator.getSwingManager();
57
    }
58

    
59
    public void execute(String actionCommand) {
60
        org.gvsig.andami.ui.mdiManager.IWindow f =
61
            PluginServices.getMDIManager().getActiveWindow();
62

    
63
        if (f instanceof FeatureTableDocumentPanel) {
64
            FeatureTableDocumentPanel featureTableDocumentPanel =
65
                (FeatureTableDocumentPanel) f;
66
            TableDocument tableDocument =
67
                (TableDocument) featureTableDocumentPanel.getDocument();
68
            showExportto(tableDocument.getStore());
69
        }
70
    }
71

    
72
    private void showExportto(FeatureStore featureStore) {
73
        JExporttoServicePanel panel =
74
            swingManager
75
                .createExportto(
76
                    featureStore,
77
                    null,
78
                    new LoadTableAction(),
79
                    new int[] { ExporttoSwingManager.VECTORIAL_TABLE_WITHOUT_GEOMETRY });
80

    
81
        swingManager.getWindowManager().showWindow(panel, "Exportto",
82
            ExporttoWindowManager.MODE_WINDOW);
83

    
84
    }
85

    
86
    public boolean isEnabled() {
87
        return true;
88
    }
89

    
90
    public boolean isVisible() {
91
        IWindow window = APPLICATION_MANAGER.getUIManager().getActiveWindow();
92

    
93
        if (window == null) {
94
            return false;
95
        }
96

    
97
        if (window instanceof FeatureTableDocumentPanel) {
98
            return true;
99
        }
100
        return false;
101
    }
102
}