Changeset 4908 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2012-02-08T22:31:29+01:00 (13 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/Main.java
r4901 r4908 268 268 menu = new MainMenu(); 269 269 270 undoRedo. listenerCommands.add(redoUndoListener);270 undoRedo.addCommandQueueListener(redoUndoListener); 271 271 272 272 // creating toolbar -
trunk/src/org/openstreetmap/josm/actions/JosmAction.java
r4733 r4908 74 74 Main.registerActionShortcut(this, sc); 75 75 } 76 putValue(SHORT_DESCRIPTION, Main.platform.makeTooltip(tooltip, sc));76 setTooltip(tooltip); 77 77 if (getValue("toolbar") == null) { 78 78 putValue("toolbar", toolbarId == null ? iconName : toolbarId); … … 119 119 } 120 120 putValue("help", helpId); 121 } 122 123 public void setTooltip(String tooltip) { 124 putValue(SHORT_DESCRIPTION, Main.platform.makeTooltip(tooltip, sc)); 121 125 } 122 126 -
trunk/src/org/openstreetmap/josm/actions/RedoAction.java
r3810 r4908 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 … … 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 /** … … 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 setTooltip(tr("Redo the last undone action.")); 48 } else { 49 putValue(NAME, tr("Redo ...")); 50 setTooltip(tr("Redo {0}", 51 Main.main.undoRedo.redoCommands.getFirst().getDescrpitionText())); 52 } 53 } 41 54 } -
trunk/src/org/openstreetmap/josm/actions/UndoAction.java
r3810 r4908 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 … … 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 /** … … 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 setTooltip(tr("Undo the last action.")); 48 } else { 49 putValue(NAME, tr("Undo ...")); 50 setTooltip(tr("Undo {0}", 51 Main.main.undoRedo.commands.getFirst().getDescrpitionText())); 52 } 53 } 42 54 } -
trunk/src/org/openstreetmap/josm/command/Command.java
r4894 r4908 160 160 @Override public Collection<? extends OsmPrimitive> getParticipatingPrimitives() { 161 161 return cloneMap.keySet(); 162 } 163 164 public String getDescrpitionText() { 165 Object o = getDescription(); 166 if (o instanceof JLabel) { 167 return ((JLabel) o).getText(); 168 } else { 169 return o.toString(); 170 } 162 171 } 163 172 -
trunk/src/org/openstreetmap/josm/data/UndoRedoHandler.java
r3910 r4908 24 24 public final LinkedList<Command> redoCommands = new LinkedList<Command>(); 25 25 26 p ublicfinal LinkedList<CommandQueueListener> listenerCommands = new LinkedList<CommandQueueListener>();26 private final LinkedList<CommandQueueListener> listenerCommands = new LinkedList<CommandQueueListener>(); 27 27 28 28 public UndoRedoHandler() { … … 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 } -
trunk/src/org/openstreetmap/josm/gui/MainMenu.java
r4843 r4908 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); -
trunk/src/org/openstreetmap/josm/gui/dialogs/CommandStackDialog.java
r4395 r4908 203 203 listener.updateEnabledState(); 204 204 } 205 Main.main.undoRedo. listenerCommands.add(this);205 Main.main.undoRedo.addCommandQueueListener(this); 206 206 } 207 207 … … 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
Note:
See TracChangeset
for help on using the changeset viewer.