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