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