Search in sources :

Example 1 with IChangeListener

use of org.jowidgets.util.event.IChangeListener in project jo-client-platform by jo-source.

the class BeanTableHeaderFormatMenuModel method addRadioItemListener.

private static void addRadioItemListener(final IRadioItemModel radioItemModel, final IAttribute<?> attribute, final DisplayFormat displayFormat) {
    final ValueHolder<IItemStateListener> itemStateListenerHolder = new ValueHolder<IItemStateListener>();
    final ValueHolder<IChangeListener> changeListenerHolder = new ValueHolder<IChangeListener>();
    itemStateListenerHolder.set(new IItemStateListener() {

        @Override
        public void itemStateChanged() {
            if (!attribute.getLabelDisplayFormat().equals(displayFormat) && radioItemModel.isSelected()) {
                attribute.removeChangeListener(changeListenerHolder.get());
                attribute.setLabelDisplayFormat(displayFormat);
                attribute.addChangeListener(changeListenerHolder.get());
            }
        }
    });
    changeListenerHolder.set(new IChangeListener() {

        @Override
        public void changed() {
            if (attribute.getLabelDisplayFormat().equals(displayFormat) && !radioItemModel.isSelected()) {
                radioItemModel.removeItemListener(itemStateListenerHolder.get());
                radioItemModel.setSelected(true);
                radioItemModel.addItemListener(itemStateListenerHolder.get());
            }
        }
    });
    radioItemModel.addItemListener(itemStateListenerHolder.get());
    attribute.addChangeListener(changeListenerHolder.get());
}
Also used : IChangeListener(org.jowidgets.util.event.IChangeListener) IItemStateListener(org.jowidgets.common.widgets.controller.IItemStateListener) ValueHolder(org.jowidgets.util.ValueHolder)

Aggregations

IItemStateListener (org.jowidgets.common.widgets.controller.IItemStateListener)1 ValueHolder (org.jowidgets.util.ValueHolder)1 IChangeListener (org.jowidgets.util.event.IChangeListener)1