use of java.beans.VetoableChangeListenerProxy in project jdk8u_jdk by JetBrains.
the class TestListeners method main.
public static void main(String[] args) throws PropertyVetoException {
VetoableChangeSupport vcs = new VetoableChangeSupport(TestListeners.class);
vcs.addVetoableChangeListener(new TestListeners(0));
vcs.addVetoableChangeListener(NAME, new TestListeners(2));
vcs.addVetoableChangeListener(new TestListeners(1));
vcs.addVetoableChangeListener(NAME, new VetoableChangeListenerProxy(NAME, new TestListeners(3)));
current = 0;
vcs.fireVetoableChange(NAME, 0, 1);
if (current != 4)
throw new Error("Expected 4 listeners, but called " + current);
current = 0;
vcs.fireVetoableChange(NONE, 1, 0);
if (current != 2)
throw new Error("Expected 2 listeners, but called " + current);
VetoableChangeListener[] all = vcs.getVetoableChangeListeners();
if (all.length != 4)
throw new Error("Expected 4 listeners, but contained " + all.length);
VetoableChangeListener[] named = vcs.getVetoableChangeListeners(NAME);
if (named.length != 2)
throw new Error("Expected 2 named listeners, but contained " + named.length);
VetoableChangeListener[] other = vcs.getVetoableChangeListeners(NONE);
if (other.length != 0)
throw new Error("Expected 0 other listeners, but contained " + other.length);
vcs.removeVetoableChangeListener(new TestListeners(0));
vcs.removeVetoableChangeListener(new TestListeners(1));
vcs.removeVetoableChangeListener(NAME, new TestListeners(2));
vcs.removeVetoableChangeListener(NAME, new VetoableChangeListenerProxy(NAME, new TestListeners(3)));
all = vcs.getVetoableChangeListeners();
if (all.length != 0)
throw new Error("Expected 4 listeners, but contained " + all.length);
named = vcs.getVetoableChangeListeners(NAME);
if (named.length != 0)
throw new Error("Expected 2 named listeners, but contained " + named.length);
other = vcs.getVetoableChangeListeners(NONE);
if (other.length != 0)
throw new Error("Expected 0 other listeners, but contained " + other.length);
}
use of java.beans.VetoableChangeListenerProxy in project jdk8u_jdk by JetBrains.
the class Test4994635 method main.
public static void main(String[] args) {
Test4994635 test = new Test4994635();
test.vcs.addVetoableChangeListener(new VetoableChangeListenerProxy("property", test));
}
use of java.beans.VetoableChangeListenerProxy in project jdk8u_jdk by JetBrains.
the class TestSerialization method check.
private static void check(VetoableChangeListener listener, int index, String name) {
if (!(listener instanceof VetoableChangeListenerProxy))
throw new Error("Unexpected listener: " + listener);
VetoableChangeListenerProxy object = (VetoableChangeListenerProxy) listener;
if (!name.equals(object.getPropertyName()))
throw new Error("Unexpected name: " + name + " != " + object.getPropertyName());
check((VetoableChangeListener) object.getListener(), index);
}
Aggregations