Skip to content

Commit

Permalink
fix #20096 - restore comment initialization from dataset changeset ha…
Browse files Browse the repository at this point in the history
…shtags if specified through remote control (regression from recent upload dialog changes)

git-svn-id: https://josm.openstreetmap.de/svn/trunk@17318 0c6e7542-c601-0410-84e7-c038aed88b3b
  • Loading branch information
don-vip committed Nov 17, 2020
1 parent aecfedc commit 3156f80
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
26 changes: 24 additions & 2 deletions src/org/openstreetmap/josm/gui/io/UploadDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ private void setChangesetTags(DataSet dataSet, boolean keepSourceComment) {
// obtain from previous input
if (!keepSourceComment) {
tags.put("source", getLastChangesetSourceFromHistory());
tags.put("comment", getLastChangesetCommentFromHistory());
tags.put("comment", getCommentWithDataSetHashTag(getLastChangesetCommentFromHistory(), dataSet));
}

// obtain from dataset
Expand Down Expand Up @@ -329,14 +329,36 @@ private void setChangesetTags(DataSet dataSet, boolean keepSourceComment) {
// ignore source/comment to keep current values from models ?
if (keepSourceComment) {
tags.put("source", changesetSourceModel.getComment());
tags.put("comment", changesetCommentModel.getComment());
tags.put("comment", getCommentWithDataSetHashTag(changesetCommentModel.getComment(), dataSet));
}

pnlTagSettings.initFromTags(tags);
pnlTagSettings.tableChanged(null);
pnlBasicUploadSettings.discardAllUndoableEdits();
}

/**
* Returns the given comment with appended hashtags from dataset changeset tags, if not already present.
* @param comment changeset comment
* @param dataSet optional dataset, which can contain hashtags in its changeset tags
* @return comment with dataset changesets tags, if any, not duplicated
*/
private static String getCommentWithDataSetHashTag(String comment, DataSet dataSet) {
String result = comment;
if (dataSet != null) {
String hashtags = dataSet.getChangeSetTags().get("hashtags");
if (hashtags != null) {
for (String hashtag : hashtags.split(";")) {
String sanitizedHashtag = hashtag.startsWith("#") ? hashtag : "#" + hashtag;
if (!result.contains(sanitizedHashtag)) {
result = result + " " + sanitizedHashtag;
}
}
}
}
return result;
}

@Override
public void rememberUserInput() {
pnlBasicUploadSettings.rememberUserInput();
Expand Down
5 changes: 5 additions & 0 deletions src/org/openstreetmap/josm/gui/tagging/TagModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,9 @@ public String getValue() {
public int getValueCount() {
return values.size();
}

@Override
public String toString() {
return name + "=" + values;
}
}

0 comments on commit 3156f80

Please sign in to comment.