source: josm/trunk/src/org/openstreetmap/josm/actions/HistoryInfoAction.java@ 12772

Last change on this file since 12772 was 12637, checked in by Don-vip, 7 years ago

see #15182 - deprecate Main.toolbar. Replacement: gui.MainApplication.getToolbar()

  • Property svn:eol-style set to native
File size: 2.5 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.actions;
3
4import static org.openstreetmap.josm.gui.help.HelpUtil.ht;
5import static org.openstreetmap.josm.tools.I18n.tr;
6
7import java.awt.event.ActionEvent;
8import java.awt.event.KeyEvent;
9
10import org.openstreetmap.josm.Main;
11import org.openstreetmap.josm.data.osm.DataSet;
12import org.openstreetmap.josm.gui.MainApplication;
13import org.openstreetmap.josm.gui.dialogs.OsmIdSelectionDialog;
14import org.openstreetmap.josm.gui.history.HistoryBrowserDialogManager;
15import org.openstreetmap.josm.io.OnlineResource;
16import org.openstreetmap.josm.tools.Shortcut;
17
18/**
19 * Display history information about OSM ways, nodes, or relations.
20 * @since 968
21 */
22public class HistoryInfoAction extends JosmAction {
23
24 /**
25 * Constructs a new {@code HistoryInfoAction}.
26 */
27 public HistoryInfoAction() {
28 super(tr("History"), "dialogs/history",
29 tr("Display history information about OSM ways, nodes, or relations."),
30 Shortcut.registerShortcut("core:historyinfo",
31 tr("History"), KeyEvent.VK_H, Shortcut.CTRL), false);
32 putValue("help", ht("/Action/ObjectHistory"));
33 putValue("toolbar", "action/historyinfo");
34 MainApplication.getToolbar().register(this);
35 setEnabled(true);
36 }
37
38 @Override
39 public void actionPerformed(ActionEvent ae) {
40 DataSet set = getLayerManager().getEditDataSet();
41 if (set != null && !set.selectionEmpty()) {
42 HistoryBrowserDialogManager.getInstance().showHistory(set.getAllSelected());
43 } else {
44 HistoryObjectIDDialog dialog = new HistoryObjectIDDialog();
45 if (dialog.showDialog().getValue() == dialog.getContinueButtonIndex()) {
46 HistoryBrowserDialogManager.getInstance().showHistory(dialog.getOsmIds());
47 }
48 }
49 }
50
51 /**
52 * Dialog allowing to choose object id if no one is selected.
53 * @since 6448
54 */
55 public static class HistoryObjectIDDialog extends OsmIdSelectionDialog {
56
57 /**
58 * Constructs a new {@code HistoryObjectIDDialog}.
59 */
60 public HistoryObjectIDDialog() {
61 super(Main.parent, tr("Show history"), tr("Show history"), tr("Cancel"));
62 setButtonIcons("dialogs/history", "cancel");
63 init();
64 }
65
66 @Override
67 public void setupDialog() {
68 super.setupDialog();
69 buttons.get(0).setEnabled(!Main.isOffline(OnlineResource.OSM_API));
70 }
71 }
72}
Note: See TracBrowser for help on using the repository browser.