Search in sources :

Example 1 with ScaledSliderModel

use of org.csstudio.opibuilder.widgets.model.ScaledSliderModel 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;
}
Also used : IManualValueChangeListener(org.csstudio.swt.widgets.datadefinition.IManualValueChangeListener) ScaledSliderModel(org.csstudio.opibuilder.widgets.model.ScaledSliderModel) ScaledSliderFigure(org.csstudio.swt.widgets.figures.ScaledSliderFigure)

Example 2 with ScaledSliderModel

use of org.csstudio.opibuilder.widgets.model.ScaledSliderModel 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);
}
Also used : ScaledSliderModel(org.csstudio.opibuilder.widgets.model.ScaledSliderModel) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler) ScaledSliderFigure(org.csstudio.swt.widgets.figures.ScaledSliderFigure) IFigure(org.eclipse.draw2d.IFigure)

Aggregations

ScaledSliderModel (org.csstudio.opibuilder.widgets.model.ScaledSliderModel)2 ScaledSliderFigure (org.csstudio.swt.widgets.figures.ScaledSliderFigure)2 IWidgetPropertyChangeHandler (org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler)1 IManualValueChangeListener (org.csstudio.swt.widgets.datadefinition.IManualValueChangeListener)1 IFigure (org.eclipse.draw2d.IFigure)1