2,2c2,2 < * @(#)DeleteCommand.java 5.2 --- > * @(#)DeleteCommand.java 3a4,9 > * Project: JHotdraw - a GUI framework for technical drawings > * http://www.jhotdraw.org > * http://jhotdraw.sourceforge.net > * Copyright: © by the original author(s) and all contributors > * License: Lesser GNU Public License (LGPL) > * http://www.opensource.org/licenses/lgpl-license.html 8,8d14 < import java.util.*; 9,9c15,15 < import CH.ifa.draw.util.Command; --- > import CH.ifa.draw.util.*; 13a19,20 > * > * @version <$CURRENT_VERSION$> 26a34,37 > setUndoActivity(createUndoActivity()); > getUndoActivity().setAffectedFigures(view().selectionElements()); > deleteFigures(getUndoActivity().getAffectedFigures()); > view().checkDamage(); 27,28d33 < deleteSelection(); < fView.checkDamage(); 31a41,58 > return view().selectionCount() > 0; > } > > /** > * Factory method for undo activity > */ > protected Undoable createUndoActivity() { > return new DeleteCommand.UndoActivity(this); > } > > public static class UndoActivity extends UndoableAdapter { > private FigureTransferCommand myCommand; > > public UndoActivity(FigureTransferCommand newCommand) { > super(newCommand.view()); > myCommand = newCommand; > setUndoable(true); > setRedoable(true); 32,32d40 < return fView.selectionCount() > 0; 34a61,69 > public boolean undo() { > if (super.undo() && getAffectedFigures().hasMoreElements()) { > getDrawingView().clearSelection(); > setAffectedFigures(myCommand.insertFigures(getAffectedFigures(), 0, 0)); > > return true; > } > > return false; 36a72,79 > public boolean redo() { > // do not call execute directly as the selection might has changed > if (isRedoable()) { > myCommand.deleteFigures(getAffectedFigures()); > getDrawingView().clearSelection(); > > return true; > } 37a81,84 > return false; > } > } > }