184 |
184 |
* Andami's launching class. This is the class used to create the Andami's
|
185 |
185 |
* plugin environment.<br>
|
186 |
186 |
* </p>
|
187 |
|
*
|
|
187 |
*
|
188 |
188 |
* <p>
|
189 |
189 |
* <b>Syntax:</b> <br>
|
190 |
190 |
* java [-Xmx512M (for 512MB of RAM)] [-classpath={a colon-separated(unix) or
|
... | ... | |
193 |
193 |
* PATH_TO_APPLICATION_HOME_DIRECTORY PATH_TO_APPLICATION_PLUGINS_DIRECTORY
|
194 |
194 |
* [{list of additional custom application arguments separated by spaces}]
|
195 |
195 |
* </p>
|
196 |
|
*
|
197 |
|
*
|
|
196 |
*
|
|
197 |
*
|
198 |
198 |
* @author $author$
|
199 |
199 |
* @version $Revision: 40305 $
|
200 |
200 |
*/
|
201 |
201 |
public class Launcher {
|
202 |
202 |
|
203 |
203 |
public static abstract class MapWithAlias<Item> extends HashMap<String, Item> {
|
204 |
|
private HashMap<String, String> aliases = new HashMap<String, String>();
|
205 |
|
|
|
204 |
private HashMap<String, String> aliases = new HashMap<String, String>();
|
|
205 |
|
206 |
206 |
public abstract String[] getAliases(Item item);
|
207 |
|
|
|
207 |
|
208 |
208 |
public boolean isAlias(String key) {
|
209 |
209 |
return aliases.get(key)!=null ;
|
210 |
210 |
}
|
... | ... | |
220 |
220 |
}
|
221 |
221 |
return null;
|
222 |
222 |
}
|
223 |
|
|
224 |
|
public Item get(Object key) {
|
|
223 |
|
|
224 |
public Item get(Object key) {
|
225 |
225 |
Item item = super.get(key);
|
226 |
226 |
if( item != null ) {
|
227 |
227 |
return item;
|
... | ... | |
232 |
232 |
}
|
233 |
233 |
return null;
|
234 |
234 |
}
|
235 |
|
|
|
235 |
|
236 |
236 |
public boolean containsKey(Object key) {
|
237 |
237 |
boolean contains = super.containsKey(key);
|
238 |
238 |
if( contains ) {
|
... | ... | |
241 |
241 |
String alias = aliases.get(key);
|
242 |
242 |
return super.containsKey(alias);
|
243 |
243 |
}
|
244 |
|
|
|
244 |
|
245 |
245 |
public Item put(String key, Item value) {
|
246 |
246 |
super.put(key, value);
|
247 |
247 |
String[] aliases = getAliases(value);
|
... | ... | |
253 |
253 |
}
|
254 |
254 |
return value;
|
255 |
255 |
}
|
256 |
|
|
|
256 |
|
257 |
257 |
public void putAll(Map<? extends String, ? extends Item> m) {
|
258 |
258 |
Iterator<?> it = m.entrySet().iterator();
|
259 |
259 |
while( it.hasNext() ) {
|
... | ... | |
261 |
261 |
this.put(x.getKey(), x.getValue());
|
262 |
262 |
}
|
263 |
263 |
}
|
264 |
|
|
|
264 |
|
265 |
265 |
public Item remove(Object key) {
|
266 |
266 |
Item item = super.get(key);
|
267 |
267 |
if( item == null ) {
|
... | ... | |
279 |
279 |
return item;
|
280 |
280 |
}
|
281 |
281 |
// Rebuild the alias list
|
282 |
|
this.aliases = new HashMap<String, String>();
|
|
282 |
this.aliases = new HashMap<String, String>();
|
283 |
283 |
Iterator<java.util.Map.Entry<String, Item>> it = this.entrySet().iterator();
|
284 |
284 |
while(it.hasNext()) {
|
285 |
285 |
java.util.Map.Entry<String, Item> entry = it.next();
|
... | ... | |
294 |
294 |
|
295 |
295 |
return item;
|
296 |
296 |
}
|
297 |
|
|
|
297 |
|
298 |
298 |
}
|
299 |
|
|
|
299 |
|
300 |
300 |
public static class PluginsConfig extends MapWithAlias<org.gvsig.andami.plugins.config.generate.PluginConfig> {
|
301 |
|
|
|
301 |
|
302 |
302 |
public String[] getAliases(
|
303 |
303 |
org.gvsig.andami.plugins.config.generate.PluginConfig item) {
|
304 |
304 |
return getAlternativeNames(item);
|
... | ... | |
315 |
315 |
}
|
316 |
316 |
return r;
|
317 |
317 |
}
|
318 |
|
|
|
318 |
|
319 |
319 |
}
|
320 |
|
|
|
320 |
|
321 |
321 |
public static class PluginsServices extends MapWithAlias<org.gvsig.andami.PluginServices> {
|
322 |
322 |
|
323 |
323 |
public String[] getAliases(org.gvsig.andami.PluginServices item) {
|
324 |
324 |
return item.getAlternativeNames();
|
325 |
325 |
}
|
326 |
326 |
}
|
327 |
|
|
|
327 |
|
328 |
328 |
protected static Logger logger = LoggerFactory.getLogger(Launcher.class
|
329 |
329 |
.getName());
|
330 |
330 |
protected static Preferences prefs = Preferences.userRoot().node(
|
... | ... | |
333 |
333 |
protected static MultiSplashWindow splashWindow;
|
334 |
334 |
protected static String appName;
|
335 |
335 |
protected static Locale locale;
|
336 |
|
protected static PluginsConfig pluginsConfig = new PluginsConfig();
|
|
336 |
protected static PluginsConfig pluginsConfig = new PluginsConfig();
|
337 |
337 |
protected static PluginsServices pluginsServices = new PluginsServices();
|
338 |
338 |
protected static MDIFrame frame;
|
339 |
339 |
protected static HashMap<Class<? extends IExtension>, ExtensionDecorator> classesExtensions = new HashMap<Class<? extends IExtension>, ExtensionDecorator>();
|
... | ... | |
349 |
349 |
protected static ListBaseException launcherrors = null;
|
350 |
350 |
|
351 |
351 |
protected static Theme theme = null;
|
352 |
|
|
|
352 |
|
353 |
353 |
private List<String> deprecatedPluginNames = null;
|
354 |
354 |
|
355 |
355 |
private static final class ProxyAuth extends Authenticator {
|
... | ... | |
373 |
373 |
}
|
374 |
374 |
return launcherInstance;
|
375 |
375 |
}
|
376 |
|
|
|
376 |
|
377 |
377 |
public static void main(String[] args) throws Exception {
|
378 |
378 |
Launcher launcher = getInstance();
|
379 |
379 |
boolean install = false;
|
... | ... | |
430 |
430 |
private String translate(String msg) {
|
431 |
431 |
return PluginServices.getText(Launcher.class,msg);
|
432 |
432 |
}
|
433 |
|
|
|
433 |
|
434 |
434 |
private List<String> getDeprecatedPluginNames() {
|
435 |
435 |
if( deprecatedPluginNames == null ) {
|
436 |
436 |
String[] ss = new String[] {
|
... | ... | |
444 |
444 |
}
|
445 |
445 |
return deprecatedPluginNames;
|
446 |
446 |
}
|
447 |
|
|
|
447 |
|
448 |
448 |
public void doMain(String[] args) throws Exception {
|
449 |
449 |
|
450 |
450 |
if (args.length < 1) {
|
... | ... | |
470 |
470 |
public void refresh() {
|
471 |
471 |
}
|
472 |
472 |
});
|
473 |
|
|
|
473 |
|
474 |
474 |
new DefaultLibrariesInitializer().fullInitialize(true);
|
475 |
475 |
InstallerLocator.getInstallerManager().setDownloadBaseURL(
|
476 |
476 |
new URL("http://downloads.gvsig.org/download/gvsig-desktop/"));
|
... | ... | |
496 |
496 |
ex);
|
497 |
497 |
}
|
498 |
498 |
UIManager.put("Desktop.background", theme.getBackgroundColor());
|
499 |
|
|
500 |
|
|
|
499 |
|
|
500 |
|
501 |
501 |
// Mostrar la ventana de inicio
|
502 |
502 |
Frame f = new Frame();
|
503 |
503 |
splashWindow = new MultiSplashWindow(f, theme, 27);
|
... | ... | |
518 |
518 |
splashWindow.process(translate("SplashWindow.initialize_install_manager"));
|
519 |
519 |
initializeInstallerManager();
|
520 |
520 |
|
521 |
|
|
|
521 |
|
522 |
522 |
InstallerManager installerManager = InstallerLocator.getInstallerManager();
|
523 |
523 |
PackageInfo[] installedPackages = null;
|
524 |
524 |
try {
|
... | ... | |
530 |
530 |
logger_info(getInformation(installedPackages));
|
531 |
531 |
saveEnvironInformation(installedPackages);
|
532 |
532 |
|
533 |
|
|
|
533 |
|
534 |
534 |
// Se leen los config.xml de los plugins
|
535 |
535 |
splashWindow.process(translate("SplashWindow.load_plugins_configuration"));
|
536 |
536 |
try {
|
... | ... | |
542 |
542 |
|
543 |
543 |
splashWindow.process(translate("SplashWindow.check_incompatible_plugins"));
|
544 |
544 |
fixIncompatiblePlugins(installedPackages);
|
545 |
|
|
546 |
|
|
|
545 |
|
|
546 |
|
547 |
547 |
// Se configura el classloader del plugin
|
548 |
548 |
splashWindow.process(translate("SplashWindow.setup_plugins_configuration"));
|
549 |
549 |
try {
|
... | ... | |
552 |
552 |
} catch (Throwable ex) {
|
553 |
553 |
this.addError("Can't initialize plugin's classloaders ", ex);
|
554 |
554 |
}
|
555 |
|
|
|
555 |
|
556 |
556 |
initializeIdentityManagement(new File(andamiConfig.getPluginsDirectory()).getAbsoluteFile());
|
557 |
557 |
|
558 |
558 |
// Initialize libraries
|
... | ... | |
632 |
632 |
|
633 |
633 |
message(translate("SplashWindow.initializing_server_data_persistence"));
|
634 |
634 |
ServerDataPersistence.registerPersistence();
|
635 |
|
|
|
635 |
|
636 |
636 |
// Se instalan las etiquetas de las extensiones de los plugins
|
637 |
637 |
message(translate("SplashWindow.installing_extensions_labels"));
|
638 |
638 |
SwingUtilities.invokeAndWait(new Runnable() {
|
... | ... | |
662 |
662 |
}
|
663 |
663 |
}
|
664 |
664 |
});
|
665 |
|
|
|
665 |
|
666 |
666 |
// Se ejecuta el postInitialize
|
667 |
667 |
message(translate("SplashWindow.post_initializing_extensions"));
|
668 |
668 |
SwingUtilities.invokeAndWait(new Runnable() {
|
... | ... | |
670 |
670 |
postInitializeExtensions();
|
671 |
671 |
}
|
672 |
672 |
});
|
673 |
|
|
|
673 |
|
674 |
674 |
message(translate("SplashWindow.enable_controls"));
|
675 |
675 |
SwingUtilities.invokeAndWait(new Runnable() {
|
676 |
676 |
public void run() {
|
... | ... | |
684 |
684 |
});
|
685 |
685 |
|
686 |
686 |
splashWindow.close();
|
687 |
|
|
|
687 |
|
688 |
688 |
frame.setCursor(Cursor.DEFAULT_CURSOR);
|
689 |
689 |
|
690 |
690 |
if (launcherrors != null) {
|
... | ... | |
692 |
692 |
}
|
693 |
693 |
org.apache.log4j.Logger.getRootLogger().addAppender(
|
694 |
694 |
new NotificationAppender());
|
695 |
|
|
|
695 |
|
696 |
696 |
/*
|
697 |
697 |
* Executes additional tasks required by plugins
|
698 |
698 |
*/
|
... | ... | |
704 |
704 |
PluginsManager pluginmgr = PluginsLocator.getManager();
|
705 |
705 |
InstallerManager installerManager = InstallerLocator.getInstallerManager();
|
706 |
706 |
|
707 |
|
//
|
|
707 |
//
|
708 |
708 |
// Configure repository of plugins
|
709 |
709 |
//
|
710 |
710 |
List<File> folders = pluginmgr.getPluginsFolders();
|
... | ... | |
712 |
712 |
installerManager.addLocalAddonRepository(folder, "plugin");
|
713 |
713 |
}
|
714 |
714 |
installerManager.setDefaultLocalAddonRepository(folders.get(0), "plugin");
|
715 |
|
|
716 |
|
//
|
|
715 |
|
|
716 |
//
|
717 |
717 |
// Configure repository of iconsets
|
718 |
718 |
//
|
719 |
719 |
IconThemeManager iconManager = ToolsSwingLocator.getIconThemeManager();
|
... | ... | |
728 |
728 |
installerManager.setDefaultLocalAddonRepository(entry.getFolder(),"iconset");
|
729 |
729 |
}
|
730 |
730 |
}
|
731 |
|
|
|
731 |
|
732 |
732 |
}
|
733 |
733 |
|
734 |
734 |
private void message(final String msg) {
|
... | ... | |
799 |
799 |
Utilities.cleanUpTempFiles();
|
800 |
800 |
|
801 |
801 |
if( args.length<2 ) {
|
802 |
|
loadAndamiConfig("gvSIG/extensiones"); // Valor por defecto
|
|
802 |
loadAndamiConfig("gvSIG/extensiones"); // Valor por defecto
|
803 |
803 |
} else {
|
804 |
804 |
loadAndamiConfig(args[1]);
|
805 |
805 |
}
|
... | ... | |
816 |
816 |
}
|
817 |
817 |
|
818 |
818 |
/**
|
819 |
|
*
|
|
819 |
*
|
820 |
820 |
*/
|
821 |
821 |
private void configureLookAndFeel() {
|
822 |
822 |
// Se pone el lookAndFeel
|
... | ... | |
850 |
850 |
}
|
851 |
851 |
|
852 |
852 |
/**
|
853 |
|
*
|
|
853 |
*
|
854 |
854 |
*/
|
855 |
855 |
private void getOrCreateConfigFolder() {
|
856 |
856 |
// Create application configuration folder
|
... | ... | |
901 |
901 |
protected void append(LoggingEvent event) {
|
902 |
902 |
if (event.getLevel() == org.apache.log4j.Level.ERROR
|
903 |
903 |
|| event.getLevel() == org.apache.log4j.Level.FATAL) {
|
904 |
|
|
|
904 |
|
905 |
905 |
Throwable th = null;
|
906 |
906 |
ThrowableInformation thi = event.getThrowableInformation();
|
907 |
907 |
if (thi != null) {
|
... | ... | |
917 |
917 |
// }
|
918 |
918 |
}
|
919 |
919 |
|
920 |
|
|
|
920 |
|
921 |
921 |
@Override
|
922 |
922 |
public void close() {
|
923 |
923 |
// TODO Auto-generated method stub
|
... | ... | |
938 |
938 |
public static String getApplicationDirectory() {
|
939 |
939 |
return getApplicationFolder().getAbsolutePath();
|
940 |
940 |
}
|
941 |
|
|
|
941 |
|
942 |
942 |
public static File getApplicationFolder() {
|
943 |
943 |
// TODO: check if there is a better way to handle this
|
944 |
944 |
return new File(System.getProperty("user.dir"));
|
... | ... | |
946 |
946 |
|
947 |
947 |
private void registerIcons() {
|
948 |
948 |
IconTheme theme = PluginServices.getIconTheme();
|
949 |
|
ClassLoader loader = Launcher.class.getClassLoader();
|
950 |
|
|
|
949 |
ClassLoader loader = Launcher.class.getClassLoader();
|
|
950 |
|
951 |
951 |
String[][] icons = {
|
952 |
952 |
// MultiSplashWindow
|
953 |
953 |
{ "main", "splash-default" },
|
... | ... | |
962 |
962 |
} catch(Exception e) {
|
963 |
963 |
logger.info("Can't register icon '"+icons[i][0]+"' ("+icons[i][1]+").");
|
964 |
964 |
}
|
965 |
|
}
|
|
965 |
}
|
966 |
966 |
theme.setDefaultIcon(loader.getResource("images/main/default-icon.png" ));
|
967 |
967 |
}
|
968 |
968 |
|
... | ... | |
978 |
978 |
}
|
979 |
979 |
return p;
|
980 |
980 |
}
|
981 |
|
|
|
981 |
|
982 |
982 |
/**
|
983 |
983 |
* Obtiene la personalizaci�n de los iconos, splash, fondo y el nombre de la
|
984 |
984 |
* aplicaci�n.
|
985 |
|
*
|
|
985 |
*
|
986 |
986 |
* @return Theme
|
987 |
987 |
*/
|
988 |
988 |
private Theme getTheme(String pluginsDirectory) {
|
... | ... | |
1013 |
1013 |
File[] pluginDirs = pluginsDir.listFiles();
|
1014 |
1014 |
if ( pluginDirs.length > 0 ) {
|
1015 |
1015 |
for ( int i = 0; i < pluginDirs.length; i++ ) {
|
1016 |
|
File pluginThemeFile = new File(pluginDirs[i],
|
|
1016 |
File pluginThemeFile = new File(pluginDirs[i],
|
1017 |
1017 |
"theme" + File.separator + "andami-theme.xml");
|
1018 |
1018 |
if ( pluginThemeFile.exists() ) {
|
1019 |
1019 |
Theme theme = new Theme(loadProperties(infoFile));
|
... | ... | |
1090 |
1090 |
* Recupera la geometr�a (tama�o, posic�n y estado) de la ventana principal
|
1091 |
1091 |
* de Andami. TODO Pendiente de ver como se asigna un pluginServices para el
|
1092 |
1092 |
* launcher.
|
1093 |
|
*
|
|
1093 |
*
|
1094 |
1094 |
* @author LWS
|
1095 |
1095 |
*/
|
1096 |
1096 |
private void restoreMDIStatus(XMLEntity xml) {
|
... | ... | |
1182 |
1182 |
|
1183 |
1183 |
/**
|
1184 |
1184 |
* Salva la persistencia de los plugins.
|
1185 |
|
*
|
|
1185 |
*
|
1186 |
1186 |
* @author LWS
|
1187 |
1187 |
*/
|
1188 |
1188 |
private void savePluginPersistence() {
|
... | ... | |
1296 |
1296 |
|
1297 |
1297 |
/**
|
1298 |
1298 |
* DOCUMENT ME!
|
1299 |
|
*
|
|
1299 |
*
|
1300 |
1300 |
* @throws MDIManagerLoadException
|
1301 |
1301 |
*/
|
1302 |
1302 |
private void skinPlugin(String defaultSkin) throws MDIManagerLoadException {
|
... | ... | |
1452 |
1452 |
.getClassLoader().loadClass(
|
1453 |
1453 |
extension.getClassName());
|
1454 |
1454 |
extensionInstance = extensionClass.newInstance();
|
|
1455 |
if(extensionInstance instanceof org.gvsig.andami.plugins.Extension){
|
|
1456 |
((org.gvsig.andami.plugins.Extension)extensionInstance).setPlugin(ps);
|
|
1457 |
} else {
|
|
1458 |
logger.warn("The extension "+extensionClass.getName()+" don't extends of Extension.");
|
|
1459 |
}
|
1455 |
1460 |
|
1456 |
1461 |
// CON DECORATOR
|
1457 |
1462 |
// ANTES: classesExtensions.put(extensionClass,
|
... | ... | |
1551 |
1556 |
menu.setKey(actionInfo.getAccelerator());
|
1552 |
1557 |
menu.setName(actionInfo.getName());
|
1553 |
1558 |
}
|
1554 |
|
}
|
|
1559 |
}
|
1555 |
1560 |
if( menu.getPosition() < 100000000 ) {
|
1556 |
1561 |
logger.info("Invalid position in menu ("+ menu.getText() + ").");
|
1557 |
1562 |
menu.setPosition( menu.getPosition() + 1000000000);
|
... | ... | |
1614 |
1619 |
}
|
1615 |
1620 |
}
|
1616 |
1621 |
}
|
1617 |
|
|
|
1622 |
|
1618 |
1623 |
@SuppressWarnings("unchecked")
|
1619 |
1624 |
private void registerActions() {
|
1620 |
1625 |
logger.info("registerActions");
|
... | ... | |
1631 |
1636 |
logger.info("registerActions of plugin '"+pluginName+"'.");
|
1632 |
1637 |
|
1633 |
1638 |
Extensions extensionConfig = pluginConfig.getExtensions();
|
1634 |
|
|
1635 |
|
|
|
1639 |
|
|
1640 |
|
1636 |
1641 |
Enumeration<SkinExtensionType> extensiones = extensionConfig.enumerateExtension();
|
1637 |
1642 |
registerActionOfExtensions(actionManager, extensiones, loader);
|
1638 |
1643 |
|
... | ... | |
1648 |
1653 |
while (menus2.hasMoreElements()) {
|
1649 |
1654 |
Menu menu = menus2.nextElement();
|
1650 |
1655 |
if (!menu.getIs_separator() ) {
|
1651 |
|
if( menu.getName() == null) {
|
|
1656 |
if( menu.getName() == null) {
|
1652 |
1657 |
logger.info("Null name for popmenu '"+menu.getText()+"' in plugin "+ pluginService.getPluginName() );
|
1653 |
1658 |
} else {
|
1654 |
1659 |
ActionInfo actionInfo = actionManager.getAction(menu.getName());
|
... | ... | |
1665 |
1670 |
}
|
1666 |
1671 |
}
|
1667 |
1672 |
}
|
1668 |
|
|
1669 |
1673 |
|
|
1674 |
|
1670 |
1675 |
}
|
1671 |
1676 |
}
|
1672 |
|
|
1673 |
1677 |
|
1674 |
|
private TreeSet<SortableMenu> getOrderedMenus() {
|
1675 |
1678 |
|
|
1679 |
private TreeSet<SortableMenu> getOrderedMenus() {
|
|
1680 |
|
1676 |
1681 |
TreeSet<SortableMenu> orderedMenus = new TreeSet<SortableMenu>(
|
1677 |
1682 |
new MenuComparator());
|
1678 |
1683 |
|
... | ... | |
1778 |
1783 |
this.loader = loader;
|
1779 |
1784 |
this.extension = extension;
|
1780 |
1785 |
}
|
1781 |
|
|
|
1786 |
|
1782 |
1787 |
public PluginServices getPlugin() {
|
1783 |
1788 |
String pluginName = loader.getPluginName();
|
1784 |
1789 |
return PluginServices.getPluginServices(pluginName);
|
1785 |
1790 |
}
|
1786 |
|
|
|
1791 |
|
1787 |
1792 |
public String getExtensionName() {
|
1788 |
1793 |
return this.extension.getClassName();
|
1789 |
1794 |
}
|
1790 |
|
|
|
1795 |
|
1791 |
1796 |
public IExtension getExtension() {
|
1792 |
1797 |
Class<?> extensionClass;
|
1793 |
1798 |
try {
|
... | ... | |
1797 |
1802 |
}
|
1798 |
1803 |
return PluginServices.getExtension(extensionClass);
|
1799 |
1804 |
}
|
1800 |
|
|
|
1805 |
|
1801 |
1806 |
public String getText() {
|
1802 |
1807 |
return this.menu.getText();
|
1803 |
1808 |
}
|
... | ... | |
1805 |
1810 |
public long getPosition() {
|
1806 |
1811 |
return this.menu.getPosition();
|
1807 |
1812 |
}
|
1808 |
|
|
|
1813 |
|
1809 |
1814 |
public String getName() {
|
1810 |
1815 |
return this.menu.getName();
|
1811 |
1816 |
}
|
1812 |
|
|
|
1817 |
|
1813 |
1818 |
public boolean isParent() {
|
1814 |
1819 |
return menu.getIs_separator();
|
1815 |
1820 |
}
|
1816 |
|
|
|
1821 |
|
1817 |
1822 |
public String getPluginName() {
|
1818 |
1823 |
return this.loader.getPluginName();
|
1819 |
1824 |
}
|
1820 |
|
|
|
1825 |
|
1821 |
1826 |
public ActionInfo getAction() {
|
1822 |
1827 |
ActionInfoManager manager = PluginsLocator.getActionInfoManager();
|
1823 |
1828 |
return manager.getAction(this.menu.getName());
|
1824 |
1829 |
}
|
1825 |
1830 |
}
|
1826 |
|
|
|
1831 |
|
1827 |
1832 |
public List<PluginMenuItem> getPluginMenuItems() {
|
1828 |
1833 |
List<PluginMenuItem> menuItems = new ArrayList<Launcher.PluginMenuItem>();
|
1829 |
1834 |
|
... | ... | |
1837 |
1842 |
return menuItems;
|
1838 |
1843 |
}
|
1839 |
1844 |
|
1840 |
|
|
|
1845 |
|
1841 |
1846 |
/**
|
1842 |
1847 |
* Installs the menus, toolbars, actiontools, selectable toolbars and
|
1843 |
1848 |
* combos. The order in which they are shown is determined here.
|
... | ... | |
2139 |
2144 |
}
|
2140 |
2145 |
}
|
2141 |
2146 |
}
|
2142 |
|
|
|
2147 |
|
2143 |
2148 |
private URL[] getPluginClasspathURLs(PluginConfig pluginConfig) {
|
2144 |
2149 |
URL[] urls = null;
|
2145 |
2150 |
|
... | ... | |
2235 |
2240 |
|
2236 |
2241 |
try {
|
2237 |
2242 |
loader = new PluginClassLoader(
|
2238 |
|
urls,
|
2239 |
|
config.getPluginFolder().getAbsolutePath(),
|
2240 |
|
Launcher.class.getClassLoader(),
|
|
2243 |
urls,
|
|
2244 |
config.getPluginFolder().getAbsolutePath(),
|
|
2245 |
Launcher.class.getClassLoader(),
|
2241 |
2246 |
loaders
|
2242 |
|
);
|
|
2247 |
);
|
2243 |
2248 |
PluginServices ps = new PluginServices(
|
2244 |
|
loader,
|
|
2249 |
loader,
|
2245 |
2250 |
PluginsConfig.getAlternativeNames(config)
|
2246 |
2251 |
);
|
2247 |
2252 |
pluginsServices.put(ps.getPluginName(), ps);
|
... | ... | |
2294 |
2299 |
}
|
2295 |
2300 |
}
|
2296 |
2301 |
}
|
2297 |
|
|
|
2302 |
|
2298 |
2303 |
private void pluginsMessages() {
|
2299 |
2304 |
Iterator<String> iterator = pluginsOrdered.iterator();
|
2300 |
2305 |
PluginConfig config;
|
... | ... | |
2325 |
2330 |
static String getPluginsDir() {
|
2326 |
2331 |
return andamiConfig.getPluginsDirectory();
|
2327 |
2332 |
}
|
2328 |
|
|
|
2333 |
|
2329 |
2334 |
static File getPluginFolder(String pluginName) {
|
2330 |
2335 |
return pluginsConfig.get(pluginName).getPluginFolder();
|
2331 |
2336 |
}
|
... | ... | |
2338 |
2343 |
return frame;
|
2339 |
2344 |
}
|
2340 |
2345 |
|
2341 |
|
|
|
2346 |
|
2342 |
2347 |
private void loadPlugins() {
|
2343 |
2348 |
InstallerManager installerManager = InstallerLocator.getInstallerManager();
|
2344 |
2349 |
List<File> repositoriesFolders = installerManager.getLocalAddonRepositories("plugin");
|
... | ... | |
2730 |
2735 |
if (e2.menu.hasPosition() && !e1.menu.hasPosition()) {
|
2731 |
2736 |
return Integer.MAX_VALUE;
|
2732 |
2737 |
}
|
2733 |
|
|
|
2738 |
|
2734 |
2739 |
if( e1.menu.getPosition() == e2.menu.getPosition() ) {
|
2735 |
2740 |
// we don't return 0 unless both objects are the same, otherwise
|
2736 |
2741 |
// the objects get overwritten in the treemap
|
... | ... | |
2740 |
2745 |
return Integer.MAX_VALUE;
|
2741 |
2746 |
}
|
2742 |
2747 |
return Integer.MIN_VALUE;
|
2743 |
|
|
|
2748 |
|
2744 |
2749 |
}
|
2745 |
2750 |
}
|
2746 |
2751 |
|
... | ... | |
2756 |
2761 |
menu = menu2;
|
2757 |
2762 |
this.loader = loader;
|
2758 |
2763 |
}
|
2759 |
|
|
|
2764 |
|
2760 |
2765 |
}
|
2761 |
2766 |
|
2762 |
2767 |
private static class SortableTool {
|
... | ... | |
2845 |
2850 |
* <li>If both tools have the same position (or they don't have a 'position'
|
2846 |
2851 |
* attribute), the priority of the extensions where the tool is defined.</li>
|
2847 |
2852 |
* </ul>
|
2848 |
|
*
|
|
2853 |
*
|
2849 |
2854 |
* @author cesar
|
2850 |
2855 |
* @version $Revision: 40305 $
|
2851 |
2856 |
*/
|
... | ... | |
2918 |
2923 |
* Gets the ISO 839 two-characters-long language code matching the provided
|
2919 |
2924 |
* language code (which may be an ISO 839-2/T three-characters-long code or
|
2920 |
2925 |
* an ISO 839-1 two-characters-long code).
|
2921 |
|
*
|
|
2926 |
*
|
2922 |
2927 |
* If the provided parameter is already two characters long, it returns the
|
2923 |
2928 |
* parameter without any modification.
|
2924 |
|
*
|
|
2929 |
*
|
2925 |
2930 |
* @param langCode
|
2926 |
2931 |
* A language code representing either an ISO 839-2/T language
|
2927 |
2932 |
* code or an ISO 839-1 code.
|
... | ... | |
2972 |
2977 |
/**
|
2973 |
2978 |
* Configures the locales (languages and local resources) to be used by the
|
2974 |
2979 |
* application.
|
2975 |
|
*
|
|
2980 |
*
|
2976 |
2981 |
* First it tries to get the locale from the command line parameters, then
|
2977 |
2982 |
* the andami-config file is checked.
|
2978 |
|
*
|
|
2983 |
*
|
2979 |
2984 |
* The locale name is normalized to get a two characters language code as
|
2980 |
2985 |
* defined by ISO-639-1 (although ISO-639-2/T three characters codes are
|
2981 |
2986 |
* also accepted from the command line or the configuration file).
|
2982 |
|
*
|
|
2987 |
*
|
2983 |
2988 |
* Finally, the gvsig-i18n library and the default locales for Java and
|
2984 |
2989 |
* Swing are configured.
|
2985 |
|
*
|
|
2990 |
*
|
2986 |
2991 |
*/
|
2987 |
2992 |
private static void configureLocales(String[] args) {
|
2988 |
2993 |
// Configurar el locale
|
... | ... | |
3032 |
3037 |
logger.info("loading resources from classloader "+i18nClassLoader.toString()+".");
|
3033 |
3038 |
org.gvsig.i18n.Messages.addResourceFamily("text", i18nClassLoader,
|
3034 |
3039 |
"Andami Launcher");
|
3035 |
|
|
|
3040 |
|
3036 |
3041 |
// Finally load the andami own i18n resources
|
3037 |
3042 |
org.gvsig.i18n.Messages.addResourceFamily("org.gvsig.andami.text",
|
3038 |
3043 |
"Andami Launcher");
|
... | ... | |
3075 |
3080 |
}
|
3076 |
3081 |
return urls.toArray(new URL[urls.size()]);
|
3077 |
3082 |
}
|
3078 |
|
|
|
3083 |
|
3079 |
3084 |
/**
|
3080 |
3085 |
* Gets Home Directory location of the application into users home folder.
|
3081 |
|
*
|
|
3086 |
*
|
3082 |
3087 |
* May be set from outside the aplication by means of
|
3083 |
3088 |
* -DgvSIG.home=C:/data/gvSIG, where gvSIG its the name of the application
|
3084 |
|
*
|
|
3089 |
*
|
3085 |
3090 |
* @return
|
3086 |
3091 |
*/
|
3087 |
3092 |
public static String getAppHomeDir() {
|
3088 |
3093 |
return appHomeDir;
|
3089 |
3094 |
}
|
3090 |
|
|
|
3095 |
|
3091 |
3096 |
public static File getApplicationHomeFolder() {
|
3092 |
3097 |
return new File(getAppHomeDir());
|
3093 |
3098 |
}
|
... | ... | |
3096 |
3101 |
* Sets Home Directory location of the application. May be set from outside
|
3097 |
3102 |
* the aplication by means of -DgvSIG.home=C:/data/gvSIG, where gvSIG its
|
3098 |
3103 |
* the name of the application
|
3099 |
|
*
|
|
3104 |
*
|
3100 |
3105 |
* @param appHomeDir
|
3101 |
3106 |
*/
|
3102 |
3107 |
public static void setAppHomeDir(String appHomeDir) {
|
... | ... | |
3111 |
3116 |
* this: <br>
|
3112 |
3117 |
* <br>
|
3113 |
3118 |
* -exclusiveUI={pathToExtensionClass} <br>
|
3114 |
|
*
|
|
3119 |
*
|
3115 |
3120 |
* @see org.gvsig.andami.plugins.IExtension#isEnabled(IExtension extension)
|
3116 |
3121 |
* @see org.gvsig.andami.plugins.IExtension#isVisible(IExtension extension)
|
3117 |
3122 |
*/
|
... | ... | |
3151 |
3156 |
public static void initIconThemes() {
|
3152 |
3157 |
PluginsManager pluginsManager = PluginsLocator.getManager();
|
3153 |
3158 |
IconThemeManager iconManager = ToolsSwingLocator.getIconThemeManager();
|
3154 |
|
|
|
3159 |
|
3155 |
3160 |
File f = new File(pluginsManager.getApplicationFolder(),"icon-theme");
|
3156 |
|
if( !f.exists() ) {
|
|
3161 |
if( !f.exists() ) {
|
3157 |
3162 |
try {
|
3158 |
3163 |
f.mkdir();
|
3159 |
3164 |
} catch(Exception ex) {
|
... | ... | |
3161 |
3166 |
}
|
3162 |
3167 |
}
|
3163 |
3168 |
iconManager.getRepository().add(f,"_Global");
|
3164 |
|
|
|
3169 |
|
3165 |
3170 |
f = new File(pluginsManager.getApplicationHomeFolder(),"icon-theme");
|
3166 |
3171 |
if( !f.exists() ) {
|
3167 |
3172 |
try {
|
... | ... | |
3171 |
3176 |
}
|
3172 |
3177 |
}
|
3173 |
3178 |
iconManager.getRepository().add(f,"_User");
|
3174 |
|
|
|
3179 |
|
3175 |
3180 |
Preferences prefs = Preferences.userRoot().node("gvsig.icontheme");
|
3176 |
3181 |
String defaultThemeID = prefs.get("default-theme", null);
|
3177 |
3182 |
if( defaultThemeID != null ) {
|
... | ... | |
3184 |
3189 |
|
3185 |
3190 |
/**
|
3186 |
3191 |
* Manages Andami termination process
|
3187 |
|
*
|
|
3192 |
*
|
3188 |
3193 |
* @author Cesar Martinez Izquierdo <cesar.martinez@iver.es>
|
3189 |
3194 |
*/
|
3190 |
3195 |
public class TerminationProcess {
|
... | ... | |
3294 |
3299 |
/**
|
3295 |
3300 |
* Exectutes the terminate method for all the extensions, in the reverse
|
3296 |
3301 |
* order they were initialized
|
3297 |
|
*
|
|
3302 |
*
|
3298 |
3303 |
*/
|
3299 |
3304 |
private void finalizeExtensions() {
|
3300 |
3305 |
for (int i = extensions.size() - 1; i >= 0; i--) {
|
... | ... | |
3364 |
3369 |
/**
|
3365 |
3370 |
* Checks if the extensions have some unsaved data, and shows a dialog
|
3366 |
3371 |
* to allow saving it. This dialog also allows to don't exit Andami.
|
3367 |
|
*
|
|
3372 |
*
|
3368 |
3373 |
* @return true if the user confirmed he wishes to exit, false otherwise
|
3369 |
3374 |
* @throws Exception
|
3370 |
3375 |
*/
|
... | ... | |
3473 |
3478 |
|
3474 |
3479 |
/**
|
3475 |
3480 |
* Launch the gvSIG package installer.
|
3476 |
|
*
|
|
3481 |
*
|
3477 |
3482 |
* @throws Exception
|
3478 |
3483 |
* if there is any error
|
3479 |
3484 |
*/
|
... | ... | |
3500 |
3505 |
|
3501 |
3506 |
/*
|
3502 |
3507 |
* Los parametros que deberian pasarse en el instalador oficial de gvSIG serian:
|
3503 |
|
*
|
|
3508 |
*
|
3504 |
3509 |
* --install
|
3505 |
3510 |
* --applicationName=gvSIG
|
3506 |
3511 |
* --language=es
|
3507 |
3512 |
* --pluginsFolder=gvSIG/extensiones
|
3508 |
|
*
|
|
3513 |
*
|
3509 |
3514 |
* Opcionales (casi mejor que dejar los de por defecto y no pasarselos):
|
3510 |
3515 |
* --installVersion=2.0.0
|
3511 |
3516 |
* --installURL=http://downloads.gvsig.org/download/gvsig-desktop/dists
|
3512 |
3517 |
* --installURLFile=gvSIG/extensiones/org.gvsig.installer.app.extension/defaultDownloadsURLs
|
3513 |
|
*
|
|
3518 |
*
|
3514 |
3519 |
*/
|
3515 |
3520 |
CommandLineParser parser = new PosixParser();
|
3516 |
3521 |
CommandLine line = null;
|
... | ... | |
3556 |
3561 |
if ( !hasAllMandatoryOptions ) {
|
3557 |
3562 |
System.err.println(Messages.get("usage") + ": Launcher " +
|
3558 |
3563 |
"--install "+
|
3559 |
|
"[--applicationName=appName] " +
|
|
3564 |
"[--applicationName=appName] " +
|
3560 |
3565 |
"[--pluginsFolder=plugins-directory] " +
|
3561 |
3566 |
"[--installURLFile=File] " +
|
3562 |
3567 |
"[--installURL=URL] " +
|
... | ... | |
3571 |
3576 |
|
3572 |
3577 |
initializeApp(myArgs, "installer");
|
3573 |
3578 |
initializeLibraries();
|
3574 |
|
|
|
3579 |
|
3575 |
3580 |
AndamiConfig config = getAndamiConfig();
|
3576 |
3581 |
config.setLocaleLanguage(locale.getLanguage());
|
3577 |
3582 |
config.setLocaleCountry(locale.getCountry());
|
3578 |
3583 |
config.setLocaleVariant(locale.getVariant());
|
3579 |
3584 |
|
3580 |
3585 |
initializeInstallerManager();
|
3581 |
|
|
|
3586 |
|
3582 |
3587 |
InstallerManager installerManager = InstallerLocator.getInstallerManager();
|
3583 |
3588 |
|
3584 |
3589 |
packageInfo = getPackageInfo(myArgs[1]);
|
... | ... | |
3690 |
3695 |
private static final int INFO_APP_THEME = 16;
|
3691 |
3696 |
private static final int INFO_APP_SKIN = 17;
|
3692 |
3697 |
private static final int INFO_PACKAGES = 18;
|
3693 |
|
|
3694 |
|
|
|
3698 |
|
|
3699 |
|
3695 |
3700 |
public static String getInformation(PackageInfo[] pkgs) {
|
3696 |
|
|
3697 |
|
String template = "OS\n"
|
|
3701 |
|
|
3702 |
String template = "OS\n"
|
3698 |
3703 |
+" name : {"+INFO_OS_NAME+"}\n"
|
3699 |
3704 |
+" arch : {"+INFO_OS_ARCH+"}\n"
|
3700 |
3705 |
+" version : {"+INFO_OS_VERSION+"} \n"
|
... | ... | |
3718 |
3723 |
+" Skin : {"+INFO_APP_SKIN+"}\n"
|
3719 |
3724 |
+"Installed packages\n"
|
3720 |
3725 |
+"{"+INFO_PACKAGES+"}";
|
3721 |
|
|
3722 |
3726 |
|
|
3727 |
|
3723 |
3728 |
String values[] = new String[INFO_PACKAGES+1];
|
3724 |
|
|
|
3729 |
|
3725 |
3730 |
PluginsManager pluginmgr = PluginsLocator.getManager();
|
3726 |
3731 |
LocaleManager localemgr = PluginsLocator.getLocaleManager();
|
3727 |
|
|
|
3732 |
|
3728 |
3733 |
Properties props = System.getProperties();
|
3729 |
3734 |
|
3730 |
|
|
|
3735 |
|
3731 |
3736 |
// OS information
|
3732 |
3737 |
values[INFO_OS_NAME] = props.getProperty("os.name");
|
3733 |
3738 |
values[INFO_OS_ARCH] = props.getProperty("os.arch");
|
3734 |
3739 |
values[INFO_OS_VERSION] = props.getProperty("os.version");
|
3735 |
|
|
|
3740 |
|
3736 |
3741 |
if ( values[INFO_OS_NAME].startsWith("Linux") ) {
|
3737 |
3742 |
try {
|
3738 |
3743 |
StringWriter writer = new StringWriter();
|
3739 |
|
|
|
3744 |
|
3740 |
3745 |
String[] command = {"lsb_release", "-a"};
|
3741 |
3746 |
Process p = Runtime.getRuntime().exec(command);
|
3742 |
3747 |
InputStream is = p.getInputStream();
|
... | ... | |
3788 |
3793 |
writer.write("\n");
|
3789 |
3794 |
}
|
3790 |
3795 |
values[INFO_PACKAGES] = writer.toString();
|
3791 |
|
|
|
3796 |
|
3792 |
3797 |
} catch (Throwable e) {
|
3793 |
3798 |
logger.warn("Can't get installed package information.",e);
|
3794 |
3799 |
}
|
3795 |
|
|
|
3800 |
|
3796 |
3801 |
String s = MessageFormat.format(template, values);
|
3797 |
3802 |
return s;
|
3798 |
3803 |
}
|
... | ... | |
3803 |
3808 |
logger.info(info[i]);
|
3804 |
3809 |
}
|
3805 |
3810 |
}
|
3806 |
|
|
|
3811 |
|
3807 |
3812 |
private void saveEnvironInformation(PackageInfo[] pkgs) {
|
3808 |
3813 |
PluginsManager manager = PluginsLocator.getManager();
|
3809 |
3814 |
File fout = new File( manager.getApplicationHomeFolder(), "gvSIG-environ.info");
|
... | ... | |
3816 |
3821 |
|
3817 |
3822 |
private void fixIncompatiblePlugins(PackageInfo[] installedPackages) {
|
3818 |
3823 |
final Set<String> incompatiblePlugins = new HashSet<String>();
|
3819 |
|
|
|
3824 |
|
3820 |
3825 |
// Add installed packages to a Map to optimize searchs
|
3821 |
3826 |
final Map<String, PackageInfo> packages = new HashMap<String, PackageInfo>();
|
3822 |
3827 |
for( int i=0 ; i<installedPackages.length; i++) {
|
... | ... | |
3828 |
3833 |
Entry<String, PluginConfig> entry = it.next();
|
3829 |
3834 |
PluginConfig pluginConfig = entry.getValue();
|
3830 |
3835 |
pluginNames.add(entry.getKey());
|
3831 |
|
|
|
3836 |
|
3832 |
3837 |
// Locate the package for this plugin.
|
3833 |
3838 |
// Be care whith alias
|
3834 |
3839 |
String[] aliases = pluginsConfig.getAliases(pluginConfig);
|
... | ... | |
3844 |
3849 |
break;
|
3845 |
3850 |
}
|
3846 |
3851 |
}
|
3847 |
|
|
|
3852 |
|
3848 |
3853 |
// If package is found verify dependencies
|
3849 |
3854 |
if( pkg!= null ) {
|
3850 |
3855 |
Dependencies dependencies = pkg.getDependencies();
|
... | ... | |
3878 |
3883 |
if( pluginsToDissable == null ) {
|
3879 |
3884 |
return;
|
3880 |
3885 |
}
|
3881 |
|
|
|
3886 |
|
3882 |
3887 |
Iterator<String> it2 = pluginsToDissable.iterator();
|
3883 |
3888 |
while( it2.hasNext() ) {
|
3884 |
3889 |
String pluginName = it2.next();
|
3885 |
3890 |
logger.info("Dissabling plugin '"+pluginName+"' by user action.");
|
3886 |
3891 |
pluginsConfig.remove(pluginName);
|
3887 |
|
}
|
|
3892 |
}
|
3888 |
3893 |
}
|
3889 |
|
|
|
3894 |
|
3890 |
3895 |
private class DisablePluginsConflictingDialog extends JDialog {
|
3891 |
|
|
|
3896 |
|
3892 |
3897 |
public static final int CONTINUE = 0;
|
3893 |
3898 |
public static final int CLOSE = 1;
|
3894 |
|
|
|
3899 |
|
3895 |
3900 |
private DisablePluginsConflictingLayoutPanel contents;
|
3896 |
3901 |
private int action = 0;
|
3897 |
3902 |
private List<Item> incompatiblePlugins = null;
|
3898 |
3903 |
private Map<String, PackageInfo> packages;
|
3899 |
|
|
|
3904 |
|
3900 |
3905 |
private class Item {
|
3901 |
3906 |
private String code;
|
3902 |
3907 |
private PackageInfo pkg;
|
... | ... | |
3922 |
3927 |
DisablePluginsConflictingDialog(Map<String, PackageInfo> packages, Set<String> incompatiblePlugins) {
|
3923 |
3928 |
super((Frame)null, "",true);
|
3924 |
3929 |
this.setTitle(translate("_Conflicting_plugins"));
|
3925 |
|
|
|
3930 |
|
3926 |
3931 |
this.packages = packages;
|
3927 |
|
|
|
3932 |
|
3928 |
3933 |
this.incompatiblePlugins = new ArrayList<Item>();
|
3929 |
3934 |
Item item = null;
|
3930 |
3935 |
Iterator<String> it = incompatiblePlugins.iterator();
|
... | ... | |
3936 |
3941 |
}
|
3937 |
3942 |
initComponents();
|
3938 |
3943 |
}
|
3939 |
|
|
|
3944 |
|
3940 |
3945 |
private void initComponents() {
|
3941 |
3946 |
this.contents = new DisablePluginsConflictingLayoutPanel();
|
3942 |
|
|
|
3947 |
|
3943 |
3948 |
doTranslations();
|
3944 |
3949 |
|
3945 |
3950 |
this.contents.buttonClose.addActionListener( new ActionListener() {
|
... | ... | |
3962 |
3967 |
setLocation((screenSize.width / 2) - (this.getWidth() / 2),
|
3963 |
3968 |
(screenSize.height / 2) - (this.getHeight()/ 2));
|
3964 |
3969 |
}
|
3965 |
|
|
|
3970 |
|
3966 |
3971 |
private void doTranslations() {
|
3967 |
3972 |
DisablePluginsConflictingLayoutPanel c = this.contents;
|
3968 |
3973 |
c.lblConflict.setText(translate("_Some_of_plugins_installed_conflict_with_each_other"));
|
... | ... | |
3972 |
3977 |
c.buttonClose.setText(translate("_Close"));
|
3973 |
3978 |
c.buttonContinue.setText(translate("_Continue"));
|
3974 |
3979 |
}
|
3975 |
|
|
|
3980 |
|
3976 |
3981 |
private String translate(String msg) {
|
3977 |
3982 |
return PluginServices.getText(this,msg);
|
3978 |
3983 |
}
|
3979 |
|
|
|
3984 |
|
3980 |
3985 |
private void doClose() {
|
3981 |
3986 |
this.action = CLOSE;
|
3982 |
3987 |
this.setVisible(false);
|
3983 |
3988 |
}
|
3984 |
|
|
|
3989 |
|
3985 |
3990 |
private void doContinue() {
|
3986 |
3991 |
this.action = CONTINUE;
|
3987 |
3992 |
this.setVisible(false);
|
3988 |
3993 |
}
|
3989 |
|
|
|
3994 |
|
3990 |
3995 |
public int getAction() {
|
3991 |
3996 |
return this.action;
|
3992 |
3997 |
}
|
... | ... | |
4007 |
4012 |
return values;
|
4008 |
4013 |
}
|
4009 |
4014 |
}
|
4010 |
|
|
4011 |
|
|
|
4015 |
|
|
4016 |
|
4012 |
4017 |
private void initializeIdentityManagement(File pluginsFolder) {
|
4013 |
4018 |
File identityManagementConfigFile = null;
|
4014 |
4019 |
PluginServices plugin = null;
|
... | ... | |
4063 |
4068 |
}
|
4064 |
4069 |
logger.info("Loaded an identity manager from plugin '"+plugin.getPluginName()+".");
|
4065 |
4070 |
}
|
4066 |
|
|
4067 |
|
|
|
4071 |
|
|
4072 |
|
4068 |
4073 |
}
|