Search in sources :

Example 76 with PropertyChangeListener

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

the class AbstractNamedBean method getListenerRefs.

/**
     * Get a meaningful list of places where the bean is in use.
     *
     * @return ArrayList of the listeners
     */
@Override
public synchronized ArrayList<String> getListenerRefs() {
    ArrayList<String> list = new ArrayList<String>();
    Enumeration<PropertyChangeListener> en = listenerRefs.keys();
    while (en.hasMoreElements()) {
        PropertyChangeListener l = en.nextElement();
        list.add(listenerRefs.get(l));
    }
    return list;
}
Also used : PropertyChangeListener(java.beans.PropertyChangeListener) ArrayList(java.util.ArrayList)

Example 77 with PropertyChangeListener

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

the class Test4985020 method main.

public static void main(String[] args) {
    PropertyChangeSupport pcs = new PropertyChangeSupport(args);
    VetoableChangeSupport vcs = new VetoableChangeSupport(args);
    Test4985020 listener = new Test4985020();
    //PropertyChangeSupport.addPropertyChangeListener(null, listener)
    System.out.println("PropertyChangeSupport.addPropertyChangeListener(null, listener)");
    try {
        pcs.addPropertyChangeListener(null, listener);
        pcs.firePropertyChange(NAME, null, null);
    } catch (Throwable error) {
        print(error);
    }
    //PropertyChangeSupport.removePropertyChangeListener(null, listener)
    System.out.println("PropertyChangeSupport.removePropertyChangeListener(null, listener)");
    try {
        pcs.removePropertyChangeListener(null, listener);
        pcs.firePropertyChange(NAME, null, null);
    } catch (Throwable error) {
        print(error);
    }
    //PropertyChangeSupport.getPropertyChangeListeners(null)
    System.out.println("PropertyChangeSupport.getPropertyChangeListeners(null)");
    try {
        PropertyChangeListener[] pcls = pcs.getPropertyChangeListeners(null);
        if (pcls == null) {
            throw new Error("getPropertyChangeListener() returned null");
        }
        if (pcls.length != 0) {
            throw new Error("getPropertyChangeListener() did not return an empty array");
        }
    } catch (Throwable error) {
        print(error);
    }
    //PropertyChangeSupport.hasListeners(null)
    System.out.println("PropertyChangeSupport.hasListeners(null)");
    try {
        pcs.hasListeners(null);
    } catch (Throwable error) {
        print(error);
    }
    //PropertyChangeSupport.hasListeners(null): with a generic listener
    System.out.println("PropertyChangeSupport.hasListeners(null) with a generic listener");
    try {
        pcs.addPropertyChangeListener(listener);
        if (!pcs.hasListeners(null)) {
            throw new Error("hasListeners(null) returned false, but there was a generic listener");
        }
    } catch (Throwable error) {
        print(error);
    }
    // reset
    pcs = new PropertyChangeSupport(args);
    //PropertyChangeSupport.hasListeners(null): with a specific listener
    System.out.println("PropertyChangeSupport.hasListeners(null) with a specific listener");
    try {
        pcs.addPropertyChangeListener(NAME, listener);
        if (pcs.hasListeners(null)) {
            throw new Error("hasListeners(null) returned true, but there were no generic listeners - only a specific listener");
        }
    } catch (Throwable error) {
        print(error);
    }
    //VetoableChangeSupport.addVetoableChangeListener(null, listener)
    System.out.println("VetoableChangeSupport.addVetoableChangeListener(null, listener)");
    try {
        vcs.addVetoableChangeListener(null, listener);
        vcs.fireVetoableChange(NAME, null, null);
    } catch (Throwable error) {
        print(error);
    }
    //VetoableChangeSupport.removeVetoableChangeListener(null, listener)
    System.out.println("VetoableChangeSupport.removeVetoableChangeListener(null, listener)");
    try {
        vcs.removeVetoableChangeListener(null, listener);
        vcs.fireVetoableChange(NAME, null, null);
    } catch (Throwable error) {
        print(error);
    }
    //VetoableChangeSupport.getVetoableChangeListeners(null)
    System.out.println("VetoableChangeSupport.getVetoableChangeListeners(null)");
    try {
        VetoableChangeListener[] pcls = vcs.getVetoableChangeListeners(null);
        if (pcls == null) {
            throw new Error("getVetoableChangeListener() returned null");
        }
        if (pcls.length != 0) {
            throw new Error("getVetoableChangeListener() did not return an empty array");
        }
    } catch (Throwable error) {
        print(error);
    }
    //VetoableChangeSupport.hasListeners(null)
    System.out.println("VetoableChangeSupport.hasListeners(null)");
    try {
        boolean result = vcs.hasListeners(null);
    } catch (Throwable error) {
        print(error);
    }
    //VetoableChangeSupport.hasListeners(null): with a generic listener
    System.out.println("VetoableChangeSupport.hasListeners(null) with a generic listener");
    try {
        vcs.addVetoableChangeListener(listener);
        if (!vcs.hasListeners(null)) {
            throw new Error("hasListeners(null) returned false, but there was a generic listener");
        }
    } catch (Throwable error) {
        print(error);
    }
    // reset
    vcs = new VetoableChangeSupport(args);
    //VetoableChangeSupport.hasListeners(null): with a specific listener
    System.out.println("VetoableChangeSupport.hasListeners(null) with a specific listener");
    try {
        vcs.addVetoableChangeListener(NAME, listener);
        if (vcs.hasListeners(null)) {
            throw new Error("hasListeners(null) returned true, but there were no generic listeners - only a specific listener");
        }
    } catch (Throwable error) {
        print(error);
    }
    if (failed) {
        throw new Error("TEST FAILED");
    }
}
Also used : PropertyChangeListener(java.beans.PropertyChangeListener) VetoableChangeSupport(java.beans.VetoableChangeSupport) PropertyChangeSupport(java.beans.PropertyChangeSupport) VetoableChangeListener(java.beans.VetoableChangeListener)

