From: <kp...@us...> - 2012-02-18 16:38:06
|
Revision: 21150 http://jedit.svn.sourceforge.net/jedit/?rev=21150&view=rev Author: kpouer Date: 2012-02-18 16:37:59 +0000 (Sat, 18 Feb 2012) Log Message: ----------- If the same plugin is installed in home and install folder, only the newest is loaded Modified Paths: -------------- jEdit/trunk/doc/CHANGES.txt jEdit/trunk/org/gjt/sp/jedit/PluginJAR.java jEdit/trunk/org/gjt/sp/jedit/jEdit.java jEdit/trunk/org/gjt/sp/jedit/jedit_gui.props jEdit/trunk/org/gjt/sp/jedit/pluginmgr/ManagePanel.java Modified: jEdit/trunk/doc/CHANGES.txt =================================================================== --- jEdit/trunk/doc/CHANGES.txt 2012-02-18 15:21:03 UTC (rev 21149) +++ jEdit/trunk/doc/CHANGES.txt 2012-02-18 16:37:59 UTC (rev 21150) @@ -11,6 +11,9 @@ {{{ Bug fixes +- If the same plugin is installed in home and install folder, only the newest + is loaded (Matthieu Casanova) + - The Install/Update plugin dialog with progress bar should not show the progression of installation in it's title (#3485497) (Matthieu Casanova) Modified: jEdit/trunk/org/gjt/sp/jedit/PluginJAR.java =================================================================== --- jEdit/trunk/org/gjt/sp/jedit/PluginJAR.java 2012-02-18 15:21:03 UTC (rev 21149) +++ jEdit/trunk/org/gjt/sp/jedit/PluginJAR.java 2012-02-18 16:37:59 UTC (rev 21150) @@ -176,6 +176,8 @@ } jEdit.addPluginJAR(path); jar = jEdit.getPluginJAR(path); + if (jar == null) + return null; EditPlugin plugin = jar.getPlugin(); if (plugin == null) { @@ -1025,12 +1027,13 @@ } //}}} //{{{ init() method - void init() + boolean init() { PluginCacheEntry cache = getPluginCache(this); if(cache != null) { - loadCache(cache); + if (!loadCache(cache)) + return false; classLoader.activate(); } else @@ -1043,6 +1046,10 @@ setPluginCache(this,cache); classLoader.activate(); } + else + { + return false; + } } catch(IOException io) { @@ -1056,6 +1063,7 @@ uninit(false); } } + return true; } //}}} //{{{ uninit() method @@ -1132,8 +1140,26 @@ } //}}} //{{{ loadCache() method - private void loadCache(PluginCacheEntry cache) + private boolean loadCache(PluginCacheEntry cache) { + // Check if a plugin with the same name + // is already loaded + if(cache.pluginClass != null) + { + // Check if a plugin with the same name + // is already loaded + if (!continueLoading(cache.pluginClass, cache.cachedProperties)) + { + return false; + } + else + { + EditPlugin otherPlugin = jEdit.getPlugin(cache.pluginClass); + if (otherPlugin != null) + jEdit.removePluginJAR(otherPlugin.getPluginJAR(), false); + } + } + classes = cache.classes; resources = cache.resources; @@ -1200,31 +1226,21 @@ if(cache.pluginClass != null) { - // Check if a plugin with the same name - // is already loaded - if(jEdit.getPlugin(cache.pluginClass) != null) - { - jEdit.pluginError(path, "plugin-error.already-loaded", - null); - uninit(false); - } - else - { - String label = jEdit.getProperty( - "plugin." + cache.pluginClass - + ".name"); - actions.setLabel(jEdit.getProperty( - "action-set.plugin", - new String[] { label })); - plugin = new EditPlugin.Deferred(this, - cache.pluginClass); - } + String label = jEdit.getProperty( + "plugin." + cache.pluginClass + + ".name"); + actions.setLabel(jEdit.getProperty( + "action-set.plugin", + new String[] { label })); + plugin = new EditPlugin.Deferred(this, + cache.pluginClass); } else { if(actions.size() != 0) actionsPresentButNotCoreClass(); } + return true; } //}}} //{{{ generateCache() method @@ -1318,12 +1334,20 @@ // Check if a plugin with the same name // is already loaded - if(jEdit.getPlugin(className) != null) + if (!continueLoading(className, cache.cachedProperties)) { - jEdit.pluginError(path, "plugin-error.already-loaded", - null); return null; } + else + { + EditPlugin otherPlugin = jEdit.getPlugin(className); + if (otherPlugin != null) + { + jEdit.removePluginJAR(otherPlugin.getPluginJAR(), false); +// otherPlugin.getPluginJAR().uninit(false); + } + } + plugin = new EditPlugin.Deferred(this, className); label = _label; @@ -1394,6 +1418,18 @@ return cache; } //}}} + + private static boolean continueLoading(String clazz, Properties cachedProperties) + { + if(jEdit.getPlugin(clazz) != null) + { + String otherVersion = jEdit.getProperty("plugin."+clazz+".version"); + String thisVersion = cachedProperties.getProperty("plugin."+clazz+".version"); + if (otherVersion.compareTo(thisVersion) > 0) + return false; + } + return true; + } //{{{ startPlugin() method private void startPlugin() Modified: jEdit/trunk/org/gjt/sp/jedit/jEdit.java =================================================================== --- jEdit/trunk/org/gjt/sp/jedit/jEdit.java 2012-02-18 15:21:03 UTC (rev 21149) +++ jEdit/trunk/org/gjt/sp/jedit/jEdit.java 2012-02-18 16:37:59 UTC (rev 21150) @@ -1161,15 +1161,21 @@ public static void addPluginJAR(String path) { PluginJAR jar = new PluginJAR(new File(path)); - jars.addElement(jar); - jar.init(); - jEdit.unsetProperty("plugin-blacklist."+MiscUtilities.getFileName(path)); - EditBus.send(new PluginUpdate(jar,PluginUpdate.LOADED,false)); - if(!isMainThread()) + if (jar.init()) { - EditBus.send(new DynamicMenuChanged("plugins")); - initKeyBindings(); + jars.addElement(jar); + jEdit.unsetProperty("plugin-blacklist."+MiscUtilities.getFileName(path)); + EditBus.send(new PluginUpdate(jar,PluginUpdate.LOADED,false)); + if(!isMainThread()) + { + EditBus.send(new DynamicMenuChanged("plugins")); + initKeyBindings(); + } } + else + { + jar.uninit(false); + } } //}}} //{{{ addPluginJARsFromDirectory() method @@ -1226,7 +1232,8 @@ { jar.uninit(false); jars.removeElement(jar); - initKeyBindings(); + if (!isMainThread()) + initKeyBindings(); } EditBus.send(new PluginUpdate(jar,PluginUpdate.UNLOADED,exit)); Modified: jEdit/trunk/org/gjt/sp/jedit/jedit_gui.props =================================================================== --- jEdit/trunk/org/gjt/sp/jedit/jedit_gui.props 2012-02-18 15:21:03 UTC (rev 21149) +++ jEdit/trunk/org/gjt/sp/jedit/jedit_gui.props 2012-02-18 16:37:59 UTC (rev 21150) @@ -2721,6 +2721,8 @@ manage-plugins.help=Help... manage-plugins.restore.icon=22x22/actions/document-open.png manage-plugins.save.icon=22x22/actions/document-save.png +plugin-load-error.message=Unable to load plugin +plugin-load-error.title=Plugin load error #}}} #{{{ Plugin installation Modified: jEdit/trunk/org/gjt/sp/jedit/pluginmgr/ManagePanel.java =================================================================== --- jEdit/trunk/org/gjt/sp/jedit/pluginmgr/ManagePanel.java 2012-02-18 15:21:03 UTC (rev 21149) +++ jEdit/trunk/org/gjt/sp/jedit/pluginmgr/ManagePanel.java 2012-02-18 16:37:59 UTC (rev 21150) @@ -523,7 +523,11 @@ if(value.equals(Boolean.FALSE)) return; - PluginJAR.load(entry.jar, true); + PluginJAR load = PluginJAR.load(entry.jar, true); + if (load == null) + { + GUIUtilities.error(ManagePanel.this, "plugin-load-error", null); + } } else { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |