Java Code Examples for java.beans.VetoableChangeSupport#fireVetoableChange()
The following examples show how to use
java.beans.VetoableChangeSupport#fireVetoableChange() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Test6630275.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
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"); }
Example 2
Source File: Test4425885.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
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"); }
Example 3
Source File: Test6630275.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
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"); }
Example 4
Source File: Test4425885.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
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"); }
Example 5
Source File: Test4425885.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
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"); }
Example 6
Source File: Test4425885.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
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"); }
Example 7
Source File: Test4425885.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
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"); }
Example 8
Source File: Test4425885.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
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"); }
Example 9
Source File: Test4425885.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
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"); }
Example 10
Source File: Test6630275.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
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"); }
Example 11
Source File: TestEquals.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
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) }
Example 12
Source File: TestEquals.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
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) }
Example 13
Source File: Bean.java From LGoodDatePicker with MIT License | 5 votes |
/** * Support for reporting changes for constrained integer properties. This method can be called * before a constrained property will be changed and it will send the appropriate * PropertyChangeEvent to any registered VetoableChangeListeners. * * @param propertyName the property whose value has changed * @param oldValue the property's previous value * @param newValue the property's new value * @throws PropertyVetoException if a constrained property change is rejected */ protected final void fireVetoableChange(String propertyName, int oldValue, int newValue) throws PropertyVetoException { VetoableChangeSupport aVetoSupport = this.vetoSupport; if (aVetoSupport == null) { return; } aVetoSupport.fireVetoableChange(propertyName, Integer.valueOf(oldValue), Integer.valueOf(newValue)); }
Example 14
Source File: TestEquals.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
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) }
Example 15
Source File: TestListeners.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
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); }
Example 16
Source File: TestListeners.java From hottub with GNU General Public License v2.0 | 4 votes |
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); }
Example 17
Source File: KeyboardFocusManager.java From jdk8u60 with GNU General Public License v2.0 | 3 votes |
/** * Fires a PropertyChangeEvent in response to a change in a vetoable * property. The event will be delivered to all registered * VetoableChangeListeners. If a VetoableChangeListener throws a * PropertyVetoException, a new event is fired reverting all * VetoableChangeListeners to the old value and the exception is then * rethrown. No event will be delivered if oldValue and newValue are the * same. * * @param propertyName the name of the property that has changed * @param oldValue the property's previous value * @param newValue the property's new value * @throws java.beans.PropertyVetoException if a * <code>VetoableChangeListener</code> threw * <code>PropertyVetoException</code> */ protected void fireVetoableChange(String propertyName, Object oldValue, Object newValue) throws PropertyVetoException { if (oldValue == newValue) { return; } VetoableChangeSupport vetoableSupport = this.vetoableSupport; if (vetoableSupport != null) { vetoableSupport.fireVetoableChange(propertyName, oldValue, newValue); } }
Example 18
Source File: KeyboardFocusManager.java From jdk1.8-source-analysis with Apache License 2.0 | 3 votes |
/** * Fires a PropertyChangeEvent in response to a change in a vetoable * property. The event will be delivered to all registered * VetoableChangeListeners. If a VetoableChangeListener throws a * PropertyVetoException, a new event is fired reverting all * VetoableChangeListeners to the old value and the exception is then * rethrown. No event will be delivered if oldValue and newValue are the * same. * * @param propertyName the name of the property that has changed * @param oldValue the property's previous value * @param newValue the property's new value * @throws java.beans.PropertyVetoException if a * <code>VetoableChangeListener</code> threw * <code>PropertyVetoException</code> */ protected void fireVetoableChange(String propertyName, Object oldValue, Object newValue) throws PropertyVetoException { if (oldValue == newValue) { return; } VetoableChangeSupport vetoableSupport = this.vetoableSupport; if (vetoableSupport != null) { vetoableSupport.fireVetoableChange(propertyName, oldValue, newValue); } }
Example 19
Source File: KeyboardFocusManager.java From JDKSourceCode1.8 with MIT License | 3 votes |
/** * Fires a PropertyChangeEvent in response to a change in a vetoable * property. The event will be delivered to all registered * VetoableChangeListeners. If a VetoableChangeListener throws a * PropertyVetoException, a new event is fired reverting all * VetoableChangeListeners to the old value and the exception is then * rethrown. No event will be delivered if oldValue and newValue are the * same. * * @param propertyName the name of the property that has changed * @param oldValue the property's previous value * @param newValue the property's new value * @throws java.beans.PropertyVetoException if a * <code>VetoableChangeListener</code> threw * <code>PropertyVetoException</code> */ protected void fireVetoableChange(String propertyName, Object oldValue, Object newValue) throws PropertyVetoException { if (oldValue == newValue) { return; } VetoableChangeSupport vetoableSupport = this.vetoableSupport; if (vetoableSupport != null) { vetoableSupport.fireVetoableChange(propertyName, oldValue, newValue); } }
Example 20
Source File: KeyboardFocusManager.java From jdk8u_jdk with GNU General Public License v2.0 | 3 votes |
/** * Fires a PropertyChangeEvent in response to a change in a vetoable * property. The event will be delivered to all registered * VetoableChangeListeners. If a VetoableChangeListener throws a * PropertyVetoException, a new event is fired reverting all * VetoableChangeListeners to the old value and the exception is then * rethrown. No event will be delivered if oldValue and newValue are the * same. * * @param propertyName the name of the property that has changed * @param oldValue the property's previous value * @param newValue the property's new value * @throws java.beans.PropertyVetoException if a * <code>VetoableChangeListener</code> threw * <code>PropertyVetoException</code> */ protected void fireVetoableChange(String propertyName, Object oldValue, Object newValue) throws PropertyVetoException { if (oldValue == newValue) { return; } VetoableChangeSupport vetoableSupport = this.vetoableSupport; if (vetoableSupport != null) { vetoableSupport.fireVetoableChange(propertyName, oldValue, newValue); } }