< prev index next >

src/share/classes/javax/swing/undo/UndoManager.java

Print this page
rev 1527 : 6727662: Code improvement and warnings removing from swing packages
Summary: Removed unnecessary castings and other warnings
Reviewed-by: malenkov

*** 164,179 **** * in the process. * * @see AbstractUndoableEdit#die */ public synchronized void discardAllEdits() { ! Enumeration cursor = edits.elements(); ! while (cursor.hasMoreElements()) { ! UndoableEdit e = (UndoableEdit)cursor.nextElement(); e.die(); } ! edits = new Vector(); indexOfNextAdd = 0; // PENDING(rjrjr) when vector grows a removeRange() method // (expected in JDK 1.2), trimEdits() will be nice and // efficient, and this method can call that instead. } --- 164,177 ---- * in the process. * * @see AbstractUndoableEdit#die */ public synchronized void discardAllEdits() { ! for (UndoableEdit e : edits) { e.die(); } ! edits = new Vector<UndoableEdit>(); indexOfNextAdd = 0; // PENDING(rjrjr) when vector grows a removeRange() method // (expected in JDK 1.2), trimEdits() will be nice and // efficient, and this method can call that instead. }
*** 238,248 **** protected void trimEdits(int from, int to) { if (from <= to) { // System.out.println("Trimming " + from + " " + to + " with index " + // indexOfNextAdd); for (int i = to; from <= i; i--) { ! UndoableEdit e = (UndoableEdit)edits.elementAt(i); // System.out.println("JUM: Discarding " + // e.getUndoPresentationName()); e.die(); // PENDING(rjrjr) when Vector supports range deletion (JDK // 1.2) , we can optimize the next line considerably. --- 236,246 ---- protected void trimEdits(int from, int to) { if (from <= to) { // System.out.println("Trimming " + from + " " + to + " with index " + // indexOfNextAdd); for (int i = to; from <= i; i--) { ! UndoableEdit e = edits.elementAt(i); // System.out.println("JUM: Discarding " + // e.getUndoPresentationName()); e.die(); // PENDING(rjrjr) when Vector supports range deletion (JDK // 1.2) , we can optimize the next line considerably.
*** 291,301 **** * @return the next significant edit to be undone */ protected UndoableEdit editToBeUndone() { int i = indexOfNextAdd; while (i > 0) { ! UndoableEdit edit = (UndoableEdit)edits.elementAt(--i); if (edit.isSignificant()) { return edit; } } --- 289,299 ---- * @return the next significant edit to be undone */ protected UndoableEdit editToBeUndone() { int i = indexOfNextAdd; while (i > 0) { ! UndoableEdit edit = edits.elementAt(--i); if (edit.isSignificant()) { return edit; } }
*** 312,322 **** protected UndoableEdit editToBeRedone() { int count = edits.size(); int i = indexOfNextAdd; while (i < count) { ! UndoableEdit edit = (UndoableEdit)edits.elementAt(i++); if (edit.isSignificant()) { return edit; } } --- 310,320 ---- protected UndoableEdit editToBeRedone() { int count = edits.size(); int i = indexOfNextAdd; while (i < count) { ! UndoableEdit edit = edits.elementAt(i++); if (edit.isSignificant()) { return edit; } }
*** 331,341 **** * <code>CannotUndoException</code> */ protected void undoTo(UndoableEdit edit) throws CannotUndoException { boolean done = false; while (!done) { ! UndoableEdit next = (UndoableEdit)edits.elementAt(--indexOfNextAdd); next.undo(); done = next == edit; } } --- 329,339 ---- * <code>CannotUndoException</code> */ protected void undoTo(UndoableEdit edit) throws CannotUndoException { boolean done = false; while (!done) { ! UndoableEdit next = edits.elementAt(--indexOfNextAdd); next.undo(); done = next == edit; } }
*** 347,357 **** * <code>CannotRedoException</code> */ protected void redoTo(UndoableEdit edit) throws CannotRedoException { boolean done = false; while (!done) { ! UndoableEdit next = (UndoableEdit)edits.elementAt(indexOfNextAdd++); next.redo(); done = next == edit; } } --- 345,355 ---- * <code>CannotRedoException</code> */ protected void redoTo(UndoableEdit edit) throws CannotRedoException { boolean done = false; while (!done) { ! UndoableEdit next = edits.elementAt(indexOfNextAdd++); next.redo(); done = next == edit; } }
< prev index next >