Ignore:
Timestamp:
2012-07-30T19:53:01+02:00 (12 years ago)
Author:
Don-vip
Message:

fix #7671 - Show last N used tags in "Add key/value" dialog for selecting with a single click

LRU tags are shown in reverse order (most recent first).

This can be customized by setting the property properties.recently-added-tags to an integer between 1 and 9.
This can be disabled by setting the same property to a number lesser or equal to 0.

Keyboard shortcuts Ctrl+1 to Ctrl+9 are available in the context of the "Add property" dialog only.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/mappaint/MapPaintStyles.java

    r5219 r5383  
    1111import java.util.Arrays;
    1212import java.util.Collection;
     13import java.util.Iterator;
    1314import java.util.LinkedList;
    1415import java.util.List;
     
    1920
    2021import org.openstreetmap.josm.Main;
     22import org.openstreetmap.josm.data.osm.Node;
     23import org.openstreetmap.josm.data.osm.Tag;
    2124import org.openstreetmap.josm.gui.PleaseWaitRunnable;
     25import org.openstreetmap.josm.gui.mappaint.StyleCache.StyleList;
    2226import org.openstreetmap.josm.gui.mappaint.mapcss.MapCSSStyleSource;
    2327import org.openstreetmap.josm.gui.mappaint.xml.XmlStyleSource;
     
    118122                .setArchive(source.zipIcons)
    119123                .setOptional(true).get();
     124    }
     125   
     126    public static ImageIcon getNodeIcon(Tag tag) {
     127        return getNodeIcon(tag, true);
     128    }
     129   
     130    public static ImageIcon getNodeIcon(Tag tag, boolean includeDeprecatedIcon) {
     131        if (tag != null) {
     132            Node virtualNode = new Node();
     133            virtualNode.put(tag.getKey(), tag.getValue());
     134            StyleList styleList = getStyles().generateStyles(virtualNode, 0, null, false).a;
     135            if (styleList != null) {
     136                for (Iterator<ElemStyle> it = styleList.iterator(); it.hasNext(); ) {
     137                    ElemStyle style = it.next();
     138                    if (style instanceof NodeElemStyle) {
     139                        MapImage mapImage = ((NodeElemStyle) style).mapImage;
     140                        if (mapImage != null) {
     141                            if (includeDeprecatedIcon || mapImage.name == null || !mapImage.name.equals("misc/deprecated.png")) {
     142                                return new ImageIcon(mapImage.getImage());
     143                            } else {
     144                                return null; // Deprecated icon found but not wanted
     145                            }
     146                        }
     147                    }
     148                }
     149            }
     150        }
     151        return null;
    120152    }
    121153
Note: See TracChangeset for help on using the changeset viewer.