Statistics
| Revision:

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
/**
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.export.app.extension;
25

    
26
import javax.swing.Action;
27
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
import org.gvsig.app.project.documents.table.TableManager;
33
import org.gvsig.app.project.documents.table.gui.FeatureTableDocumentPanel;
34
import org.gvsig.export.app.extension.FeatureStoreSearchExportAction.FeatureStoreSearchExportActionFactory;
35
import org.gvsig.fmap.dal.feature.FeatureStore;
36
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
import org.gvsig.tools.dataTypes.DataTypes;
40
import org.gvsig.tools.swing.api.windowmanager.WindowManager;
41
import org.gvsig.tools.util.ArrayUtils;
42

    
43
/**
44
 * @author gvSIG Team
45
 * @version $Id$
46
 * 
47
 */
48
public class ExportTableExtension extends Extension {
49

    
50
    @Override
51
    public void initialize() {
52
        IconThemeHelper.registerIcon("action", "table-export", this);
53
        IconThemeHelper.registerIcon("storeaction", "storeaction-export", this);
54
    }
55

    
56
    @Override
57
    public void postInitialize() {
58
        super.postInitialize();
59
        FeatureStoreSearchExportActionFactory.selfRegister();
60
    }
61
    
62
    @Override
63
    public void execute(String actionCommand) {
64
        this.execute(actionCommand, null);
65
    }
66
    
67
    public void execute(String command, Object[] args) {
68
        
69
        ApplicationManager application = ApplicationLocator.getManager();
70
        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
        if( tableDoc == null ) {
84
            return;
85
        }
86
        final FeatureTableDocumentPanel tablePanel = (FeatureTableDocumentPanel) tableDoc.getMainComponent();
87
        ExportTable exportTable = new ExportTable();
88
        exportTable.showExport(tablePanel.getFeatureStore(), null, mode);
89
    }
90

    
91
    @Override
92
    public boolean isEnabled() {
93
        return true;
94
    }
95

    
96
    @Override
97
    public boolean isVisible() {
98
        ApplicationManager application = ApplicationLocator.getManager();
99
        TableDocument tableDoc = (TableDocument) application.getActiveDocument(TableManager.TYPENAME);
100
        return tableDoc != null;
101
    }
102
}