| 1 | //License: GPL. Copyright 2007 by Immanuel Scholz and others |
|---|
| 2 | package org.openstreetmap.josm.actions; |
|---|
| 3 | |
|---|
| 4 | import java.awt.event.ActionEvent; |
|---|
| 5 | import static org.openstreetmap.josm.tools.I18n.tr; |
|---|
| 6 | import static org.openstreetmap.josm.gui.help.HelpUtil.ht; |
|---|
| 7 | |
|---|
| 8 | import java.awt.event.KeyEvent; |
|---|
| 9 | |
|---|
| 10 | import java.util.Collection; |
|---|
| 11 | import org.openstreetmap.josm.Main; |
|---|
| 12 | import org.openstreetmap.josm.data.osm.DataSet; |
|---|
| 13 | import org.openstreetmap.josm.data.osm.OsmPrimitive; |
|---|
| 14 | import org.openstreetmap.josm.gui.dialogs.InspectPrimitiveDialog; |
|---|
| 15 | import org.openstreetmap.josm.tools.Shortcut; |
|---|
| 16 | |
|---|
| 17 | public class InfoAction extends JosmAction { |
|---|
| 18 | |
|---|
| 19 | public InfoAction() { |
|---|
| 20 | super(tr("Advanced info"), "about", |
|---|
| 21 | tr("Display advanced object information about OSM nodes, ways, or relations."), |
|---|
| 22 | Shortcut.registerShortcut("core:info", |
|---|
| 23 | tr("Advanced info"), KeyEvent.VK_I, Shortcut.CTRL), |
|---|
| 24 | true, "action/info", true); |
|---|
| 25 | putValue("help", ht("/Action/InfoAboutElements")); |
|---|
| 26 | } |
|---|
| 27 | |
|---|
| 28 | @Override |
|---|
| 29 | public void actionPerformed(ActionEvent ae) { |
|---|
| 30 | DataSet set = getCurrentDataSet(); |
|---|
| 31 | if (set != null) { |
|---|
| 32 | new InspectPrimitiveDialog(set.getSelected(), Main.map.mapView.getEditLayer()).showDialog(); |
|---|
| 33 | } |
|---|
| 34 | } |
|---|
| 35 | |
|---|
| 36 | @Override |
|---|
| 37 | public void updateEnabledState() { |
|---|
| 38 | if (getCurrentDataSet() == null) { |
|---|
| 39 | setEnabled(false); |
|---|
| 40 | } else { |
|---|
| 41 | updateEnabledState(getCurrentDataSet().getSelected()); |
|---|
| 42 | } |
|---|
| 43 | } |
|---|
| 44 | |
|---|
| 45 | @Override |
|---|
| 46 | protected void updateEnabledState(Collection<? extends OsmPrimitive> selection) { |
|---|
| 47 | setEnabled(!selection.isEmpty()); |
|---|
| 48 | } |
|---|
| 49 | } |
|---|