Example 78 with PropertyChangeListener

use of java.beans.PropertyChangeListener in project cayenne by apache.

the class TemplateCreator method initBindings.

protected void initBindings() {
    BindingBuilder builder = new BindingBuilder(getApplication().getBindingFactory(), this);
    builder.bindToAction(view.getCancelButton(), "cancelAction()");
    builder.bindToAction(view.getOkButton(), "okAction()");
    final FSPath path = getLastTemplateDirectory();
    view.getTemplateChooser().setCurrentDirectory(path.getExistingDirectory(false));
    view.getTemplateChooser().addPropertyChangeListener(FileChooser.CURRENT_DIRECTORY_PROPERTY, new PropertyChangeListener() {

        public void propertyChange(PropertyChangeEvent evt) {
            File directory = view.getTemplateChooser().getCurrentDirectory();
            path.setDirectory(directory);
        }
    });
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener) BindingBuilder(org.apache.cayenne.swing.BindingBuilder) FSPath(org.apache.cayenne.modeler.pref.FSPath) File(java.io.File)

Example 79 with PropertyChangeListener

use of java.beans.PropertyChangeListener in project cayenne by apache.

the class ComponentGeometry method bindIntProperty.

/**
 * Binds this preference object to synchronize its state with a given component
 * property.
 */
public void bindIntProperty(final Component component, final String property, int defaultValue) {
    updateIntProperty(component, property, defaultValue);
    component.addPropertyChangeListener(property, new PropertyChangeListener() {

        public void propertyChange(PropertyChangeEvent e) {
            Object value = e.getNewValue();
            getPreference().put(property, value != null ? value.toString() : null);
        }
    });
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener)

Example 80 with PropertyChangeListener

use of java.beans.PropertyChangeListener in project gradle by gradle.

the class AbstractTask method getActions.

@Override
public List<Action<? super Task>> getActions() {
    if (observableActionList == null) {
        observableActionList = new ObservableActionWrapperList(getTaskActions());
        observableActionList.addPropertyChangeListener(new PropertyChangeListener() {

            public void propertyChange(PropertyChangeEvent evt) {
                taskMutator.assertMutable("Task.getActions()", evt);
            }
        });
    }
    return observableActionList;
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener)

Aggregations

PropertyChangeListener (java.beans.PropertyChangeListener)228 PropertyChangeEvent (java.beans.PropertyChangeEvent)197 ActionEvent (java.awt.event.ActionEvent)27 IWidgetPropertyChangeHandler (org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler)27 ActionListener (java.awt.event.ActionListener)26 IFigure (org.eclipse.draw2d.IFigure)25 JPanel (javax.swing.JPanel)21 ArrayList (java.util.ArrayList)16 JLabel (javax.swing.JLabel)13 BorderLayout (java.awt.BorderLayout)12 Dimension (java.awt.Dimension)12 JButton (javax.swing.JButton)12 BoxLayout (javax.swing.BoxLayout)10 GridData (org.eclipse.swt.layout.GridData)10 GridLayout (org.eclipse.swt.layout.GridLayout)10 File (java.io.File)9 Composite (org.eclipse.swt.widgets.Composite)9 Test (org.junit.Test)9 IOException (java.io.IOException)8 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)8