Changeset 18839 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2023-09-21T19:04:05+02:00 (14 months ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/NoteInputDialog.java
r16435 r18839 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 * @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); -
trunk/src/org/openstreetmap/josm/gui/dialogs/NotesDialog.java
r18715 r18839 15 15 import java.util.Arrays; 16 16 import java.util.Collection; 17 import java.util.Collections; 17 18 import java.util.List; 18 19 import java.util.Objects; 19 20 import java.util.function.Predicate; 21 import java.util.regex.Matcher; 20 22 import java.util.regex.Pattern; 21 23 import java.util.stream.Collectors; … … 41 43 import org.openstreetmap.josm.data.notes.Note.State; 42 44 import org.openstreetmap.josm.data.notes.NoteComment; 45 import org.openstreetmap.josm.data.osm.Changeset; 46 import org.openstreetmap.josm.data.osm.ChangesetCache; 43 47 import org.openstreetmap.josm.data.osm.NoteData; 44 48 import org.openstreetmap.josm.data.osm.NoteData.NoteDataUpdateListener; … … 58 62 import org.openstreetmap.josm.gui.widgets.JosmTextField; 59 63 import org.openstreetmap.josm.gui.widgets.PopupMenuLauncher; 64 import org.openstreetmap.josm.io.OsmApi; 60 65 import org.openstreetmap.josm.spi.preferences.Config; 61 66 import org.openstreetmap.josm.tools.ImageProvider; … … 423 428 @Override 424 429 public void actionPerformed(ActionEvent e) { 430 Note note = displayList.getSelectedValue(); 431 final List<String> changesetUrls = note == null ? Collections.emptyList() : getRelatedChangesetUrls(note.getId()); 425 432 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")); 433 dialog.showNoteDialog(tr("Close note with message:"), ImageProvider.get("dialogs/notes", "note_closed"), 434 String.join("\n", changesetUrls)); 427 435 if (dialog.getValue() != 1) { 428 436 return; 429 437 } 430 Note note = displayList.getSelectedValue();431 438 if (note != null) { 432 439 int selectedIndex = displayList.getSelectedIndex(); … … 443 450 444 451 /** 452 * Get a list of changeset urls that may have fixed a note 453 * @param noteId The note ID to look for 454 * @return A list of changeset URLs 455 */ 456 static List<String> getRelatedChangesetUrls(long noteId) { 457 final List<String> changesetUrls = new ArrayList<>(); 458 final int patternFlags = Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CHARACTER_CLASS; 459 final Matcher noteMatcher = Pattern.compile("note " + noteId + "( |$)", patternFlags).matcher(""); 460 final Matcher shortOsmMatcher = Pattern.compile("osm.org/note/" + noteId + "( |$)", patternFlags).matcher(""); 461 final String hostUrl = Pattern.compile("https?://(www\\.)?") 462 .matcher(Config.getUrls().getBaseBrowseUrl()) 463 .replaceFirst(""); 464 final Matcher longOsmMatcher = Pattern.compile(hostUrl + "/note/" + noteId + "( |$)", patternFlags).matcher(""); 465 final boolean isUsingDefaultOsmApi = Config.getUrls().getDefaultOsmApiUrl().equals(OsmApi.getOsmApi().getServerUrl()); 466 for (Changeset cs: ChangesetCache.getInstance().getChangesets()) { 467 final String comment = cs.getComment(); 468 if ((isUsingDefaultOsmApi && (shortOsmMatcher.reset(comment).find() || noteMatcher.reset(comment).find())) 469 || longOsmMatcher.reset(comment).find()) { 470 changesetUrls.add(Config.getUrls().getBaseBrowseUrl() + "/changeset/" + cs.getId()); 471 } 472 } 473 return changesetUrls; 474 } 475 476 /** 445 477 * Create a new note 446 478 */
Note:
See TracChangeset
for help on using the changeset viewer.