Changeset 304 in josm for src/org/openstreetmap/josm/data
- Timestamp:
- 2007-08-10T21:12:53+02:00 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/org/openstreetmap/josm/data/UndoRedoHandler.java
r301 r304 1 // 1 //License: GPL. Copyright 2007 by Immanuel Scholz and others 2 2 package org.openstreetmap.josm.data; 3 3 4 import java.util.Iterator; 4 5 import java.util.LinkedList; 5 6 import java.util.Stack; … … 7 8 import org.openstreetmap.josm.Main; 8 9 import org.openstreetmap.josm.command.Command; 10 import org.openstreetmap.josm.gui.layer.Layer; 9 11 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 12 import org.openstreetmap.josm.gui.layer.Layer.LayerChangeListener; 10 13 import org.openstreetmap.josm.gui.layer.OsmDataLayer.CommandQueueListener; 11 14 12 public class UndoRedoHandler { 15 public class UndoRedoHandler implements LayerChangeListener { 13 16 14 17 /** … … 22 25 23 26 public final LinkedList<CommandQueueListener> listenerCommands = new LinkedList<CommandQueueListener>(); 27 28 29 public UndoRedoHandler() { 30 Layer.listeners.add(this); 31 } 24 32 25 33 … … 37 45 fireCommandsChanged(); 38 46 } 39 47 40 48 /** 41 49 * Undoes the last added command. … … 81 89 commands.clear(); 82 90 fireCommandsChanged(); 83 } 91 } 92 93 public void layerRemoved(Layer oldLayer) { 94 boolean changed = false; 95 for (Iterator<Command> it = commands.iterator(); it.hasNext();) { 96 if (it.next().invalidBecauselayerRemoved(oldLayer)) { 97 it.remove(); 98 changed = true; 99 } 100 } 101 for (Iterator<Command> it = redoCommands.iterator(); it.hasNext();) { 102 if (it.next().invalidBecauselayerRemoved(oldLayer)) { 103 it.remove(); 104 changed = true; 105 } 106 } 107 if (changed) 108 fireCommandsChanged(); 109 } 110 111 public void layerAdded(Layer newLayer) {} 112 public void activeLayerChange(Layer oldLayer, Layer newLayer) {} 84 113 }
Note:
See TracChangeset
for help on using the changeset viewer.