本文整理汇总了Java中java.beans.VetoableChangeListenerProxy类的典型用法代码示例。如果您正苦于以下问题:Java VetoableChangeListenerProxy类的具体用法?Java VetoableChangeListenerProxy怎么用?Java VetoableChangeListenerProxy使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
VetoableChangeListenerProxy类属于java.beans包,在下文中一共展示了VetoableChangeListenerProxy类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testGetVetoableChangeListeners
import java.beans.VetoableChangeListenerProxy; //导入依赖的package包/类
public final void testGetVetoableChangeListeners() {
VetoableChangeListener[] listeners = kfm.getVetoableChangeListeners();
assertNotNull(listeners);
assertEquals(0, listeners.length);
kfm.addVetoableChangeListener(vlistener);
assertEquals(0, listeners.length);
listeners = kfm.getVetoableChangeListeners();
assertEquals(1, listeners.length);
assertSame(vlistener, listeners[0]);
String propName = "focusOwner";
kfm.addVetoableChangeListener(propName, vlistener);
listeners = kfm.getVetoableChangeListeners();
assertEquals(2, listeners.length);
assertNotSame(vlistener, listeners[1]);
assertTrue(listeners[1] instanceof VetoableChangeListenerProxy);
VetoableChangeListenerProxy proxy = (VetoableChangeListenerProxy) listeners[1];
assertEquals(propName, proxy.getPropertyName());
assertSame(vlistener, proxy.getListener());
}
示例2: testAddVetoableChangeListenerStringVetoableChangeListener_property_invalid
import java.beans.VetoableChangeListenerProxy; //导入依赖的package包/类
public void testAddVetoableChangeListenerStringVetoableChangeListener_property_invalid() {
MockSource source = new MockSource();
VetoableChangeSupport support = new VetoableChangeSupport(source);
VetoableChangeListener proxy = EventHandler.create(
VetoableChangeListener.class, source, "setText");
String propertyName = "label_invalid";
support.addVetoableChangeListener(propertyName, proxy);
VetoableChangeListener[] listeners1 = support
.getVetoableChangeListeners();
VetoableChangeListener[] listeners2 = support
.getVetoableChangeListeners("label_invalid");
assertEquals(1, listeners1.length);
assertEquals(1, listeners2.length);
assertEquals("label_invalid",
((VetoableChangeListenerProxy) listeners1[0]).getPropertyName());
assertSame(proxy, listeners2[0]);
assertFalse(support.hasListeners("label"));
}
示例3: testAddVetoableChangeListenerProxy
import java.beans.VetoableChangeListenerProxy; //导入依赖的package包/类
/**
* The test checks the method add() for VetoableChangeListenerProxy
*/
public void testAddVetoableChangeListenerProxy() {
VetoableChangeSupport vcs = new VetoableChangeSupport("bean1");
VetoableChangeListener vcl = new VetoableChangeListener() {
public void vetoableChange(PropertyChangeEvent pce) {
}
};
vcs.addVetoableChangeListener("property1", vcl);
VetoableChangeListener[] vcls = vcs.getVetoableChangeListeners();
assertNotNull("Returned listeners is null.", vcls);
assertEquals(1, vcls.length);
assertTrue("Listener is not of VetoableChangeListenerProxy type",
vcls[0] instanceof VetoableChangeListenerProxy);
assertEquals(vcl, ((VetoableChangeListenerProxy) vcls[0]).getListener());
assertEquals("property1", ((VetoableChangeListenerProxy) vcls[0])
.getPropertyName());
}
示例4: testAddVetoableChangeListenerStringVetoableChangeListener_null
import java.beans.VetoableChangeListenerProxy; //导入依赖的package包/类
public void testAddVetoableChangeListenerStringVetoableChangeListener_null() {
MockSource source = new MockSource();
VetoableChangeSupport support = new VetoableChangeSupport(source);
String propertyName = "label";
support.addVetoableChangeListener(propertyName, null);
VetoableChangeListener[] listeners1 = support
.getVetoableChangeListeners();
VetoableChangeListener[] listeners2 = support
.getVetoableChangeListeners(propertyName);
assertTrue(support.hasListeners(propertyName));
assertFalse(support.hasListeners("text"));
assertEquals(1, listeners1.length);
assertEquals(propertyName,
((VetoableChangeListenerProxy) listeners1[0]).getPropertyName());
assertNull(((VetoableChangeListenerProxy) listeners1[0]).getListener());
assertEquals(1, listeners2.length);
assertNull(listeners2[0]);
}
示例5: getVetoableChangeListeners
import java.beans.VetoableChangeListenerProxy; //导入依赖的package包/类
public synchronized VetoableChangeListener[] getVetoableChangeListeners() {
List<VetoableChangeListener> result = new ArrayList<VetoableChangeListener>();
if (globalListeners != null) {
result.addAll(globalListeners);
}
for (Iterator<String> iterator = children.keySet().iterator(); iterator
.hasNext();) {
String propertyName = iterator.next();
java.beans.VetoableChangeSupport namedListener = children
.get(propertyName);
VetoableChangeListener[] childListeners = namedListener
.getVetoableChangeListeners();
for (int i = 0; i < childListeners.length; i++) {
result.add(new VetoableChangeListenerProxy(propertyName,
childListeners[i]));
}
}
return (result
.toArray(new VetoableChangeListener[result.size()]));
}
示例6: check
import java.beans.VetoableChangeListenerProxy; //导入依赖的package包/类
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);
}
示例7: testAddVetoableChangeListenerStringVetoableChangeListener
import java.beans.VetoableChangeListenerProxy; //导入依赖的package包/类
public void testAddVetoableChangeListenerStringVetoableChangeListener() {
MockSource source = new MockSource();
VetoableChangeSupport support = new VetoableChangeSupport(source);
VetoableChangeListener proxy = EventHandler.create(
VetoableChangeListener.class, source, "setText");
String propertyName = "label";
support.addVetoableChangeListener(propertyName, proxy);
assertTrue(support.hasListeners(propertyName));
assertFalse(support.hasListeners("text"));
VetoableChangeListener[] listeners1 = support
.getVetoableChangeListeners();
VetoableChangeListener[] listeners2 = support
.getVetoableChangeListeners(propertyName);
VetoableChangeListener[] listeners3 = support
.getVetoableChangeListeners("text");
assertEquals(0, listeners3.length);
assertEquals(1, listeners1.length);
assertEquals(1, listeners2.length);
assertSame(proxy, listeners2[0]);
VetoableChangeListenerProxy wrappers = (VetoableChangeListenerProxy) listeners1[0];
assertSame(proxy, wrappers.getListener());
assertEquals(propertyName, wrappers.getPropertyName());
}
示例8: testAddVetoableChangeListenerStringVetoableChangeListener_property_duplicate
import java.beans.VetoableChangeListenerProxy; //导入依赖的package包/类
public void testAddVetoableChangeListenerStringVetoableChangeListener_property_duplicate() {
MockSource source = new MockSource();
VetoableChangeSupport support = new VetoableChangeSupport(source);
VetoableChangeListener proxy = EventHandler.create(
VetoableChangeListener.class, source, "setText");
VetoableChangeListener proxy2 = EventHandler.create(
VetoableChangeListener.class, source, "setText");
String propertyName = "label";
support.addVetoableChangeListener(propertyName, proxy);
support.addVetoableChangeListener(propertyName, proxy2);
assertTrue(support.hasListeners(propertyName));
assertFalse(support.hasListeners("text"));
VetoableChangeListener[] listeners1 = support
.getVetoableChangeListeners();
VetoableChangeListener[] listeners2 = support
.getVetoableChangeListeners(propertyName);
VetoableChangeListener[] listeners3 = support
.getVetoableChangeListeners("text");
assertEquals(0, listeners3.length);
assertEquals(2, listeners1.length);
assertEquals(2, listeners2.length);
for (int i = 0; i < listeners2.length; i++) {
assertTrue((proxy == listeners2[i]) || (proxy2 == listeners2[i]));
VetoableChangeListenerProxy wrappers = (VetoableChangeListenerProxy) listeners1[i];
assertTrue((proxy == wrappers.getListener())
|| (proxy2 == wrappers.getListener()));
assertEquals(propertyName, wrappers.getPropertyName());
}
}
示例9: addVetoableChangeListener
import java.beans.VetoableChangeListenerProxy; //导入依赖的package包/类
public synchronized void addVetoableChangeListener(
VetoableChangeListener listener) {
if (listener != null) {
if (listener instanceof VetoableChangeListenerProxy) {
VetoableChangeListenerProxy proxy = (VetoableChangeListenerProxy) listener;
addVetoableChangeListener(proxy.getPropertyName(),
(VetoableChangeListener) proxy.getListener());
} else {
globalListeners.add(listener);
}
}
}
示例10: main
import java.beans.VetoableChangeListenerProxy; //导入依赖的package包/类
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);
}
示例11: main
import java.beans.VetoableChangeListenerProxy; //导入依赖的package包/类
public static void main(String[] args) {
Test4994635 test = new Test4994635();
test.vcs.addVetoableChangeListener(
new VetoableChangeListenerProxy("property", test));
}