svn-gvsig-desktop / branches / v2_0_0_prep / applications / appgvSIG / src / org / gvsig / app / imp / DefaultAppgvSIGManager.java @ 34002
History | View | Annotate | Download (8.67 KB)
1 | 26919 | jmvivo | /* 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 | * 2009 IVER T.I {{Task}}
|
||
26 | */
|
||
27 | |||
28 | /**
|
||
29 | *
|
||
30 | */
|
||
31 | 29598 | jpiera | package org.gvsig.app.imp; |
32 | 26919 | jmvivo | |
33 | import java.util.ArrayList; |
||
34 | import java.util.Iterator; |
||
35 | import java.util.List; |
||
36 | 31496 | jjdelcerro | import java.util.prefs.Preferences; |
37 | 26919 | jmvivo | |
38 | 31496 | jjdelcerro | import org.cresques.cts.IProjection; |
39 | 34002 | jjdelcerro | import org.gvsig.about.AboutLocator; |
40 | import org.gvsig.about.AboutManager; |
||
41 | 31496 | jjdelcerro | import org.gvsig.andami.PluginServices; |
42 | import org.gvsig.andami.iconthemes.IconThemeManager; |
||
43 | import org.gvsig.andami.ui.mdiManager.MDIManager; |
||
44 | import org.gvsig.app.ApplicationManager; |
||
45 | import org.gvsig.app.PreferencesNode; |
||
46 | import org.gvsig.app.extension.Version; |
||
47 | 29598 | jpiera | import org.gvsig.app.gui.WizardPanel; |
48 | 31496 | jjdelcerro | import org.gvsig.app.prepareAction.PrepareContext; |
49 | import org.gvsig.app.prepareAction.PrepareContextView; |
||
50 | import org.gvsig.app.prepareAction.PrepareDataStore; |
||
51 | import org.gvsig.app.prepareAction.PrepareDataStoreParameters; |
||
52 | import org.gvsig.app.prepareAction.PrepareLayer; |
||
53 | import org.gvsig.app.project.DefaultProject; |
||
54 | import org.gvsig.app.project.Project; |
||
55 | import org.gvsig.app.project.ProjectManager; |
||
56 | import org.gvsig.fmap.crs.CRSFactory; |
||
57 | import org.gvsig.fmap.dal.DALLocator; |
||
58 | import org.gvsig.fmap.dal.DataManager; |
||
59 | 26919 | jmvivo | import org.gvsig.fmap.dal.DataStore; |
60 | import org.gvsig.fmap.dal.DataStoreParameters; |
||
61 | 31496 | jjdelcerro | import org.gvsig.fmap.geom.GeometryLocator; |
62 | import org.gvsig.fmap.geom.GeometryManager; |
||
63 | import org.gvsig.fmap.mapcontext.MapContextLocator; |
||
64 | import org.gvsig.fmap.mapcontext.MapContextManager; |
||
65 | 26932 | jmvivo | import org.gvsig.fmap.mapcontext.layers.FLayer; |
66 | 29197 | jmvivo | import org.gvsig.tools.ToolsLocator; |
67 | 31496 | jjdelcerro | import org.gvsig.tools.dispose.DisposableManager; |
68 | import org.gvsig.tools.dynobject.DynObjectManager; |
||
69 | 29197 | jmvivo | import org.gvsig.tools.extensionpoint.ExtensionPoint; |
70 | import org.gvsig.tools.extensionpoint.ExtensionPointManager; |
||
71 | import org.gvsig.tools.extensionpoint.ExtensionPoint.Extension; |
||
72 | 31496 | jjdelcerro | import org.gvsig.tools.persistence.PersistenceManager; |
73 | 26919 | jmvivo | |
74 | |||
75 | |||
76 | 29197 | jmvivo | |
77 | 26919 | jmvivo | /**
|
78 | * @author jmvivo
|
||
79 | *
|
||
80 | */
|
||
81 | 31496 | jjdelcerro | public class DefaultAppgvSIGManager implements ApplicationManager { |
82 | 26919 | jmvivo | |
83 | 31496 | jjdelcerro | private static final String EPNAME_PREPARE_OPEN_DATASTORE = "org.gvsig.datastore.open.prepare"; //"PrepareOpenDataStore"; |
84 | private static final String EPNAME_PREPARE_OPEN_DATASTOREPARAMETERS = "org.gvsig.datastoreparameters.open.prepare"; //"PrepareOpenDataStoreParameters"; |
||
85 | private static final String EPNAME_PREPARE_OPEN_LAYER = "org.gvsig.layer.open.prepare"; // "PrepareOpenLayer"; |
||
86 | 26919 | jmvivo | |
87 | 29197 | jmvivo | private static final String EPNAME_ADD_TABLE_WIZARD = "AddLayerWizard"; |
88 | |||
89 | private ExtensionPointManager epManager;
|
||
90 | |||
91 | |||
92 | |||
93 | 31496 | jjdelcerro | public DefaultAppgvSIGManager() {
|
94 | 29197 | jmvivo | epManager = ToolsLocator.getExtensionPointManager(); |
95 | epManager.add(EPNAME_PREPARE_OPEN_DATASTORE, |
||
96 | "Actions to do when open a DataStore");
|
||
97 | epManager.add(EPNAME_PREPARE_OPEN_DATASTOREPARAMETERS, |
||
98 | "Actions to do before open a DataStore with parameters");
|
||
99 | epManager.add(EPNAME_PREPARE_OPEN_LAYER, |
||
100 | "Actions to do after create a Layer");
|
||
101 | epManager.add(EPNAME_ADD_TABLE_WIZARD, |
||
102 | "Wizards to add new document table");
|
||
103 | |||
104 | 26919 | jmvivo | } |
105 | |||
106 | /* (non-Javadoc)
|
||
107 | * @see org.gvsig.appGvSigManager#pepareOpenDataSource(org.gvsig.fmap.dal.DataStore)
|
||
108 | */
|
||
109 | 31496 | jjdelcerro | @SuppressWarnings("unchecked") |
110 | 26919 | jmvivo | public DataStore pepareOpenDataSource(DataStore store,
|
111 | 29197 | jmvivo | PrepareContext context) throws Exception { |
112 | ExtensionPoint ep = epManager.get(EPNAME_PREPARE_OPEN_DATASTORE); |
||
113 | if (ep.getCount() == 0) { |
||
114 | 26919 | jmvivo | return store;
|
115 | } |
||
116 | DataStore result = store; |
||
117 | 29197 | jmvivo | Iterator<ExtensionPoint.Extension> iter = ep.iterator();
|
118 | PrepareDataStore prepare; |
||
119 | 26919 | jmvivo | while (iter.hasNext()) {
|
120 | 29197 | jmvivo | prepare = (PrepareDataStore) iter.next().create(); |
121 | result = prepare.prepare(store, context); |
||
122 | 26919 | jmvivo | } |
123 | return result;
|
||
124 | } |
||
125 | |||
126 | /* (non-Javadoc)
|
||
127 | * @see org.gvsig.appGvSigManager#prepareOpenDataStoreParameters(org.gvsig.fmap.dal.DataStoreParameters)
|
||
128 | */
|
||
129 | 31496 | jjdelcerro | @SuppressWarnings("unchecked") |
130 | 26919 | jmvivo | public DataStoreParameters prepareOpenDataStoreParameters(
|
131 | 29197 | jmvivo | DataStoreParameters storeParameters, PrepareContext context) |
132 | throws Exception { |
||
133 | |||
134 | ExtensionPoint ep = epManager |
||
135 | .get(EPNAME_PREPARE_OPEN_DATASTOREPARAMETERS); |
||
136 | if (ep.getCount() == 0) { |
||
137 | 26919 | jmvivo | return storeParameters;
|
138 | } |
||
139 | DataStoreParameters result = storeParameters; |
||
140 | 29197 | jmvivo | Iterator<ExtensionPoint.Extension> iter = ep.iterator();
|
141 | PrepareDataStoreParameters prepare; |
||
142 | 26919 | jmvivo | while (iter.hasNext()) {
|
143 | 29197 | jmvivo | prepare = (PrepareDataStoreParameters) iter.next().create(); |
144 | result = prepare.prepare(storeParameters, context); |
||
145 | 26919 | jmvivo | } |
146 | 29197 | jmvivo | |
147 | 26919 | jmvivo | return result;
|
148 | } |
||
149 | |||
150 | public void registerPrepareOpenDataStore(PrepareDataStore action) { |
||
151 | 29197 | jmvivo | ExtensionPoint ep = epManager.get(EPNAME_PREPARE_OPEN_DATASTORE); |
152 | ep.append(action.getName(), action.getDescription(), action); |
||
153 | 26919 | jmvivo | } |
154 | |||
155 | public void registerPrepareOpenDataStoreParameters( |
||
156 | PrepareDataStoreParameters action) { |
||
157 | 29197 | jmvivo | ExtensionPoint ep = epManager |
158 | .get(EPNAME_PREPARE_OPEN_DATASTOREPARAMETERS); |
||
159 | ep.append(action.getName(), action.getDescription(), action); |
||
160 | 26919 | jmvivo | |
161 | 29197 | jmvivo | |
162 | 26919 | jmvivo | } |
163 | |||
164 | 31496 | jjdelcerro | @SuppressWarnings("unchecked") |
165 | 26932 | jmvivo | public FLayer prepareOpenLayer(FLayer layer,
|
166 | 29197 | jmvivo | PrepareContextView context) |
167 | throws Exception { |
||
168 | |||
169 | ExtensionPoint ep = epManager.get(EPNAME_PREPARE_OPEN_LAYER); |
||
170 | |||
171 | if (ep.getCount() == 0) { |
||
172 | 26932 | jmvivo | return layer;
|
173 | } |
||
174 | FLayer result = layer; |
||
175 | 29197 | jmvivo | Iterator<ExtensionPoint.Extension> iter = ep.iterator();
|
176 | PrepareLayer prepare; |
||
177 | 26932 | jmvivo | while (iter.hasNext()) {
|
178 | 29197 | jmvivo | prepare = (PrepareLayer) iter.next().create(); |
179 | result = prepare.prepare(layer, context); |
||
180 | 26932 | jmvivo | } |
181 | 29197 | jmvivo | |
182 | 26932 | jmvivo | return result;
|
183 | |||
184 | } |
||
185 | |||
186 | public void registerPrepareOpenLayer(PrepareLayer action) { |
||
187 | 29197 | jmvivo | ExtensionPoint ep = epManager.get(EPNAME_PREPARE_OPEN_LAYER); |
188 | ep.append(action.getName(), action.getDescription(), action); |
||
189 | 26932 | jmvivo | } |
190 | |||
191 | 29197 | jmvivo | public void registerAddTableWizard(String name, String description, |
192 | Class<? extends WizardPanel> wpClass) { |
||
193 | ExtensionPoint ep = epManager.get(EPNAME_ADD_TABLE_WIZARD); |
||
194 | ep.append(name, description, wpClass); |
||
195 | } |
||
196 | |||
197 | 31496 | jjdelcerro | @SuppressWarnings("unchecked") |
198 | 29197 | jmvivo | public List<WizardPanel> getWizardPanels() throws Exception { |
199 | ExtensionPoint ep = epManager.get(EPNAME_ADD_TABLE_WIZARD); |
||
200 | List<WizardPanel> result = new ArrayList<WizardPanel>(); |
||
201 | Iterator<Extension> iter = ep.iterator();
|
||
202 | while (iter.hasNext()) {
|
||
203 | result.add((WizardPanel) iter.next().create()); |
||
204 | } |
||
205 | return result;
|
||
206 | } |
||
207 | 31496 | jjdelcerro | |
208 | public DataManager getDataManager() {
|
||
209 | return DALLocator.getDataManager();
|
||
210 | } |
||
211 | |||
212 | public GeometryManager getGeometryManager() {
|
||
213 | return GeometryLocator.getGeometryManager();
|
||
214 | } |
||
215 | |||
216 | public PersistenceManager getPersistenceManager() {
|
||
217 | return ToolsLocator.getPersistenceManager();
|
||
218 | } |
||
219 | |||
220 | public DisposableManager getDisposableManager() {
|
||
221 | return ToolsLocator.getDisposableManager();
|
||
222 | } |
||
223 | |||
224 | public DynObjectManager getDynObjectManager() {
|
||
225 | return ToolsLocator.getDynObjectManager();
|
||
226 | } |
||
227 | |||
228 | public ExtensionPointManager getExtensionPointManager() {
|
||
229 | return ToolsLocator.getExtensionPointManager();
|
||
230 | } |
||
231 | |||
232 | public ProjectManager getProjectManager() {
|
||
233 | return ProjectManager.getInstance();
|
||
234 | } |
||
235 | |||
236 | public MDIManager getUIManager() {
|
||
237 | return PluginServices.getMDIManager();
|
||
238 | } |
||
239 | |||
240 | public MapContextManager getMapContextManager() {
|
||
241 | return MapContextLocator.getMapContextManager();
|
||
242 | } |
||
243 | |||
244 | public IProjection getCRS(String code) { |
||
245 | return CRSFactory.getCRS(code);
|
||
246 | } |
||
247 | |||
248 | public IconThemeManager getIconThemeManager() {
|
||
249 | return IconThemeManager.getIconThemeManager();
|
||
250 | } |
||
251 | |||
252 | public String getArgument(String name) { |
||
253 | return PluginServices.getArgumentByName(name);
|
||
254 | } |
||
255 | |||
256 | public String[] getArguments() { |
||
257 | return PluginServices.getArguments();
|
||
258 | } |
||
259 | |||
260 | public String getFromClipboard() { |
||
261 | return PluginServices.getFromClipboard();
|
||
262 | } |
||
263 | |||
264 | public void putInClipboard(String data) { |
||
265 | PluginServices.putInClipboard(data); |
||
266 | } |
||
267 | |||
268 | public Project getCurrentProject() {
|
||
269 | return ProjectManager.getInstance().getCurrentProject();
|
||
270 | } |
||
271 | |||
272 | public PreferencesNode getPreferences(String node) { |
||
273 | if( node.equalsIgnoreCase("project")) { |
||
274 | return DefaultProject.getPreferences();
|
||
275 | } |
||
276 | return new DefaultPreferencesNode(node); |
||
277 | } |
||
278 | |||
279 | public PreferencesNode getPreferences() {
|
||
280 | return new DefaultPreferencesNode(); |
||
281 | } |
||
282 | |||
283 | public Version getVersion() {
|
||
284 | return new Version(); |
||
285 | } |
||
286 | |||
287 | 34002 | jjdelcerro | public AboutManager getAbout() {
|
288 | AboutManager manager = AboutLocator.getManager(); |
||
289 | return manager;
|
||
290 | } |
||
291 | 26919 | jmvivo | } |