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 / LoadTableAction.java @ 35745

History | View | Annotate | Download (3.76 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 javax.swing.JComponent;
25
import javax.swing.JOptionPane;
26

    
27
import org.slf4j.Logger;
28
import org.slf4j.LoggerFactory;
29

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

    
45

    
46
/**
47
 * @author gvSIG Team
48
 * @version $Id$
49
 *
50
 */
51
public class LoadTableAction implements ExporttoServiceFinishAction{
52
    private static final Logger LOG = LoggerFactory.getLogger(LoadLayerAction.class);   
53
    private static final DataManager DATA_MANAGER = DALLocator.getDataManager();
54

    
55
    public LoadTableAction() {
56
        super();      
57
    }
58

    
59
    public void finished(String tableName,
60
        DataStoreParameters dataStoreParameters) {
61

    
62
        int res = JOptionPane.showConfirmDialog((JComponent) PluginServices.getMDIManager().getActiveWindow(),
63
            PluginServices.getText(this,"add_table_to_project"),
64
            PluginServices.getText(this, "add_table"),
65
            JOptionPane.YES_NO_OPTION);
66

    
67
        if (res == JOptionPane.YES_OPTION) {  
68
            try{
69
                FeatureStore featureStore = (FeatureStore)DATA_MANAGER.openStore(dataStoreParameters.getDataStoreName(), dataStoreParameters);
70
                TableDocument tableDocument = (TableDocument) ProjectManager.getInstance().createDocument(
71
                    TableManager.TYPENAME, tableName);                
72
                tableDocument.setStore(featureStore);
73

    
74
                ApplicationLocator.getManager().getProjectManager().getCurrentProject().add(tableDocument);
75
                //               FeatureTableDocumentPanel featureTableDocumentPanel =
76
                //                    new FeatureTableDocumentPanel(tableDocument);
77
                //
78
                //                MDI_MANAGER.addWindow(featureTableDocumentPanel);                      
79
            } catch (ValidateDataParametersException e) {
80
                LOG.error("Error opening the exported table", e);
81
            } catch (InitializeException e) {
82
                LOG.error("Error opening the exported table", e);
83
            } catch (ProviderNotRegisteredException e) {
84
                LOG.error("Error opening the exported table", e);
85
            } catch (DataException e) {
86
                LOG.error("Error opening the exported table", e);
87
            }
88
        }
89
    }
90
}