java.beans.VetoableChangeSupport Java Examples

The following examples show how to use java.beans.VetoableChangeSupport. 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: Test4425885.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
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 #2
Source File: Test6630275.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
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 #3
Source File: Test6630275.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
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 openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
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 openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
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: Test6630275.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
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 #7
Source File: Test4425885.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
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: Test6630275.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
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 #9
Source File: Test4425885.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
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: Test4425885.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
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 #11
Source File: Test4425885.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
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 #12
Source File: Test4425885.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
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 #13
Source File: Test4076065.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    try {
        new VetoableChangeSupport(null);
    } catch (NullPointerException exception) {
        return;
    }
    throw new Error("didn't get expected NullPointerException");
}
 
Example #14
Source File: TestEquals.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
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: AbstractBean.java    From pgptool with GNU General Public License v3.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public Object clone() throws CloneNotSupportedException {
	AbstractBean result = (AbstractBean) super.clone();
	result.pcs = new PropertyChangeSupport(result);
	result.vcs = new VetoableChangeSupport(result);
	return result;
}
 
Example #16
Source File: TestSerialization.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static void check(VetoableChangeSupport vcs) {
    VetoableChangeListener[] namedListeners = vcs.getVetoableChangeListeners(NAME);
    check(namedListeners, 1);
    check(namedListeners[0], 1);

    VetoableChangeListener[] allListeners = vcs.getVetoableChangeListeners();
    check(allListeners, 2);
    check(allListeners[0], 0);
    check(allListeners[1], 1, NAME);
}
 
Example #17
Source File: Test4076065.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    try {
        new VetoableChangeSupport(null);
    } catch (NullPointerException exception) {
        return;
    }
    throw new Error("didn't get expected NullPointerException");
}
 
Example #18
Source File: TestEquals.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
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 #19
Source File: TestEquals.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
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 #20
Source File: Series.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates a new series with the specified key and description.
 *
 * @param key  the series key (<code>null</code> NOT permitted).
 * @param description  the series description (<code>null</code> permitted).
 */
protected Series(Comparable key, String description) {
    ParamChecks.nullNotPermitted(key, "key");
    this.key = key;
    this.description = description;
    this.listeners = new EventListenerList();
    this.propertyChangeSupport = new PropertyChangeSupport(this);
    this.vetoableChangeSupport = new VetoableChangeSupport(this);
    this.notify = true;
}
 
Example #21
Source File: Series.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a new series with the specified key and description.
 *
 * @param key  the series key (<code>null</code> NOT permitted).
 * @param description  the series description (<code>null</code> permitted).
 */
protected Series(Comparable key, String description) {
    ParamChecks.nullNotPermitted(key, "key");
    this.key = key;
    this.description = description;
    this.listeners = new EventListenerList();
    this.propertyChangeSupport = new PropertyChangeSupport(this);
    this.vetoableChangeSupport = new VetoableChangeSupport(this);
    this.notify = true;
}
 
Example #22
Source File: TestEquals.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
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 #23
Source File: Test4076065.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    try {
        new VetoableChangeSupport(null);
    } catch (NullPointerException exception) {
        return;
    }
    throw new Error("didn't get expected NullPointerException");
}
 
Example #24
Source File: TestSerialization.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private static void check(VetoableChangeSupport vcs) {
    VetoableChangeListener[] namedListeners = vcs.getVetoableChangeListeners(NAME);
    check(namedListeners, 1);
    check(namedListeners[0], 1);

    VetoableChangeListener[] allListeners = vcs.getVetoableChangeListeners();
    check(allListeners, 2);
    check(allListeners[0], 0);
    check(allListeners[1], 1, NAME);
}
 
Example #25
Source File: TestEquals.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
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 #26
Source File: TestEquals.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
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 #27
Source File: Test4076065.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    try {
        new VetoableChangeSupport(null);
    } catch (NullPointerException exception) {
        return;
    }
    throw new Error("didn't get expected NullPointerException");
}
 
Example #28
Source File: TestSerialization.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private static void check(VetoableChangeSupport vcs) {
    VetoableChangeListener[] namedListeners = vcs.getVetoableChangeListeners(NAME);
    check(namedListeners, 1);
    check(namedListeners[0], 1);

    VetoableChangeListener[] allListeners = vcs.getVetoableChangeListeners();
    check(allListeners, 2);
    check(allListeners[0], 0);
    check(allListeners[1], 1, NAME);
}
 
Example #29
Source File: TestEquals.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
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 #30
Source File: Test4076065.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    try {
        new VetoableChangeSupport(null);
    } catch (NullPointerException exception) {
        return;
    }
    throw new Error("didn't get expected NullPointerException");
}