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 / exportto / app / extension / LoadTableAction.java @ 40557

History | View | Annotate | Download (3.87 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 javax.swing.JComponent;
27
import javax.swing.JOptionPane;
28

    
29
import org.slf4j.Logger;
30
import org.slf4j.LoggerFactory;
31

    
32
import org.gvsig.andami.PluginServices;
33
import org.gvsig.app.ApplicationLocator;
34
import org.gvsig.app.project.ProjectManager;
35
import org.gvsig.app.project.documents.table.TableDocument;
36
import org.gvsig.app.project.documents.table.TableManager;
37
import org.gvsig.exportto.ExporttoServiceFinishAction;
38
import org.gvsig.fmap.dal.DALLocator;
39
import org.gvsig.fmap.dal.DataManager;
40
import org.gvsig.fmap.dal.DataStoreParameters;
41
import org.gvsig.fmap.dal.exception.DataException;
42
import org.gvsig.fmap.dal.exception.InitializeException;
43
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException;
44
import org.gvsig.fmap.dal.exception.ValidateDataParametersException;
45
import org.gvsig.fmap.dal.feature.FeatureStore;
46

    
47
/**
48
 * @author gvSIG Team
49
 * @version $Id$
50
 * 
51
 */
52
public class LoadTableAction implements ExporttoServiceFinishAction {
53

    
54
    private static final Logger LOG = LoggerFactory
55
        .getLogger(LoadLayerAction.class);
56
    private static final DataManager DATA_MANAGER = DALLocator.getDataManager();
57

    
58
    public LoadTableAction() {
59
        super();
60
    }
61

    
62
    public void finished(String tableName,
63
        DataStoreParameters dataStoreParameters) {
64

    
65
        int res =
66
            JOptionPane.showConfirmDialog((JComponent) PluginServices
67
                .getMDIManager().getActiveWindow(), PluginServices.getText(
68
                this, "add_table_to_project"), PluginServices.getText(this,
69
                "add_table"), JOptionPane.YES_NO_OPTION);
70

    
71
        if (res == JOptionPane.YES_OPTION) {
72
            try {
73
                FeatureStore featureStore =
74
                    (FeatureStore) DATA_MANAGER.openStore(
75
                        dataStoreParameters.getDataStoreName(),
76
                        dataStoreParameters);
77
                TableDocument tableDocument =
78
                    (TableDocument) ProjectManager.getInstance()
79
                        .createDocument(TableManager.TYPENAME, tableName);
80
                tableDocument.setStore(featureStore);
81

    
82
                ApplicationLocator.getManager().getProjectManager()
83
                    .getCurrentProject().add(tableDocument);
84
                // FeatureTableDocumentPanel featureTableDocumentPanel =
85
                // new FeatureTableDocumentPanel(tableDocument);
86
                //
87
                // MDI_MANAGER.addWindow(featureTableDocumentPanel);
88
            } catch (ValidateDataParametersException e) {
89
                LOG.error("Error opening the exported table", e);
90
            } catch (InitializeException e) {
91
                LOG.error("Error opening the exported table", e);
92
            } catch (ProviderNotRegisteredException e) {
93
                LOG.error("Error opening the exported table", e);
94
            } catch (DataException e) {
95
                LOG.error("Error opening the exported table", e);
96
            }
97
        }
98
    }
99
}