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