diff --git a/src/org/openstreetmap/josm/Main.java b/src/org/openstreetmap/josm/Main.java
index dce2e5a..df82f56 100644
|
a
|
b
|
abstract public class Main {
|
| 266 | 266 | panel.add(gettingStarted, BorderLayout.CENTER); |
| 267 | 267 | menu = new MainMenu(); |
| 268 | 268 | |
| 269 | | undoRedo.listenerCommands.add(redoUndoListener); |
| | 269 | undoRedo.addCommandQueueListener(redoUndoListener); |
| 270 | 270 | |
| 271 | 271 | // creating toolbar |
| 272 | 272 | contentPanePrivate.add(toolbar.control, BorderLayout.NORTH); |
diff --git a/src/org/openstreetmap/josm/actions/RedoAction.java b/src/org/openstreetmap/josm/actions/RedoAction.java
index 25a734d..dd90fe2 100644
|
a
|
b
|
import java.awt.event.ActionEvent;
|
| 8 | 8 | import java.awt.event.KeyEvent; |
| 9 | 9 | |
| 10 | 10 | import org.openstreetmap.josm.Main; |
| | 11 | import org.openstreetmap.josm.gui.layer.OsmDataLayer; |
| 11 | 12 | import org.openstreetmap.josm.tools.Shortcut; |
| 12 | 13 | |
| 13 | 14 | /** |
| … |
… |
import org.openstreetmap.josm.tools.Shortcut;
|
| 15 | 16 | * |
| 16 | 17 | * @author imi |
| 17 | 18 | */ |
| 18 | | public class RedoAction extends JosmAction { |
| | 19 | public class RedoAction extends JosmAction implements OsmDataLayer.CommandQueueListener { |
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * Construct the action with "Redo" as label. |
| … |
… |
public class RedoAction extends JosmAction {
|
| 38 | 39 | protected void updateEnabledState() { |
| 39 | 40 | setEnabled(Main.main != null && !Main.main.undoRedo.redoCommands.isEmpty()); |
| 40 | 41 | } |
| | 42 | |
| | 43 | @Override |
| | 44 | public void commandChanged(int queueSize, int redoSize) { |
| | 45 | if (Main.main.undoRedo.redoCommands.isEmpty()) { |
| | 46 | putValue(NAME, tr("Redo")); |
| | 47 | } else { |
| | 48 | putValue(NAME, tr("Redo {0}", Main.main.undoRedo.redoCommands.getFirst().getDescrpitionText())); |
| | 49 | } |
| | 50 | } |
| 41 | 51 | } |
diff --git a/src/org/openstreetmap/josm/actions/UndoAction.java b/src/org/openstreetmap/josm/actions/UndoAction.java
index 1c70de2..82a3b7c 100644
|
a
|
b
|
import java.awt.event.ActionEvent;
|
| 8 | 8 | import java.awt.event.KeyEvent; |
| 9 | 9 | |
| 10 | 10 | import org.openstreetmap.josm.Main; |
| | 11 | import org.openstreetmap.josm.gui.layer.OsmDataLayer; |
| 11 | 12 | import org.openstreetmap.josm.tools.Shortcut; |
| 12 | 13 | |
| 13 | 14 | /** |
| … |
… |
import org.openstreetmap.josm.tools.Shortcut;
|
| 15 | 16 | * |
| 16 | 17 | * @author imi |
| 17 | 18 | */ |
| 18 | | public class UndoAction extends JosmAction { |
| | 19 | public class UndoAction extends JosmAction implements OsmDataLayer.CommandQueueListener { |
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * Construct the action with "Undo" as label. |
| … |
… |
public class UndoAction extends JosmAction {
|
| 39 | 40 | setEnabled(Main.main != null && !Main.main.undoRedo.commands.isEmpty()); |
| 40 | 41 | } |
| 41 | 42 | |
| | 43 | @Override |
| | 44 | public void commandChanged(int queueSize, int redoSize) { |
| | 45 | if (Main.main.undoRedo.commands.isEmpty()) { |
| | 46 | putValue(NAME, tr("Undo")); |
| | 47 | } else { |
| | 48 | putValue(NAME, tr("Undo {0}", Main.main.undoRedo.commands.getFirst().getDescrpitionText())); |
| | 49 | } |
| | 50 | } |
| 42 | 51 | } |
diff --git a/src/org/openstreetmap/josm/command/Command.java b/src/org/openstreetmap/josm/command/Command.java
index 083623f..4f2d521 100644
|
a
|
b
|
abstract public class Command extends PseudoCommand {
|
| 170 | 170 | return ((DefaultMutableTreeNode) description()).getUserObject(); |
| 171 | 171 | } |
| 172 | 172 | |
| | 173 | public String getDescrpitionText() { |
| | 174 | Object o = getDescription(); |
| | 175 | if (o instanceof JLabel) { |
| | 176 | return ((JLabel) o).getText(); |
| | 177 | } else { |
| | 178 | return o.toString(); |
| | 179 | } |
| | 180 | } |
| | 181 | |
| 173 | 182 | /** |
| 174 | 183 | * @deprecated use getDescription() and getChildren() instead |
| 175 | 184 | */ |
diff --git a/src/org/openstreetmap/josm/data/UndoRedoHandler.java b/src/org/openstreetmap/josm/data/UndoRedoHandler.java
index 85ad126..b948b40 100644
|
a
|
b
|
public class UndoRedoHandler implements MapView.LayerChangeListener {
|
| 23 | 23 | */ |
| 24 | 24 | public final LinkedList<Command> redoCommands = new LinkedList<Command>(); |
| 25 | 25 | |
| 26 | | public final LinkedList<CommandQueueListener> listenerCommands = new LinkedList<CommandQueueListener>(); |
| | 26 | private final LinkedList<CommandQueueListener> listenerCommands = new LinkedList<CommandQueueListener>(); |
| 27 | 27 | |
| 28 | 28 | public UndoRedoHandler() { |
| 29 | 29 | MapView.addLayerChangeListener(this); |
| … |
… |
public class UndoRedoHandler implements MapView.LayerChangeListener {
|
| 162 | 162 | |
| 163 | 163 | public void layerAdded(Layer newLayer) {} |
| 164 | 164 | public void activeLayerChange(Layer oldLayer, Layer newLayer) {} |
| | 165 | |
| | 166 | public void removeCommandQueueListener(CommandQueueListener l) { |
| | 167 | listenerCommands.remove(l); |
| | 168 | } |
| | 169 | |
| | 170 | public boolean addCommandQueueListener(CommandQueueListener l) { |
| | 171 | return listenerCommands.add(l); |
| | 172 | } |
| 165 | 173 | } |
diff --git a/src/org/openstreetmap/josm/gui/MainMenu.java b/src/org/openstreetmap/josm/gui/MainMenu.java
index ecbec2f..e8cfe74 100644
|
a
|
b
|
public class MainMenu extends JMenuBar {
|
| 400 | 400 | add(fileMenu, exit); |
| 401 | 401 | |
| 402 | 402 | add(editMenu, undo); |
| | 403 | Main.main.undoRedo.addCommandQueueListener(undo); |
| 403 | 404 | add(editMenu, redo); |
| | 405 | Main.main.undoRedo.addCommandQueueListener(redo); |
| 404 | 406 | editMenu.addSeparator(); |
| 405 | 407 | add(editMenu, copy); |
| 406 | 408 | add(editMenu, copyCoordinates, true); |
diff --git a/src/org/openstreetmap/josm/gui/dialogs/CommandStackDialog.java b/src/org/openstreetmap/josm/gui/dialogs/CommandStackDialog.java
index a153cfc..5cfbd1f 100644
|
a
|
b
|
public class CommandStackDialog extends ToggleDialog implements CommandQueueList
|
| 202 | 202 | for (IEnabledStateUpdating listener : showNotifyListener) { |
| 203 | 203 | listener.updateEnabledState(); |
| 204 | 204 | } |
| 205 | | Main.main.undoRedo.listenerCommands.add(this); |
| | 205 | Main.main.undoRedo.addCommandQueueListener(this); |
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | /** |
| … |
… |
public class CommandStackDialog extends ToggleDialog implements CommandQueueList
|
| 218 | 218 | public void hideNotify() { |
| 219 | 219 | undoTreeModel.setRoot(new DefaultMutableTreeNode()); |
| 220 | 220 | redoTreeModel.setRoot(new DefaultMutableTreeNode()); |
| 221 | | Main.main.undoRedo.listenerCommands.remove(this); |
| | 221 | Main.main.undoRedo.removeCommandQueueListener(this); |
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | /** |