use of org.csstudio.opibuilder.widgets.model.AbstractChoiceModel.PROP_HORIZONTAL in project yamcs-studio by yamcs.
the class AbstractChoiceEditPart method registerPropertyChangeHandlers.
@Override
@SuppressWarnings("unchecked")
protected void registerPropertyChangeHandlers() {
setPropertyChangeHandler(PROP_PVNAME, (oldValue, newValue, figure) -> {
registerLoadItemsListener();
return false;
});
setPropertyChangeHandler(PROP_PVVALUE, (oldValue, newValue, refreshableFigure) -> {
if (newValue != null && newValue instanceof VType) {
var stringValue = VTypeHelper.getString((VType) newValue);
((AbstractChoiceFigure) refreshableFigure).setState(stringValue);
}
return false;
});
setPropertyChangeHandler(PROP_ITEMS, (oldValue, newValue, refreshableFigure) -> {
if (newValue != null && newValue instanceof List) {
((AbstractChoiceFigure) refreshableFigure).setStates(((List<String>) newValue));
if (getWidgetModel().isItemsFromPV()) {
((AbstractChoiceFigure) refreshableFigure).setState(VTypeHelper.getString(getPVValue(PROP_PVNAME)));
}
}
return true;
});
IWidgetPropertyChangeHandler selectedColorHandler = (oldValue, newValue, figure) -> {
((AbstractChoiceFigure) figure).setSelectedColor(((OPIColor) newValue).getSWTColor());
return false;
};
setPropertyChangeHandler(PROP_SELECTED_COLOR, selectedColorHandler);
setPropertyChangeHandler(PROP_HORIZONTAL, (oldValue, newValue, figure) -> {
((AbstractChoiceFigure) figure).setHorizontal((Boolean) newValue);
return true;
});
IWidgetPropertyChangeHandler handler = (oldValue, newValue, refreshableFigure) -> {
if (!(Boolean) newValue) {
((AbstractChoiceFigure) refreshableFigure).setStates((getWidgetModel().getItems()));
}
updatePropSheet((Boolean) newValue);
return false;
};
getWidgetModel().getProperty(PROP_ITEMS_FROM_PV).addPropertyChangeListener(evt -> handler.handleChange(evt.getOldValue(), evt.getNewValue(), getFigure()));
}
Aggregations