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