root / branches / v2_0_0_prep / applications / appgvSIG / src / org / gvsig / fmap / dal / serverexplorer / filesystem / swing / FilesystemExplorerTableWizardPanel.java @ 33659
History | View | Annotate | Download (3.36 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.andami.PluginServices; |
34 |
import org.gvsig.andami.messages.NotificationManager; |
35 |
import org.gvsig.app.ApplicationLocator; |
36 |
import org.gvsig.app.ApplicationManager; |
37 |
import org.gvsig.app.prepareAction.PrepareContext; |
38 |
import org.gvsig.app.project.Project; |
39 |
import org.gvsig.app.project.ProjectManager; |
40 |
import org.gvsig.app.project.documents.table.TableDocument; |
41 |
import org.gvsig.app.project.documents.table.TableManager; |
42 |
import org.gvsig.fmap.dal.DALLocator; |
43 |
import org.gvsig.fmap.dal.DataManager; |
44 |
import org.gvsig.fmap.dal.DataStoreParameters; |
45 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
46 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemStoreParameters; |
47 |
|
48 |
|
49 |
public class FilesystemExplorerTableWizardPanel extends |
50 |
FilesystemExplorerWizardPanel { |
51 |
|
52 |
/**
|
53 |
*
|
54 |
*/
|
55 |
private static final long serialVersionUID = 8469934188826417698L; |
56 |
|
57 |
// private static Logger logger = LoggerFactory
|
58 |
// .getLogger(FilesystemExplorerTableWizardPanel.class);
|
59 |
private PrepareContext prepareDSContext = null; |
60 |
|
61 |
public void execute() { |
62 |
FeatureStore store; |
63 |
File file;
|
64 |
TableDocument table; |
65 |
|
66 |
ApplicationManager manager = ApplicationLocator.getManager(); |
67 |
Project project = manager.getCurrentProject(); |
68 |
|
69 |
PrepareContext context = this.getPrepareDataStoreContext();
|
70 |
for (DataStoreParameters params : this.getParameters()) { |
71 |
store = null;
|
72 |
try {
|
73 |
DataManager dataManager = DALLocator.getDataManager(); |
74 |
store = (FeatureStore) dataManager.openStore(params.getDataStoreName(), params); |
75 |
// file = ((FilesystemStoreParameters) params).getFile();
|
76 |
// store = (FeatureStore) this.explorer.open(file);
|
77 |
manager.pepareOpenDataSource(store, context); |
78 |
|
79 |
table = (TableDocument) ProjectManager.getInstance().createDocument(TableManager.TYPENAME); |
80 |
table.setName(store.getName()); |
81 |
table.setStore(store); |
82 |
|
83 |
project.add(table); |
84 |
|
85 |
} catch (Exception e) { |
86 |
if( store != null ) { |
87 |
store.dispose(); |
88 |
} |
89 |
NotificationManager.addError(e); |
90 |
return;
|
91 |
|
92 |
} |
93 |
|
94 |
} |
95 |
|
96 |
} |
97 |
|
98 |
@Override
|
99 |
protected PrepareContext getPrepareDataStoreContext() {
|
100 |
if (this.prepareDSContext == null){ |
101 |
this.prepareDSContext = new PrepareContext(){ |
102 |
public Window getOwnerWindow() { |
103 |
return null; |
104 |
} |
105 |
|
106 |
}; |
107 |
} |
108 |
return this.prepareDSContext; |
109 |
} |
110 |
|
111 |
public String getTabName() { |
112 |
return PluginServices.getText(this, "File"); |
113 |
} |
114 |
|
115 |
} |