Changeset 3001 in josm for trunk


Ignore:
Timestamp:
2010-02-17T08:43:05+01:00 (10 years ago)
Author:
Gubaer
Message:

fixed #4542: don't offer build-in plugins for installation

File:
1 edited

Legend:

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

    r2826 r3001  
    1616import java.net.MalformedURLException;
    1717import java.net.URL;
     18import java.util.ArrayList;
     19import java.util.Arrays;
    1820import java.util.Collection;
    1921import java.util.Collections;
     22import java.util.HashSet;
    2023import java.util.LinkedList;
    2124import java.util.List;
     
    182185
    183186    /**
     187     * Filter information about deprecated plugins from the list of downloaded
     188     * plugins
     189     *
     190     * @param plugins the plugin informations
     191     * @return the plugin informations, without deprecated plugins
     192     */
     193    protected List<PluginInformation> filterDeprecatedPlugins(List<PluginInformation> plugins) {
     194        List<PluginInformation> ret = new ArrayList<PluginInformation>(plugins.size());
     195        HashSet<String> deprecatedPluginNames = new HashSet<String>(Arrays.asList(PluginHandler.DEPRECATED_PLUGINS));
     196        for (PluginInformation plugin: plugins) {
     197            if (deprecatedPluginNames.contains(plugin.name)) {
     198                continue;
     199            }
     200            ret.add(plugin);
     201        }
     202        return ret;
     203    }
     204
     205    /**
    184206     * Parses the plugin list
    185207     *
     
    192214            InputStream in = new ByteArrayInputStream(doc.getBytes("UTF-8"));
    193215            List<PluginInformation> pis = new PluginListParser().parse(in);
    194             availabePlugins.addAll(pis);
     216            availabePlugins.addAll(filterDeprecatedPlugins(pis));
    195217        } catch(UnsupportedEncodingException e) {
    196218            System.err.println(tr("Failed to parse plugin list document from site ''{0}''. Skipping site. Exception was: {1}", site, e.toString()));
Note: See TracChangeset for help on using the changeset viewer.