Statistics
| Revision:

root / branches / v2_0_0_prep / extensions / org.gvsig.app.document.table.app / org.gvsig.app.document.table.app.mainplugin / src / main / java / org / gvsig / fmap / dal / serverexplorer / filesystem / swing / FilesystemExplorerTableWizardPanel.java @ 36760

History | View | Annotate | Download (3.92 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

    
23
/*
24
 * AUTHORS (In addition to CIT):
25
 * 2008 IVER T.I. S.A.   {{Task}}
26
 */
27

    
28
package org.gvsig.fmap.dal.serverexplorer.filesystem.swing;
29

    
30
import java.awt.Window;
31
import java.util.ArrayList;
32
import java.util.List;
33

    
34
import org.cresques.cts.IProjection;
35
import org.gvsig.andami.PluginServices;
36
import org.gvsig.andami.messages.NotificationManager;
37
import org.gvsig.app.ApplicationLocator;
38
import org.gvsig.app.ApplicationManager;
39
import org.gvsig.app.prepareAction.PrepareContext;
40
import org.gvsig.app.project.Project;
41
import org.gvsig.app.project.ProjectManager;
42
import org.gvsig.app.project.documents.table.TableDocument;
43
import org.gvsig.app.project.documents.table.TableManager;
44
import org.gvsig.fmap.dal.DALLocator;
45
import org.gvsig.fmap.dal.DataManager;
46
import org.gvsig.fmap.dal.DataStoreParameters;
47
import org.gvsig.fmap.dal.feature.FeatureStore;
48

    
49
public class FilesystemExplorerTableWizardPanel extends
50
    FilesystemExplorerWizardPanel {
51

    
52
    private static final long serialVersionUID = 8469934188826417698L;
53

    
54
    private PrepareContext prepareDSContext = null;
55

    
56

    
57
    @Override
58
    public void execute() {
59
        executeWizard();
60
    }
61

    
62
    public Object executeWizard() {
63
        FeatureStore store;
64
        TableDocument table;
65

    
66
        ApplicationManager manager = ApplicationLocator.getManager();
67
        Project project = manager.getCurrentProject();
68

    
69
        PrepareContext context = this.getPrepareDataStoreContext();
70
        DataStoreParameters[] parameters = this.getParameters();
71
        List<TableDocument> tabledocs =
72
            new ArrayList<TableDocument>(parameters.length);
73
        for (DataStoreParameters params : parameters) {
74
            store = null;
75
            try {
76
                DataManager dataManager = DALLocator.getDataManager();
77
                store =
78
                    (FeatureStore) dataManager.openStore(
79
                        params.getDataStoreName(), params);
80
                manager.pepareOpenDataSource(store, context);
81

    
82
                table =
83
                    (TableDocument) ProjectManager.getInstance()
84
                        .createDocument(TableManager.TYPENAME);
85
                table.setName(store.getName());
86
                table.setStore(store);
87

    
88
                // project.add(table);
89
                tabledocs.add(table);
90
            } catch (Exception e) {
91
                if (store != null) {
92
                    store.dispose();
93
                }
94
                NotificationManager.addError(e);
95
            }
96

    
97
        }
98
        return tabledocs;
99
    }
100

    
101
    @Override
102
    protected PrepareContext getPrepareDataStoreContext() {
103
        if (this.prepareDSContext == null) {
104
            this.prepareDSContext = new PrepareContext() {
105

    
106
                public Window getOwnerWindow() {
107
                    return null;
108
                }
109
                
110
                public IProjection getViewProjection() {
111
                        return null;
112
                }
113

    
114
            };
115
        }
116
        return this.prepareDSContext;
117
    }
118

    
119
    public String getTabName() {
120
        return PluginServices.getText(this, "File");
121
    }
122

    
123
}