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());
}
Aggregations