Ignore:
Timestamp:
2016-01-17T22:38:38+01:00 (8 years ago)
Author:
simon04
Message:

fix #4003 fix #7004 fix #8149 - Improve changeset tags handling (from earlier changeset, from dataset)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/io/TagSettingsPanel.java

    r9246 r9514  
    33
    44import java.awt.BorderLayout;
    5 import java.util.HashMap;
     5import java.util.Collections;
    66import java.util.Map;
    77import java.util.Observable;
     
    1313
    1414import org.openstreetmap.josm.Main;
    15 import org.openstreetmap.josm.data.Version;
    1615import org.openstreetmap.josm.data.osm.Changeset;
     16import org.openstreetmap.josm.data.osm.DataSet;
    1717import org.openstreetmap.josm.gui.tagging.TagEditorPanel;
    1818import org.openstreetmap.josm.gui.tagging.TagModel;
     
    2626    private final transient ChangesetCommentModel changesetCommentModel;
    2727    private final transient ChangesetCommentModel changesetSourceModel;
    28     /** tags that applied to uploaded changesets by default*/
    29     private final transient Map<String, String> defaultTags = new HashMap<>();
    3028
    3129    protected void build() {
     
    8179
    8280    /**
    83      * Initialize panel from changeset.
    84      * @param cs changeset
     81     * Initialize panel from the given tags.
     82     * @param tags the tags used to initialize the panel
    8583     */
    86     public void initFromChangeset(Changeset cs) {
    87         Map<String, String> tags = getDefaultTags();
    88         if (cs != null) {
    89             tags.putAll(cs.getKeys());
    90         }
    91         if (tags.get("comment") == null) {
    92             tags.put("comment", getTagEditorValue("comment"));
    93         }
    94         if (tags.get("source") == null) {
    95             tags.put("source", getTagEditorValue("source"));
    96         }
    97         String agent = Version.getInstance().getAgentString(false);
    98         String created_by = tags.get("created_by");
    99         if (created_by == null || created_by.isEmpty()) {
    100             tags.put("created_by", agent);
    101         } else if (!created_by.contains(agent)) {
    102             tags.put("created_by", created_by + ';' + agent);
    103         }
     84    public void initFromTags(Map<String, String> tags) {
    10485        pnlTagEditor.getModel().initFromTags(tags);
    10586    }
     
    11596
    11697    /**
    117      * Replies the map with the default tags.
    118      * @return the map with the default tags
     98     * @return an empty map
     99     * @deprecated No longer supported, returns an empty map
    119100     */
     101    @Deprecated
    120102    public Map<String, String> getDefaultTags() {
    121         Map<String, String> tags = new HashMap<>();
    122         tags.putAll(defaultTags);
    123         return tags;
     103        return Collections.emptyMap();
    124104    }
    125105
    126106    /**
    127      * Sets the map with the default tags.
    128      * @param tags the map with the default tags
     107     * @param tags ignored
     108     * @deprecated No longer supported, does nothing; use {@link UploadDialog#setChangesetTags(DataSet)} instead!
    129109     */
     110    @Deprecated
    130111    public void setDefaultTags(Map<String, String> tags) {
    131         defaultTags.clear();
    132         defaultTags.putAll(tags);
    133         tableChanged(null);
    134112    }
    135113
Note: See TracChangeset for help on using the changeset viewer.