use of org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler in project yamcs-studio by yamcs.
the class TankEditPart method registerPropertyChangeHandlers.
/**
* {@inheritDoc}
*/
@Override
protected void registerPropertyChangeHandlers() {
registerCommonPropertyChangeHandlers();
// fillColor
IWidgetPropertyChangeHandler fillColorHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
TankFigure tank = (TankFigure) refreshableFigure;
tank.setFillColor(((OPIColor) newValue).getSWTColor());
return false;
}
};
setPropertyChangeHandler(TankModel.PROP_FILL_COLOR, fillColorHandler);
// fillBackgroundColor
IWidgetPropertyChangeHandler fillBackColorHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
TankFigure tank = (TankFigure) refreshableFigure;
tank.setFillBackgroundColor(((OPIColor) newValue).getSWTColor());
return false;
}
};
setPropertyChangeHandler(TankModel.PROP_FILLBACKGROUND_COLOR, fillBackColorHandler);
// effect 3D
IWidgetPropertyChangeHandler effect3DHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
TankFigure tank = (TankFigure) refreshableFigure;
tank.setEffect3D((Boolean) newValue);
return false;
}
};
setPropertyChangeHandler(TankModel.PROP_EFFECT3D, effect3DHandler);
// Change fill color when "FillColor Alarm Sensitive" property changes.
IWidgetPropertyChangeHandler fillColorAlarmSensitiveHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure refreshableFigure) {
TankFigure figure = (TankFigure) refreshableFigure;
boolean sensitive = (Boolean) newValue;
figure.setFillColor(delegate.calculateAlarmColor(sensitive, getWidgetModel().getFillColor()));
return true;
}
};
setPropertyChangeHandler(TankModel.PROP_FILLCOLOR_ALARM_SENSITIVE, fillColorAlarmSensitiveHandler);
// Change fill color when alarm severity changes.
delegate.addAlarmSeverityListener(new AlarmSeverityListener() {
@Override
public boolean severityChanged(AlarmSeverity severity, IFigure figure) {
if (!getWidgetModel().isFillColorAlarmSensitive())
return false;
TankFigure tank = (TankFigure) figure;
tank.setFillColor(delegate.calculateAlarmColor(getWidgetModel().isFillColorAlarmSensitive(), getWidgetModel().getFillColor()));
return true;
}
});
}
use of org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler in project yamcs-studio by yamcs.
the class TextInputEditpart method registerPropertyChangeHandlers.
@Override
protected void registerPropertyChangeHandlers() {
super.registerPropertyChangeHandlers();
if (getExecutionMode() == ExecutionMode.RUN_MODE) {
removeAllPropertyChangeHandlers(LabelModel.PROP_TEXT);
IWidgetPropertyChangeHandler handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, final IFigure figure) {
String text = (String) newValue;
if (getPV() == null) {
setFigureText(text);
if (getWidgetModel().isAutoSize()) {
Display.getCurrent().timerExec(10, new Runnable() {
@Override
public void run() {
performAutoSize();
}
});
}
}
// Output pv value even if pv name is empty, so setPVValuelistener can be triggered.
outputPVValue(text);
return false;
}
};
setPropertyChangeHandler(LabelModel.PROP_TEXT, handler);
}
IWidgetPropertyChangeHandler pvNameHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
registerLoadLimitsListener();
return false;
}
};
setPropertyChangeHandler(AbstractPVWidgetModel.PROP_PVNAME, pvNameHandler);
PropertyChangeListener updatePropSheetListener = new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent arg0) {
updatePropSheet();
}
};
getWidgetModel().getProperty(TextInputModel.PROP_LIMITS_FROM_PV).addPropertyChangeListener(updatePropSheetListener);
getWidgetModel().getProperty(TextInputModel.PROP_SELECTOR_TYPE).addPropertyChangeListener(updatePropSheetListener);
PropertyChangeListener reCreateWidgetListener = new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
reCreateWidget();
}
};
getWidgetModel().getProperty(TextInputModel.PROP_STYLE).addPropertyChangeListener(reCreateWidgetListener);
delegate.registerPropertyChangeHandlers();
}
use of org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler in project yamcs-studio by yamcs.
the class ThermometerEditPart method registerPropertyChangeHandlers.
/**
* {@inheritDoc}
*/
@Override
protected void registerPropertyChangeHandlers() {
registerCommonPropertyChangeHandlers();
// fillColor
IWidgetPropertyChangeHandler fillColorHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
ThermometerFigure thermometer = (ThermometerFigure) refreshableFigure;
thermometer.setFillColor(((OPIColor) newValue).getSWTColor());
return false;
}
};
setPropertyChangeHandler(ThermometerModel.PROP_FILL_COLOR, fillColorHandler);
// fillBackgroundColor
IWidgetPropertyChangeHandler fillBackColorHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
ThermometerFigure thermometer = (ThermometerFigure) refreshableFigure;
thermometer.setFillBackgroundColor(((OPIColor) newValue).getSWTColor());
return false;
}
};
setPropertyChangeHandler(ThermometerModel.PROP_FILLBACKGROUND_COLOR, fillBackColorHandler);
// show bulb
IWidgetPropertyChangeHandler showBulbHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
ThermometerFigure thermometer = (ThermometerFigure) refreshableFigure;
thermometer.setShowBulb((Boolean) newValue);
return false;
}
};
setPropertyChangeHandler(ThermometerModel.PROP_SHOW_BULB, showBulbHandler);
// unit
IWidgetPropertyChangeHandler fahrenheitHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
ThermometerFigure thermometer = (ThermometerFigure) refreshableFigure;
thermometer.setTemperatureUnit(TemperatureUnit.values()[(Integer) newValue]);
return false;
}
};
setPropertyChangeHandler(ThermometerModel.PROP_UNIT, fahrenheitHandler);
// effect 3D
IWidgetPropertyChangeHandler effect3DHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
ThermometerFigure thermo = (ThermometerFigure) refreshableFigure;
thermo.setEffect3D((Boolean) newValue);
return false;
}
};
setPropertyChangeHandler(ThermometerModel.PROP_EFFECT3D, effect3DHandler);
// Change fill color when "FillColor Alarm Sensitive" property changes.
IWidgetPropertyChangeHandler fillColorAlarmSensitiveHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure refreshableFigure) {
ThermometerFigure figure = (ThermometerFigure) refreshableFigure;
boolean sensitive = (Boolean) newValue;
figure.setFillColor(delegate.calculateAlarmColor(sensitive, getWidgetModel().getFillColor()));
return true;
}
};
setPropertyChangeHandler(ThermometerModel.PROP_FILLCOLOR_ALARM_SENSITIVE, fillColorAlarmSensitiveHandler);
// Change fill color when alarm severity changes.
delegate.addAlarmSeverityListener(new AlarmSeverityListener() {
@Override
public boolean severityChanged(AlarmSeverity severity, IFigure figure) {
if (!getWidgetModel().isFillColorAlarmSensitive())
return false;
ThermometerFigure thermo = (ThermometerFigure) figure;
thermo.setFillColor(delegate.calculateAlarmColor(getWidgetModel().isFillColorAlarmSensitive(), getWidgetModel().getFillColor()));
return true;
}
});
}
use of org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler in project yamcs-studio by yamcs.
the class XYGraphEditPart method registerAxisPropertyChangeHandlers.
private void registerAxisPropertyChangeHandlers() {
XYGraphModel model = (XYGraphModel) getModel();
// set prop handlers and init all the potential axes
for (int i = 0; i < XYGraphModel.MAX_AXES_AMOUNT; i++) {
for (AxisProperty axisProperty : AxisProperty.values()) {
// there is no primary and y-axis property for primary axes.
if (i < 2 && (axisProperty == AxisProperty.PRIMARY || axisProperty == AxisProperty.Y_AXIS)) {
continue;
}
String propID = XYGraphModel.makeAxisPropID(axisProperty.propIDPre, i);
IWidgetPropertyChangeHandler handler = new AxisPropertyChangeHandler(i, axisProperty);
setPropertyChangeHandler(propID, handler);
}
}
for (int i = XYGraphModel.MAX_AXES_AMOUNT - 1; i >= model.getAxesAmount(); i--) {
for (AxisProperty axisProperty : AxisProperty.values()) {
String propID = XYGraphModel.makeAxisPropID(axisProperty.propIDPre, i);
model.setPropertyVisible(propID, false);
}
}
}
use of org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler in project yamcs-studio by yamcs.
the class XYGraphEditPart method registerAxesAmountChangeHandler.
private void registerAxesAmountChangeHandler() {
final IWidgetPropertyChangeHandler handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure refreshableFigure) {
XYGraphModel model = (XYGraphModel) getModel();
IXYGraph xyGraph = ((ToolbarArmedXYGraph) refreshableFigure).getXYGraph();
int currentAxisAmount = xyGraph.getAxisList().size();
// add axis
if ((Integer) newValue > currentAxisAmount) {
for (int i = 0; i < (Integer) newValue - currentAxisAmount; i++) {
for (AxisProperty axisProperty : AxisProperty.values()) {
String propID = XYGraphModel.makeAxisPropID(axisProperty.propIDPre, i + currentAxisAmount);
model.setPropertyVisible(propID, true);
}
xyGraph.addAxis(axisList.get(i + currentAxisAmount));
}
} else if ((Integer) newValue < currentAxisAmount) {
// remove axis
for (int i = 0; i < currentAxisAmount - (Integer) newValue; i++) {
for (AxisProperty axisProperty : AxisProperty.values()) {
String propID = XYGraphModel.makeAxisPropID(axisProperty.propIDPre, i + (Integer) newValue);
model.setPropertyVisible(propID, false);
}
xyGraph.removeAxis(axisList.get(i + (Integer) newValue));
}
}
return true;
}
};
getWidgetModel().getProperty(XYGraphModel.PROP_AXIS_COUNT).addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
handler.handleChange(evt.getOldValue(), evt.getNewValue(), getFigure());
}
});
// setPropertyChangeHandler(XYGraphModel.PROP_AXES_AMOUNT, handler);
}
Aggregations