Changeset 6452 in josm


Ignore:
Timestamp:
2013-12-07T14:47:47+01:00 (8 years ago)
Author:
Don-vip
Message:

fix #9360 - listed Values in Enhanced Preferences cannot be removed completely

Location:
trunk/src/org/openstreetmap/josm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/preferences/advanced/ListEditor.java

    r6021 r6452  
    2121import org.openstreetmap.josm.gui.widgets.JosmTextField;
    2222import org.openstreetmap.josm.tools.GBC;
     23import org.openstreetmap.josm.tools.Predicate;
     24import org.openstreetmap.josm.tools.Utils;
    2325import org.openstreetmap.josm.tools.WindowGeometry;
    2426
     
    2830    PrefEntry entry;
    2931
     32    /**
     33     * Constructs a new {@code ListEditor}.
     34     */
    3035    public ListEditor(final JComponent gui, PrefEntry entry, ListSetting setting) {
    3136        super(gui, tr("Change list setting"), new String[] {tr("OK"), tr("Cancel")});
     
    4247    }
    4348
     49    /**
     50     * Returns the list of values.
     51     * @return The list of values.
     52     */
    4453    public List<String> getData() {
    45         return data;
     54        return new ArrayList<String>(Utils.filter(data, new Predicate<String>() {
     55            @Override
     56            public boolean evaluate(String object) {
     57                return object != null && !object.isEmpty();
     58            }
     59        }));
    4660    }
    4761
     
    101115        }
    102116    }
    103 
    104117}
  • trunk/src/org/openstreetmap/josm/tools/Predicate.java

    r3177 r6452  
    22package org.openstreetmap.josm.tools;
    33
    4 // Used to identify objects that fulfill a certain condition, e.g. when filtering a collection
     4/**
     5 * Used to identify objects that fulfill a certain condition, e.g. when filtering a collection.
     6 *
     7 * @param <T> The objects type
     8 * @since 3177
     9 */
    510public interface Predicate<T> {
    6     // @return whether the object passes the test or not
     11   
     12    /**
     13     * Determines whether the object passes the test or not
     14     * @param object The object to evaluate
     15     * @return {@code true} if the object passes the test, {@code false} otherwise
     16     */
    717    public boolean evaluate(T object);
    818}
Note: See TracChangeset for help on using the changeset viewer.