source: josm/trunk/src/org/openstreetmap/josm/actions/RedoAction.java@ 13329

Last change on this file since 13329 was 12718, checked in by Don-vip, 7 years ago

see #13036 - see #15229 - see #15182 - make Commands depends only on a DataSet, not a Layer. This removes a lot of GUI dependencies

  • Property svn:eol-style set to native
File size: 1.8 KB
RevLine 
[6380]1// License: GPL. For details, see LICENSE file.
[626]2package org.openstreetmap.josm.actions;
3
[3810]4import static org.openstreetmap.josm.gui.help.HelpUtil.ht;
[626]5import static org.openstreetmap.josm.tools.I18n.tr;
6
7import java.awt.event.ActionEvent;
8import java.awt.event.KeyEvent;
9
10import org.openstreetmap.josm.Main;
[12718]11import org.openstreetmap.josm.data.UndoRedoHandler.CommandQueueListener;
[12630]12import org.openstreetmap.josm.gui.MainApplication;
13import org.openstreetmap.josm.gui.MapFrame;
[1084]14import org.openstreetmap.josm.tools.Shortcut;
[626]15
16/**
17 * Redoes the last command.
[1023]18 *
[626]19 * @author imi
20 */
[12718]21public class RedoAction extends JosmAction implements CommandQueueListener {
[626]22
[1169]23 /**
24 * Construct the action with "Redo" as label.
25 */
26 public RedoAction() {
27 super(tr("Redo"), "redo", tr("Redo the last undone action."),
[4982]28 Shortcut.registerShortcut("system:redo", tr("Edit: {0}", tr("Redo")), KeyEvent.VK_Y, Shortcut.CTRL), true);
[1169]29 setEnabled(false);
[2323]30 putValue("help", ht("/Action/Redo"));
[1169]31 }
[626]32
[6084]33 @Override
[1169]34 public void actionPerformed(ActionEvent e) {
[12630]35 MapFrame map = MainApplication.getMap();
36 if (map == null)
[1169]37 return;
[12630]38 map.repaint();
[12641]39 MainApplication.undoRedo.redo();
[1169]40 }
[1820]41
42 @Override
43 protected void updateEnabledState() {
[12641]44 setEnabled(Main.main != null && !MainApplication.undoRedo.redoCommands.isEmpty());
[1820]45 }
[4908]46
47 @Override
48 public void commandChanged(int queueSize, int redoSize) {
[12641]49 if (MainApplication.undoRedo.redoCommands.isEmpty()) {
[4908]50 putValue(NAME, tr("Redo"));
51 setTooltip(tr("Redo the last undone action."));
52 } else {
53 putValue(NAME, tr("Redo ..."));
54 setTooltip(tr("Redo {0}",
[12641]55 MainApplication.undoRedo.redoCommands.getFirst().getDescriptionText()));
[4908]56 }
57 }
[626]58}
Note: See TracBrowser for help on using the repository browser.