001// License: GPL. For details, see LICENSE file.
002package org.openstreetmap.josm.actions;
003
004import static org.openstreetmap.josm.gui.help.HelpUtil.ht;
005import static org.openstreetmap.josm.tools.I18n.tr;
006
007import java.awt.event.KeyEvent;
008
009import org.openstreetmap.josm.Main;
010import org.openstreetmap.josm.data.osm.OsmPrimitive;
011import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
012import org.openstreetmap.josm.tools.Shortcut;
013
014public class HistoryInfoWebAction extends AbstractInfoAction {
015
016    /**
017     * Constructs a new {@code HistoryInfoWebAction}.
018     */
019    public HistoryInfoWebAction() {
020        super(tr("History (web)"), "dialogs/history",
021                tr("Display history information about OSM ways, nodes, or relations in web browser."),
022                Shortcut.registerShortcut("core:historyinfoweb",
023                        tr("History (web)"), KeyEvent.VK_H, Shortcut.CTRL_SHIFT),
024                true, "action/historyinfoweb", true);
025        putValue("help", ht("/Action/ObjectHistoryWeb"));
026    }
027
028    @Override
029    protected  String createInfoUrl(Object infoObject) {
030        if (infoObject instanceof OsmPrimitive) {
031            OsmPrimitive primitive = (OsmPrimitive) infoObject;
032            return Main.getBaseBrowseUrl() + '/' + OsmPrimitiveType.from(primitive).getAPIName() + '/' + primitive.getId() + "/history";
033        } else {
034            return null;
035        }
036    }
037}