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

Print this page




  55      * Sends <code>undo</code> to all contained
  56      * <code>UndoableEdits</code> in the reverse of
  57      * the order in which they were added.
  58      */
  59     public void undo() throws CannotUndoException {
  60         super.undo();
  61         int i = edits.size();
  62         while (i-- > 0) {
  63             UndoableEdit e = edits.elementAt(i);
  64             e.undo();
  65         }
  66     }
  67 
  68     /**
  69      * Sends <code>redo</code> to all contained
  70      * <code>UndoableEdit</code>s in the order in
  71      * which they were added.
  72      */
  73     public void redo() throws CannotRedoException {
  74         super.redo();
  75         Enumeration cursor = edits.elements();
  76         while (cursor.hasMoreElements()) {
  77             ((UndoableEdit)cursor.nextElement()).redo();
  78         }
  79     }
  80 
  81     /**
  82      * Returns the last <code>UndoableEdit</code> in
  83      * <code>edits</code>, or <code>null</code>
  84      * if <code>edits</code> is empty.
  85      *
  86      * @return the last {@code UndoableEdit} in {@code edits},
  87      *         or {@code null} if {@code edits} is empty.
  88      */
  89     protected UndoableEdit lastEdit() {
  90         int count = edits.size();
  91         if (count > 0)
  92             return edits.elementAt(count-1);
  93         else
  94             return null;
  95     }
  96 
  97     /**


 181     }
 182 
 183     /**
 184      * Returns true if this edit is in progress--that is, it has not
 185      * received end. This generally means that edits are still being
 186      * added to it.
 187      *
 188      * @return  whether this edit is in progress
 189      * @see     #end
 190      */
 191     public boolean isInProgress() {
 192         return inProgress;
 193     }
 194 
 195     /**
 196      * Returns true if any of the <code>UndoableEdit</code>s
 197      * in <code>edits</code> do.
 198      * Returns false if they all return false.
 199      */
 200     public boolean  isSignificant() {
 201         Enumeration cursor = edits.elements();
 202         while (cursor.hasMoreElements()) {
 203             if (((UndoableEdit)cursor.nextElement()).isSignificant()) {
 204                 return true;
 205             }
 206         }
 207         return false;
 208     }
 209 
 210     /**
 211      * Returns <code>getPresentationName</code> from the
 212      * last <code>UndoableEdit</code> added to
 213      * <code>edits</code>. If <code>edits</code> is empty,
 214      * calls super.
 215      */
 216     public String getPresentationName() {
 217         UndoableEdit last = lastEdit();
 218         if (last != null) {
 219             return last.getPresentationName();
 220         } else {
 221             return super.getPresentationName();
 222         }
 223     }




  55      * Sends <code>undo</code> to all contained
  56      * <code>UndoableEdits</code> in the reverse of
  57      * the order in which they were added.
  58      */
  59     public void undo() throws CannotUndoException {
  60         super.undo();
  61         int i = edits.size();
  62         while (i-- > 0) {
  63             UndoableEdit e = edits.elementAt(i);
  64             e.undo();
  65         }
  66     }
  67 
  68     /**
  69      * Sends <code>redo</code> to all contained
  70      * <code>UndoableEdit</code>s in the order in
  71      * which they were added.
  72      */
  73     public void redo() throws CannotRedoException {
  74         super.redo();
  75         Enumeration<UndoableEdit> cursor = edits.elements();
  76         while (cursor.hasMoreElements()) {
  77             cursor.nextElement().redo();
  78         }
  79     }
  80 
  81     /**
  82      * Returns the last <code>UndoableEdit</code> in
  83      * <code>edits</code>, or <code>null</code>
  84      * if <code>edits</code> is empty.
  85      *
  86      * @return the last {@code UndoableEdit} in {@code edits},
  87      *         or {@code null} if {@code edits} is empty.
  88      */
  89     protected UndoableEdit lastEdit() {
  90         int count = edits.size();
  91         if (count > 0)
  92             return edits.elementAt(count-1);
  93         else
  94             return null;
  95     }
  96 
  97     /**


 181     }
 182 
 183     /**
 184      * Returns true if this edit is in progress--that is, it has not
 185      * received end. This generally means that edits are still being
 186      * added to it.
 187      *
 188      * @return  whether this edit is in progress
 189      * @see     #end
 190      */
 191     public boolean isInProgress() {
 192         return inProgress;
 193     }
 194 
 195     /**
 196      * Returns true if any of the <code>UndoableEdit</code>s
 197      * in <code>edits</code> do.
 198      * Returns false if they all return false.
 199      */
 200     public boolean  isSignificant() {
 201         Enumeration<UndoableEdit> cursor = edits.elements();
 202         while (cursor.hasMoreElements()) {
 203             if (cursor.nextElement().isSignificant()) {
 204                 return true;
 205             }
 206         }
 207         return false;
 208     }
 209 
 210     /**
 211      * Returns <code>getPresentationName</code> from the
 212      * last <code>UndoableEdit</code> added to
 213      * <code>edits</code>. If <code>edits</code> is empty,
 214      * calls super.
 215      */
 216     public String getPresentationName() {
 217         UndoableEdit last = lastEdit();
 218         if (last != null) {
 219             return last.getPresentationName();
 220         } else {
 221             return super.getPresentationName();
 222         }
 223     }