本文整理汇总了Java中java.beans.PropertyChangeListenerProxy类的典型用法代码示例。如果您正苦于以下问题:Java PropertyChangeListenerProxy类的具体用法?Java PropertyChangeListenerProxy怎么用?Java PropertyChangeListenerProxy使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PropertyChangeListenerProxy类属于java.beans包,在下文中一共展示了PropertyChangeListenerProxy类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addPropertyChangeListener
import java.beans.PropertyChangeListenerProxy; //导入依赖的package包/类
/**
* Add a PropertyChangeListener 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.
*
* @param listener The PropertyChangeListener to be added
*/
public void addPropertyChangeListener(PropertyChangeListener listener)
{
if (listener instanceof PropertyChangeListenerProxy)
{
PropertyChangeListenerProxy proxy = (PropertyChangeListenerProxy) listener;
addPropertyChangeListener(proxy.getPropertyName(),
(PropertyChangeListener)proxy.getListener());
}
else
{
listeners.add(new WeakReference<PropertyChangeListener>(listener));
}
}
示例2: setDelegate
import java.beans.PropertyChangeListenerProxy; //导入依赖的package包/类
public void setDelegate(ChatServerConnection newDelegate) {
if (delegate != null && delegate.isConnected()) {
throw new IllegalStateException(Resources.getString("Server.error1")); //$NON-NLS-1$
}
ChatServerConnection oldDelegate = delegate;
if (oldDelegate != null) {
newDelegate.setUserInfo(oldDelegate.getUserInfo());
}
PropertyChangeListener[] listeners = propSupport.getPropertyChangeListeners();
for (int i = 0; i < listeners.length; i++) {
newDelegate.addPropertyChangeListener(((PropertyChangeListenerProxy) listeners[i]).getPropertyName(), listeners[i]);
}
if (controls != null) {
if (delegate instanceof ChatControlsInitializer) {
((ChatControlsInitializer) delegate).uninitializeControls(controls);
}
if (newDelegate instanceof ChatControlsInitializer) {
((ChatControlsInitializer) newDelegate).initializeControls(controls);
}
}
delegate = newDelegate;
}
示例3: testAddingAProxy
import java.beans.PropertyChangeListenerProxy; //导入依赖的package包/类
public void testAddingAProxy() {
Object bean = new Object();
PropertyChangeSupport support = new PropertyChangeSupport(bean);
PropertyChangeListener listener = new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent event) {}
};
PropertyChangeListenerProxy proxy = new PropertyChangeListenerProxy("a", listener);
support.addPropertyChangeListener("b", proxy);
// this proxy sets us up to receive 'b' events
PropertyChangeListenerProxy p1
= (PropertyChangeListenerProxy) support.getPropertyChangeListeners()[0];
assertEquals(PropertyChangeListenerProxy.class, p1.getClass());
assertEquals("b", p1.getPropertyName());
// this proxy sets us up to receive 'a' events
PropertyChangeListenerProxy p2 = (PropertyChangeListenerProxy) p1.getListener();
assertEquals(PropertyChangeListenerProxy.class, p2.getClass());
assertEquals("a", p2.getPropertyName());
assertEquals(listener, p2.getListener());
}
示例4: getPropertyChangeListeners
import java.beans.PropertyChangeListenerProxy; //导入依赖的package包/类
@SuppressWarnings({"unused", "UnusedParameters"})
private PropertyChangeListener[] getPropertyChangeListeners(Object proxy) {
List<PropertyChangeListener> listeners = new ArrayList<>();
if (propertyChangeSupport != null) {
for (PropertyChangeListener pcl : propertyChangeSupport.getPropertyChangeListeners()) {
// Avoid single property change listeners
if (!(pcl instanceof PropertyChangeListenerProxy)) {
listeners.add(pcl);
}
}
}
if (weakPropertyChangeSupport != null) {
Collections.addAll(listeners, weakPropertyChangeSupport.getPropertyChangeListeners());
}
return listeners.toArray(new PropertyChangeListener[listeners.size()]);
}
示例5: getPropertyChangeListeners
import java.beans.PropertyChangeListenerProxy; //导入依赖的package包/类
/**
* Retrieves listeners.
*
* @return all of the {@code PropertyChangeListeners} added or an empty array
* if no listeners have been added
*
* @see java.beans.PropertyChangeSupport#getPropertyChangeListeners()
*/
@Override
public PropertyChangeListener[] getPropertyChangeListeners() {
ArrayList<PropertyChangeListener> listeners = new ArrayList<>();
if (propertyChangeSupport != null) {
for (PropertyChangeListener pcl : propertyChangeSupport.getPropertyChangeListeners()) {
// do not add single property change listeners
if (!(pcl instanceof PropertyChangeListenerProxy)) {
listeners.add(pcl);
}
}
}
if (weakPropertyChangeSupport != null) {
listeners.addAll(Arrays.asList(weakPropertyChangeSupport.getPropertyChangeListeners()));
}
return listeners.toArray(new PropertyChangeListener[listeners.size()]);
}
示例6: testGetPropertyChangeListeners
import java.beans.PropertyChangeListenerProxy; //导入依赖的package包/类
public final void testGetPropertyChangeListeners() {
PropertyChangeListener[] listeners = kfm.getPropertyChangeListeners();
assertNotNull(listeners);
assertEquals(0, listeners.length);
kfm.addPropertyChangeListener(listener);
assertEquals(0, listeners.length);
listeners = kfm.getPropertyChangeListeners();
assertEquals(1, listeners.length);
assertSame(listener, listeners[0]);
String propName = "currentFocusCycleRoot";
kfm.addPropertyChangeListener(propName, listener);
listeners = kfm.getPropertyChangeListeners();
assertEquals(2, listeners.length);
assertNotSame(listener, listeners[1]);
assertTrue(listeners[1] instanceof PropertyChangeListenerProxy);
PropertyChangeListenerProxy proxy = (PropertyChangeListenerProxy) listeners[1];
assertEquals(propName, proxy.getPropertyName());
assertSame(listener, proxy.getListener());
}
示例7: testRemovePropertyChangeListener_PropertyChangeListener_String_PropertyRegistered
import java.beans.PropertyChangeListenerProxy; //导入依赖的package包/类
public void testRemovePropertyChangeListener_PropertyChangeListener_String_PropertyRegistered() {
Object src = new Object();
PropertyChangeSupport sup = new PropertyChangeSupport(src);
PropertyChangeListener l1 = new MockPropertyChangeListener();
sup.addPropertyChangeListener("myProp", l1);
assertEquals(1, sup.getPropertyChangeListeners().length);
sup.removePropertyChangeListener("myProp", l1);
assertEquals(0, sup.getPropertyChangeListeners().length);
assertEquals(0, sup.getPropertyChangeListeners("myProp").length);
PropertyChangeListener l2 = new MockPropertyChangeListener();
PropertyChangeListener l3 = new PropertyChangeListenerProxy("myProp",
l2);
sup.addPropertyChangeListener(l3);
assertEquals(1, sup.getPropertyChangeListeners().length);
sup.removePropertyChangeListener("myProp", l2);
assertEquals(0, sup.getPropertyChangeListeners().length);
assertEquals(0, sup.getPropertyChangeListeners("myProp").length);
}
示例8: testGetPropertyChangeListener_String_Normal
import java.beans.PropertyChangeListenerProxy; //导入依赖的package包/类
public void testGetPropertyChangeListener_String_Normal() {
Object src = new Object();
PropertyChangeSupport sup = new PropertyChangeSupport(src);
PropertyChangeListener l1 = new MockPropertyChangeListener();
PropertyChangeListener l2 = new MockPropertyChangeListener();
PropertyChangeListener l3 = new PropertyChangeListenerProxy("myProp",
l2);
PropertyChangeListener l4 = new MockPropertyChangeListener();
sup.addPropertyChangeListener(l1);
sup.addPropertyChangeListener(l3);
sup.addPropertyChangeListener("myProp2", l4);
assertEquals(1, sup.getPropertyChangeListeners("myProp").length);
assertSame(l2, sup.getPropertyChangeListeners("myProp")[0]);
sup.addPropertyChangeListener("myProp",
new MockPropertyChangeListener());
assertEquals(2, sup.getPropertyChangeListeners("myProp").length);
}
示例9: testHasListener_AllRegistered
import java.beans.PropertyChangeListenerProxy; //导入依赖的package包/类
public void testHasListener_AllRegistered() {
Object src = new Object();
PropertyChangeSupport sup = new PropertyChangeSupport(src);
PropertyChangeListener l1 = new MockPropertyChangeListener();
PropertyChangeListener l2 = new MockPropertyChangeListener();
PropertyChangeListener l3 = new PropertyChangeListenerProxy("myProp",
l2);
assertFalse(sup.hasListeners("myProp"));
sup.addPropertyChangeListener(l1);
assertTrue(sup.hasListeners("myProp"));
sup.removePropertyChangeListener(l1);
assertFalse(sup.hasListeners("myProp"));
sup.addPropertyChangeListener(l3);
assertTrue(sup.hasListeners("myProp"));
}
示例10: testHasListener_PropertyRegistered
import java.beans.PropertyChangeListenerProxy; //导入依赖的package包/类
public void testHasListener_PropertyRegistered() {
Object src = new Object();
PropertyChangeSupport sup = new PropertyChangeSupport(src);
PropertyChangeListener l1 = new MockPropertyChangeListener();
PropertyChangeListener l2 = new MockPropertyChangeListener();
PropertyChangeListener l3 = new PropertyChangeListenerProxy("myProp",
l2);
assertFalse(sup.hasListeners("myProp"));
sup.addPropertyChangeListener("myProP", l1);
assertFalse(sup.hasListeners("myProp"));
sup.addPropertyChangeListener("myProp", l2);
assertTrue(sup.hasListeners("myProp"));
sup.removePropertyChangeListener("myProp", l2);
assertFalse(sup.hasListeners("myProp"));
// The following assertion fails on RI. See HARMONY-2526
sup.addPropertyChangeListener("myProp", l3);
assertTrue(sup.hasListeners("myProp"));
}
示例11: testFirePropertyChange_Object_Normal
import java.beans.PropertyChangeListenerProxy; //导入依赖的package包/类
public void testFirePropertyChange_Object_Normal() {
Object src = new Object();
PropertyChangeSupport sup = new PropertyChangeSupport(src);
Object newValue = new Object();
Object oldValue = new Object();
MockPropertyChangeListener l1 = new MockPropertyChangeListener(src,
"myProp", oldValue, newValue);
MockPropertyChangeListener l2 = new MockPropertyChangeListener(src,
"myProp", oldValue, newValue);
PropertyChangeListener l3 = new PropertyChangeListenerProxy("myProp",
l2);
MockPropertyChangeListener l4 = new MockPropertyChangeListener(src,
"myProp", oldValue, newValue);
sup.addPropertyChangeListener(l1);
sup.addPropertyChangeListener(l3);
sup.addPropertyChangeListener("myProp", l4);
sup.firePropertyChange("myProp", oldValue, newValue);
l1.assertCalled();
l2.assertCalled();
l4.assertCalled();
}
示例12: testFirePropertyChange_Object_EqualValues
import java.beans.PropertyChangeListenerProxy; //导入依赖的package包/类
public void testFirePropertyChange_Object_EqualValues() {
Object src = new Object();
PropertyChangeSupport sup = new PropertyChangeSupport(src);
Object newValue = new Object();
Object oldValue = newValue;
MockPropertyChangeListener l1 = new MockPropertyChangeListener(src,
"myProp", oldValue, newValue);
MockPropertyChangeListener l2 = new MockPropertyChangeListener(src,
"myProp", oldValue, newValue);
PropertyChangeListener l3 = new PropertyChangeListenerProxy("myProp",
l2);
MockPropertyChangeListener l4 = new MockPropertyChangeListener(src,
"myProp", oldValue, newValue);
sup.addPropertyChangeListener(l1);
sup.addPropertyChangeListener(l3);
sup.addPropertyChangeListener("myProp", l4);
sup.firePropertyChange("myProp", oldValue, newValue);
l1.assertNotCalled();
l2.assertNotCalled();
l4.assertNotCalled();
}
示例13: testFirePropertyChange_Object_NullValues
import java.beans.PropertyChangeListenerProxy; //导入依赖的package包/类
public void testFirePropertyChange_Object_NullValues() {
Object src = new Object();
PropertyChangeSupport sup = new PropertyChangeSupport(src);
Object newValue = null;
Object oldValue = null;
MockPropertyChangeListener l1 = new MockPropertyChangeListener(src,
"myProp", oldValue, newValue);
MockPropertyChangeListener l2 = new MockPropertyChangeListener(src,
"myProp", oldValue, newValue);
PropertyChangeListener l3 = new PropertyChangeListenerProxy("myProp",
l2);
MockPropertyChangeListener l4 = new MockPropertyChangeListener(src,
"myProp", oldValue, newValue);
sup.addPropertyChangeListener(l1);
sup.addPropertyChangeListener(l3);
sup.addPropertyChangeListener("myProp", l4);
sup.firePropertyChange("myProp", oldValue, newValue);
l1.assertCalled();
l2.assertCalled();
l4.assertCalled();
}
示例14: testFirePropertyChange_Object_NullNewValue
import java.beans.PropertyChangeListenerProxy; //导入依赖的package包/类
public void testFirePropertyChange_Object_NullNewValue() {
Object src = new Object();
PropertyChangeSupport sup = new PropertyChangeSupport(src);
Object newValue = null;
Object oldValue = new Object();
MockPropertyChangeListener l1 = new MockPropertyChangeListener(src,
"myProp", oldValue, newValue);
MockPropertyChangeListener l2 = new MockPropertyChangeListener(src,
"myProp", oldValue, newValue);
PropertyChangeListener l3 = new PropertyChangeListenerProxy("myProp",
l2);
MockPropertyChangeListener l4 = new MockPropertyChangeListener(src,
"myProp", oldValue, newValue);
sup.addPropertyChangeListener(l1);
sup.addPropertyChangeListener(l3);
sup.addPropertyChangeListener("myProp", l4);
sup.firePropertyChange("myProp", oldValue, newValue);
l1.assertCalled();
l2.assertCalled();
l4.assertCalled();
}
示例15: testFirePropertyChange_Object_NullOldValue
import java.beans.PropertyChangeListenerProxy; //导入依赖的package包/类
public void testFirePropertyChange_Object_NullOldValue() {
Object src = new Object();
PropertyChangeSupport sup = new PropertyChangeSupport(src);
Object newValue = new Object();
Object oldValue = null;
MockPropertyChangeListener l1 = new MockPropertyChangeListener(src,
"myProp", oldValue, newValue);
MockPropertyChangeListener l2 = new MockPropertyChangeListener(src,
"myProp", oldValue, newValue);
PropertyChangeListener l3 = new PropertyChangeListenerProxy("myProp",
l2);
MockPropertyChangeListener l4 = new MockPropertyChangeListener(src,
"myProp", oldValue, newValue);
sup.addPropertyChangeListener(l1);
sup.addPropertyChangeListener(l3);
sup.addPropertyChangeListener("myProp", l4);
sup.firePropertyChange("myProp", oldValue, newValue);
l1.assertCalled();
l2.assertCalled();
l4.assertCalled();
}