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

File center-map-on-note-v2.patch, 2.2 KB (added by NoteRoamer, 23 months ago)

Add center man on note option to 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            super(tr("Center mapview on note"), "dialogs/position", tr("Center mapview on note"),
     424                    Shortcut.registerShortcut("notes:comment:center", tr("Notes: Center mapview on note"), KeyEvent.VK_UNDEFINED, Shortcut.NONE),
     425                    false, false);
     426        }
     427
     428        @Override
     429        public void actionPerformed(ActionEvent e) {
     430            if (noteData != null && noteData.getSelectedNote() != null) {
     431                MainApplication.getMap().mapView.zoomTo(noteData.getSelectedNote().getLatLon());
     432            }
     433        }
     434    }
     435
     436    /**
    415437     * Close a note
    416438     */
    417439    class CloseAction extends JosmAction {