Example usage for java.beans PropertyChangeListenerProxy getPropertyName

List of usage examples for java.beans PropertyChangeListenerProxy getPropertyName

Introduction

In this page you can find the example usage for java.beans PropertyChangeListenerProxy getPropertyName.

Prototype

public String getPropertyName() 

Source Link

Document

Returns the name of the named property associated with the listener.

Usage

From source file:org.jtrfp.trcl.flow.IndirectProperty.java

private void connectAllTo(PROPERTY_TYPE tgt) {
    for (PropertyChangeListener l : targetPCS.getPropertyChangeListeners()) {
        if (l instanceof PropertyChangeListenerProxy) {
            final PropertyChangeListenerProxy proxy = (PropertyChangeListenerProxy) l;
            try {
                tgt.getClass()/*from  w  w w . j a va  2  s  . c  o m*/
                        .getMethod("addPropertyChangeListener", String.class, PropertyChangeListener.class)
                        .invoke(tgt, proxy.getPropertyName(), proxy);
            } catch (Exception e) {
                e.printStackTrace();
            }
        } else {
            try {
                tgt.getClass().getMethod("addPropertyChangeListener", PropertyChangeListener.class).invoke(tgt,
                        l);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    } //end for(listener)
}

From source file:org.jtrfp.trcl.flow.IndirectProperty.java

private void fireAllPropertiesChanged() {
    PROPERTY_TYPE target = this.target.get();
    if (target == null)
        return;/*  w  w w .  j  a v  a  2s .  co m*/
    HashSet<String> propertiesToFireChanged = new HashSet<String>();
    PropertyChangeListener[] listeners = targetPCS.getPropertyChangeListeners();
    for (PropertyChangeListener l : listeners) {
        if (l instanceof PropertyChangeListenerProxy) {
            final PropertyChangeListenerProxy prox = (PropertyChangeListenerProxy) l;
            propertiesToFireChanged.add(prox.getPropertyName());
        } //end if(...)
    } //end for(listener)
    for (String propertyName : propertiesToFireChanged) {
        try {
            targetPCS.firePropertyChange(propertyName, null, PropertyUtils.getProperty(target, propertyName));
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
    } //end for(propertyNames)
}