Ticket #18974: center-map-on-note.patch

File center-map-on-note.patch, 2.0 KB (added by NoteRoamer, 14 months ago)

Patch to add a "Center map on note" to the note list menu.

  • src/org/openstreetmap/josm/gui/dialogs/NotesDialog.java

     
    8080    private JList<Note> displayList;
    8181    private final JosmTextField filter = setupFilter();
    8282    private final AddCommentAction addCommentAction;
     83    private final CenterMapAction centerMapAction;
    8384    private final CloseAction closeAction;
    8485    private final DownloadNotesInViewAction downloadNotesInViewAction;
    8586    private final NewAction newAction;
     
    9697                Shortcut.registerShortcut("subwindow:notes", tr("Windows: {0}", tr("Notes")),
    9798                KeyEvent.CHAR_UNDEFINED, Shortcut.NONE), 150);
    9899        addCommentAction = new AddCommentAction();
     100        centerMapAction = new CenterMapAction();
    99101        closeAction = new CloseAction();
    100102        downloadNotesInViewAction = DownloadNotesInViewAction.newActionWithDownloadIcon();
    101103        newAction = new NewAction();
     
    144146        updateButtonStates();
    145147
    146148        JPopupMenu notesPopupMenu = new JPopupMenu();
     149        notesPopupMenu.add(centerMapAction);
    147150        notesPopupMenu.add(addCommentAction);
    148151        notesPopupMenu.add(openInBrowserAction);
    149152        notesPopupMenu.add(closeAction);
     
    412415    }
    413416
    414417    /**
     418     * Center the mapview on the note
     419     *
     420     */
     421    class CenterMapAction extends JosmAction {
     422        CenterMapAction() {
     423            putValue(NAME, tr("Center mapview on note"));
     424            putValue(SHORT_DESCRIPTION, tr("Center mapview on note"));
     425            new ImageProvider("dialogs/autoscale", "selection").getResource().attachImageIcon(this, true);
     426        }
     427
     428        @Override
     429        public void actionPerformed(ActionEvent e) {
     430            MainApplication.getMap().mapView.zoomTo(noteData.getSelectedNote().getLatLon());
     431        }
     432    }
     433
     434    /**
    415435     * Close a note
    416436     */
    417437    class CloseAction extends JosmAction {