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