2,2c2,2 < * @(#)CutCommand.java 5.2 --- > * @(#)CutCommand.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,8c15,15 < import CH.ifa.draw.util.*; --- > import CH.ifa.draw.util.*; 13a20,20 > * 14a22,23 > * > * @version <$CURRENT_VERSION$> 27a37,42 > setUndoActivity(createUndoActivity()); > getUndoActivity().setAffectedFigures(view().selectionElements()); > copyFigures(getUndoActivity().getAffectedFigures(), > view().selectionCount()); > deleteFigures(getUndoActivity().getAffectedFigures()); > view().checkDamage(); 28,30d36 < copySelection(); < deleteSelection(); < fView.checkDamage(); 33a46,53 > return view().selectionCount() > 0; > } > > /** > * Factory method for undo activity > */ > protected Undoable createUndoActivity() { > return new CutCommand.UndoActivity(this); 34,34d45 < return fView.selectionCount() > 0; 36a56,63 > public static class UndoActivity extends UndoableAdapter { > private FigureTransferCommand myCommand; > > public UndoActivity(FigureTransferCommand newCommand) { > super(newCommand.view()); > myCommand = newCommand; > setUndoable(true); > setRedoable(true); 38a66,71 > public boolean undo() { > if (super.undo() && getAffectedFigures().hasMoreElements()) { > getDrawingView().clearSelection(); > > setAffectedFigures(myCommand.insertFigures( > getAffectedFigures(), 0, 0)); 39a73,90 > return true; > } > > return false; > } > > public boolean redo() { > // do not call execute directly as the selection might has changed > if (isRedoable()) { > myCommand.copyFigures(getAffectedFigures(), getDrawingView().selectionCount()); > myCommand.deleteFigures(getAffectedFigures()); > return true; > } > > return false; > } > } > }