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