mirror of https://github.com/sipwise/jitsi.git
Use java.beans.PropertyChangeEvent instead of own implementation. This removes some classes from SC and removes ambiguities with respect to PropertyChangeEvent handling. Rename SC's own PropertyVetoException to ConfigPropertyVetoException to show the difference in usage and implementation. ConfigPropertyVetoException is a subclass of Runtime exception (intentionally) to simplify handling.cusax-fix
parent
ad827e67f6
commit
73cf690b04
@ -1,46 +0,0 @@
|
||||
/*
|
||||
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
package net.java.sip.communicator.service.configuration.event;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import net.java.sip.communicator.service.configuration.*;
|
||||
import net.java.sip.communicator.util.*;
|
||||
|
||||
/**
|
||||
* A VetoableChange event gets fired whenever a property is about to change.
|
||||
* One can register a VetoableChangeListener with the ConfigurationService so as
|
||||
* to be notified in advance of any property updates. The purpose of a
|
||||
* VetoableChaneListener is that it allows registered instances to veto or in
|
||||
* other words cancel events by throwing a PropertyVetoException. In case
|
||||
* none of the registered listeners has thrown an exception, the property is
|
||||
* changed and a propertyChange event is dispatched to all registered
|
||||
* PropertyChangeListener-s
|
||||
*
|
||||
* @author Emil Ivov
|
||||
*/
|
||||
public interface VetoableChangeListener
|
||||
extends EventListener
|
||||
{
|
||||
|
||||
/**
|
||||
* This method gets called when a constrained property is about to change.
|
||||
* Note that the method only warns about the change and in case none of
|
||||
* the interested listeners vetos it (i.e. no PropertyVetoException
|
||||
* is thrown) the propertyChange method will be called next to indicate
|
||||
* that the change has taken place. In case you don't want to be notified
|
||||
* for pending changes over constrained properties you should provide
|
||||
* an empty implementation of the method.
|
||||
*
|
||||
* @param evt a <tt>PropertyChangeEvent</tt> object describing the
|
||||
* event source and the property that has changed.
|
||||
* @exception PropertyVetoException if the recipient wishes the property
|
||||
* change to be rolled back.
|
||||
*/
|
||||
void vetoableChange(PropertyChangeEvent evt)
|
||||
throws PropertyVetoException;
|
||||
}
|
||||
@ -1,111 +0,0 @@
|
||||
/*
|
||||
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
package net.java.sip.communicator.util;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* A "ConfigurationChange" event gets delivered whenever a someone changes a
|
||||
* configuration property. A ConfigurationEvent object is sent as an argument to
|
||||
* the ConfigurationChangeListener methods.
|
||||
* <P>
|
||||
* Normally ConfigurationChangeEvents are accompanied by the name and the old
|
||||
* and new values of the changed property. If the new value is a primitive type
|
||||
* (such as int or boolean) it must be wrapped as the corresponding java.lang.*
|
||||
* Object type (such as Integer or Boolean).
|
||||
* <P>
|
||||
* Null values may be provided for the old and the new values if their true
|
||||
* values are not known.
|
||||
* <P>
|
||||
* An event source may send a null object as the name to indicate that an
|
||||
* arbitrary set of if its properties have changed. In this case the old and new
|
||||
* values should also be null.
|
||||
* <P>
|
||||
* In the case where the event reflects the change of a constrained property, it
|
||||
* will first be dispatched to all propertyWillChange methods and only in case
|
||||
* that none of them has objected (no ChangeVetoException has been thrown) the
|
||||
* propertyChange method is called.
|
||||
*
|
||||
* @author Emil Ivov
|
||||
*/
|
||||
public class PropertyChangeEvent
|
||||
extends EventObject
|
||||
{
|
||||
|
||||
/**
|
||||
* name of the property that changed. May be null, if not known.
|
||||
*
|
||||
* @serial
|
||||
*/
|
||||
private final String propertyName;
|
||||
|
||||
/**
|
||||
* New value for property. May be null if not known.
|
||||
*
|
||||
* @serial
|
||||
*/
|
||||
private final Object newValue;
|
||||
|
||||
/**
|
||||
* Previous value for property. May be null if not known.
|
||||
*
|
||||
* @serial
|
||||
*/
|
||||
private final Object oldValue;
|
||||
|
||||
/**
|
||||
* Constructs a new <tt>PropertyChangeEvent</tt>.
|
||||
*
|
||||
* @param source The bean that fired the event.
|
||||
* @param propertyName The programmatic name of the property that was
|
||||
* changed.
|
||||
* @param oldValue The old value of the property.
|
||||
* @param newValue The new value of the property.
|
||||
*/
|
||||
public PropertyChangeEvent(Object source, String propertyName,
|
||||
Object oldValue, Object newValue)
|
||||
{
|
||||
super(source);
|
||||
|
||||
this.propertyName = propertyName;
|
||||
this.newValue = newValue;
|
||||
this.oldValue = oldValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the programmatic name of the property that was changed.
|
||||
*
|
||||
* @return The programmatic name of the property that was changed. May be
|
||||
* null if multiple properties have changed.
|
||||
*/
|
||||
public String getPropertyName()
|
||||
{
|
||||
return propertyName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the new value for the property, expressed as an Object.
|
||||
*
|
||||
* @return The new value for the property, expressed as an Object. May be
|
||||
* null if multiple properties have changed.
|
||||
*/
|
||||
public Object getNewValue()
|
||||
{
|
||||
return newValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the old value for the property, expressed as an Object.
|
||||
*
|
||||
* @return The old value for the property, expressed as an Object. May be
|
||||
* null if multiple properties have changed.
|
||||
*/
|
||||
public Object getOldValue()
|
||||
{
|
||||
return oldValue;
|
||||
}
|
||||
}
|
||||
@ -1,28 +0,0 @@
|
||||
/*
|
||||
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
package net.java.sip.communicator.util;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* A "ConfigurationChange" event gets fired whenever a configuration property
|
||||
* changes. Depending on whether the property was constrained or not, the
|
||||
* propertyChange or vetoableChange methods get called.
|
||||
*
|
||||
* @author Emil Ivov
|
||||
*/
|
||||
public interface PropertyChangeListener
|
||||
extends EventListener
|
||||
{
|
||||
/**
|
||||
* This method gets called when a bound property is changed.
|
||||
*
|
||||
* @param evt A PropertyChangeEvent object describing the event source and
|
||||
* the property that has changed.
|
||||
*/
|
||||
void propertyChange(PropertyChangeEvent evt);
|
||||
}
|
||||
@ -1,93 +0,0 @@
|
||||
/*
|
||||
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
package net.java.sip.communicator.util;
|
||||
|
||||
/**
|
||||
* Represents a mechanism to easily add to a specific <tt>Object</tt> by means
|
||||
* of composition support for firing <tt>PropertyChangeEvent</tt>s to
|
||||
* <tt>PropertyChangeListener</tt>s.
|
||||
*
|
||||
* @author Lubomir Marinov
|
||||
*/
|
||||
public class PropertyChangeSupport
|
||||
extends PropertyChangeNotifier
|
||||
{
|
||||
|
||||
/**
|
||||
* The <tt>Object</tt> to be reported as the source of the
|
||||
* <tt>PropertyChangeEvent</tt>s fired by this instance.
|
||||
*/
|
||||
private final Object source;
|
||||
|
||||
/**
|
||||
* Initializes a new <tt>PropertyChangeSupport</tt> which is to fire
|
||||
* <tt>PropertyChangeEvent</tt>s and to report their source as a specific
|
||||
* <tt>Object</tt>
|
||||
*
|
||||
* @param source the <tt>Object</tt> to be reported as the source of the
|
||||
* <tt>PropertyChangeEvent</tt>s fired by the new instance
|
||||
*/
|
||||
public PropertyChangeSupport(Object source)
|
||||
{
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fires a new <tt>PropertyChangeEvent</tt> to the
|
||||
* <tt>PropertyChangeListener</tt>s registered with this
|
||||
* <tt>PropertyChangeSupport</tt> in order to notify about a change in the
|
||||
* value of a specific property which had its old value modified to a
|
||||
* specific new value.
|
||||
*
|
||||
* @param property the name of the property of this
|
||||
* <tt>PropertyChangeSupport</tt> which had its value changed
|
||||
* @param oldValue the value of the property with the specified name before
|
||||
* the change
|
||||
* @param newValue the value of the property with the specified name after
|
||||
* the change
|
||||
* @see PropertyChangeNotifier#firePropertyChange(String, Object, Object)
|
||||
*/
|
||||
@Override
|
||||
public void firePropertyChange(
|
||||
String property,
|
||||
Object oldValue,
|
||||
Object newValue)
|
||||
{
|
||||
super.firePropertyChange(property, oldValue, newValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the <tt>Object</tt> to be reported as the source of a new
|
||||
* <tt>PropertyChangeEvent</tt> which is to notify the
|
||||
* <tt>PropertyChangeListener</tt>s registered with this
|
||||
* <tt>PropertyChangeSupport</tt> about the change in the value of a
|
||||
* property with a specific name from a specific old value to a specific new
|
||||
* value.
|
||||
*
|
||||
* @param property the name of the property which had its value changed from
|
||||
* the specified old value to the specified new value
|
||||
* @param oldValue the value of the property with the specified name before
|
||||
* the change
|
||||
* @param newValue the value of the property with the specified name after
|
||||
* the change
|
||||
* @return the <tt>Object</tt> to be reported as the source of the new
|
||||
* <tt>PropertyChangeEvent</tt> which is to notify the
|
||||
* <tt>PropertyChangeListener</tt>s registered with this
|
||||
* <tt>PropertyChangeSupport</tt> about the change in the value of the
|
||||
* property with the specified name from the specified old value to the
|
||||
* specified new value
|
||||
* @see PropertyChangeNotifier#getPropertyChangeSource(String, Object, Object)
|
||||
*/
|
||||
@Override
|
||||
protected Object getPropertyChangeSource(
|
||||
String property,
|
||||
Object oldValue,
|
||||
Object newValue)
|
||||
{
|
||||
return source;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in new issue