use of org.csstudio.opibuilder.widgets.model.AbstractBoolWidgetModel.PROP_BOOL_LABEL_POS in project yamcs-studio by yamcs.
the class AbstractBoolEditPart method registerCommonPropertyChangeHandlers.
/**
* Registers property change handlers for the properties defined in {@link AbstractBoolWidgetModel}. This method is
* provided for the convenience of subclasses, which can call this method in their implementation of
* {@link #registerPropertyChangeHandlers()}.
*/
protected void registerCommonPropertyChangeHandlers() {
setPropertyChangeHandler(PROP_PVVALUE, (oldValue, newValue, refreshableFigure) -> {
if (newValue == null || !(newValue instanceof VType)) {
return false;
}
var figure = (AbstractBoolFigure) refreshableFigure;
switch(VTypeHelper.getBasicDataType((VType) newValue)) {
case SHORT:
figure.setTotalBits(TotalBits.BITS_16);
break;
case INT:
case ENUM:
figure.setTotalBits(TotalBits.BITS_32);
break;
default:
break;
}
updateFromValue((VType) newValue, figure);
return true;
});
setPropertyChangeHandler(PROP_BIT, (oldValue, newValue, refreshableFigure) -> {
if (getWidgetModel().getDataType() != 0) {
return false;
}
var figure = (AbstractBoolFigure) refreshableFigure;
figure.setBit((Integer) newValue);
updateFromValue(getPVValue(PROP_PVNAME), figure);
return true;
});
IWidgetPropertyChangeHandler dataTypeHandler = (oldValue, newValue, refreshableFigure) -> {
var figure = (AbstractBoolFigure) refreshableFigure;
if ((Integer) newValue == 0) {
figure.setBit(getWidgetModel().getBit());
} else {
figure.setBit(-1);
}
updateFromValue(getPVValue(PROP_PVNAME), figure);
updatePropSheet((Integer) newValue);
return true;
};
getWidgetModel().getProperty(PROP_DATA_TYPE).addPropertyChangeListener(evt -> dataTypeHandler.handleChange(evt.getOldValue(), evt.getNewValue(), getFigure()));
setPropertyChangeHandler(PROP_ON_STATE, (oldValue, newValue, refreshableFigure) -> {
var figure = (AbstractBoolFigure) refreshableFigure;
updateFromValue(getPVValue(PROP_PVNAME), figure);
return true;
});
setPropertyChangeHandler(PROP_SHOW_BOOL_LABEL, (oldValue, newValue, refreshableFigure) -> {
var figure = (AbstractBoolFigure) refreshableFigure;
figure.setShowBooleanLabel((Boolean) newValue);
return true;
});
setPropertyChangeHandler(PROP_BOOL_LABEL_POS, (oldValue, newValue, refreshableFigure) -> {
var figure = (AbstractBoolFigure) refreshableFigure;
figure.setBoolLabelPosition(BoolLabelPosition.values()[(Integer) newValue]);
return false;
});
setPropertyChangeHandler(PROP_ON_LABEL, (oldValue, newValue, refreshableFigure) -> {
var figure = (AbstractBoolFigure) refreshableFigure;
figure.setOnLabel((String) newValue);
return true;
});
setPropertyChangeHandler(PROP_OFF_LABEL, (oldValue, newValue, refreshableFigure) -> {
var figure = (AbstractBoolFigure) refreshableFigure;
figure.setOffLabel((String) newValue);
return true;
});
setPropertyChangeHandler(PROP_ON_COLOR, (oldValue, newValue, refreshableFigure) -> {
var figure = (AbstractBoolFigure) refreshableFigure;
figure.setOnColor(((OPIColor) newValue).getSWTColor());
return true;
});
setPropertyChangeHandler(PROP_OFF_COLOR, (oldValue, newValue, refreshableFigure) -> {
var figure = (AbstractBoolFigure) refreshableFigure;
figure.setOffColor(((OPIColor) newValue).getSWTColor());
return true;
});
}
Aggregations