use of org.csstudio.swt.widgets.figures.AbstractScaledWidgetFigure in project yamcs-studio by yamcs.
the class AbstractScaledWidgetEditPart method registerCommonPropertyChangeHandlers.
/**
* Registers property change handlers for the properties defined in {@link AbstractScaledWidgetModel}. This method
* is provided for the convenience of subclasses, which can call this method in their implementation of
* {@link #registerPropertyChangeHandlers()}.
*/
protected void registerCommonPropertyChangeHandlers() {
// value
IWidgetPropertyChangeHandler valueHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
if (newValue == null)
return false;
AbstractScaledWidgetFigure figure = (AbstractScaledWidgetFigure) refreshableFigure;
figure.setValue(VTypeHelper.getDouble((VType) newValue));
return false;
}
};
setPropertyChangeHandler(AbstractPVWidgetModel.PROP_PVVALUE, valueHandler);
// minimum
IWidgetPropertyChangeHandler minimumHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
AbstractScaledWidgetFigure figure = (AbstractScaledWidgetFigure) refreshableFigure;
figure.setRange((Double) newValue, ((AbstractScaledWidgetModel) getModel()).getMaximum());
return false;
}
};
setPropertyChangeHandler(AbstractScaledWidgetModel.PROP_MIN, minimumHandler);
// maximum
IWidgetPropertyChangeHandler maximumHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
AbstractScaledWidgetFigure figure = (AbstractScaledWidgetFigure) refreshableFigure;
figure.setRange(((AbstractScaledWidgetModel) getModel()).getMinimum(), (Double) newValue);
return false;
}
};
setPropertyChangeHandler(AbstractScaledWidgetModel.PROP_MAX, maximumHandler);
// major tick step hint
IWidgetPropertyChangeHandler majorTickHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
AbstractScaledWidgetFigure figure = (AbstractScaledWidgetFigure) refreshableFigure;
figure.setMajorTickMarkStepHint((Integer) newValue);
return false;
}
};
setPropertyChangeHandler(AbstractScaledWidgetModel.PROP_MAJOR_TICK_STEP_HINT, majorTickHandler);
// logScale
IWidgetPropertyChangeHandler logScaleHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
AbstractScaledWidgetFigure figure = (AbstractScaledWidgetFigure) refreshableFigure;
figure.setLogScale((Boolean) newValue);
return false;
}
};
setPropertyChangeHandler(AbstractScaledWidgetModel.PROP_LOG_SCALE, logScaleHandler);
// showScale
IWidgetPropertyChangeHandler showScaleHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
AbstractScaledWidgetFigure figure = (AbstractScaledWidgetFigure) refreshableFigure;
figure.setShowScale((Boolean) newValue);
return false;
}
};
setPropertyChangeHandler(AbstractScaledWidgetModel.PROP_SHOW_SCALE, showScaleHandler);
// showMinorTicks
IWidgetPropertyChangeHandler showMinorTicksHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
AbstractScaledWidgetFigure figure = (AbstractScaledWidgetFigure) refreshableFigure;
figure.setShowMinorTicks((Boolean) newValue);
return false;
}
};
setPropertyChangeHandler(AbstractScaledWidgetModel.PROP_SHOW_MINOR_TICKS, showMinorTicksHandler);
// Transparent
IWidgetPropertyChangeHandler transparentHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
AbstractScaledWidgetFigure figure = (AbstractScaledWidgetFigure) refreshableFigure;
figure.setTransparent((Boolean) newValue);
return false;
}
};
setPropertyChangeHandler(AbstractScaledWidgetModel.PROP_TRANSPARENT, transparentHandler);
IWidgetPropertyChangeHandler scaleFontHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure refreshableFigure) {
AbstractScaledWidgetFigure figure = (AbstractScaledWidgetFigure) refreshableFigure;
figure.getScale().setFont(((OPIFont) newValue).getSWTFont());
return false;
}
};
setPropertyChangeHandler(AbstractScaledWidgetModel.PROP_SCALE_FONT, scaleFontHandler);
// scale format
IWidgetPropertyChangeHandler numericFormatHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
AbstractScaledWidgetFigure scaleFigure = (AbstractScaledWidgetFigure) figure;
setScaleFormat(scaleFigure, (String) newValue);
return false;
}
};
setPropertyChangeHandler(AbstractScaledWidgetModel.PROP_SCALE_FORMAT, numericFormatHandler);
// value label format
IWidgetPropertyChangeHandler valueFormatHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
AbstractScaledWidgetFigure scaleFigure = (AbstractScaledWidgetFigure) figure;
setValueLabelFormat(scaleFigure, (String) newValue);
return false;
}
};
setPropertyChangeHandler(AbstractScaledWidgetModel.PROP_VALUE_LABEL_FORMAT, valueFormatHandler);
}
Aggregations