Revision 40821 trunk/org.gvsig.desktop/org.gvsig.desktop.framework/org.gvsig.andami/src/main/java/org/gvsig/andami/Launcher.java
Launcher.java | ||
---|---|---|
31 | 31 |
import java.awt.KeyboardFocusManager; |
32 | 32 |
import java.awt.Point; |
33 | 33 |
import java.awt.Toolkit; |
34 |
import java.awt.Window; |
|
35 |
import java.awt.event.ActionEvent; |
|
36 |
import java.awt.event.ActionListener; |
|
34 | 37 |
import java.io.BufferedOutputStream; |
35 | 38 |
import java.io.BufferedReader; |
36 | 39 |
import java.io.File; |
... | ... | |
75 | 78 |
import javax.swing.ImageIcon; |
76 | 79 |
import javax.swing.JButton; |
77 | 80 |
import javax.swing.JComponent; |
81 |
import javax.swing.JDialog; |
|
78 | 82 |
import javax.swing.JFrame; |
79 | 83 |
import javax.swing.JOptionPane; |
80 | 84 |
import javax.swing.JPopupMenu; |
85 |
import javax.swing.ListSelectionModel; |
|
81 | 86 |
import javax.swing.SwingUtilities; |
82 | 87 |
import javax.swing.UIManager; |
83 | 88 |
|
... | ... | |
129 | 134 |
import org.gvsig.andami.plugins.status.IExtensionStatus; |
130 | 135 |
import org.gvsig.andami.plugins.status.IUnsavedData; |
131 | 136 |
import org.gvsig.andami.ui.AndamiEventQueue; |
137 |
import org.gvsig.andami.ui.DisablePluginsConflictingLayoutPanel; |
|
132 | 138 |
import org.gvsig.andami.ui.MDIManagerLoadException; |
133 | 139 |
import org.gvsig.andami.ui.ToolsWindowManager; |
134 | 140 |
import org.gvsig.andami.ui.fonts.FontUtils; |
... | ... | |
156 | 162 |
import org.gvsig.tools.util.FolderSet; |
157 | 163 |
import org.gvsig.tools.util.FolderSet.FolderEntry; |
158 | 164 |
import org.gvsig.utils.DateTime; |
165 |
import org.gvsig.utils.DefaultListModel; |
|
159 | 166 |
import org.gvsig.utils.XMLEntity; |
160 | 167 |
import org.gvsig.utils.xml.XMLEncodingUtils; |
161 | 168 |
import org.gvsig.utils.xmlEntity.generate.XmlTag; |
... | ... | |
245 | 252 |
if( aliases==null ) { |
246 | 253 |
return item; |
247 | 254 |
} |
248 |
for( int n=0; n<aliases.length; n++ ) { |
|
249 |
this.aliases.remove(aliases[n].trim()); |
|
255 |
// Rebuild the alias list |
|
256 |
this.aliases = new HashMap<String, String>(); |
|
257 |
Iterator<java.util.Map.Entry<String, Item>> it = this.entrySet().iterator(); |
|
258 |
while(it.hasNext()) { |
|
259 |
java.util.Map.Entry<String, Item> entry = it.next(); |
|
260 |
aliases = getAliases(entry.getValue()); |
|
261 |
if( aliases==null ) { |
|
262 |
continue; |
|
263 |
} |
|
264 |
for( int n=0; n<aliases.length; n++ ) { |
|
265 |
this.aliases.put(aliases[n].trim(), entry.getKey()); |
|
266 |
} |
|
250 | 267 |
} |
268 |
|
|
251 | 269 |
return item; |
252 | 270 |
} |
253 | 271 |
|
... | ... | |
380 | 398 |
this.addError(msg, null); |
381 | 399 |
} |
382 | 400 |
|
401 |
private String translate(String msg) { |
|
402 |
return PluginServices.getText(Launcher.class,msg); |
|
403 |
} |
|
404 |
|
|
383 | 405 |
public void doMain(String[] args) throws Exception { |
384 | 406 |
|
385 | 407 |
if (args.length < 1) { |
... | ... | |
405 | 427 |
public void refresh() { |
406 | 428 |
} |
407 | 429 |
}); |
408 |
|
|
409 |
/* |
|
410 |
new ToolsLibrary().initialize(); |
|
411 |
new ToolsSwingLibrary().initialize(); |
|
412 |
new ToolsSwingDefaultImplLibrary().initialize(); |
|
413 |
*/ |
|
414 | 430 |
|
415 | 431 |
new DefaultLibrariesInitializer().fullInitialize(true); |
416 | 432 |
InstallerLocator.getInstallerManager().setDownloadBaseURL( |
... | ... | |
429 | 445 |
} |
430 | 446 |
validate(); |
431 | 447 |
|
432 |
// Obtener la personalizaci�n de la aplicaci�n.
|
|
448 |
// Obtener la personalizaci�n de la aplicacion.
|
|
433 | 449 |
try { |
434 | 450 |
logger.info("Initialize andami theme"); |
435 | 451 |
theme = getTheme(andamiConfig.getPluginsDirectory()); |
... | ... | |
440 | 456 |
|
441 | 457 |
// Mostrar la ventana de inicio |
442 | 458 |
Frame f = new Frame(); |
443 |
splashWindow = new MultiSplashWindow(f, theme, 190);
|
|
459 |
splashWindow = new MultiSplashWindow(f, theme, 27);
|
|
444 | 460 |
|
445 |
// 1. Ponemos los datos del proxy |
|
446 |
splashWindow.process(10, PluginServices.getText(Launcher.class, |
|
447 |
"SplashWindow.configuring_proxy")); |
|
461 |
// Ponemos los datos del proxy |
|
462 |
splashWindow.process(translate("SplashWindow.configuring_proxy")); |
|
448 | 463 |
logger.info("Configute http proxy"); |
449 | 464 |
configureProxy(); |
450 | 465 |
|
451 |
// 2. TODO Buscar actualizaciones de los plugins |
|
452 |
// splashWindow.process(20, PluginServices.getText(Launcher.class, |
|
453 |
// "SplashWindow.looking_for_updates")); |
|
454 |
// try { |
|
466 |
// Buscar actualizaciones de los plugins |
|
467 |
splashWindow.process(translate("SplashWindow.looking_for_updates")); |
|
468 |
try { |
|
455 | 469 |
// this.downloadExtensions(andamiConfig.getPluginsDirectory()); |
456 |
// } catch (Exception ex) {
|
|
457 |
// this.addError("Can't downloads plugins", ex);
|
|
458 |
// }
|
|
470 |
} catch (Exception ex) { |
|
471 |
this.addError("Can't downloads plugins", ex); |
|
472 |
} |
|
459 | 473 |
|
460 |
// 2.5. Initialize andami libraries |
|
461 |
splashWindow.process(25, PluginServices.getText(Launcher.class, |
|
462 |
"SplashWindow.initialize_andami_libraries")); |
|
474 |
// Initialize andami libraries |
|
475 |
splashWindow.process(translate("SplashWindow.initialize_install_manager")); |
|
463 | 476 |
|
464 | 477 |
File defaultAddonsRepository = PluginsLocator.getManager() |
465 | 478 |
.getPluginsFolder(); |
... | ... | |
469 | 482 |
installerManager |
470 | 483 |
.setDefaultLocalAddonRepository(defaultAddonsRepository); |
471 | 484 |
|
485 |
splashWindow.process(translate("SplashWindow.initialize_list_of_addons_installeds")); |
|
472 | 486 |
// --------------------------------------------- |
473 | 487 |
// Get the list of installed packages |
474 | 488 |
PluginsManager pluginmgr = PluginsLocator.getManager(); |
... | ... | |
482 | 496 |
// Do nothing, ignore errors |
483 | 497 |
} |
484 | 498 |
|
499 |
splashWindow.process(translate("SplashWindow.Dump_system_information")); |
|
485 | 500 |
logger.info("Dump system information"); |
486 | 501 |
logger_info(getInformation(installedPackages)); |
487 | 502 |
saveEnvironInformation(installedPackages); |
488 | 503 |
|
489 |
// 3. Se leen los config.xml de los plugins -----++++ |
|
490 |
splashWindow.process(30, PluginServices.getText(Launcher.class, |
|
491 |
"SplashWindow.reading_plugins_config.xml")); |
|
504 |
// Se leen los config.xml de los plugins |
|
505 |
splashWindow.process(translate("SplashWindow.load_plugins_configuration")); |
|
492 | 506 |
try { |
493 | 507 |
logger.info("Load plugins information"); |
494 | 508 |
this.loadPlugins(andamiConfig.getPluginsDirectory()); |
... | ... | |
496 | 510 |
this.addError("Can't load plugins", ex); |
497 | 511 |
} |
498 | 512 |
|
513 |
splashWindow.process(translate("SplashWindow.check_incompatible_plugins")); |
|
499 | 514 |
fixIncompatiblePlugins(installedPackages); |
500 | 515 |
|
501 |
// 4. Se configura el classloader del plugin |
|
502 |
splashWindow.process(40, PluginServices.getText(Launcher.class, |
|
503 |
"SplashWindow.setting_up_class_loaders")); |
|
516 |
// Se configura el classloader del plugin |
|
517 |
splashWindow.process(translate("SplashWindow.setup_plugins_configuration")); |
|
504 | 518 |
try { |
505 | 519 |
logger.info("Configure plugins class loader"); |
506 | 520 |
this.pluginsClassLoaders(); |
... | ... | |
508 | 522 |
this.addError("Can't initialize plugin's classloaders ", ex); |
509 | 523 |
} |
510 | 524 |
|
511 |
// 5. Initialize libraries |
|
512 |
splashWindow.process(50, PluginServices.getText(Launcher.class, |
|
513 |
"SplashWindow.initialize_libraries")); |
|
525 |
// Initialize libraries |
|
526 |
splashWindow.process(translate("SplashWindow.initialize_plugins_libraries")); |
|
514 | 527 |
initializeLibraries(); |
515 | 528 |
|
516 |
// 6. Se carga un Skin si alguno ide los plugins trae informaci�n |
|
517 |
// para ello |
|
518 |
splashWindow.process(60, PluginServices.getText(Launcher.class, |
|
519 |
"SplashWindow.looking_for_a_skin")); |
|
520 |
// skinPlugin( "com.iver.core.mdiManager.NewSkin"); |
|
529 |
// Se carga un Skin si alguno ide los plugins trae informacion para ello |
|
530 |
splashWindow.process(translate("SplashWindow.looking_for_a_skin")); |
|
521 | 531 |
logger.info("Initialize skin"); |
522 | 532 |
skinPlugin(null); |
523 | 533 |
|
524 |
// 7. Se configura la cola de eventos |
|
525 |
splashWindow.process(70, PluginServices.getText(Launcher.class, |
|
526 |
"setting_up_event_queue")); |
|
534 |
// Se configura la cola de eventos |
|
535 |
splashWindow.process(translate("setting_up_event_queue")); |
|
527 | 536 |
EventQueue waitQueue = new AndamiEventQueue(); |
528 | 537 |
Toolkit.getDefaultToolkit().getSystemEventQueue().push(waitQueue); |
529 | 538 |
|
530 |
// 8. Se configura la mensajer�a del plugin |
|
531 |
splashWindow.process(80, PluginServices.getText(Launcher.class, |
|
532 |
"SplashWindow.starting_plugin_internationalization_system")); |
|
539 |
// Se configura la internacionalizacion del plugin |
|
540 |
splashWindow.process(translate("SplashWindow.starting_plugin_internationalization_system")); |
|
533 | 541 |
pluginsMessages(); |
534 | 542 |
|
535 |
// 9. Se modifica el andami-config con los plugins nuevos |
|
536 |
splashWindow.process(90, PluginServices.getText(Launcher.class, |
|
537 |
"SplashWindow.looking_for_a_skin")); |
|
543 |
// Se modifica el andami-config con los plugins nuevos |
|
544 |
splashWindow.process(translate("SplashWindow.update_framework_configuration")); |
|
538 | 545 |
updateAndamiConfig(); |
539 | 546 |
|
540 | 547 |
frame = new MDIFrame(); |
541 |
// 10. Se configura el nombre e icono de la aplicaci�n |
|
542 |
splashWindow.process(100, PluginServices.getText(Launcher.class, |
|
543 |
"SplashWindow.setting_up_applications_name_and_icons")); |
|
548 |
// Se configura el nombre e icono de la aplicacion |
|
549 |
splashWindow.process(translate("SplashWindow.setting_up_applications_name_and_icons")); |
|
544 | 550 |
frameIcon(theme); |
545 | 551 |
|
546 |
// 11. Se prepara el MainFrame para albergar las extensiones |
|
547 |
splashWindow.process(110, PluginServices.getText(Launcher.class, |
|
548 |
"SplashWindow.preparing_workbench")); |
|
552 |
// Se prepara el MainFrame para albergar las extensiones |
|
553 |
splashWindow.process(translate("SplashWindow.preparing_workbench")); |
|
549 | 554 |
JPopupMenu.setDefaultLightWeightPopupEnabled(false); |
550 |
|
|
551 | 555 |
SwingUtilities.invokeAndWait(new Runnable() { |
552 |
|
|
553 | 556 |
public void run() { |
554 | 557 |
frame.init(); |
555 | 558 |
} |
556 | 559 |
}); |
557 | 560 |
ToolsSwingLocator.registerWindowManager(ToolsWindowManager.class); |
558 | 561 |
|
559 |
// 12. Leer el fichero de persistencia |
|
560 |
// info de los plugins |
|
561 |
// bookmarks de los plugins |
|
562 |
splashWindow.process(120, PluginServices.getText(Launcher.class, |
|
563 |
"SplashWindow.loading_plugin_settings")); |
|
562 |
// Leer el fichero de persistencia de los plugins |
|
563 |
splashWindow.process(translate("SplashWindow.loading_plugin_settings")); |
|
564 | 564 |
loadPluginsPersistence(); |
565 | 565 |
|
566 | 566 |
// Se instalan los controles del skin |
567 |
// 13. Se inicializan todas las extensiones de todos los plugins |
|
568 |
splashWindow.process(130, PluginServices.getText(Launcher.class, |
|
569 |
"SplashWindow.initializing_extensions")); |
|
567 |
// Se inicializan todas las extensiones de todos los plugins |
|
568 |
splashWindow.process(translate("SplashWindow.initializing_extensions")); |
|
570 | 569 |
SwingUtilities.invokeAndWait(new Runnable() { |
571 |
|
|
572 | 570 |
public void run() { |
573 | 571 |
initializeExtensions(); |
574 | 572 |
} |
575 | 573 |
}); |
576 | 574 |
|
577 |
// 14. Se inicializan la extensi�n exclusiva |
|
578 |
splashWindow.process(140, PluginServices.getText(Launcher.class, |
|
579 |
"SplashWindow.setting_up_master_extension")); |
|
575 |
// Se inicializan la extension exclusiva |
|
576 |
splashWindow.process(translate("SplashWindow.setting_up_master_extension")); |
|
580 | 577 |
SwingUtilities.invokeAndWait(new Runnable() { |
581 |
|
|
582 | 578 |
public void run() { |
583 | 579 |
initializeExclusiveUIExtension(); |
584 | 580 |
} |
585 | 581 |
}); |
586 | 582 |
frame.setClassesExtensions(classesExtensions); |
587 | 583 |
|
588 |
// 15. Se instalan los controles de las extensiones de los plugins |
|
589 |
splashWindow.process(150, PluginServices.getText(Launcher.class, |
|
590 |
"SplashWindow.installing_extensions_controls")); |
|
584 |
// Se instalan los controles de las extensiones de los plugins |
|
585 |
splashWindow.process(translate("SplashWindow.installing_extensions_controls")); |
|
591 | 586 |
SwingUtilities.invokeAndWait(new Runnable() { |
592 |
|
|
593 | 587 |
public void run() { |
594 | 588 |
installPluginsControls(); |
595 |
|
|
596 | 589 |
} |
597 | 590 |
}); |
598 | 591 |
|
599 |
// 16. Se instalan los menus de las extensiones de los plugins |
|
600 |
splashWindow.process(160, PluginServices.getText(Launcher.class, |
|
601 |
"SplashWindow.installing_extensions_menus")); |
|
592 |
// Se instalan los menus de las extensiones de los plugins |
|
593 |
splashWindow.process(translate("SplashWindow.installing_extensions_menus")); |
|
602 | 594 |
SwingUtilities.invokeAndWait(new Runnable() { |
603 |
|
|
604 | 595 |
public void run() { |
605 | 596 |
installPluginsMenus(); |
606 |
|
|
607 | 597 |
} |
608 | 598 |
}); |
609 | 599 |
|
610 |
// 17. Se instalan las etiquetas de las extensiones de los plugins |
|
611 |
splashWindow.process(170, PluginServices.getText(Launcher.class, |
|
612 |
"SplashWindow.installing_extensions_labels")); |
|
600 |
// Se instalan las etiquetas de las extensiones de los plugins |
|
601 |
splashWindow.process(translate("SplashWindow.installing_extensions_labels")); |
|
613 | 602 |
SwingUtilities.invokeAndWait(new Runnable() { |
614 |
|
|
615 | 603 |
public void run() { |
616 | 604 |
installPluginsLabels(); |
617 |
|
|
618 | 605 |
} |
619 | 606 |
}); |
620 | 607 |
|
621 |
// 18. Se instalan los bookmarks de los plugins |
|
622 |
|
|
623 |
// 19. Se muestra el frame principal |
|
624 |
splashWindow.process(180, PluginServices.getText(Launcher.class, |
|
625 |
"creating_main_window")); |
|
608 |
// Se muestra el frame principal |
|
609 |
splashWindow.process(translate("creating_main_window")); |
|
626 | 610 |
frame.setVisible(true); |
627 | 611 |
|
628 | 612 |
/* |
629 |
* Initialize installer local repository folders
|
|
613 |
* Initialize local repository folders of the installer
|
|
630 | 614 |
*/ |
615 |
splashWindow.process(translate("SplashWindow.initializing_local_addon_repository_folders")); |
|
631 | 616 |
initializeLocalAddOnRepositoryFolders(); |
632 | 617 |
|
633 |
// 19. Se ejecuta el postInitialize |
|
634 |
splashWindow.process(190, PluginServices.getText(Launcher.class, |
|
635 |
"SplashWindow.post_initializing_extensions")); |
|
618 |
// Se ejecuta el postInitialize |
|
619 |
splashWindow.process(translate("SplashWindow.post_initializing_extensions")); |
|
636 | 620 |
SwingUtilities.invokeAndWait(new Runnable() { |
637 |
|
|
638 | 621 |
public void run() { |
639 | 622 |
postInitializeExtensions(); |
640 |
ServerDataPersistence.registerPersistence(); |
|
641 | 623 |
} |
642 | 624 |
}); |
643 | 625 |
|
626 |
splashWindow.process(translate("SplashWindow.initializing_server_data_persistence")); |
|
627 |
ServerDataPersistence.registerPersistence(); |
|
628 |
|
|
644 | 629 |
// Definimos un KeyEventDispatcher global para que las extensiones |
645 |
// puedan registrar sus "teclas r�pidas". |
|
630 |
// puedan registrar sus "teclas rapidas". |
|
631 |
splashWindow.process(translate("SplashWindow.initializing_accelerator_keys")); |
|
646 | 632 |
GlobalKeyEventDispatcher keyDispatcher = GlobalKeyEventDispatcher.getInstance(); |
647 | 633 |
KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(keyDispatcher); |
648 | 634 |
|
635 |
splashWindow.process(translate("SplashWindow.enable_controls")); |
|
649 | 636 |
SwingUtilities.invokeAndWait(new Runnable() { |
650 |
|
|
651 | 637 |
public void run() { |
652 | 638 |
frame.enableControls(); |
653 | 639 |
} |
654 | 640 |
}); |
655 | 641 |
|
656 |
frame.message(Messages.getString("StatusBar.Aplicacion_iniciada"), JOptionPane.INFORMATION_MESSAGE);
|
|
642 |
frame.message(translate("StatusBar.Aplicacion_iniciada"), JOptionPane.INFORMATION_MESSAGE);
|
|
657 | 643 |
|
658 | 644 |
splashWindow.close(); |
645 |
|
|
659 | 646 |
if (launcherrors != null) { |
660 | 647 |
NotificationManager.addError(launcherrors); |
661 | 648 |
} |
662 |
|
|
663 |
|
|
664 | 649 |
org.apache.log4j.Logger.getRootLogger().addAppender( |
665 | 650 |
new NotificationAppender()); |
666 | 651 |
|
... | ... | |
750 | 735 |
|
751 | 736 |
configureLocales(args); |
752 | 737 |
|
753 |
logger.info("Load and initialize andami and plugins libraries"); |
|
754 |
// LibrariesInitializer libsInitializer = |
|
755 |
// new DefaultLibrariesInitializer(); |
|
756 |
// libsInitializer.initialize(true); |
|
757 |
// libsInitializer.postInitialize(true); |
|
758 |
|
|
759 | 738 |
logger.info("Configure LookAndFeel"); |
760 | 739 |
configureLookAndFeel(); |
761 | 740 |
} |
... | ... | |
2953 | 2932 |
private static void configureLocales(String[] args) { |
2954 | 2933 |
// Configurar el locale |
2955 | 2934 |
String localeStr = null; |
2956 |
/* |
|
2957 |
* for (int i=2; i < args.length; i++) { int index = |
|
2958 |
* args[i].indexOf("language="); if (index != -1) localeStr = |
|
2959 |
* args[i].substring(index+9); } |
|
2960 |
*/ |
|
2935 |
|
|
2961 | 2936 |
localeStr = PluginServices.getArgumentByName("language"); |
2962 | 2937 |
if (localeStr == null) { |
2963 | 2938 |
localeStr = andamiConfig.getLocaleLanguage(); |
... | ... | |
2987 | 2962 |
File andamiI18nFolder = |
2988 | 2963 |
new File(System.getProperty("user.dir"), "i18n"); |
2989 | 2964 |
File userI18nFolder = new File(getAppHomeDir(), "i18n"); |
2965 |
if( !userI18nFolder.exists() ) { |
|
2966 |
try { |
|
2967 |
FileUtils.forceMkdir(userI18nFolder); |
|
2968 |
} catch (IOException e) { |
|
2969 |
logger.info("Can't create i18n folder in gvSIG home ("+userI18nFolder+").",e); |
|
2970 |
} |
|
2971 |
} |
|
2990 | 2972 |
|
2991 | 2973 |
logger.info("Loading i18n resources from the application and user " |
2992 | 2974 |
+ "folders: {}, {}", andamiI18nFolder, userI18nFolder); |
... | ... | |
3736 | 3718 |
} |
3737 | 3719 |
|
3738 | 3720 |
private void fixIncompatiblePlugins(PackageInfo[] installedPackages) { |
3739 |
Set<String> incompatiblePlugins = new HashSet<String>(); |
|
3721 |
final Set<String> incompatiblePlugins = new HashSet<String>();
|
|
3740 | 3722 |
|
3741 | 3723 |
// Add installed packages to a Map to optimize searchs |
3742 |
Map<String, PackageInfo> packages = new HashMap<String, PackageInfo>(); |
|
3724 |
final Map<String, PackageInfo> packages = new HashMap<String, PackageInfo>();
|
|
3743 | 3725 |
for( int i=0 ; i<installedPackages.length; i++) { |
3744 | 3726 |
packages.put(installedPackages[i].getCode(), installedPackages[i]); |
3745 | 3727 |
} |
... | ... | |
3784 | 3766 |
if( incompatiblePlugins.isEmpty() ) { |
3785 | 3767 |
return; |
3786 | 3768 |
} |
3787 |
|
|
3788 |
StringBuffer buffer = new StringBuffer(); |
|
3769 |
splashWindow.toBack(); |
|
3770 |
DisablePluginsConflictingDialog dlg = new DisablePluginsConflictingDialog(packages, incompatiblePlugins); |
|
3771 |
// dlg.setAlwaysOnTop(true); |
|
3772 |
dlg.setVisible(true); |
|
3773 |
splashWindow.toFront(); |
|
3774 |
switch(dlg.getAction()) { |
|
3775 |
case DisablePluginsConflictingDialog.CLOSE: |
|
3776 |
System.exit(0); |
|
3777 |
break; |
|
3778 |
case DisablePluginsConflictingDialog.CONTINUE: |
|
3779 |
break; |
|
3780 |
} |
|
3781 |
List<String> pluginsToDesable = dlg.getPluginNamesToDisable(); |
|
3782 |
if( pluginsToDesable == null ) { |
|
3783 |
return; |
|
3784 |
} |
|
3785 |
PluginConfig x = pluginsConfig.get("org.gvsig.projection.app.mainplugin"); |
|
3789 | 3786 |
|
3790 |
buffer.append("\n"); |
|
3791 |
buffer.append("Some of plugins installed conflict with each other.\n"); |
|
3792 |
// buffer.append("Select the plugins that you want to disable and click the continue button.\n"); |
|
3793 |
// buffer.append("You can click on continue button directly if you want to disable any plugins.\n"); |
|
3794 |
Iterator<String> it2 = incompatiblePlugins.iterator(); |
|
3787 |
Iterator<String> it2 = pluginsToDesable.iterator(); |
|
3795 | 3788 |
while( it2.hasNext() ) { |
3796 |
String code = it2.next(); |
|
3797 |
PackageInfo pkg = packages.get(code); |
|
3798 |
if( pkg == null ) { |
|
3799 |
buffer.append("- "); |
|
3800 |
buffer.append(code); |
|
3801 |
buffer.append("\n"); |
|
3802 |
} else { |
|
3803 |
PluginConfig plugin = pluginsConfig.get(code); |
|
3804 |
buffer.append("- "); |
|
3805 |
buffer.append(pkg.getName()); |
|
3806 |
buffer.append(" ("); |
|
3807 |
buffer.append(pkg.getCode()); |
|
3808 |
buffer.append(")\n"); |
|
3809 |
} |
|
3789 |
String pluginName = it2.next(); |
|
3790 |
logger.info("Disabling plugin '"+pluginName+"' by user action."); |
|
3791 |
pluginsConfig.remove(pluginName); |
|
3810 | 3792 |
} |
3811 |
buffer.append("Eliminate conflicting plugins for normal operation of the application.\n"); |
|
3812 |
buffer.append("You can find them in:\n"); |
|
3813 |
buffer.append(" "); |
|
3814 |
buffer.append( new File(andamiConfig.getPluginsDirectory()).getAbsolutePath()); |
|
3815 |
buffer.append("\n"); |
|
3816 |
this.addError(buffer.toString()); |
|
3793 |
PluginConfig y = pluginsConfig.get("org.gvsig.projection.app.mainplugin"); |
|
3817 | 3794 |
|
3818 |
// TODO: Display a window for the user to select the desired option |
|
3819 |
// and then remove plugins entries from pluginsConfig. |
|
3820 | 3795 |
} |
3821 | 3796 |
|
3797 |
private class DisablePluginsConflictingDialog extends JDialog { |
|
3822 | 3798 |
|
3799 |
public static final int CONTINUE = 0; |
|
3800 |
public static final int CLOSE = 1; |
|
3801 |
|
|
3802 |
private DisablePluginsConflictingLayoutPanel contents; |
|
3803 |
private int action = 0; |
|
3804 |
private List<Item> incompatiblePlugins = null; |
|
3805 |
private Map<String, PackageInfo> packages; |
|
3806 |
|
|
3807 |
private class Item { |
|
3808 |
private String code; |
|
3809 |
private PackageInfo pkg; |
|
3810 |
|
|
3811 |
public Item(String code, PackageInfo pkg) { |
|
3812 |
this.code = code; |
|
3813 |
this.pkg = pkg; |
|
3814 |
} |
|
3815 |
public String toString() { |
|
3816 |
if( this.pkg == null ) { |
|
3817 |
return code; |
|
3818 |
} |
|
3819 |
return this.pkg.getName() + " (" + this.pkg.getCode() + ")"; |
|
3820 |
} |
|
3821 |
public String getCode() { |
|
3822 |
if( pkg == null ) { |
|
3823 |
return code; |
|
3824 |
} |
|
3825 |
return pkg.getCode(); |
|
3826 |
} |
|
3827 |
} |
|
3828 |
|
|
3829 |
DisablePluginsConflictingDialog(Map<String, PackageInfo> packages, Set<String> incompatiblePlugins) { |
|
3830 |
super((Frame)null, "Plugins confincting",true); |
|
3831 |
this.packages = packages; |
|
3832 |
|
|
3833 |
this.incompatiblePlugins = new ArrayList<Item>(); |
|
3834 |
Item item = null; |
|
3835 |
Iterator<String> it = incompatiblePlugins.iterator(); |
|
3836 |
while( it.hasNext() ) { |
|
3837 |
String code = it.next(); |
|
3838 |
item = new Item(code, packages.get(code)); |
|
3839 |
this.incompatiblePlugins.add(item); |
|
3840 |
logger.info("Found plugin '"+item.getCode()+"' incopatibles with each other."); |
|
3841 |
} |
|
3842 |
initComponents(); |
|
3843 |
} |
|
3844 |
|
|
3845 |
private void initComponents() { |
|
3846 |
this.contents = new DisablePluginsConflictingLayoutPanel(); |
|
3847 |
|
|
3848 |
doTranslations(); |
|
3849 |
|
|
3850 |
this.contents.buttonClose.addActionListener( new ActionListener() { |
|
3851 |
public void actionPerformed(ActionEvent arg0) { |
|
3852 |
doClose(); |
|
3853 |
} |
|
3854 |
}); |
|
3855 |
this.contents.buttonContinue.addActionListener( new ActionListener() { |
|
3856 |
public void actionPerformed(ActionEvent arg0) { |
|
3857 |
doContinue(); |
|
3858 |
} |
|
3859 |
}); |
|
3860 |
this.contents.pluginList.setModel(new DefaultListModel(this.incompatiblePlugins)); |
|
3861 |
ListSelectionModel sm = this.contents.pluginList.getSelectionModel(); |
|
3862 |
sm.setSelectionMode(sm.MULTIPLE_INTERVAL_SELECTION); |
|
3863 |
this.setContentPane(this.contents); |
|
3864 |
this.pack(); |
|
3865 |
|
|
3866 |
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); |
|
3867 |
setLocation((screenSize.width / 2) - (this.getWidth() / 2), |
|
3868 |
(screenSize.height / 2) - (this.getHeight()/ 2)); |
|
3869 |
} |
|
3870 |
|
|
3871 |
private void doTranslations() { |
|
3872 |
DisablePluginsConflictingLayoutPanel c = this.contents; |
|
3873 |
c.lblConflict.setText(translate("_Some_of_plugins_installed_conflict_with_each_other")); |
|
3874 |
c.lblSelectPluginToDisable.setText(translate("_Select_the_plugins_that_you_want_to_disable_and_click_the_continue_button")); |
|
3875 |
c.lblClickContinue.setText(translate("_You_can_click_on_continue_button_directly_if_you_want_to_disable_any_plugins")); |
|
3876 |
c.lblClickClose.setText(translate("_Or_click_the_close_button_to_close_the_application")); |
|
3877 |
c.buttonClose.setText(translate("_Close")); |
|
3878 |
c.buttonContinue.setText(translate("_Continue")); |
|
3879 |
} |
|
3880 |
|
|
3881 |
private String translate(String msg) { |
|
3882 |
return PluginServices.getText(this,msg); |
|
3883 |
} |
|
3884 |
|
|
3885 |
private void doClose() { |
|
3886 |
this.action = CLOSE; |
|
3887 |
this.setVisible(false); |
|
3888 |
} |
|
3889 |
|
|
3890 |
private void doContinue() { |
|
3891 |
this.action = CONTINUE; |
|
3892 |
this.setVisible(false); |
|
3893 |
} |
|
3894 |
|
|
3895 |
public int getAction() { |
|
3896 |
return this.action; |
|
3897 |
} |
|
3898 |
|
|
3899 |
public List<String> getPluginNamesToDisable() { |
|
3900 |
if( this.action == CLOSE ) { |
|
3901 |
return null; |
|
3902 |
} |
|
3903 |
Object[] selecteds = null; |
|
3904 |
selecteds = (Object[]) this.contents.pluginList.getSelectedValues(); |
|
3905 |
if( selecteds == null || selecteds.length < 1 ) { |
|
3906 |
return null; |
|
3907 |
} |
|
3908 |
List<String> values = new ArrayList<String>(); |
|
3909 |
for( int i=0 ; i<selecteds.length; i++ ) { |
|
3910 |
values.add(((Item)selecteds[i]).getCode()); |
|
3911 |
} |
|
3912 |
return values; |
|
3913 |
} |
|
3914 |
} |
|
3823 | 3915 |
} |
Also available in: Unified diff