Search in sources :

Example 86 with PropertyChangeEvent

use of java.beans.PropertyChangeEvent in project jdk8u_jdk by JetBrains.

the class TestMethods method main.

public static void main(String[] args) throws PropertyVetoException {
    Object source = new Object();
    new TestMethods(source).fireVetoableChange(new PropertyChangeEvent(source, NAME, null, null));
    new TestMethods(source).fireVetoableChange(NAME, null, null);
    new TestMethods(source).fireVetoableChange(NAME, 0, 1);
    new TestMethods(source).fireVetoableChange(NAME, true, false);
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent)

Example 87 with PropertyChangeEvent

use of java.beans.PropertyChangeEvent in project jdk8u_jdk by JetBrains.

the class TestSynchronization method main.

public static void main(String[] args) throws PropertyVetoException {
    final VetoableChangeSupport vcs = new VetoableChangeSupport(TestSynchronization.class);
    vcs.addVetoableChangeListener("name", new VetoableChangeListener() {

        public void vetoableChange(PropertyChangeEvent event) {
            isCalled = true;
        }
    });
    vcs.addVetoableChangeListener(new VetoableChangeListener() {

        public void vetoableChange(PropertyChangeEvent event) {
            for (VetoableChangeListener listener : vcs.getVetoableChangeListeners()) vcs.removeVetoableChangeListener(listener);
        }
    });
    vcs.fireVetoableChange("name", null, null);
    if (!isCalled)
        throw new Error("test failed");
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) VetoableChangeSupport(java.beans.VetoableChangeSupport) VetoableChangeListener(java.beans.VetoableChangeListener)

Example 88 with PropertyChangeEvent

use of java.beans.PropertyChangeEvent in project geode by apache.

the class TestSessionsTomcat8Base method testSessionExpiration2.

/**
   * Test setting the session expiration via a property change as would happen under normal
   * deployment conditions.
   */
@Test
public void testSessionExpiration2() throws Exception {
    // TestSessions only live for a minute
    sessionManager.propertyChange(new PropertyChangeEvent(server.getRootContext(), "sessionTimeout", new Integer(30), new Integer(1)));
    // Check that the value has been set to 60 seconds
    assertEquals(60, sessionManager.getMaxInactiveInterval());
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) Test(org.junit.Test)

Example 89 with PropertyChangeEvent

use of java.beans.PropertyChangeEvent in project processdash by dtuma.

the class DefaultTimeLoggingModelTest method testBoundaryConditions.

public void testBoundaryConditions() {
    // stop the timer when it is already stopped.  Should have no effect.
    timeLoggingModel.setPaused(true);
    assertTrue(eventsReceived.isEmpty());
    // log some time to get the model in a common state for normal
    // dashboard operation
    setPath(PATH1, null, null);
    startTiming();
    setStopwatch(6, 0);
    expectTime(PATH1, 6);
    MutableTimeLogEntry tle = new MutableTimeLogEntryVO(1, PATH1, timeLoggingModel.stopwatch.getCreateTime(), 6, 0, null, ChangeFlagged.ADDED);
    assertTimeLogEvent(tle);
    stopTiming();
    eventsReceived.clear();
    // "change" the active task model to exercise listener registration
    timeLoggingModel.setActiveTaskModel(activeTaskModel);
    // since the active task is still the same, no changes should have been
    // received
    assertTrue(eventsReceived.isEmpty());
    // disconnect the active task model, and make certain we no longer
    // respond to its changes
    timeLoggingModel.setActiveTaskModel(null);
    assertNull(timeLoggingModel.getActiveTaskModel());
    assertTrue(activeTaskModel.setPath(PATH2));
    assertTrue(eventsReceived.isEmpty());
    // check that disconnecting our listener to the timeLoggingModel
    // causes us no longer to receive events
    timeLoggingModel.setRecentPaths(new LinkedList());
    assertPropertyChangeEvent(timeLoggingModel, TimeLoggingModel.RECENT_PATHS_PROPERTY, null, null);
    timeLoggingModel.removePropertyChangeListener(this);
    timeLoggingModel.setRecentPaths(Collections.singletonList("foo"));
    assertTrue(eventsReceived.isEmpty());
    // send a nonsense, unrelated property change event and make certain
    // it gets ignored
    PropertyChangeEvent pce = new PropertyChangeEvent(this, "foo", "bar", "baz");
    timeLoggingModel.externalChangeListener.propertyChange(pce);
    assertTrue(eventsReceived.isEmpty());
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) LinkedList(java.util.LinkedList)

Example 90 with PropertyChangeEvent

use of java.beans.PropertyChangeEvent in project processdash by dtuma.

the class TimeLogEntryTest method assertPropertyChange.

private void assertPropertyChange(Object source, String propName, Object oldVal, Object newVal) {
    assertFalse(eventsReceived.isEmpty());
    Object obj = eventsReceived.remove(0);
    assertTrue(obj instanceof PropertyChangeEvent);
    PropertyChangeEvent evt = (PropertyChangeEvent) obj;
    assertEquals(source, evt.getSource());
    assertEquals(propName, evt.getPropertyName());
    assertEquals(oldVal, evt.getOldValue());
    assertEquals(newVal, evt.getNewValue());
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent)

Aggregations

PropertyChangeEvent (java.beans.PropertyChangeEvent)589 PropertyChangeListener (java.beans.PropertyChangeListener)375 ActionEvent (java.awt.event.ActionEvent)42 ActionListener (java.awt.event.ActionListener)35 JPanel (javax.swing.JPanel)35 Test (org.junit.Test)33 ArrayList (java.util.ArrayList)30 IWidgetPropertyChangeHandler (org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler)27 IFigure (org.eclipse.draw2d.IFigure)25 File (java.io.File)24 JLabel (javax.swing.JLabel)24 BorderLayout (java.awt.BorderLayout)22 List (java.util.List)21 IOException (java.io.IOException)19 Dimension (java.awt.Dimension)16 ChangeEvent (javax.swing.event.ChangeEvent)15 PropertyVetoException (java.beans.PropertyVetoException)14 PropertyChangeSupport (java.beans.PropertyChangeSupport)13 ChangeListener (javax.swing.event.ChangeListener)13 UnprocessedChangeEvents (org.jvnet.hk2.config.UnprocessedChangeEvents)13