13a14,15 > import java.util.List; > 14a17,17 > import CH.ifa.draw.util.CollectionsFactory; 36a40,42 > /** > * @see CH.ifa.draw.util.Command#execute() > */ 39a46,69 > /* ricardo_padilha: bugfix for correct delete/undelete behavior > * When enumerating the affected figures we must not forget the dependent > * figures, since they are deleted as well! > */ > FigureEnumeration fe = view().selection(); > List affected = CollectionsFactory.current().createList(); > Figure f; > FigureEnumeration dfe; > while (fe.hasNextFigure()) { > f = fe.nextFigure(); > affected.add(0, f); > dfe = f.getDependendFigures(); > if (dfe != null) { > while (dfe.hasNextFigure()) { > affected.add(0, dfe.nextFigure()); > } > } > } > fe = new FigureEnumerator(affected); > getUndoActivity().setAffectedFigures(fe); > UndoActivity ua = (UndoActivity) getUndoActivity(); > ua.setSelectedFigures(view().selection()); > copyFigures(ua.getSelectedFigures(), ua.getSelectedFiguresCount()); > /* ricardo_padilha: end of bugfix */ 40,42d45 < getUndoActivity().setAffectedFigures(view().selection()); < copyFigures(getUndoActivity().getAffectedFigures(), < view().selectionCount()); 46a74,76 > /** > * @see CH.ifa.draw.standard.AbstractCommand#isExecutableWithView() > */ 52a83,83 > * @return Undoable 59a92,92 > private List mySelectedFigures; 60a94,97 > /** > * Constructor for UndoActivity. > * @param newCommand > */ 67a105,107 > /** > * @see CH.ifa.draw.util.Undoable#undo() > */ 71,72d110 < < setAffectedFigures(myCommand.insertFigures( 73,73c111,111 < getAffectedFigures(), 0, 0)); --- > myCommand.insertFigures(getAffectedFiguresReversed(), 0, 0); 74,74d111 < 77,77c90,90 < --- > 80a117,119 > /** > * @see CH.ifa.draw.util.Undoable#redo() > */ 83a123,123 > myCommand.copyFigures(getSelectedFigures(), getSelectedFiguresCount()); 84,84d122 < myCommand.copyFigures(getAffectedFigures(), getDrawingView().selectionCount()); 90a130,179 > > /** > * Preserve the selection of figures the moment the command was executed. > * @param newSelectedFigures > */ > public void setSelectedFigures(FigureEnumeration newSelectedFigures) { > // the enumeration is not reusable therefore a copy is made > // to be able to undo-redo the command several time > rememberSelectedFigures(newSelectedFigures); > } > > /** > * Preserve a copy of the enumeration in a private list. > * @param toBeRemembered > */ > protected void rememberSelectedFigures(FigureEnumeration toBeRemembered) { > mySelectedFigures = CollectionsFactory.current().createList(); > while (toBeRemembered.hasNextFigure()) { > mySelectedFigures.add(toBeRemembered.nextFigure()); > } > } > > /** > * Returns the selection of figures to perform the command on. > * @return > */ > public FigureEnumeration getSelectedFigures() { > return new FigureEnumerator( > CollectionsFactory.current().createList(mySelectedFigures)); > } > > /** > * Returns the size of the selection. > * @return > */ > public int getSelectedFiguresCount() { > return mySelectedFigures.size(); > } > > /** > * @see CH.ifa.draw.util.UndoableAdapter#release() > */ > public void release() { > super.release(); > FigureEnumeration fe = getSelectedFigures(); > while (fe.hasNextFigure()) { > fe.nextFigure().release(); > } > setSelectedFigures(FigureEnumerator.getEmptyEnumeration()); > }