Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / extensions / org.gvsig.exportto.app / org.gvsig.exportto.app.extension / src / main / java / org / gvsig / exportto / app / extension / ExporttoTableExtension.java @ 37781

History | View | Annotate | Download (3.29 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.PluginServices;
25
import org.gvsig.andami.plugins.Extension;
26
import org.gvsig.andami.ui.mdiManager.IWindow;
27
import org.gvsig.app.ApplicationLocator;
28
import org.gvsig.app.ApplicationManager;
29
import org.gvsig.app.project.documents.table.TableDocument;
30
import org.gvsig.app.project.documents.table.gui.FeatureTableDocumentPanel;
31
import org.gvsig.exportto.swing.ExporttoSwingLocator;
32
import org.gvsig.exportto.swing.ExporttoSwingManager;
33
import org.gvsig.exportto.swing.ExporttoWindowManager;
34
import org.gvsig.exportto.swing.JExporttoServicePanel;
35
import org.gvsig.fmap.dal.feature.FeatureStore;
36

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

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

    
48
    public void initialize() {
49

    
50
    }
51

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

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

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

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

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

    
83
    }
84

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

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

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

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