Ticket #17196: 17196.patch
File 17196.patch, 2.8 KB (added by , 5 years ago) |
---|
-
src/org/openstreetmap/josm/data/UndoRedoHandler.java
1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.data; 3 3 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 4 6 import java.util.EventObject; 5 7 import java.util.Iterator; 6 8 import java.util.LinkedList; … … 7 9 import java.util.List; 8 10 import java.util.Objects; 9 11 12 import javax.swing.JOptionPane; 13 10 14 import org.openstreetmap.josm.command.Command; 11 15 import org.openstreetmap.josm.data.osm.DataSet; 12 16 import org.openstreetmap.josm.data.osm.OsmDataManager; 17 import org.openstreetmap.josm.gui.Notification; 13 18 import org.openstreetmap.josm.gui.util.GuiHelper; 14 19 import org.openstreetmap.josm.spi.preferences.Config; 15 20 import org.openstreetmap.josm.tools.CheckParameterUtil; … … 348 353 return; 349 354 GuiHelper.runInEDTAndWait(() -> { 350 355 DataSet ds = OsmDataManager.getInstance().getEditDataSet(); 356 351 357 if (ds != null) { 352 358 ds.beginUpdate(); 353 359 } … … 354 360 try { 355 361 for (int i = 1; i <= num; ++i) { 356 362 final Command c = commands.removeLast(); 363 if (c.getAffectedDataSet() != ds) { 364 new Notification(tr("Cannot undo change in inactive data layer.")) 365 .setIcon(JOptionPane.WARNING_MESSAGE).setDuration(Notification.TIME_SHORT).show(); 366 commands.add(c); 367 break; 368 } 357 369 c.undoCommand(); 358 370 redoCommands.addFirst(c); 359 371 fireEvent(new CommandUndoneEvent(this, c)); … … 371 383 } 372 384 373 385 /** 374 * Redoes the last undo edcommand.386 * Redoes the last undone command. 375 387 */ 376 388 public void redo() { 377 389 redo(1); … … 384 396 public synchronized void redo(int num) { 385 397 if (redoCommands.isEmpty()) 386 398 return; 399 DataSet ds = OsmDataManager.getInstance().getEditDataSet(); 400 387 401 for (int i = 0; i < num; ++i) { 388 402 final Command c = redoCommands.removeFirst(); 403 if (c.getAffectedDataSet() != ds) { 404 new Notification(tr("Cannot redo change in inactive data layer.")) 405 .setIcon(JOptionPane.INFORMATION_MESSAGE).setDuration(Notification.TIME_SHORT).show(); 406 redoCommands.addFirst(c); 407 break; 408 } 389 409 c.executeCommand(); 390 410 commands.add(c); 391 411 fireEvent(new CommandRedoneEvent(this, c));