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 @ 36630
History | View | Annotate | Download (3.77 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.gvsig.andami.PluginServices; |
35 |
import org.gvsig.andami.messages.NotificationManager; |
36 |
import org.gvsig.app.ApplicationLocator; |
37 |
import org.gvsig.app.ApplicationManager; |
38 |
import org.gvsig.app.prepareAction.PrepareContext; |
39 |
import org.gvsig.app.project.Project; |
40 |
import org.gvsig.app.project.ProjectManager; |
41 |
import org.gvsig.app.project.documents.table.TableDocument; |
42 |
import org.gvsig.app.project.documents.table.TableManager; |
43 |
import org.gvsig.fmap.dal.DALLocator; |
44 |
import org.gvsig.fmap.dal.DataManager; |
45 |
import org.gvsig.fmap.dal.DataStoreParameters; |
46 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
47 |
|
48 |
public class FilesystemExplorerTableWizardPanel extends |
49 |
FilesystemExplorerWizardPanel { |
50 |
|
51 |
private static final long serialVersionUID = 8469934188826417698L; |
52 |
|
53 |
private PrepareContext prepareDSContext = null; |
54 |
|
55 |
private List<TableDocument> tabledocs; |
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 |
tabledocs = new ArrayList<TableDocument>(parameters.length); |
72 |
for (DataStoreParameters params : parameters) {
|
73 |
store = null;
|
74 |
try {
|
75 |
DataManager dataManager = DALLocator.getDataManager(); |
76 |
store = |
77 |
(FeatureStore) dataManager.openStore( |
78 |
params.getDataStoreName(), params); |
79 |
manager.pepareOpenDataSource(store, context); |
80 |
|
81 |
table = |
82 |
(TableDocument) ProjectManager.getInstance() |
83 |
.createDocument(TableManager.TYPENAME); |
84 |
table.setName(store.getName()); |
85 |
table.setStore(store); |
86 |
|
87 |
// project.add(table);
|
88 |
tabledocs.add(table); |
89 |
} catch (Exception e) { |
90 |
if (store != null) { |
91 |
store.dispose(); |
92 |
} |
93 |
NotificationManager.addError(e); |
94 |
} |
95 |
|
96 |
} |
97 |
return tabledocs;
|
98 |
} |
99 |
|
100 |
@Override
|
101 |
protected PrepareContext getPrepareDataStoreContext() {
|
102 |
if (this.prepareDSContext == null) { |
103 |
this.prepareDSContext = new PrepareContext() { |
104 |
|
105 |
public Window getOwnerWindow() { |
106 |
return null; |
107 |
} |
108 |
|
109 |
}; |
110 |
} |
111 |
return this.prepareDSContext; |
112 |
} |
113 |
|
114 |
public String getTabName() { |
115 |
return PluginServices.getText(this, "File"); |
116 |
} |
117 |
|
118 |
} |