Ignore:
Timestamp:
2017-11-11T02:03:41+01:00 (16 months ago)
Author:
Don-vip
Message:

fix #15537 - Support changeset hashtags (hashtags changeset tag, extracted from comment at upload, or set by remote control through new changeset_hashtags parameter)

File:
1 edited

Legend:

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

    r12726 r13109  
    4848        this.changesetSourceModel = changesetSourceModel;
    4949        this.changesetReviewModel = changesetReviewModel;
    50         changesetCommentModel.addChangeListener(new ChangesetCommentChangeListener("comment"));
     50        changesetCommentModel.addChangeListener(new ChangesetCommentChangeListener("comment", "hashtags"));
    5151        changesetSourceModel.addChangeListener(new ChangesetCommentChangeListener("source"));
    5252        changesetReviewModel.addChangeListener(new ChangesetReviewChangeListener());
     
    135135
    136136        private final String key;
     137        private final String hashtagsKey;
    137138
    138139        ChangesetCommentChangeListener(String key) {
     140            this(key, null);
     141        }
     142
     143        ChangesetCommentChangeListener(String key, String hashtagsKey) {
    139144            this.key = key;
     145            this.hashtagsKey = hashtagsKey;
    140146        }
    141147
     
    143149        public void stateChanged(ChangeEvent e) {
    144150            if (e.getSource() instanceof ChangesetCommentModel) {
    145                 String newValue = ((ChangesetCommentModel) e.getSource()).getComment();
     151                ChangesetCommentModel model = ((ChangesetCommentModel) e.getSource());
     152                String newValue = model.getComment();
    146153                String oldValue = Optional.ofNullable(getTagEditorValue(key)).orElse("");
    147154                if (!oldValue.equals(newValue)) {
    148155                    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                    }
    149163                }
    150164            }
Note: See TracChangeset for help on using the changeset viewer.