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

Last change on this file since 4918 was 4918, checked in by simon04, 12 years ago

fix #7370 - Refactor Command.getDescription

  • Property svn:eol-style set to native
File size: 1.7 KB
RevLine 
[298]1// License: GPL. Copyright 2007 by Immanuel Scholz and others
[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;
[4908]11import org.openstreetmap.josm.gui.layer.OsmDataLayer;
[1084]12import org.openstreetmap.josm.tools.Shortcut;
[626]13
14/**
15 * Redoes the last command.
[1023]16 *
[626]17 * @author imi
18 */
[4908]19public 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."),
[1820]26 Shortcut.registerShortcut("system:redo", tr("Edit: {0}", tr("Redo")), KeyEvent.VK_Y, Shortcut.GROUP_MENU), true);
[1169]27 setEnabled(false);
[2323]28 putValue("help", ht("/Action/Redo"));
[1169]29 }
[626]30
[1169]31 public void actionPerformed(ActionEvent e) {
32 if (Main.map == null)
33 return;
34 Main.map.repaint();
35 Main.main.undoRedo.redo();
36 }
[1820]37
38 @Override
39 protected void updateEnabledState() {
[3810]40 setEnabled(Main.main != null && !Main.main.undoRedo.redoCommands.isEmpty());
[1820]41 }
[4908]42
43 @Override
44 public void commandChanged(int queueSize, int redoSize) {
45 if (Main.main.undoRedo.redoCommands.isEmpty()) {
46 putValue(NAME, tr("Redo"));
47 setTooltip(tr("Redo the last undone action."));
48 } else {
49 putValue(NAME, tr("Redo ..."));
50 setTooltip(tr("Redo {0}",
[4918]51 Main.main.undoRedo.redoCommands.getFirst().getDescriptionText()));
[4908]52 }
53 }
[626]54}
Note: See TracBrowser for help on using the repository browser.