13a14,15 > import java.util.List; > 14a17 > import CH.ifa.draw.util.CollectionsFactory; 36a40,42 > /** > * @see CH.ifa.draw.util.Command#execute() > */ 40,42c46,69 < getUndoActivity().setAffectedFigures(view().selection()); < copyFigures(getUndoActivity().getAffectedFigures(), < view().selectionCount()); --- > /* 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 */ 46a74,76 > /** > * @see CH.ifa.draw.standard.AbstractCommand#isExecutableWithView() > */ 52a83 > * @return Undoable 58a90 > 59a92 > private List mySelectedFigures; 60a94,97 > /** > * Constructor for UndoActivity. > * @param newCommand > */ 67a105,107 > /** > * @see CH.ifa.draw.util.Undoable#undo() > */ 71,74c111 < < setAffectedFigures(myCommand.insertFigures( < getAffectedFigures(), 0, 0)); < --- > myCommand.insertFigures(getAffectedFiguresReversed(), 0, 0); 77d113 < 80a117,119 > /** > * @see CH.ifa.draw.util.Undoable#redo() > */ 84c123 < myCommand.copyFigures(getAffectedFigures(), getDrawingView().selectionCount()); --- > myCommand.copyFigures(getSelectedFigures(), getSelectedFiguresCount()); 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()); > }