use of org.csstudio.swt.widgets.figures.ScaledSliderFigure in project yamcs-studio by yamcs.
the class ScaledSliderEditPart method doCreateFigure.
/**
* {@inheritDoc}
*/
@Override
protected IFigure doCreateFigure() {
final ScaledSliderModel model = getWidgetModel();
ScaledSliderFigure slider = new ScaledSliderFigure();
initializeCommonFigureProperties(slider, model);
slider.setFillColor(model.getFillColor());
slider.setEffect3D(model.isEffect3D());
slider.setFillBackgroundColor(model.getFillbackgroundColor());
slider.setThumbColor(model.getThumbColor());
slider.setHorizontal(model.isHorizontal());
slider.setStepIncrement(model.getStepIncrement());
slider.setPageIncrement(model.getPageIncrement());
slider.addManualValueChangeListener(new IManualValueChangeListener() {
public void manualValueChanged(double newValue) {
if (getExecutionMode() == ExecutionMode.RUN_MODE)
setPVValue(ScaledSliderModel.PROP_PVNAME, newValue);
}
});
markAsControlPV(ScaledSliderModel.PROP_PVNAME, AbstractPVWidgetModel.PROP_PVVALUE);
return slider;
}
use of org.csstudio.swt.widgets.figures.ScaledSliderFigure in project yamcs-studio by yamcs.
the class ScaledSliderEditPart method registerPropertyChangeHandlers.
/**
* {@inheritDoc}
*/
@Override
protected void registerPropertyChangeHandlers() {
registerCommonPropertyChangeHandlers();
// fillColor
IWidgetPropertyChangeHandler fillColorHandler = new IWidgetPropertyChangeHandler() {
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
ScaledSliderFigure slider = (ScaledSliderFigure) refreshableFigure;
slider.setFillColor(((OPIColor) newValue).getSWTColor());
return false;
}
};
setPropertyChangeHandler(ScaledSliderModel.PROP_FILL_COLOR, fillColorHandler);
// fillBackgroundColor
IWidgetPropertyChangeHandler fillBackColorHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
ScaledSliderFigure slider = (ScaledSliderFigure) refreshableFigure;
slider.setFillBackgroundColor(((OPIColor) newValue).getSWTColor());
return false;
}
};
setPropertyChangeHandler(ScaledSliderModel.PROP_FILLBACKGROUND_COLOR, fillBackColorHandler);
// thumbColor
IWidgetPropertyChangeHandler thumbColorHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
ScaledSliderFigure slider = (ScaledSliderFigure) refreshableFigure;
slider.setThumbColor(((OPIColor) newValue).getSWTColor());
return false;
}
};
setPropertyChangeHandler(ScaledSliderModel.PROP_THUMB_COLOR, thumbColorHandler);
// effect 3D
IWidgetPropertyChangeHandler effect3DHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
ScaledSliderFigure slider = (ScaledSliderFigure) refreshableFigure;
slider.setEffect3D((Boolean) newValue);
return false;
}
};
setPropertyChangeHandler(ScaledSliderModel.PROP_EFFECT3D, effect3DHandler);
// horizontal
IWidgetPropertyChangeHandler horizontalHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
ScaledSliderFigure slider = (ScaledSliderFigure) refreshableFigure;
slider.setHorizontal((Boolean) newValue);
ScaledSliderModel model = (ScaledSliderModel) getModel();
if (// from vertical to horizontal
(Boolean) newValue)
model.setLocation(model.getLocation().x - model.getSize().height / 2 + model.getSize().width / 2, model.getLocation().y + model.getSize().height / 2 - model.getSize().width / 2);
else
// from horizontal to vertical
model.setLocation(model.getLocation().x + model.getSize().width / 2 - model.getSize().height / 2, model.getLocation().y - model.getSize().width / 2 + model.getSize().height / 2);
model.setSize(model.getSize().height, model.getSize().width);
return false;
}
};
setPropertyChangeHandler(ScaledSliderModel.PROP_HORIZONTAL, horizontalHandler);
// enabled. WidgetBaseEditPart will force the widget as disabled in edit model,
// which is not the case for the scaled slider
IWidgetPropertyChangeHandler enableHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
ScaledSliderFigure slider = (ScaledSliderFigure) refreshableFigure;
slider.setEnabled((Boolean) newValue);
return false;
}
};
setPropertyChangeHandler(ScaledSliderModel.PROP_ENABLED, enableHandler);
IWidgetPropertyChangeHandler incrementHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
ScaledSliderFigure slider = (ScaledSliderFigure) refreshableFigure;
slider.setStepIncrement((Double) newValue);
return false;
}
};
setPropertyChangeHandler(ScaledSliderModel.PROP_STEP_INCREMENT, incrementHandler);
IWidgetPropertyChangeHandler pageIncrementHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
ScaledSliderFigure slider = (ScaledSliderFigure) refreshableFigure;
slider.setPageIncrement((Double) newValue);
return false;
}
};
setPropertyChangeHandler(ScaledSliderModel.PROP_PAGE_INCREMENT, pageIncrementHandler);
}
Aggregations