Ticket #2813: pluginselection.patch

File pluginselection.patch, 3.2 KB (added by jttt, 16 years ago)
  • src/org/openstreetmap/josm/plugins/PluginSelection.java

     
    2222import java.util.LinkedList;
    2323import java.util.Map;
    2424import java.util.Set;
    25 import java.util.SortedMap;
    2625import java.util.TreeMap;
    2726import java.util.Map.Entry;
    2827
     
    6968            PluginInformation local = localPlugins.get(proxy.info.name);
    7069            PluginInformation description = availablePlugins.get(local.name);
    7170
    72             if (description != null && (description.version == null || description.version.equals("")) ?
    73             (local.version != null && local.version.equals("")) : !description.version.equals(local.version)) {
     71            if (description.version != null && !description.version.equals(local.version)) {
    7472                toUpdate.add(description);
    7573                toUpdateStr.append(description.name+"\n");
    7674            }
     
    9694
    9795    public boolean finish() {
    9896        Collection<PluginInformation> toDownload = new LinkedList<PluginInformation>();
     97        Collection<String> installedPlugins = Main.pref.getCollection("plugins", null);
     98
    9999        String msg = "";
    100100        for (Entry<String, Boolean> entry : pluginMap.entrySet()) {
    101             if(entry.getValue())
     101            if(entry.getValue() && !installedPlugins.contains(entry.getKey()))
    102102            {
    103103                String name = entry.getKey();
    104104                PluginInformation ap = availablePlugins.get(name);
     
    135135
    136136    /* return true when plugin list changed */
    137137    public void drawPanel(JPanel pluginPanel) {
    138         availablePlugins = getAvailablePlugins();
     138        loadPlugins();
    139139        Collection<String> enabledPlugins = Main.pref.getCollection("plugins", null);
    140140
    141141        if (pluginMap == null)
     
    221221        pluginPanel.updateUI();
    222222    }
    223223
    224     /**
    225      * Return information about a loaded plugin.
    226      *
    227      * Note that if you call this in your plugins bootstrap, you may get <code>null</code> if
    228      * the plugin requested is not loaded yet.
    229      *
    230      * @return The PluginInformation to a specific plugin, but only if the plugin is loaded.
    231      * If it is not loaded, <code>null</code> is returned.
    232      */
    233     private static PluginInformation getLoaded(String pluginName) {
    234         for (PluginProxy p : PluginHandler.pluginList)
    235             if (p.info.name.equals(pluginName))
    236                 return p.info;
    237         return null;
    238     }
    239 
    240     private Map<String, PluginInformation> getAvailablePlugins() {
    241         SortedMap<String, PluginInformation> availablePlugins = new TreeMap<String, PluginInformation>(new Comparator<String>(){
     224    private void loadPlugins() {
     225        availablePlugins = new TreeMap<String, PluginInformation>(new Comparator<String>(){
    242226            public int compare(String o1, String o2) {
    243227                return o1.compareToIgnoreCase(o2);
    244228            }
     
    345329            if (!localPlugins.containsKey(proxy.info.name))
    346330                localPlugins.put(proxy.info.name, proxy.info);
    347331        }
    348         return availablePlugins;
    349332    }
    350333}