001 //License: GPL. Copyright 2007 by Immanuel Scholz and others 002 package org.openstreetmap.josm.actions; 003 004 import java.awt.event.ActionEvent; 005 import static org.openstreetmap.josm.tools.I18n.tr; 006 import static org.openstreetmap.josm.gui.help.HelpUtil.ht; 007 008 import java.awt.event.KeyEvent; 009 010 import java.util.Collection; 011 import org.openstreetmap.josm.Main; 012 import org.openstreetmap.josm.data.osm.DataSet; 013 import org.openstreetmap.josm.data.osm.OsmPrimitive; 014 import org.openstreetmap.josm.gui.dialogs.InspectPrimitiveDialog; 015 import org.openstreetmap.josm.tools.Shortcut; 016 017 public class InfoAction extends JosmAction { 018 019 public InfoAction() { 020 super(tr("Advanced info"), "about", 021 tr("Display advanced object information about OSM nodes, ways, or relations."), 022 Shortcut.registerShortcut("core:info", 023 tr("Advanced info"), KeyEvent.VK_I, Shortcut.CTRL), 024 true, "action/info", true); 025 putValue("help", ht("/Action/InfoAboutElements")); 026 } 027 028 @Override 029 public void actionPerformed(ActionEvent ae) { 030 DataSet set = getCurrentDataSet(); 031 if (set != null) { 032 new InspectPrimitiveDialog(set.getAllSelected(), Main.map.mapView.getEditLayer()).showDialog(); 033 } 034 } 035 036 @Override 037 public void updateEnabledState() { 038 if (getCurrentDataSet() == null) { 039 setEnabled(false); 040 } else { 041 updateEnabledState(getCurrentDataSet().getAllSelected()); 042 } 043 } 044 045 @Override 046 protected void updateEnabledState(Collection<? extends OsmPrimitive> selection) { 047 setEnabled(!selection.isEmpty()); 048 } 049 }