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