Changeset 17318 in josm


Ignore:
Timestamp:
2020-11-17T01:15:05+01:00 (2 weeks ago)
Author:
Don-vip
Message:

fix #20096 - restore comment initialization from dataset changeset hashtags if specified through remote control (regression from recent upload dialog changes)

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

Legend:

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

    r17238 r17318  
    298298        if (!keepSourceComment) {
    299299            tags.put("source", getLastChangesetSourceFromHistory());
    300             tags.put("comment", getLastChangesetCommentFromHistory());
     300            tags.put("comment", getCommentWithDataSetHashTag(getLastChangesetCommentFromHistory(), dataSet));
    301301        }
    302302
     
    330330        if (keepSourceComment) {
    331331            tags.put("source", changesetSourceModel.getComment());
    332             tags.put("comment", changesetCommentModel.getComment());
     332            tags.put("comment", getCommentWithDataSetHashTag(changesetCommentModel.getComment(), dataSet));
    333333        }
    334334
     
    336336        pnlTagSettings.tableChanged(null);
    337337        pnlBasicUploadSettings.discardAllUndoableEdits();
     338    }
     339
     340    /**
     341     * Returns the given comment with appended hashtags from dataset changeset tags, if not already present.
     342     * @param comment changeset comment
     343     * @param dataSet optional dataset, which can contain hashtags in its changeset tags
     344     * @return comment with dataset changesets tags, if any, not duplicated
     345     */
     346    private static String getCommentWithDataSetHashTag(String comment, DataSet dataSet) {
     347        String result = comment;
     348        if (dataSet != null) {
     349            String hashtags = dataSet.getChangeSetTags().get("hashtags");
     350            if (hashtags != null) {
     351                for (String hashtag : hashtags.split(";")) {
     352                    String sanitizedHashtag = hashtag.startsWith("#") ? hashtag : "#" + hashtag;
     353                    if (!result.contains(sanitizedHashtag)) {
     354                        result = result + " " + sanitizedHashtag;
     355                    }
     356                }
     357            }
     358        }
     359        return result;
    338360    }
    339361
  • trunk/src/org/openstreetmap/josm/gui/tagging/TagModel.java

    r16913 r17318  
    144144        return values.size();
    145145    }
     146
     147    @Override
     148    public String toString() {
     149        return name + "=" + values;
     150    }
    146151}
Note: See TracChangeset for help on using the changeset viewer.