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

Print this page




  84      * Returns an array of all the <code>UndoableEditListener</code>s added
  85      * to this UndoableEditSupport with addUndoableEditListener().
  86      *
  87      * @return all of the <code>UndoableEditListener</code>s added or an empty
  88      *         array if no listeners have been added
  89      * @since 1.4
  90      */
  91     public synchronized UndoableEditListener[] getUndoableEditListeners() {
  92         return listeners.toArray(new UndoableEditListener[0]);
  93     }
  94 
  95     /**
  96      * Called only from <code>postEdit</code> and <code>endUpdate</code>. Calls
  97      * <code>undoableEditHappened</code> in all listeners. No synchronization
  98      * is performed here, since the two calling methods are synchronized.
  99      *
 100      * @param e edit to be verified
 101      */
 102     protected void _postEdit(UndoableEdit e) {
 103         UndoableEditEvent ev = new UndoableEditEvent(realSource, e);
 104         Enumeration cursor = ((Vector)listeners.clone()).elements();


 105         while (cursor.hasMoreElements()) {
 106             ((UndoableEditListener)cursor.nextElement()).
 107                 undoableEditHappened(ev);
 108         }
 109     }
 110 
 111     /**
 112      * DEADLOCK WARNING: Calling this method may call
 113      * <code>undoableEditHappened</code> in all listeners.
 114      * It is unwise to call this method from one of its listeners.
 115      *
 116      * @param e edit to be posted
 117      */
 118     public synchronized void postEdit(UndoableEdit e) {
 119         if (updateLevel == 0) {
 120             _postEdit(e);
 121         } else {
 122             // PENDING(rjrjr) Throw an exception if this fails?
 123             compoundEdit.addEdit(e);
 124         }
 125     }
 126 
 127     /**




  84      * Returns an array of all the <code>UndoableEditListener</code>s added
  85      * to this UndoableEditSupport with addUndoableEditListener().
  86      *
  87      * @return all of the <code>UndoableEditListener</code>s added or an empty
  88      *         array if no listeners have been added
  89      * @since 1.4
  90      */
  91     public synchronized UndoableEditListener[] getUndoableEditListeners() {
  92         return listeners.toArray(new UndoableEditListener[0]);
  93     }
  94 
  95     /**
  96      * Called only from <code>postEdit</code> and <code>endUpdate</code>. Calls
  97      * <code>undoableEditHappened</code> in all listeners. No synchronization
  98      * is performed here, since the two calling methods are synchronized.
  99      *
 100      * @param e edit to be verified
 101      */
 102     protected void _postEdit(UndoableEdit e) {
 103         UndoableEditEvent ev = new UndoableEditEvent(realSource, e);
 104         @SuppressWarnings("unchecked")
 105         Enumeration<UndoableEditListener> cursor =
 106             ((Vector<UndoableEditListener>)listeners.clone()).elements();
 107         while (cursor.hasMoreElements()) {
 108             cursor.nextElement().undoableEditHappened(ev);

 109         }
 110     }
 111 
 112     /**
 113      * DEADLOCK WARNING: Calling this method may call
 114      * <code>undoableEditHappened</code> in all listeners.
 115      * It is unwise to call this method from one of its listeners.
 116      *
 117      * @param e edit to be posted
 118      */
 119     public synchronized void postEdit(UndoableEdit e) {
 120         if (updateLevel == 0) {
 121             _postEdit(e);
 122         } else {
 123             // PENDING(rjrjr) Throw an exception if this fails?
 124             compoundEdit.addEdit(e);
 125         }
 126     }
 127 
 128     /**