Changeset 9467 in josm


Ignore:
Timestamp:
2016-01-15T18:44:48+01:00 (9 years ago)
Author:
simon04
Message:

fix #12286 - Preset dialog: display the added tags due to <key> items

Location:
trunk/src/org/openstreetmap/josm/gui/tagging/presets
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPreset.java

    r9266 r9467  
    9797     */
    9898    public Set<TaggingPresetType> types;
    99     public transient List<TaggingPresetItem> data = new LinkedList<>();
     99    public final List<TaggingPresetItem> data = new LinkedList<>();
    100100    public transient Roles roles;
    101101    public transient TemplateEntry nameTemplate;
     
    238238    }
    239239
     240    /**
     241     * Returns the tags being directly applied (without UI element) by {@link Key} items
     242     *
     243     * @return a list of tags
     244     */
     245    private List<Tag> getDirectlyAppliedTags() {
     246        List<Tag> tags = new ArrayList<>();
     247        for (TaggingPresetItem item : data) {
     248            if (item instanceof Key) {
     249                tags.add(((Key) item).asTag());
     250            }
     251        }
     252        return tags;
     253    }
     254
     255    /**
     256     * Creates a panel for this preset. This includes general information such as name and supported {@link TaggingPresetType types}.
     257     * This includes the elements from the individual {@link TaggingPresetItem items}.
     258     *
     259     * @param selected the selected primitives
     260     * @return the newly created panel
     261     */
    240262    public PresetPanel createPanel(Collection<OsmPrimitive> selected) {
    241         if (data == null)
    242             return null;
    243263        PresetPanel p = new PresetPanel();
    244264        List<Link> l = new LinkedList<>();
    245265        List<PresetLink> presetLink = new LinkedList<>();
     266
     267        final JPanel pp = new JPanel();
    246268        if (types != null) {
    247             JPanel pp = new JPanel();
    248269            for (TaggingPresetType t : types) {
    249270                JLabel la = new JLabel(ImageProvider.get(t.getIconName()));
     
    251272                pp.add(la);
    252273            }
     274        }
     275        final List<Tag> directlyAppliedTags = getDirectlyAppliedTags();
     276        if (!directlyAppliedTags.isEmpty()) {
     277            final JLabel label = new JLabel(ImageProvider.get("pastetags"));
     278            label.setToolTipText("<html>" + tr("This preset also sets: {0}", Utils.joinAsHtmlUnorderedList(directlyAppliedTags)));
     279            pp.add(label);
     280        }
     281        if (pp.getComponentCount() > 0) {
    253282            p.add(pp, GBC.eol());
    254283        }
  • trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/Key.java

    r8863 r9467  
    2626    @Override
    2727    public void addCommands(List<Tag> changedTags) {
    28         changedTags.add(new Tag(key, value));
     28        changedTags.add(asTag());
     29    }
     30
     31    /**
     32     * Returns the {@link Tag} set by this item
     33     * @return the tag
     34     */
     35    public Tag asTag() {
     36        return new Tag(key, value);
    2937    }
    3038
Note: See TracChangeset for help on using the changeset viewer.