001// License: GPL. For details, see LICENSE file. 002package org.openstreetmap.josm.actions; 003 004import java.awt.event.ActionEvent; 005import static org.openstreetmap.josm.tools.I18n.tr; 006import static org.openstreetmap.josm.gui.help.HelpUtil.ht; 007 008import java.awt.event.KeyEvent; 009 010import java.util.Collection; 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 017public class InfoAction extends JosmAction { 018 019 /** 020 * Constructs a new {@code InfoAction}. 021 */ 022 public InfoAction() { 023 super(tr("Advanced info"), "about", 024 tr("Display advanced object information about OSM nodes, ways, or relations."), 025 Shortcut.registerShortcut("core:info", 026 tr("Advanced info"), KeyEvent.VK_I, Shortcut.CTRL), 027 true, "action/info", true); 028 putValue("help", ht("/Action/InfoAboutElements")); 029 } 030 031 @Override 032 public void actionPerformed(ActionEvent ae) { 033 DataSet set = getCurrentDataSet(); 034 if (set != null) { 035 new InspectPrimitiveDialog(set.getAllSelected(), Main.main.getEditLayer()).showDialog(); 036 } 037 } 038 039 @Override 040 public void updateEnabledState() { 041 if (getCurrentDataSet() == null) { 042 setEnabled(false); 043 } else { 044 updateEnabledState(getCurrentDataSet().getAllSelected()); 045 } 046 } 047 048 @Override 049 protected void updateEnabledState(Collection<? extends OsmPrimitive> selection) { 050 setEnabled(!selection.isEmpty()); 051 } 052}