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

Last change on this file since 9917 was 6380, checked in by Don-vip, 10 years ago

update license/copyright information

  • Property svn:eol-style set to native
File size: 1.6 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.actions;
3
4import static org.openstreetmap.josm.gui.help.HelpUtil.ht;
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;
11import org.openstreetmap.josm.gui.layer.OsmDataLayer;
12import org.openstreetmap.josm.tools.Shortcut;
13
14/**
15 * Redoes the last command.
16 *
17 * @author imi
18 */
19public class RedoAction extends JosmAction implements OsmDataLayer.CommandQueueListener {
20
21 /**
22 * Construct the action with "Redo" as label.
23 */
24 public RedoAction() {
25 super(tr("Redo"), "redo", tr("Redo the last undone action."),
26 Shortcut.registerShortcut("system:redo", tr("Edit: {0}", tr("Redo")), KeyEvent.VK_Y, Shortcut.CTRL), true);
27 setEnabled(false);
28 putValue("help", ht("/Action/Redo"));
29 }
30
31 @Override
32 public void actionPerformed(ActionEvent e) {
33 if (Main.map == null)
34 return;
35 Main.map.repaint();
36 Main.main.undoRedo.redo();
37 }
38
39 @Override
40 protected void updateEnabledState() {
41 setEnabled(Main.main != null && !Main.main.undoRedo.redoCommands.isEmpty());
42 }
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}",
52 Main.main.undoRedo.redoCommands.getFirst().getDescriptionText()));
53 }
54 }
55}
Note: See TracBrowser for help on using the repository browser.