本文整理汇总了Java中java.beans.VetoableChangeSupport类的典型用法代码示例。如果您正苦于以下问题:Java VetoableChangeSupport类的具体用法?Java VetoableChangeSupport怎么用?Java VetoableChangeSupport使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
VetoableChangeSupport类属于java.beans包,在下文中一共展示了VetoableChangeSupport类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import java.beans.VetoableChangeSupport; //导入依赖的package包/类
public static void main(String[] args) {
CheckListener first = new CheckListener(false);
CheckListener second = new CheckListener(true);
CheckListener third = new CheckListener(false);
VetoableChangeSupport vcs = new VetoableChangeSupport(Test6630275.class);
vcs.addVetoableChangeListener(first);
vcs.addVetoableChangeListener(PROPERTY, first);
vcs.addVetoableChangeListener(PROPERTY, second);
vcs.addVetoableChangeListener(PROPERTY, third);
try {
vcs.fireVetoableChange(PROPERTY, true, false);
} catch (PropertyVetoException exception) {
first.validate();
second.validate();
third.validate();
return; // expected exception
}
throw new Error("exception should be thrown");
}
示例2: main
import java.beans.VetoableChangeSupport; //导入依赖的package包/类
public static void main(String[] args) {
CheckListener first = new CheckListener();
VetoListener second = new VetoListener();
CheckListener third = new CheckListener();
VetoableChangeSupport vcs = new VetoableChangeSupport(Test4425885.class);
vcs.addVetoableChangeListener(PROPERTY, first);
vcs.addVetoableChangeListener(PROPERTY, second);
vcs.addVetoableChangeListener(PROPERTY, third);
try {
vcs.fireVetoableChange(PROPERTY, 0, 1);
} catch (PropertyVetoException exception) {
if (first.odd)
throw new Error("no undo for the first listener", exception);
if (third.odd)
throw new Error("no undo for the third listener", exception);
return; // expected exception
}
throw new Error("exception should be thrown");
}
示例3: testRemoveVetoableChangeListenerVetoableChangeListener_all_null
import java.beans.VetoableChangeSupport; //导入依赖的package包/类
public void testRemoveVetoableChangeListenerVetoableChangeListener_all_null() {
MockSource source = new MockSource();
VetoableChangeSupport support = new VetoableChangeSupport(source);
VetoableChangeListener proxy = EventHandler.create(
VetoableChangeListener.class, source, "setText");
String propertyName = "label";
support.addVetoableChangeListener(null);
assertFalse(support.hasListeners(propertyName));
assertEquals(0, support.getVetoableChangeListeners().length);
support.removeVetoableChangeListener(proxy);
assertFalse(support.hasListeners(propertyName));
assertEquals(0, support.getVetoableChangeListeners(propertyName).length);
assertEquals(0, support.getVetoableChangeListeners().length);
}
示例4: testRemoveVetoableChangeListenerVetoableChangeListener_null
import java.beans.VetoableChangeSupport; //导入依赖的package包/类
public void testRemoveVetoableChangeListenerVetoableChangeListener_null() {
MockSource source = new MockSource();
VetoableChangeSupport support = new VetoableChangeSupport(source);
VetoableChangeListener proxy = EventHandler.create(
VetoableChangeListener.class, source, "setText");
String propertyName = "label";
support.addVetoableChangeListener(proxy);
assertTrue(support.hasListeners(propertyName));
assertEquals(1, support.getVetoableChangeListeners().length);
support.removeVetoableChangeListener(null);
assertTrue(support.hasListeners(propertyName));
assertEquals(0, support.getVetoableChangeListeners(propertyName).length);
assertEquals(1, support.getVetoableChangeListeners().length);
}
示例5: testAddVetoableChangeListenerStringVetoableChangeListener_property_invalid
import java.beans.VetoableChangeSupport; //导入依赖的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"));
}
示例6: testAddVetoableChangeListenerVetoableChangeListener_null
import java.beans.VetoableChangeSupport; //导入依赖的package包/类
public void testAddVetoableChangeListenerVetoableChangeListener_null() {
MockSource source = new MockSource();
VetoableChangeSupport support = new VetoableChangeSupport(source);
support.addVetoableChangeListener(null);
assertFalse(support.hasListeners("label"));
assertFalse(support.hasListeners("text"));
VetoableChangeListener[] listeners1 = support
.getVetoableChangeListeners();
VetoableChangeListener[] listeners2 = support
.getVetoableChangeListeners("label");
VetoableChangeListener[] listeners3 = support
.getVetoableChangeListeners("text");
assertEquals(0, listeners1.length);
assertEquals(0, listeners2.length);
assertEquals(0, listeners3.length);
}
示例7: testFireVetoableChangePropertyChangeEvent_property
import java.beans.VetoableChangeSupport; //导入依赖的package包/类
public void testFireVetoableChangePropertyChangeEvent_property()
throws PropertyVetoException {
MockSource source = new MockSource();
VetoableChangeSupport support = new VetoableChangeSupport(source);
VetoableChangeListener proxy = EventHandler.create(
VetoableChangeListener.class, source, "setText");
String propertyName = "label";
support.addVetoableChangeListener(propertyName, proxy);
PropertyChangeEvent event = new PropertyChangeEvent(source, "label",
"Label: old", "Label: new");
support.fireVetoableChange(event);
assertEquals("called", source.getText());
}
示例8: testRemoveVetoableChangeListenerVetoableChangeListener_all
import java.beans.VetoableChangeSupport; //导入依赖的package包/类
public void testRemoveVetoableChangeListenerVetoableChangeListener_all() {
MockSource source = new MockSource();
VetoableChangeSupport support = new VetoableChangeSupport(source);
VetoableChangeListener proxy = EventHandler.create(
VetoableChangeListener.class, source, "setText");
String propertyName = "label";
support.addVetoableChangeListener(proxy);
assertTrue(support.hasListeners(propertyName));
support.removeVetoableChangeListener(proxy);
assertFalse(support.hasListeners(propertyName));
assertEquals(0, support.getVetoableChangeListeners(propertyName).length);
assertEquals(0, support.getVetoableChangeListeners().length);
}
示例9: testFireVetoableChangeStringbooleanboolean_listener_Property_invalid
import java.beans.VetoableChangeSupport; //导入依赖的package包/类
public void testFireVetoableChangeStringbooleanboolean_listener_Property_invalid()
throws PropertyVetoException {
MockSource source = new MockSource();
VetoableChangeSupport support = new VetoableChangeSupport(source);
VetoableChangeListener proxy = EventHandler.create(
VetoableChangeListener.class, source, "label", "source.text");
support.addVetoableChangeListener("label", proxy);
String newText = "new Text value";
source.setText(newText);
support.fireVetoableChange("text", true, false);
assertEquals("label.default", source.getLabel());
support.fireVetoableChange("label_invalid", true, false);
assertEquals("label.default", source.getLabel());
support.fireVetoableChange("label", true, false);
assertEquals(newText, source.getLabel());
}
示例10: testRemoveVetoableChangeListenerStringVetoableChangeListener_propertyName_Invalid
import java.beans.VetoableChangeSupport; //导入依赖的package包/类
public void testRemoveVetoableChangeListenerStringVetoableChangeListener_propertyName_Invalid() {
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));
support.removeVetoableChangeListener(propertyName + "_invalid", proxy);
assertTrue(support.hasListeners(propertyName));
assertEquals(1, support.getVetoableChangeListeners(propertyName).length);
assertEquals(1, support.getVetoableChangeListeners().length);
}
示例11: testRemoveVetoableChangeListenerVetoableChangeListener_all_more_diff
import java.beans.VetoableChangeSupport; //导入依赖的package包/类
public void testRemoveVetoableChangeListenerVetoableChangeListener_all_more_diff() {
MockSource source = new MockSource();
VetoableChangeSupport support = new VetoableChangeSupport(source);
VetoableChangeListener proxy = EventHandler.create(
VetoableChangeListener.class, source, "setText");
VetoableChangeListener proxy2 = EventHandler.create(
VetoableChangeListener.class, source, "getText");
String propertyName = "label";
support.addVetoableChangeListener(proxy);
support.addVetoableChangeListener(proxy2);
assertTrue(support.hasListeners(propertyName));
assertEquals(2, support.getVetoableChangeListeners().length);
support.removeVetoableChangeListener(proxy);
assertTrue(support.hasListeners(propertyName));
assertEquals(0, support.getVetoableChangeListeners(propertyName).length);
assertEquals(1, support.getVetoableChangeListeners().length);
assertEquals(proxy2, support.getVetoableChangeListeners()[0]);
}
示例12: testRemoveVetoableChangeListenerStringVetoableChangeListener_property_more
import java.beans.VetoableChangeSupport; //导入依赖的package包/类
public void testRemoveVetoableChangeListenerStringVetoableChangeListener_property_more() {
MockSource source = new MockSource();
VetoableChangeSupport support = new VetoableChangeSupport(source);
VetoableChangeListener proxy = EventHandler.create(
VetoableChangeListener.class, source, "setText");
String propertyName = "label";
support.addVetoableChangeListener(propertyName, proxy);
support.addVetoableChangeListener(propertyName, proxy);
assertTrue(support.hasListeners(propertyName));
assertEquals(2, support.getVetoableChangeListeners(propertyName).length);
support.removeVetoableChangeListener(propertyName, proxy);
assertTrue(support.hasListeners(propertyName));
assertEquals(1, support.getVetoableChangeListeners(propertyName).length);
assertEquals(1, support.getVetoableChangeListeners().length);
}
示例13: testRemoveVetoableChangeListenerStringVetoableChangeListener_property_diff
import java.beans.VetoableChangeSupport; //导入依赖的package包/类
public void testRemoveVetoableChangeListenerStringVetoableChangeListener_property_diff() {
MockSource source = new MockSource();
VetoableChangeSupport support = new VetoableChangeSupport(source);
VetoableChangeListener proxy = EventHandler.create(
VetoableChangeListener.class, source, "setText");
VetoableChangeListener proxy2 = EventHandler.create(
VetoableChangeListener.class, source, "getText");
String propertyName = "label";
support.addVetoableChangeListener(propertyName, proxy);
support.addVetoableChangeListener(propertyName, proxy2);
assertTrue(support.hasListeners(propertyName));
assertEquals(2, support.getVetoableChangeListeners(propertyName).length);
support.removeVetoableChangeListener(propertyName, proxy);
assertTrue(support.hasListeners(propertyName));
assertEquals(1, support.getVetoableChangeListeners(propertyName).length);
assertEquals(1, support.getVetoableChangeListeners().length);
assertSame(proxy2, support.getVetoableChangeListeners(propertyName)[0]);
}
示例14: addVetoableChangeListener
import java.beans.VetoableChangeSupport; //导入依赖的package包/类
/**
* Adds a <code>VetoableChangeListener</code> to the listener list.
* The listener is registered for all properties.
*
* @param listener the <code>VetoableChangeListener</code> to be added
*/
public synchronized void addVetoableChangeListener(VetoableChangeListener listener) {
if (vetoableChangeSupport == null) {
vetoableChangeSupport = new java.beans.VetoableChangeSupport(this);
}
vetoableChangeSupport.addVetoableChangeListener(listener);
}
示例15: main
import java.beans.VetoableChangeSupport; //导入依赖的package包/类
public static void main(String[] args) throws PropertyVetoException {
TestEquals one = new TestEquals(1);
TestEquals two = new TestEquals(2);
Object source = TestEquals.class;
VetoableChangeSupport vcs = new VetoableChangeSupport(source);
vcs.addVetoableChangeListener(PROPERTY, one);
vcs.addVetoableChangeListener(PROPERTY, two);
PropertyChangeEvent event = new PropertyChangeEvent(source, PROPERTY, one, two);
vcs.fireVetoableChange(event);
test(one, two, 1); // only one check
vcs.fireVetoableChange(PROPERTY, one, two);
test(one, two, 2); // because it invokes fireVetoableChange(PropertyChangeEvent)
}