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