Statistics
| Revision:

root / branches / v2_0_0_prep / applications / appgvSIG / src / org / gvsig / fmap / dal / serverexplorer / filesystem / swing / FilesystemExplorerTableWizardPanel.java @ 27723

History | View | Annotate | Download (2.78 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.io.File;
32

    
33
import org.gvsig.PrepareContext;
34
import org.gvsig.fmap.dal.DALLocator;
35
import org.gvsig.fmap.dal.DataManager;
36
import org.gvsig.fmap.dal.DataStoreParameters;
37
import org.gvsig.fmap.dal.feature.FeatureStore;
38
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemStoreParameters;
39
import org.gvsig.project.document.table.FeatureTableDocument;
40

    
41
import com.iver.andami.PluginServices;
42
import com.iver.andami.messages.NotificationManager;
43
import com.iver.cit.gvsig.ProjectExtension;
44
import com.iver.cit.gvsig.project.Project;
45
import com.iver.cit.gvsig.project.ProjectFactory;
46

    
47
public class FilesystemExplorerTableWizardPanel extends
48
                FilesystemExplorerWizardPanel {
49

    
50
        /**
51
         *
52
         */
53
        private static final long serialVersionUID = 8469934188826417698L;
54

    
55
        private PrepareContext prepareDSContext = null;
56

    
57
        @Override
58
        public void execute() {
59
                DataManager man = DALLocator.getDataManager();
60
                FeatureStore store;
61
                File file;
62
                String tableName;
63
                FeatureTableDocument table;
64
                Project project = ((ProjectExtension) PluginServices
65
                                .getExtension(ProjectExtension.class)).getProject();
66

    
67
                for (DataStoreParameters params : this.getParameters()) {
68
                        file = ((FilesystemStoreParameters) params).getFile();
69
                        tableName = file
70
                                        .getName();
71

    
72
                        try {
73
                                store = (FeatureStore) this.explorer.open(file);
74
                        } catch (Exception e) {
75
                                NotificationManager.addError(e);
76
                                return;
77
                        }
78

    
79
                        table = ProjectFactory.createTable(file.getName(), store);
80

    
81
                        project.addDocument(table);
82

    
83

    
84
                }
85

    
86
        }
87

    
88
        @Override
89
        protected PrepareContext getPrepareDataStoreContext() {
90
                if (this.prepareDSContext == null){
91
                        this.prepareDSContext = new PrepareContext(){
92
                                public Window getOwnerWindow() {
93
                                        return null;
94
                                }
95

    
96
                        };
97
                }
98
                return this.prepareDSContext;
99
        }
100

    
101
}