Changeset 13802 in josm


Ignore:
Timestamp:
2018-05-21T13:43:38+02:00 (11 months ago)
Author:
Don-vip
Message:

fix #16220 - fix plugin filter

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/preferences/plugin/PluginPreferencesModel.java

    r13799 r13802  
    5050     */
    5151    public void filterDisplayedPlugins(PluginInstallation status) {
    52         if (status == null) {
    53             displayedPlugins.clear();
    54             displayedPlugins.addAll(availablePlugins);
    55             this.filterStatus = null;
    56             return;
    57         }
    58         displayedPlugins.clear();
    59         for (PluginInformation pi: availablePlugins) {
    60             boolean installed = currentActivePlugins.contains(pi.getName());
    61             if (PluginInstallation.ALL == status
    62             || (PluginInstallation.INSTALLED == status && installed)
    63             || (PluginInstallation.AVAILABLE == status && !installed)) {
    64                 displayedPlugins.add(pi);
    65             }
    66         }
    6752        filterStatus = status;
    68         fireStateChanged();
     53        doFilter();
    6954    }
    7055
     
    7459     */
    7560    public void filterDisplayedPlugins(String filter) {
    76         if (filter == null) {
    77             displayedPlugins.clear();
    78             displayedPlugins.addAll(availablePlugins);
    79             this.filterExpression = null;
    80             return;
    81         }
     61        filterExpression = filter;
     62        doFilter();
     63    }
     64
     65    private void doFilter() {
    8266        displayedPlugins.clear();
    8367        for (PluginInformation pi: availablePlugins) {
    84             if (pi.matches(filter)) {
     68            if ((filterStatus == null || matchesInstallationStatus(pi))
     69             && (filterExpression == null || pi.matches(filterExpression))) {
    8570                displayedPlugins.add(pi);
    8671            }
    8772        }
    88         filterExpression = filter;
    8973        fireStateChanged();
     74    }
     75
     76    private boolean matchesInstallationStatus(PluginInformation pi) {
     77        boolean installed = currentActivePlugins.contains(pi.getName());
     78        return PluginInstallation.ALL == filterStatus
     79           || (PluginInstallation.INSTALLED == filterStatus && installed)
     80           || (PluginInstallation.AVAILABLE == filterStatus && !installed);
    9081    }
    9182
Note: See TracChangeset for help on using the changeset viewer.