Changeset 13109 in josm
- Timestamp:
- 2017-11-11T02:03:41+01:00 (7 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/io/ChangesetCommentModel.java
r10210 r13109 2 2 package org.openstreetmap.josm.gui.io; 3 3 4 import java.util.Arrays; 5 import java.util.List; 4 6 import java.util.Objects; 7 import java.util.stream.Collectors; 5 8 6 9 import org.openstreetmap.josm.gui.util.ChangeNotifier; … … 35 38 return comment == null ? "" : comment; 36 39 } 40 41 /** 42 * Extracts the list of hashtags from the comment text. 43 * @return the list of hashtags from the comment text. Can be empty, but not null. 44 * @since 13109 45 */ 46 public List<String> findHashTags() { 47 return Arrays.stream(comment.split("\\s")).filter(s -> s.length() >= 2 && s.charAt(0) == '#').collect(Collectors.toList()); 48 } 37 49 } -
trunk/src/org/openstreetmap/josm/gui/io/TagSettingsPanel.java
r12726 r13109 48 48 this.changesetSourceModel = changesetSourceModel; 49 49 this.changesetReviewModel = changesetReviewModel; 50 changesetCommentModel.addChangeListener(new ChangesetCommentChangeListener("comment" ));50 changesetCommentModel.addChangeListener(new ChangesetCommentChangeListener("comment", "hashtags")); 51 51 changesetSourceModel.addChangeListener(new ChangesetCommentChangeListener("source")); 52 52 changesetReviewModel.addChangeListener(new ChangesetReviewChangeListener()); … … 135 135 136 136 private final String key; 137 private final String hashtagsKey; 137 138 138 139 ChangesetCommentChangeListener(String key) { 140 this(key, null); 141 } 142 143 ChangesetCommentChangeListener(String key, String hashtagsKey) { 139 144 this.key = key; 145 this.hashtagsKey = hashtagsKey; 140 146 } 141 147 … … 143 149 public void stateChanged(ChangeEvent e) { 144 150 if (e.getSource() instanceof ChangesetCommentModel) { 145 String newValue = ((ChangesetCommentModel) e.getSource()).getComment(); 151 ChangesetCommentModel model = ((ChangesetCommentModel) e.getSource()); 152 String newValue = model.getComment(); 146 153 String oldValue = Optional.ofNullable(getTagEditorValue(key)).orElse(""); 147 154 if (!oldValue.equals(newValue)) { 148 155 setProperty(key, newValue); 156 if (hashtagsKey != null) { 157 String newHashTags = String.join(";", model.findHashTags()); 158 String oldHashTags = Optional.ofNullable(getTagEditorValue(hashtagsKey)).orElse(""); 159 if (!oldHashTags.equals(newHashTags)) { 160 setProperty(hashtagsKey, newHashTags); 161 } 162 } 149 163 } 150 164 } -
trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/LoadAndZoomHandler.java
r12846 r13109 6 6 import java.awt.geom.Area; 7 7 import java.awt.geom.Rectangle2D; 8 import java.util.Arrays; 8 9 import java.util.Collection; 9 10 import java.util.Collections; … … 77 78 @Override 78 79 public String[] getOptionalParams() { 79 return new String[] {"new_layer", "layer_name", "addtags", "select", "zoom_mode", "changeset_comment", "changeset_source", "search"}; 80 return new String[] {"new_layer", "layer_name", "addtags", "select", "zoom_mode", 81 "changeset_comment", "changeset_source", "changeset_hashtags", "search"}; 80 82 } 81 83 … … 213 215 214 216 // add changeset tags after download if necessary 215 if (args.containsKey("changeset_comment") || args.containsKey("changeset_source") ) {217 if (args.containsKey("changeset_comment") || args.containsKey("changeset_source") || args.containsKey("changeset_hashtags")) { 216 218 MainApplication.worker.submit(() -> { 217 if (MainApplication.getLayerManager().getEditDataSet() != null) {218 if (args.containsKey("changeset_comment")) {219 MainApplication.getLayerManager().getEditDataSet().addChangeSetTag("comment", args.get("changeset_comment"));220 }221 if (args.containsKey("changeset_source")) {222 MainApplication.getLayerManager().getEditDataSet().addChangeSetTag("source", args.get("changeset_source"));219 DataSet ds = MainApplication.getLayerManager().getEditDataSet(); 220 if (ds != null) { 221 for (String tag : Arrays.asList("changeset_comment", "changeset_source", "changeset_hashtags")) { 222 if (args.containsKey(tag)) { 223 ds.addChangeSetTag(tag.substring("changeset_".length()), args.get(tag)); 224 } 223 225 } 224 226 }
Note:
See TracChangeset
for help on using the changeset viewer.