source: josm/trunk/src/org/openstreetmap/josm/actions/InfoWebAction.java@ 12855

Last change on this file since 12855 was 12630, checked in by Don-vip, 7 years ago

see #15182 - deprecate Main.map and Main.isDisplayingMapView(). Replacements: gui.MainApplication.getMap() / gui.MainApplication.isDisplayingMapView()

  • Property svn:eol-style set to native
File size: 2.6 KB
RevLine 
[8378]1// License: GPL. For details, see LICENSE file.
[4408]2package org.openstreetmap.josm.actions;
3
[5926]4import static org.openstreetmap.josm.gui.help.HelpUtil.ht;
[4408]5import static org.openstreetmap.josm.tools.I18n.tr;
6
7import java.awt.event.KeyEvent;
[8475]8import java.util.Collection;
[4408]9
[7678]10import org.openstreetmap.josm.Main;
[8475]11import org.openstreetmap.josm.data.notes.Note;
[4408]12import org.openstreetmap.josm.data.osm.OsmPrimitive;
13import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
[12630]14import org.openstreetmap.josm.gui.MainApplication;
[4408]15import org.openstreetmap.josm.tools.Shortcut;
16
[7859]17/**
18 * Display object information about OSM nodes, ways, or relations in web browser.
19 * @since 4408
20 */
[4408]21public class InfoWebAction extends AbstractInfoAction {
22
[7859]23 /**
24 * Constructs a new {@code InfoWebAction}.
25 */
[4408]26 public InfoWebAction() {
[7771]27 super(tr("Advanced info (web)"), "info",
[4408]28 tr("Display object information about OSM nodes, ways, or relations in web browser."),
29 Shortcut.registerShortcut("core:infoweb",
[4982]30 tr("Advanced info (web)"), KeyEvent.VK_I, Shortcut.CTRL_SHIFT),
[4942]31 true, "action/infoweb", true);
[4700]32 putValue("help", ht("/Action/InfoAboutElementsWeb"));
[4408]33 }
34
35 @Override
[8475]36 protected String createInfoUrl(Object infoObject) {
37 if (infoObject instanceof OsmPrimitive) {
[8510]38 OsmPrimitive primitive = (OsmPrimitive) infoObject;
[8846]39 return Main.getBaseBrowseUrl() + '/' + OsmPrimitiveType.from(primitive).getAPIName() + '/' + primitive.getId();
[8475]40 } else if (infoObject instanceof Note) {
[8510]41 Note note = (Note) infoObject;
[8475]42 return Main.getBaseBrowseUrl() + "/note/" + note.getId();
43 } else {
44 return null;
45 }
[4408]46 }
[8475]47
48 @Override
49 protected void updateEnabledState() {
50 super.updateEnabledState();
51 updateEnabledStateWithNotes();
52 }
53
54 @Override
55 protected void updateEnabledState(Collection<? extends OsmPrimitive> selection) {
56 super.updateEnabledState(selection);
57 updateEnabledStateWithNotes();
58 }
59
60 private void updateEnabledStateWithNotes() {
61 // Allows enabling if a note is selected, even if no OSM object is selected
[12630]62 if (!isEnabled() && MainApplication.isDisplayingMapView() && MainApplication.getMap().noteDialog.getSelectedNote() != null) {
[9136]63 setEnabled(true);
[8475]64 }
65 }
66
67 /**
68 * Called when the note selection has changed.
69 * TODO: make a proper listener mechanism to handle change of note selection
70 * @since 8475
71 */
72 public final void noteSelectionChanged() {
73 updateEnabledState();
74 }
[4408]75}
Note: See TracBrowser for help on using the repository browser.