svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.app / org.gvsig.app.mainplugin / src / main / java / org / gvsig / app / imp / DefaultApplicationManager.java @ 44317
History | View | Annotate | Download (20.3 KB)
1 | 40558 | jjdelcerro | /**
|
---|---|---|---|
2 | * gvSIG. Desktop Geographic Information System.
|
||
3 | *
|
||
4 | * Copyright (C) 2007-2013 gvSIG Association.
|
||
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 3
|
||
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 | * For any additional information, do not hesitate to contact us
|
||
22 | * at info AT gvsig.com, or visit our website www.gvsig.com.
|
||
23 | */
|
||
24 | 40435 | jjdelcerro | |
25 | package org.gvsig.app.imp; |
||
26 | |||
27 | import java.awt.Component; |
||
28 | import java.io.File; |
||
29 | import java.util.ArrayList; |
||
30 | import java.util.Iterator; |
||
31 | import java.util.List; |
||
32 | 44317 | jjdelcerro | import java.util.Map; |
33 | 41264 | jjdelcerro | import javax.swing.JComponent; |
34 | 40435 | jjdelcerro | |
35 | import javax.swing.JFileChooser; |
||
36 | 41441 | jjdelcerro | import javax.swing.SwingUtilities; |
37 | 41442 | jjdelcerro | import javax.swing.event.HyperlinkListener; |
38 | 40435 | jjdelcerro | import javax.swing.filechooser.FileFilter; |
39 | 42651 | jjdelcerro | import javax.swing.tree.TreeModel; |
40 | 40435 | jjdelcerro | |
41 | import org.cresques.cts.IProjection; |
||
42 | import org.gvsig.about.AboutLocator; |
||
43 | import org.gvsig.about.AboutManager; |
||
44 | import org.gvsig.andami.Launcher; |
||
45 | import org.gvsig.andami.PluginServices; |
||
46 | 41080 | jjdelcerro | import org.gvsig.andami.actioninfo.ActionInfo; |
47 | 40435 | jjdelcerro | import org.gvsig.andami.ui.mdiFrame.MainFrame; |
48 | import org.gvsig.andami.ui.mdiManager.IWindow; |
||
49 | import org.gvsig.andami.ui.mdiManager.MDIManager; |
||
50 | import org.gvsig.app.ApplicationManager; |
||
51 | import org.gvsig.app.PreferencesNode; |
||
52 | import org.gvsig.app.extension.Version; |
||
53 | 41441 | jjdelcerro | import org.gvsig.app.extension.develtools.InfoPanel; |
54 | 40435 | jjdelcerro | import org.gvsig.app.gui.WizardPanel; |
55 | import org.gvsig.app.prepareAction.PrepareContext; |
||
56 | import org.gvsig.app.prepareAction.PrepareContextView; |
||
57 | import org.gvsig.app.prepareAction.PrepareDataStore; |
||
58 | import org.gvsig.app.prepareAction.PrepareDataStoreParameters; |
||
59 | import org.gvsig.app.prepareAction.PrepareLayer; |
||
60 | import org.gvsig.app.project.DefaultProject; |
||
61 | import org.gvsig.app.project.Project; |
||
62 | import org.gvsig.app.project.ProjectManager; |
||
63 | import org.gvsig.app.project.documents.Document; |
||
64 | import org.gvsig.app.project.documents.gui.IDocumentWindow; |
||
65 | 41264 | jjdelcerro | import org.gvsig.app.project.documents.view.ViewDocument; |
66 | 42651 | jjdelcerro | import org.gvsig.app.project.documents.view.ViewManager; |
67 | 40435 | jjdelcerro | import org.gvsig.fmap.crs.CRSFactory; |
68 | import org.gvsig.fmap.dal.DALLocator; |
||
69 | import org.gvsig.fmap.dal.DataManager; |
||
70 | import org.gvsig.fmap.dal.DataStore; |
||
71 | import org.gvsig.fmap.dal.DataStoreParameters; |
||
72 | import org.gvsig.fmap.geom.GeometryLocator; |
||
73 | import org.gvsig.fmap.geom.GeometryManager; |
||
74 | import org.gvsig.fmap.mapcontext.MapContextLocator; |
||
75 | import org.gvsig.fmap.mapcontext.MapContextManager; |
||
76 | import org.gvsig.fmap.mapcontext.layers.FLayer; |
||
77 | 42651 | jjdelcerro | import org.gvsig.fmap.mapcontrol.CompoundLayersTreeModel; |
78 | import org.gvsig.fmap.mapcontrol.MapControlLocator; |
||
79 | 40435 | jjdelcerro | import org.gvsig.gui.ColorTablesFactory; |
80 | import org.gvsig.symbology.swing.SymbologySwingLocator; |
||
81 | import org.gvsig.tools.ToolsLocator; |
||
82 | import org.gvsig.tools.dataTypes.DataTypesManager; |
||
83 | import org.gvsig.tools.dispose.DisposableManager; |
||
84 | import org.gvsig.tools.dynobject.DynObjectManager; |
||
85 | import org.gvsig.tools.extensionpoint.ExtensionPoint; |
||
86 | import org.gvsig.tools.extensionpoint.ExtensionPoint.Extension; |
||
87 | import org.gvsig.tools.extensionpoint.ExtensionPointManager; |
||
88 | import org.gvsig.tools.persistence.PersistenceManager; |
||
89 | import org.gvsig.tools.swing.api.ToolsSwingLocator; |
||
90 | 41441 | jjdelcerro | import org.gvsig.tools.swing.api.windowmanager.WindowManager; |
91 | 40435 | jjdelcerro | import org.gvsig.tools.swing.icontheme.IconThemeManager; |
92 | 44317 | jjdelcerro | import org.gvsig.tools.util.PropertiesSupportHelper; |
93 | 40435 | jjdelcerro | import org.slf4j.Logger; |
94 | import org.slf4j.LoggerFactory; |
||
95 | |||
96 | |||
97 | |||
98 | |||
99 | /**
|
||
100 | * @author jmvivo
|
||
101 | *
|
||
102 | */
|
||
103 | 41312 | jjdelcerro | public class DefaultApplicationManager implements ApplicationManager { |
104 | 40435 | jjdelcerro | |
105 | @SuppressWarnings("unused") |
||
106 | 41312 | jjdelcerro | private static Logger logger = LoggerFactory.getLogger(DefaultApplicationManager.class); |
107 | 40435 | jjdelcerro | |
108 | private static final String EPNAME_PREPARE_OPEN_DATASTORE = "org.gvsig.datastore.open.prepare"; //"PrepareOpenDataStore"; |
||
109 | private static final String EPNAME_PREPARE_OPEN_DATASTOREPARAMETERS = "org.gvsig.datastoreparameters.open.prepare"; //"PrepareOpenDataStoreParameters"; |
||
110 | private static final String EPNAME_PREPARE_OPEN_LAYER = "org.gvsig.layer.open.prepare"; // "PrepareOpenLayer"; |
||
111 | |||
112 | private static final String EPNAME_ADD_TABLE_WIZARD = "AddLayerWizard"; |
||
113 | |||
114 | private ExtensionPointManager epManager;
|
||
115 | |||
116 | private Version version;
|
||
117 | 44317 | jjdelcerro | private PropertiesSupportHelper psh;
|
118 | 40435 | jjdelcerro | |
119 | 43913 | jjdelcerro | public DefaultApplicationManager() {
|
120 | 44317 | jjdelcerro | this.psh = new PropertiesSupportHelper(); |
121 | |||
122 | 43913 | jjdelcerro | epManager = ToolsLocator.getExtensionPointManager(); |
123 | epManager.add(EPNAME_PREPARE_OPEN_DATASTORE, |
||
124 | "Actions to do when open a DataStore");
|
||
125 | epManager.add(EPNAME_PREPARE_OPEN_DATASTOREPARAMETERS, |
||
126 | "Actions to do before open a DataStore with parameters");
|
||
127 | epManager.add(EPNAME_PREPARE_OPEN_LAYER, |
||
128 | "Actions to do after create a Layer");
|
||
129 | epManager.add(EPNAME_ADD_TABLE_WIZARD, |
||
130 | "Wizards to add new document table");
|
||
131 | 40435 | jjdelcerro | |
132 | 43913 | jjdelcerro | try {
|
133 | version = new Version();
|
||
134 | } catch(Exception ex) { |
||
135 | logger.warn("Can't locate application version.");
|
||
136 | } |
||
137 | } |
||
138 | 40435 | jjdelcerro | |
139 | /* (non-Javadoc)
|
||
140 | * @see org.gvsig.appGvSigManager#pepareOpenDataSource(org.gvsig.fmap.dal.DataStore)
|
||
141 | */
|
||
142 | @SuppressWarnings("unchecked") |
||
143 | public DataStore pepareOpenDataSource(DataStore store,
|
||
144 | PrepareContext context) throws Exception { |
||
145 | ExtensionPoint ep = epManager.get(EPNAME_PREPARE_OPEN_DATASTORE); |
||
146 | if (ep.getCount() == 0) { |
||
147 | return store;
|
||
148 | } |
||
149 | DataStore result = store; |
||
150 | Iterator<ExtensionPoint.Extension> iter = ep.iterator();
|
||
151 | PrepareDataStore prepare; |
||
152 | while (iter.hasNext()) {
|
||
153 | prepare = (PrepareDataStore) iter.next().create(); |
||
154 | result = prepare.prepare(store, context); |
||
155 | } |
||
156 | return result;
|
||
157 | } |
||
158 | |||
159 | /* (non-Javadoc)
|
||
160 | * @see org.gvsig.appGvSigManager#prepareOpenDataStoreParameters(org.gvsig.fmap.dal.DataStoreParameters)
|
||
161 | */
|
||
162 | @SuppressWarnings("unchecked") |
||
163 | public DataStoreParameters prepareOpenDataStoreParameters(
|
||
164 | DataStoreParameters storeParameters, PrepareContext context) |
||
165 | throws Exception { |
||
166 | |||
167 | ExtensionPoint ep = epManager |
||
168 | .get(EPNAME_PREPARE_OPEN_DATASTOREPARAMETERS); |
||
169 | if (ep.getCount() == 0) { |
||
170 | return storeParameters;
|
||
171 | } |
||
172 | DataStoreParameters result = storeParameters; |
||
173 | Iterator<ExtensionPoint.Extension> iter = ep.iterator();
|
||
174 | PrepareDataStoreParameters prepare; |
||
175 | while (iter.hasNext()) {
|
||
176 | prepare = (PrepareDataStoreParameters) iter.next().create(); |
||
177 | result = prepare.prepare(storeParameters, context); |
||
178 | } |
||
179 | |||
180 | return result;
|
||
181 | } |
||
182 | |||
183 | /*
|
||
184 | * (non-Javadoc)
|
||
185 | * @see org.gvsig.app.ApplicationManager#prepareOpenDataStoreParameters(java.util.List, org.gvsig.app.prepareAction.PrepareContext)
|
||
186 | */
|
||
187 | @SuppressWarnings("unchecked") |
||
188 | public List<DataStoreParameters> prepareOpenDataStoreParameters( |
||
189 | List<DataStoreParameters> storeParameters, PrepareContext context)
|
||
190 | throws Exception { |
||
191 | |||
192 | ExtensionPoint ep = epManager |
||
193 | .get(EPNAME_PREPARE_OPEN_DATASTOREPARAMETERS); |
||
194 | if (ep.getCount() == 0) { |
||
195 | return storeParameters;
|
||
196 | } |
||
197 | |||
198 | List<DataStoreParameters> result = new ArrayList<DataStoreParameters>(); |
||
199 | |||
200 | Iterator<ExtensionPoint.Extension> iter = ep.iterator();
|
||
201 | List<PrepareDataStoreParameters> prepareList = new ArrayList<PrepareDataStoreParameters>(); |
||
202 | while (iter.hasNext()) {
|
||
203 | prepareList.add((PrepareDataStoreParameters) iter.next().create()); |
||
204 | } |
||
205 | |||
206 | for (int i = 0; i < storeParameters.size(); i++) { |
||
207 | DataStoreParameters param = storeParameters.get(i); |
||
208 | for (int j = 0; j < prepareList.size(); j++) { |
||
209 | prepareList.get(j).pre(param, context); |
||
210 | } |
||
211 | } |
||
212 | |||
213 | for (int i = 0; i < storeParameters.size(); i++) { |
||
214 | DataStoreParameters param = storeParameters.get(i); |
||
215 | if(param != null) { |
||
216 | for (int j = 0; j < prepareList.size(); j++) { |
||
217 | param = prepareList.get(j).prepare(param, context); |
||
218 | if(param == null) |
||
219 | break;
|
||
220 | } |
||
221 | if(param != null) |
||
222 | result.add(param); |
||
223 | } |
||
224 | } |
||
225 | |||
226 | for (int i = 0; i < storeParameters.size(); i++) { |
||
227 | DataStoreParameters param = storeParameters.get(i); |
||
228 | for (int j = 0; j < prepareList.size(); j++) { |
||
229 | prepareList.get(j).post(param, context); |
||
230 | } |
||
231 | } |
||
232 | |||
233 | return result;
|
||
234 | } |
||
235 | |||
236 | public void registerPrepareOpenDataStore(PrepareDataStore action) { |
||
237 | ExtensionPoint ep = epManager.get(EPNAME_PREPARE_OPEN_DATASTORE); |
||
238 | ep.append(action.getName(), action.getDescription(), action); |
||
239 | } |
||
240 | |||
241 | public void registerPrepareOpenDataStoreParameters( |
||
242 | PrepareDataStoreParameters action) { |
||
243 | ExtensionPoint ep = epManager |
||
244 | .get(EPNAME_PREPARE_OPEN_DATASTOREPARAMETERS); |
||
245 | ep.append(action.getName(), action.getDescription(), action); |
||
246 | |||
247 | |||
248 | } |
||
249 | |||
250 | @SuppressWarnings("unchecked") |
||
251 | public FLayer prepareOpenLayer(FLayer layer,
|
||
252 | PrepareContextView context) |
||
253 | throws Exception { |
||
254 | |||
255 | ExtensionPoint ep = epManager.get(EPNAME_PREPARE_OPEN_LAYER); |
||
256 | |||
257 | if (ep.getCount() == 0) { |
||
258 | return layer;
|
||
259 | } |
||
260 | FLayer result = layer; |
||
261 | Iterator<ExtensionPoint.Extension> iter = ep.iterator();
|
||
262 | PrepareLayer prepare; |
||
263 | while (iter.hasNext()) {
|
||
264 | prepare = (PrepareLayer) iter.next().create(); |
||
265 | result = prepare.prepare(result, context); |
||
266 | } |
||
267 | |||
268 | return result;
|
||
269 | |||
270 | } |
||
271 | |||
272 | public void registerPrepareOpenLayer(PrepareLayer action) { |
||
273 | ExtensionPoint ep = epManager.get(EPNAME_PREPARE_OPEN_LAYER); |
||
274 | ep.append(action.getName(), action.getDescription(), action); |
||
275 | } |
||
276 | |||
277 | public void registerAddTableWizard(String name, String description, |
||
278 | Class<? extends WizardPanel> wpClass) { |
||
279 | ExtensionPoint ep = epManager.get(EPNAME_ADD_TABLE_WIZARD); |
||
280 | ep.append(name, description, wpClass); |
||
281 | } |
||
282 | |||
283 | @SuppressWarnings("unchecked") |
||
284 | public List<WizardPanel> getWizardPanels() throws Exception { |
||
285 | ExtensionPoint ep = epManager.get(EPNAME_ADD_TABLE_WIZARD); |
||
286 | List<WizardPanel> result = new ArrayList<WizardPanel>(); |
||
287 | Iterator<Extension> iter = ep.iterator();
|
||
288 | while (iter.hasNext()) {
|
||
289 | result.add((WizardPanel) iter.next().create()); |
||
290 | } |
||
291 | return result;
|
||
292 | } |
||
293 | |||
294 | public DataManager getDataManager() {
|
||
295 | return DALLocator.getDataManager();
|
||
296 | } |
||
297 | |||
298 | public GeometryManager getGeometryManager() {
|
||
299 | return GeometryLocator.getGeometryManager();
|
||
300 | } |
||
301 | |||
302 | public PersistenceManager getPersistenceManager() {
|
||
303 | return ToolsLocator.getPersistenceManager();
|
||
304 | } |
||
305 | |||
306 | public DisposableManager getDisposableManager() {
|
||
307 | return ToolsLocator.getDisposableManager();
|
||
308 | } |
||
309 | |||
310 | public DynObjectManager getDynObjectManager() {
|
||
311 | return ToolsLocator.getDynObjectManager();
|
||
312 | } |
||
313 | |||
314 | public ExtensionPointManager getExtensionPointManager() {
|
||
315 | return ToolsLocator.getExtensionPointManager();
|
||
316 | } |
||
317 | |||
318 | public ProjectManager getProjectManager() {
|
||
319 | return ProjectManager.getInstance();
|
||
320 | } |
||
321 | |||
322 | public MDIManager getUIManager() {
|
||
323 | return PluginServices.getMDIManager();
|
||
324 | } |
||
325 | |||
326 | public MapContextManager getMapContextManager() {
|
||
327 | return MapContextLocator.getMapContextManager();
|
||
328 | } |
||
329 | |||
330 | public DataTypesManager getDataTypesManager() {
|
||
331 | return ToolsLocator.getDataTypesManager();
|
||
332 | } |
||
333 | |||
334 | public IProjection getCRS(String code) { |
||
335 | return CRSFactory.getCRS(code);
|
||
336 | } |
||
337 | |||
338 | public IconThemeManager getIconThemeManager() {
|
||
339 | return ToolsSwingLocator.getIconThemeManager();
|
||
340 | } |
||
341 | |||
342 | public String getArgument(String name) { |
||
343 | return PluginServices.getArgumentByName(name);
|
||
344 | } |
||
345 | |||
346 | public String[] getArguments() { |
||
347 | return PluginServices.getArguments();
|
||
348 | } |
||
349 | |||
350 | public String getFromClipboard() { |
||
351 | return PluginServices.getFromClipboard();
|
||
352 | } |
||
353 | |||
354 | public void putInClipboard(String data) { |
||
355 | PluginServices.putInClipboard(data); |
||
356 | } |
||
357 | |||
358 | public Project getCurrentProject() {
|
||
359 | return ProjectManager.getInstance().getCurrentProject();
|
||
360 | } |
||
361 | |||
362 | public PreferencesNode getPreferences(String node) { |
||
363 | if( node.equalsIgnoreCase("project")) { |
||
364 | return DefaultProject.getPreferences();
|
||
365 | } |
||
366 | return new DefaultPreferencesNode(node); |
||
367 | } |
||
368 | |||
369 | public PreferencesNode getPreferences() {
|
||
370 | return new DefaultPreferencesNode(); |
||
371 | } |
||
372 | |||
373 | public Version getVersion() {
|
||
374 | return version;
|
||
375 | } |
||
376 | |||
377 | public AboutManager getAbout() {
|
||
378 | AboutManager manager = AboutLocator.getManager(); |
||
379 | return manager;
|
||
380 | } |
||
381 | |||
382 | public ColorTablesFactory getColorTablesFactory() {
|
||
383 | return SymbologySwingLocator.getSwingManager().getColorTablesFactory();
|
||
384 | } |
||
385 | |||
386 | public void registerColorTablesFactory(ColorTablesFactory factory) { |
||
387 | SymbologySwingLocator.getSwingManager().setColorTablesFactory(factory); |
||
388 | |||
389 | } |
||
390 | |||
391 | public IWindow getActiveWindow() {
|
||
392 | try {
|
||
393 | IWindow window = PluginServices.getMDIManager().getActiveWindow(); |
||
394 | return window;
|
||
395 | } catch (Exception ex) { |
||
396 | return null; |
||
397 | } |
||
398 | } |
||
399 | |||
400 | public Document getActiveDocument() { |
||
401 | return this.getActiveDocument((Class<? extends Document>)null); |
||
402 | } |
||
403 | |||
404 | public Document getActiveDocument(String documentTypeName) { |
||
405 | Document document = this.getActiveDocument(); |
||
406 | if( document!= null && document.getTypeName().equalsIgnoreCase(documentTypeName) ) { |
||
407 | return document;
|
||
408 | } |
||
409 | return null; |
||
410 | } |
||
411 | |||
412 | public Document getActiveDocument(Class<? extends Document> documentClass) { |
||
413 | Project project = this.getCurrentProject();
|
||
414 | if( project == null ) { |
||
415 | return null; |
||
416 | } |
||
417 | return project.getActiveDocument(documentClass);
|
||
418 | } |
||
419 | 41264 | jjdelcerro | |
420 | public JComponent getActiveComponent(Class<? extends Document> documentClass) { |
||
421 | Document document = this.getActiveDocument(documentClass); |
||
422 | if (document == null) { |
||
423 | return null; |
||
424 | } |
||
425 | return document.getMainComponent();
|
||
426 | } |
||
427 | 40435 | jjdelcerro | |
428 | 41264 | jjdelcerro | |
429 | 40435 | jjdelcerro | public IDocumentWindow getDocumentWindow(Document document) { |
430 | Class<? extends IDocumentWindow> defaultDocumentClass = |
||
431 | document.getFactory().getMainWindowClass(); |
||
432 | return (IDocumentWindow) this.getUIManager().getSingletonWindow(defaultDocumentClass, document); |
||
433 | } |
||
434 | |||
435 | public String getLocaleLanguage() { |
||
436 | return Launcher.getAndamiConfig().getLocaleLanguage();
|
||
437 | } |
||
438 | |||
439 | public void messageDialog(String message, String title, int messageType) { |
||
440 | MainFrame main = PluginServices.getMainFrame(); |
||
441 | main.messageDialog(message, title, messageType); |
||
442 | } |
||
443 | |||
444 | public void messageDialog(String message, String[] messageArgs, |
||
445 | String title, int messageType) { |
||
446 | MainFrame main = PluginServices.getMainFrame(); |
||
447 | main.messageDialog(message, messageArgs, title, messageType); |
||
448 | } |
||
449 | |||
450 | 43167 | jjdelcerro | @Override
|
451 | public void messageDialog(String message, String[] messageArgs, String title, int messageType, String msgid) { |
||
452 | MainFrame main = PluginServices.getMainFrame(); |
||
453 | main.messageDialog(message, messageArgs, title, messageType, msgid); |
||
454 | } |
||
455 | |||
456 | @Override
|
||
457 | 40435 | jjdelcerro | public int confirmDialog(String message, String title, int optionType, |
458 | int messageType) {
|
||
459 | MainFrame main = PluginServices.getMainFrame(); |
||
460 | return main.confirmDialog(message, title, optionType, messageType);
|
||
461 | } |
||
462 | |||
463 | 43167 | jjdelcerro | @Override
|
464 | public int confirmDialog(String message, String title, int optionType, |
||
465 | int messageType, String msgid) { |
||
466 | MainFrame main = PluginServices.getMainFrame(); |
||
467 | return main.confirmDialog(message, title, optionType, messageType, msgid);
|
||
468 | } |
||
469 | |||
470 | 40435 | jjdelcerro | public String inputDialog(String message, String title, int messageType, |
471 | String initialValue) {
|
||
472 | MainFrame main = PluginServices.getMainFrame(); |
||
473 | return main.inputDialog(message, title, messageType, initialValue);
|
||
474 | } |
||
475 | |||
476 | public String inputDialog(String message, String title) { |
||
477 | MainFrame main = PluginServices.getMainFrame(); |
||
478 | return main.inputDialog(message, title);
|
||
479 | } |
||
480 | |||
481 | public void showDialog(Component contents, String title) { |
||
482 | MainFrame main = PluginServices.getMainFrame(); |
||
483 | main.showDialog(contents, title); |
||
484 | } |
||
485 | |||
486 | public Component createComponent(Class<? extends Component> theClass, |
||
487 | Object... parameters) {
|
||
488 | MainFrame main = PluginServices.getMainFrame(); |
||
489 | return main.createComponentWithParams(theClass, parameters);
|
||
490 | } |
||
491 | |||
492 | public Component createComponentWithParams( |
||
493 | Class<? extends Component> theClass, Object[] parameters) { |
||
494 | MainFrame main = PluginServices.getMainFrame(); |
||
495 | return main.createComponentWithParams(theClass, parameters);
|
||
496 | } |
||
497 | |||
498 | |||
499 | public File[] showChooserDialog( |
||
500 | final String title, |
||
501 | final int type, // SAVE_DIALOG / OPEN_DIALOG |
||
502 | final int selectionMode, // JFileChooser.FILES_ONLY, JFileChooser.DIRECTORIES_ONLY, JFileChooser.FILES_AND_DIRECTORIES |
||
503 | final boolean multiselection, |
||
504 | final File initialPath, |
||
505 | final FileFilter filter, |
||
506 | final boolean fileHidingEnabled |
||
507 | ) { |
||
508 | MainFrame main = PluginServices.getMainFrame(); |
||
509 | return main.showChooserDialog(title, type, selectionMode, multiselection, initialPath, filter, fileHidingEnabled);
|
||
510 | } |
||
511 | |||
512 | public File[] showOpenDirectoryDialog(String title, File initialPath) { |
||
513 | return showChooserDialog(title, JFileChooser.OPEN_DIALOG, JFileChooser.DIRECTORIES_ONLY, false, initialPath, null, false); |
||
514 | } |
||
515 | |||
516 | |||
517 | public File[] showOpenFileDialog(String title, File initialPath) { |
||
518 | return showChooserDialog(title, JFileChooser.OPEN_DIALOG, JFileChooser.FILES_ONLY, false, initialPath, null, false); |
||
519 | } |
||
520 | |||
521 | |||
522 | public File[] showSaveFileDialog(String title, File initialPath) { |
||
523 | return showChooserDialog(title, JFileChooser.SAVE_DIALOG, JFileChooser.FILES_ONLY, false, initialPath, null, false); |
||
524 | } |
||
525 | 43913 | jjdelcerro | |
526 | @Override
|
||
527 | public void message(String message, int message_type) { |
||
528 | MainFrame main = PluginServices.getMainFrame(); |
||
529 | main.message(message, message_type); |
||
530 | } |
||
531 | 40435 | jjdelcerro | |
532 | public String translate(String message, String... args) { |
||
533 | return org.gvsig.i18n.Messages.translate(message, args);
|
||
534 | } |
||
535 | |||
536 | public Component getRootComponent() { |
||
537 | return (Component) PluginServices.getMainFrame(); |
||
538 | } |
||
539 | |||
540 | public void refreshMenusAndToolBars() { |
||
541 | PluginServices.getMainFrame().refreshControls(); |
||
542 | } |
||
543 | |||
544 | 41080 | jjdelcerro | public MainFrame getMainFrame() {
|
545 | return PluginServices.getMainFrame();
|
||
546 | } |
||
547 | |||
548 | public void addMenu(ActionInfo action, String text) { |
||
549 | MainFrame f = this.getMainFrame();
|
||
550 | f.addMenu(action,text); |
||
551 | } |
||
552 | |||
553 | 42924 | jjdelcerro | @Override
|
554 | 41080 | jjdelcerro | public void addTool(ActionInfo action, String toolBarName) { |
555 | MainFrame f = this.getMainFrame();
|
||
556 | f.addTool(action,toolBarName); |
||
557 | f.refreshControls(); |
||
558 | } |
||
559 | 42924 | jjdelcerro | |
560 | @Override
|
||
561 | public void addSelectableTool(ActionInfo action, String toolBarName) { |
||
562 | MainFrame f = this.getMainFrame();
|
||
563 | f.addSelectableTool(action,toolBarName,"unico",false); |
||
564 | f.refreshControls(); |
||
565 | } |
||
566 | |||
567 | 41441 | jjdelcerro | public void showTextDialog(final WindowManager.MODE mode, final String title, final String htmlText) { |
568 | 41442 | jjdelcerro | this.showTextDialog(mode, title, htmlText, null); |
569 | } |
||
570 | |||
571 | public void showTextDialog(final WindowManager.MODE mode, final String title, final String htmlText, final HyperlinkListener hyperlinkListener) { |
||
572 | 41441 | jjdelcerro | if (!SwingUtilities.isEventDispatchThread()) { |
573 | if( mode == WindowManager.MODE.DIALOG ) {
|
||
574 | try {
|
||
575 | SwingUtilities.invokeAndWait(new Runnable() { |
||
576 | public void run() { |
||
577 | 41442 | jjdelcerro | showTextDialog(mode, title, htmlText,hyperlinkListener); |
578 | 41441 | jjdelcerro | } |
579 | }); |
||
580 | } catch (Exception ex) { |
||
581 | logger.warn("Can't show text dialog:\n"+htmlText,ex);
|
||
582 | } |
||
583 | } else {
|
||
584 | SwingUtilities.invokeLater(new Runnable() { |
||
585 | public void run() { |
||
586 | 41442 | jjdelcerro | showTextDialog(mode, title, htmlText,hyperlinkListener); |
587 | 41441 | jjdelcerro | } |
588 | }); |
||
589 | } |
||
590 | return;
|
||
591 | } |
||
592 | 41442 | jjdelcerro | InfoPanel.showPanel(title, mode, htmlText,hyperlinkListener); |
593 | 41441 | jjdelcerro | } |
594 | |||
595 | 42651 | jjdelcerro | @Override
|
596 | public TreeModel createProjectLayersTreeModel() { |
||
597 | CompoundLayersTreeModel model = (CompoundLayersTreeModel) MapControlLocator.getMapControlManager().createCompoundLayersTreeModel(); |
||
598 | Project project = this.getCurrentProject();
|
||
599 | List<Document> views = project.getDocuments(ViewManager.TYPENAME); |
||
600 | for (Document view : views) { |
||
601 | model.addLayers( ((ViewDocument)view).getMapContext().getLayers() ); |
||
602 | } |
||
603 | return model;
|
||
604 | } |
||
605 | 44317 | jjdelcerro | |
606 | @Override
|
||
607 | public Object getProperty(String name) { |
||
608 | return this.psh.getProperty(name); |
||
609 | } |
||
610 | |||
611 | @Override
|
||
612 | public void setProperty(String name, Object value) { |
||
613 | this.psh.setProperty(name, value);
|
||
614 | } |
||
615 | |||
616 | @Override
|
||
617 | public Map<String, Object> getProperties() { |
||
618 | return this.psh.getProperties(); |
||
619 | } |
||
620 | 40435 | jjdelcerro | } |