Search in sources :

Example 1 with ScrollBarModel

use of org.csstudio.opibuilder.widgets.model.ScrollBarModel in project yamcs-studio by yamcs.

the class ScrollbarEditPart method registerLoadLimitsListener.

/**
 */
private void registerLoadLimitsListener() {
    if (getExecutionMode() == ExecutionMode.RUN_MODE) {
        final ScrollBarModel model = getWidgetModel();
        if (model.isLimitsFromPV()) {
            IPV pv = getPV(AbstractPVWidgetModel.PROP_PVNAME);
            if (pv != null) {
                if (pvLoadLimitsListener == null)
                    pvLoadLimitsListener = new IPVListener.Stub() {

                        @Override
                        public void valueChanged(IPV pv) {
                            VType value = pv.getValue();
                            Display displayInfo = VTypeHelper.getDisplayInfo(value);
                            if (value != null && displayInfo != null) {
                                Display new_meta = displayInfo;
                                if (meta == null || !meta.equals(new_meta)) {
                                    meta = new_meta;
                                    model.setPropertyValue(ScrollBarModel.PROP_MAX, meta.getUpperDisplayLimit());
                                    model.setPropertyValue(ScrollBarModel.PROP_MIN, meta.getLowerDisplayLimit());
                                }
                            }
                        }
                    };
                pv.addListener(pvLoadLimitsListener);
            }
        }
    }
}
Also used : VType(org.diirt.vtype.VType) ScrollBarModel(org.csstudio.opibuilder.widgets.model.ScrollBarModel) IPV(org.csstudio.simplepv.IPV) Display(org.diirt.vtype.Display)

Example 2 with ScrollBarModel

use of org.csstudio.opibuilder.widgets.model.ScrollBarModel in project yamcs-studio by yamcs.

the class ScrollbarEditPart method registerPropertyChangeHandlers.

@Override
protected void registerPropertyChangeHandlers() {
    IWidgetPropertyChangeHandler pvNameHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            registerLoadLimitsListener();
            return false;
        }
    };
    setPropertyChangeHandler(AbstractPVWidgetModel.PROP_PVNAME, pvNameHandler);
    ((ScrollbarFigure) getFigure()).setEnabled(getWidgetModel().isEnabled() && (getExecutionMode() == ExecutionMode.RUN_MODE));
    removeAllPropertyChangeHandlers(AbstractWidgetModel.PROP_ENABLED);
    // enable
    IWidgetPropertyChangeHandler enableHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            if (getExecutionMode() == ExecutionMode.RUN_MODE)
                figure.setEnabled((Boolean) newValue);
            return false;
        }
    };
    setPropertyChangeHandler(AbstractWidgetModel.PROP_ENABLED, enableHandler);
    // value
    IWidgetPropertyChangeHandler valueHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            if (newValue == null)
                return false;
            ((ScrollbarFigure) refreshableFigure).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) {
            ((ScrollbarFigure) refreshableFigure).setMinimum((Double) newValue);
            return false;
        }
    };
    setPropertyChangeHandler(ScrollBarModel.PROP_MIN, minimumHandler);
    // maximum
    IWidgetPropertyChangeHandler maximumHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            ((ScrollbarFigure) refreshableFigure).setMaximum((Double) newValue);
            return false;
        }
    };
    setPropertyChangeHandler(ScrollBarModel.PROP_MAX, maximumHandler);
    // page increment
    IWidgetPropertyChangeHandler pageIncrementHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            ((ScrollbarFigure) refreshableFigure).setPageIncrement((Double) newValue);
            return false;
        }
    };
    setPropertyChangeHandler(ScrollBarModel.PROP_PAGE_INCREMENT, pageIncrementHandler);
    // step increment
    IWidgetPropertyChangeHandler stepIncrementHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            ((ScrollbarFigure) refreshableFigure).setStepIncrement((Double) newValue);
            return false;
        }
    };
    setPropertyChangeHandler(ScrollBarModel.PROP_STEP_INCREMENT, stepIncrementHandler);
    // bar length
    IWidgetPropertyChangeHandler barLengthHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            ((ScrollbarFigure) refreshableFigure).setExtent((Double) newValue);
            return false;
        }
    };
    setPropertyChangeHandler(ScrollBarModel.PROP_BAR_LENGTH, barLengthHandler);
    // value tip
    IWidgetPropertyChangeHandler valueTipHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            ((ScrollbarFigure) refreshableFigure).setShowValueTip((Boolean) newValue);
            return false;
        }
    };
    setPropertyChangeHandler(ScrollBarModel.PROP_SHOW_VALUE_TIP, valueTipHandler);
    // horizontal
    IWidgetPropertyChangeHandler horizontalHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            ((ScrollbarFigure) refreshableFigure).setHorizontal((Boolean) newValue);
            ScrollBarModel model = getWidgetModel();
            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(ScrollBarModel.PROP_HORIZONTAL, horizontalHandler);
}
Also used : VType(org.diirt.vtype.VType) ScrollBarModel(org.csstudio.opibuilder.widgets.model.ScrollBarModel) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler) IFigure(org.eclipse.draw2d.IFigure) ScrollbarFigure(org.csstudio.swt.widgets.figures.ScrollbarFigure)

Example 3 with ScrollBarModel

use of org.csstudio.opibuilder.widgets.model.ScrollBarModel in project yamcs-studio by yamcs.

the class ScrollbarEditPart method doCreateFigure.

@Override
protected IFigure doCreateFigure() {
    ScrollbarFigure scrollBar = new ScrollbarFigure();
    ScrollBarModel model = getWidgetModel();
    scrollBar.setMaximum(model.getMaximum());
    scrollBar.setMinimum(model.getMinimum());
    scrollBar.setStepIncrement(model.getStepIncrement());
    scrollBar.setPageIncrement(model.getPageIncrement());
    scrollBar.setExtent(model.getBarLength());
    scrollBar.setShowValueTip(model.isShowValueTip());
    scrollBar.setHorizontal(model.isHorizontal());
    if (getExecutionMode() == ExecutionMode.RUN_MODE) {
        scrollBar.addManualValueChangeListener(new IManualValueChangeListener() {

            public void manualValueChanged(double newValue) {
                setPVValue(ScrollBarModel.PROP_PVNAME, newValue);
            }
        });
    }
    markAsControlPV(AbstractPVWidgetModel.PROP_PVNAME, AbstractPVWidgetModel.PROP_PVVALUE);
    return scrollBar;
}
Also used : IManualValueChangeListener(org.csstudio.swt.widgets.datadefinition.IManualValueChangeListener) ScrollBarModel(org.csstudio.opibuilder.widgets.model.ScrollBarModel) ScrollbarFigure(org.csstudio.swt.widgets.figures.ScrollbarFigure)

Aggregations

ScrollBarModel (org.csstudio.opibuilder.widgets.model.ScrollBarModel)3 ScrollbarFigure (org.csstudio.swt.widgets.figures.ScrollbarFigure)2 VType (org.diirt.vtype.VType)2 IWidgetPropertyChangeHandler (org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler)1 IPV (org.csstudio.simplepv.IPV)1 IManualValueChangeListener (org.csstudio.swt.widgets.datadefinition.IManualValueChangeListener)1 Display (org.diirt.vtype.Display)1 IFigure (org.eclipse.draw2d.IFigure)1