From 2de14135050c3d24e9df81832049d269cd5d1596 Mon Sep 17 00:00:00 2001
From: Jiri Vlasak <jiri.hubacek@gmail.com>
Date: Tue, 19 Sep 2023 01:02:05 +0200
Subject: [PATCH v3] Include changeset in note comment if feasible
When closing a note, check for the changeset in the changeset cache. If
there is a changeset with the comment that contains a link to the note
being closed, put the link to the changeset as the default text of the
closing note comment.
---
.../openstreetmap/josm/gui/NoteInputDialog.java | 12 ++++++++++++
.../josm/gui/dialogs/NotesDialog.java | 17 +++++++++++++++--
2 files changed, 27 insertions(+), 2 deletions(-)
diff --git a/src/org/openstreetmap/josm/gui/NoteInputDialog.java b/src/org/openstreetmap/josm/gui/NoteInputDialog.java
index 779959b856..c2881d5d13 100644
|
a
|
b
|
public class NoteInputDialog extends ExtendedDialog {
|
| 44 | 44 | * @param icon Icon to display in the action button |
| 45 | 45 | */ |
| 46 | 46 | public void showNoteDialog(String message, Icon icon) { |
| | 47 | showNoteDialog(message, icon, ""); |
| | 48 | } |
| | 49 | |
| | 50 | /** |
| | 51 | * Displays the dialog to the user |
| | 52 | * @param message Translated message to display to the user as input prompt |
| | 53 | * @param icon Icon to display in the action button |
| | 54 | * @param text Default text of the note's comment |
| | 55 | * @param since xxx |
| | 56 | */ |
| | 57 | public void showNoteDialog(String message, Icon icon, String text) { |
| | 58 | textArea.setText(text); |
| 47 | 59 | textArea.setRows(6); |
| 48 | 60 | textArea.setColumns(30); |
| 49 | 61 | textArea.setLineWrap(true); |
diff --git a/src/org/openstreetmap/josm/gui/dialogs/NotesDialog.java b/src/org/openstreetmap/josm/gui/dialogs/NotesDialog.java
index 6e0fc7e8ff..65ab6289d5 100644
|
a
|
b
|
import org.openstreetmap.josm.actions.mapmode.AddNoteAction;
|
| 40 | 40 | import org.openstreetmap.josm.data.notes.Note; |
| 41 | 41 | import org.openstreetmap.josm.data.notes.Note.State; |
| 42 | 42 | import org.openstreetmap.josm.data.notes.NoteComment; |
| | 43 | import org.openstreetmap.josm.data.osm.Changeset; |
| | 44 | import org.openstreetmap.josm.data.osm.ChangesetCache; |
| 43 | 45 | import org.openstreetmap.josm.data.osm.NoteData; |
| 44 | 46 | import org.openstreetmap.josm.data.osm.NoteData.NoteDataUpdateListener; |
| 45 | 47 | import org.openstreetmap.josm.gui.MainApplication; |
| … |
… |
import org.openstreetmap.josm.gui.widgets.DisableShortcutsOnFocusGainedTextField
|
| 57 | 59 | import org.openstreetmap.josm.gui.widgets.FilterField; |
| 58 | 60 | import org.openstreetmap.josm.gui.widgets.JosmTextField; |
| 59 | 61 | import org.openstreetmap.josm.gui.widgets.PopupMenuLauncher; |
| | 62 | import org.openstreetmap.josm.io.OsmApi; |
| 60 | 63 | import org.openstreetmap.josm.spi.preferences.Config; |
| 61 | 64 | import org.openstreetmap.josm.tools.ImageProvider; |
| 62 | 65 | import org.openstreetmap.josm.tools.OpenBrowser; |
| … |
… |
public class NotesDialog extends ToggleDialog implements LayerChangeListener, No
|
| 422 | 425 | |
| 423 | 426 | @Override |
| 424 | 427 | public void actionPerformed(ActionEvent e) { |
| | 428 | Note note = displayList.getSelectedValue(); |
| | 429 | String changesetUrl = ""; |
| | 430 | if (note != null) { |
| | 431 | String noteUrlShort = "osm.org/note/" + note.getId(); |
| | 432 | String noteUrlLong = OsmApi.getOsmApi().getHost().substring(4) + "/note/" + note.getId(); |
| | 433 | for (Changeset cs: ChangesetCache.getInstance().getChangesets()) { |
| | 434 | if (cs.getComment().indexOf(noteUrlShort) > -1 || cs.getComment().indexOf(noteUrlLong) > -1) { |
| | 435 | changesetUrl = "https://www.osm.org/changeset/" + cs.getId(); |
| | 436 | } |
| | 437 | } |
| | 438 | } |
| 425 | 439 | NoteInputDialog dialog = new NoteInputDialog(MainApplication.getMainFrame(), tr("Close note"), tr("Close note")); |
| 426 | | dialog.showNoteDialog(tr("Close note with message:"), ImageProvider.get("dialogs/notes", "note_closed")); |
| | 440 | dialog.showNoteDialog(tr("Close note with message:"), ImageProvider.get("dialogs/notes", "note_closed"), changesetUrl); |
| 427 | 441 | if (dialog.getValue() != 1) { |
| 428 | 442 | return; |
| 429 | 443 | } |
| 430 | | Note note = displayList.getSelectedValue(); |
| 431 | 444 | if (note != null) { |
| 432 | 445 | int selectedIndex = displayList.getSelectedIndex(); |
| 433 | 446 | noteData.closeNote(note, dialog.getInputText()); |