Example usage for com.jgoodies.binding.beans BeanUtils addPropertyChangeListener

List of usage examples for com.jgoodies.binding.beans BeanUtils addPropertyChangeListener

Introduction

In this page you can find the example usage for com.jgoodies.binding.beans BeanUtils addPropertyChangeListener.

Prototype

public static void addPropertyChangeListener(Object bean, String propertyName,
        PropertyChangeListener listener) 

Source Link

Document

Adds a named property change listener to the given bean.

Usage

From source file:org.mbari.aved.ui.classifier.swing.FilePropertyAdapter.java

License:Open Source License

public FilePropertyAdapter(Object bean, String propertyName) {
    super();/*from   ww w .j a v a  2s. c om*/
    this.bean = bean;

    try {
        descriptor = BeanUtils.getPropertyDescriptor(bean.getClass(), propertyName);

        if (!descriptor.getPropertyType().equals(File.class)) {
            throw new IllegalArgumentException("Property must be of type File"); // $NON-NLS-1$
        }
    } catch (IntrospectionException e) {

        // Do nothing, hope for the best
    }

    BeanUtils.addPropertyChangeListener(bean, propertyName, new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent arg0) {
            String oldValue = null, newValue = null;

            if (arg0.getOldValue() != null) {
                oldValue = ((File) arg0.getOldValue()).getAbsolutePath();
            }

            if (arg0.getNewValue() != null) {
                newValue = ((File) arg0.getNewValue()).getAbsolutePath();
            }

            fireValueChange(oldValue, newValue);
        }
    });
}

From source file:org.mbari.aved.ui.classifier.swing.StringValueModel.java

License:Open Source License

public StringValueModel(Object bean, String propertyName) {
    super();// w w w . ja  v a2 s.co  m
    this.bean = bean;

    try {
        descriptor = BeanUtils.getPropertyDescriptor(bean.getClass(), propertyName);

        if (!descriptor.getPropertyType().equals(String.class)) {
            throw new IllegalArgumentException("Property must be of type String"); // $NON-NLS-1$
        }
    } catch (IntrospectionException e) {

        // Do nothing, hope for the best
    }

    BeanUtils.addPropertyChangeListener(bean, propertyName, new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent arg0) {
            String oldValue = null, newValue = null;

            oldValue = (String) arg0.getOldValue();
            newValue = (String) arg0.getNewValue();
            fireValueChange(oldValue, newValue);
        }
    });
}

From source file:org.seasar.golf.binding.GolfBindingUtil.java

License:Apache License

public static void bindTableRowColumn(TableBindHandler rowBindHandler, GolfTableModel golfTableModel,
        String field, String columnName) {
    ValueHolder vh = (ValueHolder) golfTableModel.getFormValidationManager().getFormManager()
            .getFormBindingManager().getValueModel(field);
    rowBindHandler.addSrcAndColumn(vh, columnName);
    BeanUtils.addPropertyChangeListener(vh, ValueHolder.class, rowBindHandler);

}