< prev index next >

src/share/classes/javax/swing/undo/UndoableEditSupport.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


  72     /**
  73      * Removes an <code>UndoableEditListener</code>.
  74      *
  75      * @param l  the <code>UndoableEditListener</code> object to be removed
  76      * @see #addUndoableEditListener
  77      */
  78     public synchronized void removeUndoableEditListener(UndoableEditListener l)
  79     {
  80         listeners.removeElement(l);
  81     }
  82 
  83     /**
  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 (UndoableEditListener[])(listeners.toArray(
  93                 new UndoableEditListener[0]));
  94     }
  95 
  96     /**
  97      * Called only from <code>postEdit</code> and <code>endUpdate</code>. Calls
  98      * <code>undoableEditHappened</code> in all listeners. No synchronization
  99      * is performed here, since the two calling methods are synchronized.
 100      */
 101     protected void _postEdit(UndoableEdit e) {
 102         UndoableEditEvent ev = new UndoableEditEvent(realSource, e);
 103         Enumeration cursor = ((Vector)listeners.clone()).elements();
 104         while (cursor.hasMoreElements()) {
 105             ((UndoableEditListener)cursor.nextElement()).
 106                 undoableEditHappened(ev);
 107         }
 108     }
 109 
 110     /**
 111      * DEADLOCK WARNING: Calling this method may call
 112      * <code>undoableEditHappened</code> in all listeners.
 113      * It is unwise to call this method from one of its listeners.




  72     /**
  73      * Removes an <code>UndoableEditListener</code>.
  74      *
  75      * @param l  the <code>UndoableEditListener</code> object to be removed
  76      * @see #addUndoableEditListener
  77      */
  78     public synchronized void removeUndoableEditListener(UndoableEditListener l)
  79     {
  80         listeners.removeElement(l);
  81     }
  82 
  83     /**
  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     protected void _postEdit(UndoableEdit e) {
 101         UndoableEditEvent ev = new UndoableEditEvent(realSource, e);
 102         Enumeration cursor = ((Vector)listeners.clone()).elements();
 103         while (cursor.hasMoreElements()) {
 104             ((UndoableEditListener)cursor.nextElement()).
 105                 undoableEditHappened(ev);
 106         }
 107     }
 108 
 109     /**
 110      * DEADLOCK WARNING: Calling this method may call
 111      * <code>undoableEditHappened</code> in all listeners.
 112      * It is unwise to call this method from one of its listeners.


< prev index next >