[6380] | 1 | // License: GPL. For details, see LICENSE file.
|
---|
[626] | 2 | package org.openstreetmap.josm.actions;
|
---|
| 3 |
|
---|
[3810] | 4 | import static org.openstreetmap.josm.gui.help.HelpUtil.ht;
|
---|
[626] | 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;
|
---|
[4908] | 11 | import org.openstreetmap.josm.gui.layer.OsmDataLayer;
|
---|
[1084] | 12 | import org.openstreetmap.josm.tools.Shortcut;
|
---|
[626] | 13 |
|
---|
| 14 | /**
|
---|
| 15 | * Redoes the last command.
|
---|
[1023] | 16 | *
|
---|
[626] | 17 | * @author imi
|
---|
| 18 | */
|
---|
[4908] | 19 | public class RedoAction extends JosmAction implements OsmDataLayer.CommandQueueListener {
|
---|
[626] | 20 |
|
---|
[1169] | 21 | /**
|
---|
| 22 | * Construct the action with "Redo" as label.
|
---|
| 23 | */
|
---|
| 24 | public RedoAction() {
|
---|
| 25 | super(tr("Redo"), "redo", tr("Redo the last undone action."),
|
---|
[4982] | 26 | Shortcut.registerShortcut("system:redo", tr("Edit: {0}", tr("Redo")), KeyEvent.VK_Y, Shortcut.CTRL), true);
|
---|
[1169] | 27 | setEnabled(false);
|
---|
[2323] | 28 | putValue("help", ht("/Action/Redo"));
|
---|
[1169] | 29 | }
|
---|
[626] | 30 |
|
---|
[6084] | 31 | @Override
|
---|
[1169] | 32 | public void actionPerformed(ActionEvent e) {
|
---|
| 33 | if (Main.map == null)
|
---|
| 34 | return;
|
---|
| 35 | Main.map.repaint();
|
---|
| 36 | Main.main.undoRedo.redo();
|
---|
| 37 | }
|
---|
[1820] | 38 |
|
---|
| 39 | @Override
|
---|
| 40 | protected void updateEnabledState() {
|
---|
[3810] | 41 | setEnabled(Main.main != null && !Main.main.undoRedo.redoCommands.isEmpty());
|
---|
[1820] | 42 | }
|
---|
[4908] | 43 |
|
---|
| 44 | @Override
|
---|
| 45 | public void commandChanged(int queueSize, int redoSize) {
|
---|
| 46 | if (Main.main.undoRedo.redoCommands.isEmpty()) {
|
---|
| 47 | putValue(NAME, tr("Redo"));
|
---|
| 48 | setTooltip(tr("Redo the last undone action."));
|
---|
| 49 | } else {
|
---|
| 50 | putValue(NAME, tr("Redo ..."));
|
---|
| 51 | setTooltip(tr("Redo {0}",
|
---|
[4918] | 52 | Main.main.undoRedo.redoCommands.getFirst().getDescriptionText()));
|
---|
[4908] | 53 | }
|
---|
| 54 | }
|
---|
[626] | 55 | }
|
---|