1 19 package org.netbeans.spi.java.classpath.support; 20 21 22 import java.beans.PropertyChangeListener ; 23 import java.beans.PropertyChangeEvent ; 24 import java.util.ArrayList ; 25 import java.util.Iterator ; 26 import org.netbeans.spi.java.classpath.PathResourceImplementation; 27 28 32 public abstract class PathResourceBase implements PathResourceImplementation { 33 34 private ArrayList <PropertyChangeListener > pListeners; 35 36 37 42 public synchronized final void addPropertyChangeListener(PropertyChangeListener listener) { 43 if (this.pListeners == null) 44 this.pListeners = new ArrayList <PropertyChangeListener > (); 45 this.pListeners.add (listener); 46 } 47 48 52 public synchronized final void removePropertyChangeListener(PropertyChangeListener listener) { 53 if (this.pListeners == null) 54 return; 55 this.pListeners.remove (listener); 56 } 57 58 64 protected final void firePropertyChange (String propName, Object oldValue, Object newValue) { 65 PropertyChangeListener [] _listeners; 66 synchronized (this) { 67 if (this.pListeners == null) 68 return; 69 _listeners = this.pListeners.toArray(new PropertyChangeListener [this.pListeners.size()]); 70 } 71 PropertyChangeEvent event = new PropertyChangeEvent (this, propName, oldValue, newValue); 72 for (PropertyChangeListener l : _listeners) { 73 l.propertyChange (event); 74 } 75 } 76 } 77 | Popular Tags |