Changeset 3297 in josm


Ignore:
Timestamp:
Jun 3, 2010 8:48:38 AM (3 years ago)
Author:
stoecker
Message:

fixed #4810 - error handling plugin exception

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/plugins/PluginHandler.java

    r3287 r3297  
    376376     */ 
    377377    public static void loadPlugin(Window parent, PluginInformation plugin, ClassLoader pluginClassLoader) { 
     378        String msg = tr("Could not load plugin {0}. Delete from preferences?", plugin.name); 
    378379        try { 
    379380            Class<?> klass = plugin.loadClass(pluginClassLoader); 
     
    382383                pluginList.add(plugin.load(klass)); 
    383384            } 
     385            msg = null; 
    384386        } catch(PluginException e) { 
    385387            e.printStackTrace(); 
    386388            if (e.getCause() instanceof ClassNotFoundException) { 
    387                 String msg = tr("<html>Could not load plugin {0} because the plugin<br>main class ''{1}'' was not found.<br>" 
     389                msg = tr("<html>Could not load plugin {0} because the plugin<br>main class ''{1}'' was not found.<br>" 
    388390                        + "Delete from preferences?", plugin.name, plugin.className); 
    389                 if (confirmDisablePlugin(parent, msg, plugin.name)) { 
    390                     Main.pref.removeFromCollection("plugins", plugin.name); 
    391                 } 
    392391            } 
    393392        }  catch (Throwable e) { 
    394393            e.printStackTrace(); 
    395             String msg = tr("Could not load plugin {0}. Delete from preferences?", plugin.name); 
    396             if (confirmDisablePlugin(parent, msg, plugin.name)) { 
    397                 Main.pref.removeFromCollection("plugins", plugin.name); 
    398             } 
    399         } 
     394        } 
     395        if(msg != null && confirmDisablePlugin(parent, msg, plugin.name)) 
     396            Main.pref.removeFromCollection("plugins", plugin.name); 
    400397    } 
    401398 
     
    910907    public static String getBugReportText() { 
    911908        String text = ""; 
    912         String pl = Main.pref.getCollectionAsString("plugins"); 
    913         if (pl != null && pl.length() != 0) { 
    914             text += "Plugins: " + pl + "\n"; 
    915         } 
     909        LinkedList <String> pl = new LinkedList<String>(Main.pref.getCollection("plugins", new LinkedList<String>())); 
    916910        for (final PluginProxy pp : pluginList) { 
    917             text += "Plugin " + pp.getPluginInformation().name; 
    918             String version = pp.getPluginInformation().localversion; 
    919             text += version != null && !version.equals("") ? " (Version: " + version + ")\n" 
    920                     : "\n"; 
    921         } 
     911            PluginInformation pi = pp.getPluginInformation(); 
     912            pl.remove(pi.name); 
     913            pl.add(pi.name + " (" + (pi.localversion != null && !pi.localversion.equals("") 
     914            ? pi.localversion : "unknown") + ")"); 
     915        } 
     916        Collections.sort(pl); 
     917        for (String s : pl) 
     918            text += "Plugin: " + s + "\n"; 
    922919        return text; 
    923920    } 
Note: See TracChangeset for help on using the changeset viewer.