Changeset 11030 in josm


Ignore:
Timestamp:
2016-09-19T21:12:05+02:00 (8 years ago)
Author:
simon04
Message:

fix #13664 - Open selected note in an external browser

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/dialogs/NotesDialog.java

    r10611 r11030  
    4545import org.openstreetmap.josm.gui.layer.NoteLayer;
    4646import org.openstreetmap.josm.tools.ImageProvider;
     47import org.openstreetmap.josm.tools.OpenBrowser;
    4748import org.openstreetmap.josm.tools.date.DateUtils;
    4849
     
    6263    private final ReopenAction reopenAction;
    6364    private final SortAction sortAction;
     65    private final OpenInBrowserAction openInBrowserAction;
    6466    private final UploadNotesAction uploadAction;
    6567
     
    7577        reopenAction = new ReopenAction();
    7678        sortAction = new SortAction();
     79        openInBrowserAction = new OpenInBrowserAction();
    7780        uploadAction = new UploadNotesAction();
    7881        buildDialog();
     
    113116                new SideButton(reopenAction, false),
    114117                new SideButton(sortAction, false),
     118                new SideButton(openInBrowserAction, false),
    115119                new SideButton(uploadAction, false)}));
    116120        updateButtonStates();
     
    131135            reopenAction.setEnabled(true);
    132136        }
     137        openInBrowserAction.setEnabled(noteData != null && noteData.getSelectedNote() != null && noteData.getSelectedNote().getId() > 0);
    133138        if (noteData == null || !noteData.isModified()) {
    134139            uploadAction.setEnabled(false);
     
    402407        }
    403408    }
     409
     410    class OpenInBrowserAction extends AbstractAction {
     411        OpenInBrowserAction() {
     412            putValue(SHORT_DESCRIPTION, tr("Open the note in an external browser"));
     413            putValue(SMALL_ICON, ImageProvider.get("help", "internet"));
     414        }
     415
     416        @Override
     417        public void actionPerformed(ActionEvent e) {
     418            final Note note = displayList.getSelectedValue();
     419            if (note.getId() > 0) {
     420                final String url = Main.getBaseBrowseUrl() + "/note/" + note.getId();
     421                OpenBrowser.displayUrl(url);
     422            }
     423        }
     424    }
    404425}
Note: See TracChangeset for help on using the changeset viewer.