Search in sources :

Example 61 with PropertyChangeEvent

use of java.beans.PropertyChangeEvent in project JMRI by JMRI.

the class IntTriggerTest method testPropertyChange.

@Test
public void testPropertyChange() {
    IntTrigger uut = new IntTrigger("unitUnderTest", 4, Trigger.CompareType.EQ);
    uut.setEventName("test event");
    uut.setMatchValue(2);
    uut.setCallback(new TriggerListener() {

        @Override
        public void takeAction() {
            Assert.assertTrue("callback called", true);
        }

        @Override
        public void takeAction(int i) {
            Assert.fail("wrong callback called");
        }

        @Override
        public void takeAction(float f) {
            Assert.fail("wrong callback called");
        }
    });
    uut.setCompareType(Trigger.CompareType.GT);
    PropertyChangeEvent e = new PropertyChangeEvent(this, "test event", Integer.valueOf(1), Integer.valueOf(3));
    uut.propertyChange(e);
    uut.setCompareType(Trigger.CompareType.LT);
    e = new PropertyChangeEvent(this, "test event", 3, 1);
    //new Integer(3), 
    //new Integer(1));
    uut.propertyChange(e);
    uut.setCompareType(Trigger.CompareType.GTE);
    e = new PropertyChangeEvent(this, "test event", Integer.valueOf(1), Integer.valueOf(2));
    uut.propertyChange(e);
    uut.setCompareType(Trigger.CompareType.LTE);
    e = new PropertyChangeEvent(this, "test event", Integer.valueOf(3), Integer.valueOf(2));
    uut.propertyChange(e);
    uut.setCompareType(Trigger.CompareType.EQ);
    e = new PropertyChangeEvent(this, "test event", Integer.valueOf(3), Integer.valueOf(2));
    uut.propertyChange(e);
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) Test(org.junit.Test)

Example 62 with PropertyChangeEvent

use of java.beans.PropertyChangeEvent in project JMRI by JMRI.

the class NotchTriggerTest method testPropertyChange.

@Test
public void testPropertyChange() {
    NotchTrigger uut = new NotchTrigger("unitUnderTest", 4, 5);
    uut.setEventName("test event");
    uut.setCallback(new TriggerListener() {

        @Override
        public void takeAction() {
            Assert.fail("wrong callback called");
        }

        @Override
        public void takeAction(int i) {
            Assert.assertTrue("callback called", true);
        }

        @Override
        public void takeAction(float f) {
            Assert.fail("wrong callback called");
        }
    });
    // 2/8 = 0.25
    uut.setNotch(2);
    PropertyChangeEvent e = new PropertyChangeEvent(this, "test event", 0.2f, 0.3f);
    uut.propertyChange(e);
    e = new PropertyChangeEvent(this, "test event", 0.3, 0.2);
    uut.propertyChange(e);
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) Test(org.junit.Test)

Example 63 with PropertyChangeEvent

use of java.beans.PropertyChangeEvent in project JMRI by JMRI.

the class BoolTriggerTest method testPropertyChange.

@Test
public void testPropertyChange() {
    BoolTrigger uut = new BoolTrigger("unitUnderTest", false);
    uut.setEventName("test event");
    uut.setMatchValue(true);
    uut.setCallback(new TriggerListener() {

        @Override
        public void takeAction() {
            Assert.assertTrue("callback called", true);
        }

        @Override
        public void takeAction(int i) {
            Assert.fail("wrong callback called");
        }

        @Override
        public void takeAction(float f) {
            Assert.fail("wrong callback called");
        }
    });
    PropertyChangeEvent e = new PropertyChangeEvent(this, "test event", Boolean.valueOf(false), Boolean.valueOf(true));
    uut.propertyChange(e);
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) Test(org.junit.Test)

Example 64 with PropertyChangeEvent

use of java.beans.PropertyChangeEvent in project JMRI by JMRI.

the class FloatTriggerTest method testPropertyChange.

@Test
public void testPropertyChange() {
    FloatTrigger uut = new FloatTrigger("unitUnderTest", 1.5f, Trigger.CompareType.EQ);
    uut.setEventName("test event");
    uut.setMatchValue(0.5f);
    uut.setCompareType(Trigger.CompareType.GT);
    uut.setCallback(new TriggerListener() {

        @Override
        public void takeAction() {
            Assert.assertTrue("callback called", true);
        }

        @Override
        public void takeAction(int i) {
            Assert.fail("wrong callback called");
        }

        @Override
        public void takeAction(float f) {
            Assert.fail("wrong callback called");
        }
    });
    PropertyChangeEvent e = new PropertyChangeEvent(this, "test event", new Float(1.0f), new Float(2.0f));
    uut.propertyChange(e);
    uut.setCompareType(Trigger.CompareType.LT);
    e = new PropertyChangeEvent(this, "test event", new Float(2.0f), new Float(1.0f));
    uut.propertyChange(e);
    uut.setCompareType(Trigger.CompareType.GTE);
    e = new PropertyChangeEvent(this, "test event", new Float(2.0f), new Float(0.5f));
    uut.propertyChange(e);
    uut.setCompareType(Trigger.CompareType.LTE);
    e = new PropertyChangeEvent(this, "test event", new Float(2.0f), new Float(0.5f));
    uut.propertyChange(e);
    uut.setCompareType(Trigger.CompareType.EQ);
    e = new PropertyChangeEvent(this, "test event", new Float(2.0f), new Float(0.5f));
    uut.propertyChange(e);
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) Test(org.junit.Test)

Example 65 with PropertyChangeEvent

use of java.beans.PropertyChangeEvent in project JMRI by JMRI.

the class AbstractThrottleTest method testRemovePropertyChangeListener.

/**
     * Test of removePropertyChangeListener method, of class AbstractThrottle.
     */
public void testRemovePropertyChangeListener() {
    PropertyChangeListener l = (PropertyChangeEvent evt) -> {
    };
    AbstractThrottle instance = new AbstractThrottleImpl();
    instance.removePropertyChangeListener(l);
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener)

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