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.ActionEvent;
008import java.awt.event.KeyEvent;
009import java.util.Collection;
010
011import org.openstreetmap.josm.Main;
012import org.openstreetmap.josm.data.osm.DataSet;
013import org.openstreetmap.josm.data.osm.OsmPrimitive;
014import org.openstreetmap.josm.gui.dialogs.InspectPrimitiveDialog;
015import org.openstreetmap.josm.tools.Shortcut;
016
017/**
018 * Display advanced object information about OSM nodes, ways, or relations.
019 * @since 1697
020 */
021public class InfoAction extends JosmAction {
022
023    /**
024     * Constructs a new {@code InfoAction}.
025     */
026    public InfoAction() {
027        super(tr("Advanced info"), "info",
028            tr("Display advanced object information about OSM nodes, ways, or relations."),
029            Shortcut.registerShortcut("core:info",
030                tr("Advanced info"), KeyEvent.VK_I, Shortcut.CTRL),
031            true, "action/info", true);
032        putValue("help", ht("/Action/InfoAboutElements"));
033    }
034
035    @Override
036    public void actionPerformed(ActionEvent ae) {
037        DataSet set = getCurrentDataSet();
038        if (set != null) {
039            new InspectPrimitiveDialog(set.getAllSelected(), Main.main.getEditLayer()).showDialog();
040        }
041    }
042
043    @Override
044    public void updateEnabledState() {
045        if (getCurrentDataSet() == null) {
046            setEnabled(false);
047        } else {
048            updateEnabledState(getCurrentDataSet().getAllSelected());
049        }
050    }
051
052    @Override
053    protected void updateEnabledState(Collection<? extends OsmPrimitive> selection) {
054        setEnabled(!selection.isEmpty());
055    }
056}