Methods Summary |
---|
public synchronized void | addVetoableChangeListener(java.beans.VetoableChangeListener listener)Add a VetoableListener to the listener list.
The listener is registered for all properties.
The same listener object may be added more than once, and will be called
as many times as it is added.
If listener is null, no exception is thrown and no action
is taken.
if (listener == null) {
return;
}
if (listener instanceof VetoableChangeListenerProxy) {
VetoableChangeListenerProxy proxy =
(VetoableChangeListenerProxy)listener;
// Call two argument add method.
addVetoableChangeListener(proxy.getPropertyName(),
(VetoableChangeListener)proxy.getListener());
} else {
if (listeners == null) {
listeners = new java.util.Vector();
}
}
listeners.addElement(listener);
|
public synchronized void | addVetoableChangeListener(java.lang.String propertyName, java.beans.VetoableChangeListener listener)Add a VetoableChangeListener for a specific property. The listener
will be invoked only when a call on fireVetoableChange names that
specific property.
The same listener object may be added more than once. For each
property, the listener will be invoked the number of times it was added
for that property.
If propertyName or listener is null, no
exception is thrown and no action is taken.
if (listener == null || propertyName == null) {
return;
}
if (children == null) {
children = new java.util.Hashtable();
}
VetoableChangeSupport child = (VetoableChangeSupport)children.get(propertyName);
if (child == null) {
child = new VetoableChangeSupport(source);
children.put(propertyName, child);
}
child.addVetoableChangeListener(listener);
|
public void | fireVetoableChange(java.lang.String propertyName, boolean oldValue, boolean newValue)Report a boolean vetoable property update to any registered listeners.
No event is fired if old and new are equal and non-null.
This is merely a convenience wrapper around the more general
fireVetoableChange method that takes Object values.
if (oldValue == newValue) {
return;
}
fireVetoableChange(propertyName, Boolean.valueOf(oldValue), Boolean.valueOf(newValue));
|
public void | fireVetoableChange(java.beans.PropertyChangeEvent evt)Fire a vetoable property update to any registered listeners. If
anyone vetos the change, then fire a new event reverting everyone to
the old value and then rethrow the PropertyVetoException.
No event is fired if old and new are equal and non-null.
Object oldValue = evt.getOldValue();
Object newValue = evt.getNewValue();
String propertyName = evt.getPropertyName();
if (oldValue != null && newValue != null && oldValue.equals(newValue)) {
return;
}
java.util.Vector targets = null;
VetoableChangeSupport child = null;
synchronized (this) {
if (listeners != null) {
targets = (java.util.Vector) listeners.clone();
}
if (children != null && propertyName != null) {
child = (VetoableChangeSupport)children.get(propertyName);
}
}
if (listeners != null) {
try {
for (int i = 0; i < targets.size(); i++) {
VetoableChangeListener target =
(VetoableChangeListener)targets.elementAt(i);
target.vetoableChange(evt);
}
} catch (PropertyVetoException veto) {
// Create an event to revert everyone to the old value.
evt = new PropertyChangeEvent(source, propertyName, newValue, oldValue);
for (int i = 0; i < targets.size(); i++) {
try {
VetoableChangeListener target =
(VetoableChangeListener)targets.elementAt(i);
target.vetoableChange(evt);
} catch (PropertyVetoException ex) {
// We just ignore exceptions that occur during reversions.
}
}
// And now rethrow the PropertyVetoException.
throw veto;
}
}
if (child != null) {
child.fireVetoableChange(evt);
}
|
public void | fireVetoableChange(java.lang.String propertyName, java.lang.Object oldValue, java.lang.Object newValue)Report a vetoable property update to any registered listeners. If
anyone vetos the change, then fire a new event reverting everyone to
the old value and then rethrow the PropertyVetoException.
No event is fired if old and new are equal and non-null.
if (listeners == null && children == null) {
return;
}
PropertyChangeEvent evt = new PropertyChangeEvent(source, propertyName,
oldValue, newValue);
fireVetoableChange(evt);
|
public void | fireVetoableChange(java.lang.String propertyName, int oldValue, int newValue)Report a int vetoable property update to any registered listeners.
No event is fired if old and new are equal and non-null.
This is merely a convenience wrapper around the more general
fireVetoableChange method that takes Object values.
if (oldValue == newValue) {
return;
}
fireVetoableChange(propertyName, new Integer(oldValue), new Integer(newValue));
|
public synchronized java.beans.VetoableChangeListener[] | getVetoableChangeListeners()Returns the list of VetoableChangeListeners. If named vetoable change listeners
were added, then VetoableChangeListenerProxy wrappers will returned
List returnList = new ArrayList();
// Add all the VetoableChangeListeners
if (listeners != null) {
returnList.addAll(listeners);
}
// Add all the VetoableChangeListenerProxys
if (children != null) {
Iterator iterator = children.keySet().iterator();
while (iterator.hasNext()) {
String key = (String)iterator.next();
VetoableChangeSupport child =
(VetoableChangeSupport)children.get(key);
VetoableChangeListener[] childListeners =
child.getVetoableChangeListeners();
for (int index = childListeners.length - 1; index >= 0;
index--) {
returnList.add(new VetoableChangeListenerProxy(
key, childListeners[index]));
}
}
}
return (VetoableChangeListener[])(returnList.toArray(
new VetoableChangeListener[0]));
|
public synchronized java.beans.VetoableChangeListener[] | getVetoableChangeListeners(java.lang.String propertyName)Returns an array of all the listeners which have been associated
with the named property.
List returnList = new ArrayList();
if (children != null && propertyName != null) {
VetoableChangeSupport support =
(VetoableChangeSupport)children.get(propertyName);
if (support != null) {
returnList.addAll(
Arrays.asList(support.getVetoableChangeListeners()));
}
}
return (VetoableChangeListener[])(returnList.toArray(new
VetoableChangeListener[0]));
|
public synchronized boolean | hasListeners(java.lang.String propertyName)Check if there are any listeners for a specific property, including
those registered on all properties. If propertyName
is null, only check for listeners registered on all properties.
if (listeners != null && !listeners.isEmpty()) {
// there is a generic listener
return true;
}
if (children != null && propertyName != null) {
VetoableChangeSupport child = (VetoableChangeSupport)children.get(propertyName);
if (child != null && child.listeners != null) {
return !child.listeners.isEmpty();
}
}
return false;
|
private void | readObject(java.io.ObjectInputStream s)
s.defaultReadObject();
Object listenerOrNull;
while(null != (listenerOrNull = s.readObject())) {
addVetoableChangeListener((VetoableChangeListener)listenerOrNull);
}
|
public synchronized void | removeVetoableChangeListener(java.beans.VetoableChangeListener listener)Remove a VetoableChangeListener from the listener list.
This removes a VetoableChangeListener that was registered
for all properties.
If listener was added more than once to the same event
source, it will be notified one less time after being removed.
If listener is null, or was never added, no exception is
thrown and no action is taken.
if (listener == null) {
return;
}
if (listener instanceof VetoableChangeListenerProxy) {
VetoableChangeListenerProxy proxy =
(VetoableChangeListenerProxy)listener;
// Call two argument remove method.
removeVetoableChangeListener(proxy.getPropertyName(),
(VetoableChangeListener)proxy.getListener());
} else {
if (listeners == null) {
return;
}
listeners.removeElement(listener);
}
|
public synchronized void | removeVetoableChangeListener(java.lang.String propertyName, java.beans.VetoableChangeListener listener)Remove a VetoableChangeListener for a specific property.
If listener was added more than once to the same event
source for the specified property, it will be notified one less time
after being removed.
If propertyName is null, no exception is thrown and no
action is taken.
If listener is null, or was never added for the specified
property, no exception is thrown and no action is taken.
if (listener == null || propertyName == null) {
return;
}
if (children == null) {
return;
}
VetoableChangeSupport child = (VetoableChangeSupport)children.get(propertyName);
if (child == null) {
return;
}
child.removeVetoableChangeListener(listener);
|
private void | writeObject(java.io.ObjectOutputStream s)
s.defaultWriteObject();
java.util.Vector v = null;
synchronized (this) {
if (listeners != null) {
v = (java.util.Vector) listeners.clone();
}
}
if (v != null) {
for(int i = 0; i < v.size(); i++) {
VetoableChangeListener l = (VetoableChangeListener)v.elementAt(i);
if (l instanceof Serializable) {
s.writeObject(l);
}
}
}
s.writeObject(null);
|