use of org.csstudio.opibuilder.widgets.model.LEDModel.PROP_STATE_FALLBACK_COLOR in project yamcs-studio by yamcs.
the class LEDEditPart method registerPropertyChangeHandlers.
@Override
protected void registerPropertyChangeHandlers() {
registerCommonPropertyChangeHandlers();
setPropertyChangeHandler(PROP_EFFECT3D, (oldValue, newValue, refreshableFigure) -> {
var led = (LEDFigure) refreshableFigure;
led.setEffect3D((Boolean) newValue);
return true;
});
setPropertyChangeHandler(PROP_SQUARE_LED, (oldValue, newValue, refreshableFigure) -> {
var led = (LEDFigure) refreshableFigure;
led.setSquareLED((Boolean) newValue);
if (!(Boolean) newValue) {
var width = Math.min(getWidgetModel().getWidth(), getWidgetModel().getHeight());
getWidgetModel().setSize(width, width);
}
return true;
});
// force square size
IWidgetPropertyChangeHandler sizeHandler = (oldValue, newValue, figure) -> {
if (getWidgetModel().isSquareLED()) {
return false;
}
if (((Integer) newValue) < LEDModel.MINIMUM_SIZE) {
newValue = LEDModel.MINIMUM_SIZE;
}
getWidgetModel().setSize((Integer) newValue, (Integer) newValue);
return false;
};
PropertyChangeListener sizeListener = evt -> sizeHandler.handleChange(evt.getOldValue(), evt.getNewValue(), getFigure());
getWidgetModel().getProperty(PROP_WIDTH).addPropertyChangeListener(sizeListener);
getWidgetModel().getProperty(PROP_HEIGHT).addPropertyChangeListener(sizeListener);
getWidgetModel().getProperty(PROP_NSTATES).addPropertyChangeListener(evt -> initializeNStatesProperties((Integer) evt.getOldValue(), (Integer) evt.getNewValue(), (LEDFigure) getFigure(), getWidgetModel()));
getWidgetModel().getProperty(PROP_STATE_FALLBACK_LABEL).addPropertyChangeListener(evt -> initializeStateFallbackLabel((String) evt.getOldValue(), (String) evt.getNewValue(), (LEDFigure) getFigure(), getWidgetModel()));
getWidgetModel().getProperty(PROP_STATE_FALLBACK_COLOR).addPropertyChangeListener(evt -> initializeStateFallbackColor(((OPIColor) evt.getOldValue()).getSWTColor(), ((OPIColor) evt.getNewValue()).getSWTColor(), (LEDFigure) getFigure(), getWidgetModel()));
getWidgetModel().getProperty(PROP_BULB_BORDER).addPropertyChangeListener(evt -> initializeStateBulbBorderWidth((Integer) evt.getNewValue(), (LEDFigure) getFigure(), getWidgetModel()));
getWidgetModel().getProperty(PROP_BULB_BORDER_COLOR).addPropertyChangeListener(evt -> initializeStateBulbBorderColor(((OPIColor) evt.getNewValue()).getSWTColor(), (LEDFigure) getFigure(), getWidgetModel()));
for (var idx = 0; idx < LEDFigure.MAX_NSTATES; idx++) {
var state = idx;
getWidgetModel().getProperty(String.format(PROP_STATE_LABEL, state)).addPropertyChangeListener(evt -> initializeStateLabel(state, (String) evt.getOldValue(), (String) evt.getNewValue(), (LEDFigure) getFigure(), getWidgetModel()));
getWidgetModel().getProperty(String.format(PROP_STATE_COLOR, state)).addPropertyChangeListener(evt -> initializeStateColor(state, ((OPIColor) evt.getOldValue()).getSWTColor(), ((OPIColor) evt.getNewValue()).getSWTColor(), (LEDFigure) getFigure(), getWidgetModel()));
getWidgetModel().getProperty(String.format(PROP_STATE_VALUE, state)).addPropertyChangeListener(evt -> initializeStateValue(state, (Double) evt.getOldValue(), (Double) evt.getNewValue(), (LEDFigure) getFigure(), getWidgetModel()));
}
}
Aggregations