Changeset 6403 in josm for trunk


Ignore:
Timestamp:
2013-11-23T14:21:45+01:00 (11 years ago)
Author:
Don-vip
Message:

fix #9352 - find icon in presets for recent added tags if none is defined in map paint styles

Location:
trunk/src/org/openstreetmap/josm/gui
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PresetListPanel.java

    r6084 r6403  
    9292        for (TaggingPreset t : TaggingPreset.getMatchingPresets(types, tags, true)) {
    9393            JLabel lbl = new JLabel(t.getName() + " …");
    94             lbl.setIcon((Icon) t.getValue(Action.SMALL_ICON));
     94            lbl.setIcon(t.getIcon());
    9595            lbl.addMouseListener(new PresetLabelML(lbl, t, presetHandler));
    9696            add(lbl, GBC.eol().fill(GBC.HORIZONTAL));
  • trunk/src/org/openstreetmap/josm/gui/dialogs/properties/TagEditHelper.java

    r6362 r6403  
    6868import org.openstreetmap.josm.gui.ExtendedDialog;
    6969import org.openstreetmap.josm.gui.mappaint.MapPaintStyles;
     70import org.openstreetmap.josm.gui.tagging.TaggingPreset;
    7071import org.openstreetmap.josm.gui.tagging.ac.AutoCompletingComboBox;
    7172import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionListItem;
     
    670671                ImageIcon icon = MapPaintStyles.getNodeIcon(t, false); // Filters deprecated icon
    671672                if (icon == null) {
    672                     icon = new ImageIcon(new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB));
     673                    // If no icon found in map style look at presets
     674                    Map<String, String> map = new HashMap<String, String>();
     675                    map.put(t.getKey(), t.getValue());
     676                    for (TaggingPreset tp : TaggingPreset.getMatchingPresets(null, map, false)) {
     677                        icon = tp.getIcon();
     678                        if (icon != null) {
     679                            break;
     680                        }
     681                    }
     682                    // If still nothing display an empty icon
     683                    if (icon == null) {
     684                        icon = new ImageIcon(new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB));
     685                    }
    673686                }
    674687                GridBagConstraints gbc = new GridBagConstraints();
     
    723736        }
    724737
    725 
    726738        /**
    727739         * Read tags from comboboxes and add it to all selected objects
  • trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPreset.java

    r6326 r6403  
    123123        return group != null ? group.getRawName() + "/" + name : name;
    124124    }
    125 
    126     /*
     125   
     126    /**
     127     * Returns the preset icon.
     128     * @return The preset icon, or {@code null} if none defined
     129     * @since 6403
     130     */
     131    public final ImageIcon getIcon() {
     132        Object icon = getValue(Action.SMALL_ICON);
     133        if (icon instanceof ImageIcon) {
     134            return (ImageIcon) icon;
     135        }
     136        return null;
     137    }
     138
     139    /**
    127140     * Called from the XML parser to set the icon.
    128141     * This task is performed in the background in order to speedup startup.
     
    156169    }
    157170
    158     /*
     171    /**
    159172     * Called from the XML parser to set the types this preset affects.
    160173     */
Note: See TracChangeset for help on using the changeset viewer.