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

Last change on this file since 14140 was 14121, checked in by Don-vip, 6 years ago

see #15229 - deprecate all Main methods related to network features. New NetworkManager class

  • Property svn:eol-style set to native
File size: 2.6 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.OsmData;
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.NetworkManager;
16import org.openstreetmap.josm.io.OnlineResource;
17import org.openstreetmap.josm.tools.Shortcut;
18
19/**
20 * Display history information about OSM ways, nodes, or relations.
21 * @since 968
22 */
23public class HistoryInfoAction extends JosmAction {
24
25 /**
26 * Constructs a new {@code HistoryInfoAction}.
27 */
28 public HistoryInfoAction() {
29 super(tr("History"), "dialogs/history",
30 tr("Display history information about OSM ways, nodes, or relations."),
31 Shortcut.registerShortcut("core:historyinfo",
32 tr("History"), KeyEvent.VK_H, Shortcut.CTRL), false);
33 putValue("help", ht("/Action/ObjectHistory"));
34 putValue("toolbar", "action/historyinfo");
35 MainApplication.getToolbar().register(this);
36 setEnabled(true);
37 }
38
39 @Override
40 public void actionPerformed(ActionEvent ae) {
41 OsmData<?, ?, ?, ?> set = getLayerManager().getActiveData();
42 if (set != null && !set.selectionEmpty()) {
43 HistoryBrowserDialogManager.getInstance().showHistory(set.getAllSelected());
44 } else {
45 HistoryObjectIDDialog dialog = new HistoryObjectIDDialog();
46 if (dialog.showDialog().getValue() == dialog.getContinueButtonIndex()) {
47 HistoryBrowserDialogManager.getInstance().showHistory(dialog.getOsmIds());
48 }
49 }
50 }
51
52 /**
53 * Dialog allowing to choose object id if no one is selected.
54 * @since 6448
55 */
56 public static class HistoryObjectIDDialog extends OsmIdSelectionDialog {
57
58 /**
59 * Constructs a new {@code HistoryObjectIDDialog}.
60 */
61 public HistoryObjectIDDialog() {
62 super(Main.parent, tr("Show history"), tr("Show history"), tr("Cancel"));
63 setButtonIcons("dialogs/history", "cancel");
64 init();
65 }
66
67 @Override
68 public void setupDialog() {
69 super.setupDialog();
70 buttons.get(0).setEnabled(!NetworkManager.isOffline(OnlineResource.OSM_API));
71 }
72 }
73}
Note: See TracBrowser for help on using the repository browser.