Search in sources :

Example 1 with ArrayModel

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

the class ArrayFeedbackFactory method showChangeBoundsFeedback.

@Override
public void showChangeBoundsFeedback(AbstractWidgetModel widgetModel, PrecisionRectangle bounds, IFigure feedbackFigure, ChangeBoundsRequest request) {
    ArrayModel arrayModel = (ArrayModel) widgetModel;
    if (arrayModel.getChildren().isEmpty()) {
        super.showChangeBoundsFeedback(widgetModel, bounds, feedbackFigure, request);
        return;
    }
    Dimension sizeDelta = request.getSizeDelta();
    if (arrayModel.isHorizontal()) {
        int eWidth = arrayModel.getChildren().get(0).getWidth();
        bounds.width -= sizeDelta.width;
        sizeDelta.width = Math.round((float) sizeDelta.width / eWidth) * eWidth;
        bounds.width += sizeDelta.width;
    } else {
        int eHeight = arrayModel.getChildren().get(0).getHeight();
        bounds.height -= sizeDelta.height;
        sizeDelta.height = Math.round((float) sizeDelta.height / eHeight) * eHeight;
        bounds.height += sizeDelta.height;
    }
    super.showChangeBoundsFeedback(widgetModel, bounds, feedbackFigure, request);
}
Also used : Dimension(org.eclipse.draw2d.geometry.Dimension) ArrayModel(org.csstudio.opibuilder.widgets.model.ArrayModel)

Example 2 with ArrayModel

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

the class ArrayEditPart method registerLoadPVDataTypeListener.

private void registerLoadPVDataTypeListener() {
    if (getExecutionMode() == ExecutionMode.RUN_MODE) {
        final ArrayModel model = getWidgetModel();
        IPV pv = getPV();
        if (pv != null) {
            if (pvDataTypeListener == null)
                pvDataTypeListener = new IPVListener.Stub() {

                    @Override
                    public void valueChanged(IPV pv) {
                        VType value = pv.getValue();
                        if (value != null) {
                            model.setArrayLength(VTypeHelper.getSize(value));
                            BasicDataType dataType = VTypeHelper.getBasicDataType(value);
                            model.setPropertyValue(ArrayModel.PROP_DATA_TYPE, mapBasicDataTypeToArrayType(dataType));
                        }
                    }
                };
            pv.addListener(pvDataTypeListener);
        }
    }
}
Also used : VType(org.diirt.vtype.VType) BasicDataType(org.csstudio.simplepv.BasicDataType) ArrayModel(org.csstudio.opibuilder.widgets.model.ArrayModel) IPV(org.csstudio.simplepv.IPV)

Example 3 with ArrayModel

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

the class ArrayEditPart method doCreateFigure.

@Override
protected IFigure doCreateFigure() {
    ArrayFigure figure = new ArrayFigure();
    ArrayModel model = getWidgetModel();
    figure.setArrayLength(model.getArrayLength());
    figure.setHorizontal(model.isHorizontal());
    figure.setSpinnerWidth(model.getSpinnerWidth());
    figure.setShowSpinner(model.isShowSpinner());
    figure.setShowScrollbar(model.isShowScrollbar());
    figure.setIndex(0);
    figure.addIndexChangeListener(new IManualValueChangeListener() {

        @Override
        public void manualValueChanged(double newValue) {
            setValue(getValue());
        }
    });
    updatePropSheet();
    return figure;
}
Also used : IManualValueChangeListener(org.csstudio.swt.widgets.datadefinition.IManualValueChangeListener) ArrayFigure(org.csstudio.swt.widgets.figures.ArrayFigure) ArrayModel(org.csstudio.opibuilder.widgets.model.ArrayModel)

Aggregations

ArrayModel (org.csstudio.opibuilder.widgets.model.ArrayModel)3 BasicDataType (org.csstudio.simplepv.BasicDataType)1 IPV (org.csstudio.simplepv.IPV)1 IManualValueChangeListener (org.csstudio.swt.widgets.datadefinition.IManualValueChangeListener)1 ArrayFigure (org.csstudio.swt.widgets.figures.ArrayFigure)1 VType (org.diirt.vtype.VType)1 Dimension (org.eclipse.draw2d.geometry.Dimension)1