Search in sources :

Example 1 with PROP_WIDTH

use of org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_WIDTH in project yamcs-studio by yamcs.

the class ImageBoolIndicatorEditPart method registerPropertyChangeHandlers.

@Override
protected void registerPropertyChangeHandlers() {
    registerCommonPropertyChangeHandlers();
    // Don't autosize to save CPU usage
    // removeAllPropertyChangeHandlers(AbstractPVWidgetModel.PROP_PVVALUE);
    // value
    // IWidgetPropertyChangeHandler handler = new IWidgetPropertyChangeHandler() {
    // public boolean handleChange(Object oldValue,
    // final Object newValue,
    // final IFigure refreshableFigure) {
    // if(newValue == null)
    // return false;
    // ImageBoolButtonFigure figure = (ImageBoolButtonFigure) refreshableFigure;
    // // autoSizeWidget(figure);
    // return true;
    // }
    // };
    // setPropertyChangeHandler(AbstractPVWidgetModel.PROP_PVVALUE, handler);
    setPropertyChangeHandler(PROP_ON_IMAGE, (oldValue, newValue, figure) -> {
        var imageFigure = (ImageBoolButtonFigure) figure;
        var absolutePath = (String) newValue;
        if (!absolutePath.contains("://")) {
            var path = Path.fromPortableString(absolutePath);
            if (!path.isAbsolute()) {
                path = ResourceUtil.buildAbsolutePath(getWidgetModel(), path);
                absolutePath = path.toPortableString();
            }
        }
        imageFigure.setOnImagePath(absolutePath);
        autoSizeWidget(imageFigure);
        return true;
    });
    setPropertyChangeHandler(PROP_OFF_IMAGE, (oldValue, newValue, figure) -> {
        var imageFigure = (ImageBoolButtonFigure) figure;
        var absolutePath = (String) newValue;
        if (!absolutePath.contains("://")) {
            var path = Path.fromPortableString(absolutePath);
            if (!path.isAbsolute()) {
                path = ResourceUtil.buildAbsolutePath(getWidgetModel(), path);
                absolutePath = path.toPortableString();
            }
        }
        imageFigure.setOffImagePath(absolutePath);
        autoSizeWidget(imageFigure);
        return true;
    });
    setPropertyChangeHandler(PROP_STRETCH, (oldValue, newValue, figure) -> {
        var imageFigure = (ImageBoolButtonFigure) figure;
        imageFigure.setStretch((Boolean) newValue);
        autoSizeWidget(imageFigure);
        return true;
    });
    setPropertyChangeHandler(PROP_AUTOSIZE, (oldValue, newValue, figure) -> {
        var imageFigure = (ImageBoolButtonFigure) figure;
        autoSizeWidget(imageFigure);
        return true;
    });
    setPropertyChangeHandler(PROP_NO_ANIMATION, (oldValue, newValue, figure) -> {
        var imageFigure = (ImageBoolButtonFigure) figure;
        imageFigure.setAnimationDisabled((Boolean) newValue);
        return false;
    });
    setPropertyChangeHandler(PROP_ALIGN_TO_NEAREST_SECOND, (oldValue, newValue, figure) -> {
        var imageFigure = (ImageBoolButtonFigure) figure;
        imageFigure.setAlignedToNearestSecond((Boolean) newValue);
        return false;
    });
    // changes to the border width property
    IWidgetPropertyChangeHandler handle = (oldValue, newValue, figure) -> {
        var imageFigure = (ImageBoolButtonFigure) figure;
        autoSizeWidget(imageFigure);
        return true;
    };
    setPropertyChangeHandler(PROP_BORDER_WIDTH, handle);
    setPropertyChangeHandler(PROP_BORDER_STYLE, handle);
    // size change handlers - so we can stretch accordingly
    handle = (oldValue, newValue, figure) -> {
        var imageFigure = (ImageBoolButtonFigure) figure;
        autoSizeWidget(imageFigure);
        return true;
    };
    setPropertyChangeHandler(PROP_HEIGHT, handle);
    setPropertyChangeHandler(PROP_WIDTH, handle);
    FigureTransparencyHelper.addHandler(this, figure);
}
Also used : ImageBoolIndicatorModel(org.csstudio.opibuilder.widgets.model.ImageBoolIndicatorModel) PROP_BORDER_WIDTH(org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_BORDER_WIDTH) PROP_NO_ANIMATION(org.csstudio.opibuilder.widgets.model.ImageBoolIndicatorModel.PROP_NO_ANIMATION) PROP_HEIGHT(org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_HEIGHT) ResourceUtil(org.csstudio.opibuilder.util.ResourceUtil) Display(org.eclipse.swt.widgets.Display) ImageBoolButtonFigure(org.csstudio.opibuilder.widgets.figures.ImageBoolButtonFigure) IFigure(org.eclipse.draw2d.IFigure) PROP_ON_IMAGE(org.csstudio.opibuilder.widgets.model.ImageBoolIndicatorModel.PROP_ON_IMAGE) PROP_STRETCH(org.csstudio.opibuilder.widgets.model.ImageBoolIndicatorModel.PROP_STRETCH) PROP_OFF_IMAGE(org.csstudio.opibuilder.widgets.model.ImageBoolIndicatorModel.PROP_OFF_IMAGE) Color(org.eclipse.swt.graphics.Color) Path(org.eclipse.core.runtime.Path) PROP_AUTOSIZE(org.csstudio.opibuilder.widgets.model.ImageBoolIndicatorModel.PROP_AUTOSIZE) FigureTransparencyHelper(org.csstudio.opibuilder.widgets.FigureTransparencyHelper) PROP_ALIGN_TO_NEAREST_SECOND(org.csstudio.opibuilder.widgets.model.ImageBoolIndicatorModel.PROP_ALIGN_TO_NEAREST_SECOND) PROP_BORDER_STYLE(org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_BORDER_STYLE) SymbolImageProperties(org.csstudio.swt.widgets.symbol.SymbolImageProperties) PROP_WIDTH(org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_WIDTH) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler) ImageBoolButtonFigure(org.csstudio.opibuilder.widgets.figures.ImageBoolButtonFigure)

Example 2 with PROP_WIDTH

use of org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_WIDTH in project yamcs-studio by yamcs.

the class ArrayEditPart method registerPropertyChangeHandlers.

@Override
protected void registerPropertyChangeHandlers() {
    IWidgetPropertyChangeHandler handler = (oldValue, newValue, figure) -> {
        for (var child : getWidgetModel().getAllChildren()) {
            child.setEnabled((Boolean) newValue);
        }
        return true;
    };
    setPropertyChangeHandler(AbstractWidgetModel.PROP_ENABLED, handler);
    handler = (oldValue, newValue, figure) -> {
        var value = (VType) newValue;
        if (value instanceof VNumberArray) {
            var wrappedArray = VTypeHelper.getWrappedArray((value));
            if (wrappedArray != null) {
                setValue(wrappedArray);
            } else {
                setValue(VTypeHelper.getDoubleArray(value));
            }
        } else {
            if (value instanceof VEnum) {
                setValue(new String[] { ((VEnum) value).getValue() });
            } else if (value instanceof VString) {
                setValue(new String[] { ((VString) value).getValue() });
            } else if (value instanceof VStringArray) {
                setValue(((VStringArray) value).getData().toArray());
            } else {
                setValue(VTypeHelper.getDoubleArray(value));
            }
        }
        return false;
    };
    setPropertyChangeHandler(PROP_PVVALUE, handler);
    getWidgetModel().getProperty(PROP_PVNAME).addPropertyChangeListener(evt -> updatePropSheet());
    handler = (oldValue, newValue, figure) -> {
        registerLoadPVDataTypeListener();
        return false;
    };
    setPropertyChangeHandler(PROP_PVNAME, handler);
    getWidgetModel().getProperty(PROP_DATA_TYPE).addPropertyChangeListener(evt -> initValueArray());
    handler = (oldValue, newValue, figure) -> {
        updateWidgetSize();
        return false;
    };
    setPropertyChangeHandler(PROP_BORDER_STYLE, handler);
    setPropertyChangeHandler(PROP_BORDER_WIDTH, handler);
    handler = (oldValue, newValue, figure) -> {
        getArrayFigure().setArrayLength((Integer) newValue);
        return false;
    };
    setPropertyChangeHandler(PROP_ARRAY_LENGTH, handler);
    handler = (oldValue, newValue, figure) -> {
        ((ArrayFigure) figure).setSpinnerWidth((Integer) newValue);
        keepElementSize = true;
        getWidgetModel().setSize(((ArrayFigure) figure).getPreferredSize());
        keepElementSize = false;
        return false;
    };
    setPropertyChangeHandler(PROP_SPINNER_WIDTH, handler);
    handler = (oldValue, newValue, figure) -> {
        ((ArrayFigure) figure).setHorizontal((Boolean) newValue);
        keepElementSize = true;
        getWidgetModel().setSize(((ArrayFigure) figure).getPreferredSize());
        keepElementSize = false;
        return false;
    };
    setPropertyChangeHandler(PROP_HORIZONTAL, handler);
    handler = (oldValue, newValue, figure) -> {
        ((ArrayFigure) figure).setShowScrollbar((Boolean) newValue);
        keepElementSize = true;
        getWidgetModel().setSize(((ArrayFigure) figure).getPreferredSize());
        keepElementSize = false;
        return false;
    };
    setPropertyChangeHandler(PROP_SHOW_SCROLLBAR, handler);
    handler = (oldValue, newValue, figure) -> {
        ((ArrayFigure) figure).setShowSpinner((Boolean) newValue);
        keepElementSize = true;
        getWidgetModel().setSize(((ArrayFigure) figure).getPreferredSize());
        keepElementSize = false;
        return false;
    };
    setPropertyChangeHandler(PROP_SHOW_SPINNER, handler);
    PropertyChangeListener sizePropertyChangeListener = evt -> {
        if (getWidgetModel().getChildren().size() == 0 || inSync || keepElementSize) {
            return;
        }
        var elementSize = getArrayFigure().getElementSize();
        var delta = (Integer) evt.getNewValue() - (Integer) evt.getOldValue();
        var elementWH = elementSize.height;
        var propID = evt.getPropertyName();
        var elementCountDirection = false;
        if (getWidgetModel().isHorizontal() && propID.equals(PROP_WIDTH)) {
            elementWH = elementSize.width;
            elementCountDirection = true;
        } else if (!getWidgetModel().isHorizontal() && propID.equals(PROP_HEIGHT)) {
            elementWH = elementSize.height;
            elementCountDirection = true;
        }
        if (elementCountDirection) {
            var deltaElementsCount = Math.round((float) delta / elementWH);
            var idelta = (Math.round((float) delta / elementWH) * elementWH);
            setPropertyValue(propID, (Integer) evt.getOldValue() + idelta, false);
            var visibleElementsCount = getArrayFigure().getVisibleElementsCount() + deltaElementsCount;
            setPropertyValue(PROP_VISIBLE_ELEMENTS_COUNT, visibleElementsCount);
            setValue(getValue());
        } else {
            int wh;
            if (propID.equals(PROP_WIDTH)) {
                wh = getArrayFigure().getElementSize().width;
            } else {
                wh = getArrayFigure().getElementSize().height;
            }
            syncAllChildrenProperties(propID, wh + delta);
        }
    };
    getWidgetModel().getProperty(PROP_WIDTH).addPropertyChangeListener(sizePropertyChangeListener);
    getWidgetModel().getProperty(PROP_HEIGHT).addPropertyChangeListener(sizePropertyChangeListener);
}
Also used : IPrimaryArrayWrapper(org.csstudio.swt.widgets.datadefinition.IPrimaryArrayWrapper) Arrays(java.util.Arrays) PROP_BORDER_WIDTH(org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_BORDER_WIDTH) ProcessVariable(org.csstudio.csdata.ProcessVariable) ByteArrayWrapper(org.csstudio.swt.widgets.datadefinition.ByteArrayWrapper) AbstractWidgetModel(org.csstudio.opibuilder.model.AbstractWidgetModel) ConnectionHandler(org.csstudio.opibuilder.editparts.ConnectionHandler) PROP_PVNAME(org.csstudio.opibuilder.model.IPVWidgetModel.PROP_PVNAME) PROP_VISIBLE_ELEMENTS_COUNT(org.csstudio.opibuilder.widgets.model.ArrayModel.PROP_VISIBLE_ELEMENTS_COUNT) IFigure(org.eclipse.draw2d.IFigure) ITextFigure(org.csstudio.swt.widgets.figures.ITextFigure) IPV(org.yamcs.studio.data.IPV) UIBundlingThread(org.csstudio.ui.util.thread.UIBundlingThread) Arrays.asList(java.util.Arrays.asList) ErrorHandlerUtil(org.csstudio.opibuilder.util.ErrorHandlerUtil) IPVListener(org.yamcs.studio.data.IPVListener) IPVWidgetEditpart(org.csstudio.opibuilder.editparts.IPVWidgetEditpart) IntArrayWrapper(org.csstudio.swt.widgets.datadefinition.IntArrayWrapper) LongArrayWrapper(org.csstudio.swt.widgets.datadefinition.LongArrayWrapper) ExecutionMode(org.csstudio.opibuilder.editparts.ExecutionMode) ArrayFigure(org.csstudio.swt.widgets.figures.ArrayFigure) SelectEditPartTracker(org.eclipse.gef.tools.SelectEditPartTracker) VTypeHelper(org.yamcs.studio.data.VTypeHelper) NLS(org.eclipse.osgi.util.NLS) PROP_FORECOLOR_ALARMSENSITIVE(org.csstudio.opibuilder.model.IPVWidgetModel.PROP_FORECOLOR_ALARMSENSITIVE) IWidgetInfoProvider(org.csstudio.opibuilder.model.IWidgetInfoProvider) PROP_ALARM_PULSING(org.csstudio.opibuilder.model.IPVWidgetModel.PROP_ALARM_PULSING) FloatArrayWrapper(org.csstudio.swt.widgets.datadefinition.FloatArrayWrapper) PROP_YPOS(org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_YPOS) MouseEvent(org.eclipse.swt.events.MouseEvent) List(java.util.List) VString(org.yamcs.studio.data.vtype.VString) PropertyChangeListener(java.beans.PropertyChangeListener) PROP_HORIZONTAL(org.csstudio.opibuilder.widgets.model.ArrayModel.PROP_HORIZONTAL) VType(org.yamcs.studio.data.vtype.VType) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) PROP_SHOW_SCROLLBAR(org.csstudio.opibuilder.widgets.model.ArrayModel.PROP_SHOW_SCROLLBAR) EditPart(org.eclipse.gef.EditPart) PROP_BORDER_STYLE(org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_BORDER_STYLE) PROP_WIDTH(org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_WIDTH) PROP_TOOLTIP(org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_TOOLTIP) PROP_PVVALUE(org.csstudio.opibuilder.model.IPVWidgetModel.PROP_PVVALUE) PROP_BACKCOLOR_ALARMSENSITIVE(org.csstudio.opibuilder.model.IPVWidgetModel.PROP_BACKCOLOR_ALARMSENSITIVE) EditPartViewer(org.eclipse.gef.EditPartViewer) VNumberArray(org.yamcs.studio.data.vtype.VNumberArray) PROP_HEIGHT(org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_HEIGHT) PROP_ARRAY_LENGTH(org.csstudio.opibuilder.widgets.model.ArrayModel.PROP_ARRAY_LENGTH) RequestConstants(org.eclipse.gef.RequestConstants) ArrayList(java.util.ArrayList) PROP_XPOS(org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_XPOS) ArrayModel(org.csstudio.opibuilder.widgets.model.ArrayModel) Border(org.eclipse.draw2d.Border) Request(org.eclipse.gef.Request) PROP_SPINNER_WIDTH(org.csstudio.opibuilder.widgets.model.ArrayModel.PROP_SPINNER_WIDTH) PROP_DATA_TYPE(org.csstudio.opibuilder.widgets.model.ArrayModel.PROP_DATA_TYPE) PVWidgetConnectionHandler(org.csstudio.opibuilder.editparts.PVWidgetConnectionHandler) PVWidgetEditpartDelegate(org.csstudio.opibuilder.editparts.PVWidgetEditpartDelegate) ShortArrayWrapper(org.csstudio.swt.widgets.datadefinition.ShortArrayWrapper) VEnum(org.yamcs.studio.data.vtype.VEnum) AbstractBaseEditPart(org.csstudio.opibuilder.editparts.AbstractBaseEditPart) PROP_SCALE_OPTIONS(org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_SCALE_OPTIONS) BasicDataType(org.yamcs.studio.data.BasicDataType) NonExistPropertyException(org.csstudio.opibuilder.model.NonExistPropertyException) DoubleArrayWrapper(org.csstudio.swt.widgets.datadefinition.DoubleArrayWrapper) ArrayDataType(org.csstudio.opibuilder.widgets.model.ArrayModel.ArrayDataType) DragTracker(org.eclipse.gef.DragTracker) AbstractContainerEditpart(org.csstudio.opibuilder.editparts.AbstractContainerEditpart) EditPolicy(org.eclipse.gef.EditPolicy) PROP_BORDER_ALARMSENSITIVE(org.csstudio.opibuilder.model.IPVWidgetModel.PROP_BORDER_ALARMSENSITIVE) PROP_SHOW_SPINNER(org.csstudio.opibuilder.widgets.model.ArrayModel.PROP_SHOW_SPINNER) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler) VStringArray(org.yamcs.studio.data.vtype.VStringArray) PropertyChangeListener(java.beans.PropertyChangeListener) VEnum(org.yamcs.studio.data.vtype.VEnum) VString(org.yamcs.studio.data.vtype.VString) VNumberArray(org.yamcs.studio.data.vtype.VNumberArray) VType(org.yamcs.studio.data.vtype.VType) ArrayFigure(org.csstudio.swt.widgets.figures.ArrayFigure) VString(org.yamcs.studio.data.vtype.VString) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler) VStringArray(org.yamcs.studio.data.vtype.VStringArray)

Example 3 with PROP_WIDTH

use of org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_WIDTH in project yamcs-studio by yamcs.

the class ImageEditPart method registerPropertyChangeHandlers.

@Override
protected void registerPropertyChangeHandlers() {
    setPropertyChangeHandler(PROP_IMAGE_FILE, (oldValue, newValue, figure) -> {
        var imageFigure = (ImageFigure) figure;
        var absolutePath = (String) newValue;
        if (!absolutePath.contains("://")) {
            var path = Path.fromPortableString(absolutePath);
            if (!path.isAbsolute()) {
                path = ResourceUtil.buildAbsolutePath(getWidgetModel(), path);
                absolutePath = path.toPortableString();
            }
        }
        imageFigure.setFilePath(absolutePath);
        autoSizeWidget(imageFigure);
        return false;
    });
    setPropertyChangeHandler(PROP_STRETCH, (oldValue, newValue, figure) -> {
        var imageFigure = (ImageFigure) figure;
        imageFigure.setStretch((Boolean) newValue);
        autoSizeWidget(imageFigure);
        return false;
    });
    setPropertyChangeHandler(PROP_AUTOSIZE, (oldValue, newValue, figure) -> {
        var imageFigure = (ImageFigure) figure;
        imageFigure.setAutoSize((Boolean) newValue);
        var model = (ImageModel) getModel();
        var d = imageFigure.getAutoSizedDimension();
        if ((Boolean) newValue && !model.getStretch() && d != null) {
            model.setSize(d.width, d.height);
        }
        return false;
    });
    setPropertyChangeHandler(PROP_NO_ANIMATION, (oldValue, newValue, figure) -> {
        var imageFigure = (ImageFigure) figure;
        imageFigure.setAnimationDisabled((Boolean) newValue);
        return false;
    });
    setPropertyChangeHandler(PROP_ALIGN_TO_NEAREST_SECOND, (oldValue, newValue, figure) -> {
        var imageFigure = (ImageFigure) figure;
        imageFigure.setAlignedToNearestSecond((Boolean) newValue);
        return false;
    });
    // changes to the border width property
    IWidgetPropertyChangeHandler handle = (oldValue, newValue, figure) -> {
        var imageFigure = (ImageFigure) figure;
        imageFigure.resizeImage();
        autoSizeWidget(imageFigure);
        return false;
    };
    setPropertyChangeHandler(PROP_BORDER_WIDTH, handle);
    setPropertyChangeHandler(PROP_BORDER_STYLE, handle);
    // size change handlers - so we can stretch accordingly
    handle = (oldValue, newValue, figure) -> {
        var imageFigure = (ImageFigure) figure;
        imageFigure.resizeImage();
        autoSizeWidget(imageFigure);
        return false;
    };
    setPropertyChangeHandler(PROP_HEIGHT, handle);
    setPropertyChangeHandler(PROP_WIDTH, handle);
    FigureTransparencyHelper.addHandler(this, figure);
    registerCropPropertyHandlers();
    registerImageRotationPropertyHandlers();
}
Also used : AbstractWidgetEditPart(org.csstudio.opibuilder.editparts.AbstractWidgetEditPart) PROP_AUTOSIZE(org.csstudio.opibuilder.widgets.model.ImageModel.PROP_AUTOSIZE) PROP_BORDER_WIDTH(org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_BORDER_WIDTH) PROP_HEIGHT(org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_HEIGHT) PROP_LEFTCROP(org.csstudio.opibuilder.widgets.model.ImageModel.PROP_LEFTCROP) ImageModel(org.csstudio.opibuilder.widgets.model.ImageModel) ResourceUtil(org.csstudio.opibuilder.util.ResourceUtil) IFigure(org.eclipse.draw2d.IFigure) PROP_FLIP_HORIZONTAL(org.csstudio.opibuilder.widgets.model.ImageModel.PROP_FLIP_HORIZONTAL) PROP_ALIGN_TO_NEAREST_SECOND(org.csstudio.opibuilder.widgets.model.ImageModel.PROP_ALIGN_TO_NEAREST_SECOND) PROP_TOPCROP(org.csstudio.opibuilder.widgets.model.ImageModel.PROP_TOPCROP) FigureTransparencyHelper(org.csstudio.opibuilder.widgets.FigureTransparencyHelper) PROP_FLIP_VERTICAL(org.csstudio.opibuilder.widgets.model.ImageModel.PROP_FLIP_VERTICAL) PROP_RIGHTCROP(org.csstudio.opibuilder.widgets.model.ImageModel.PROP_RIGHTCROP) PROP_DEGREE(org.csstudio.opibuilder.widgets.model.ImageModel.PROP_DEGREE) PROP_BOTTOMCROP(org.csstudio.opibuilder.widgets.model.ImageModel.PROP_BOTTOMCROP) Display(org.eclipse.swt.widgets.Display) PROP_IMAGE_FILE(org.csstudio.opibuilder.widgets.model.ImageModel.PROP_IMAGE_FILE) PROP_NO_ANIMATION(org.csstudio.opibuilder.widgets.model.ImageModel.PROP_NO_ANIMATION) ImageFigure(org.csstudio.opibuilder.widgets.figures.ImageFigure) Color(org.eclipse.swt.graphics.Color) Path(org.eclipse.core.runtime.Path) PROP_STRETCH(org.csstudio.opibuilder.widgets.model.ImageModel.PROP_STRETCH) PermutationMatrix(org.csstudio.swt.widgets.symbol.util.PermutationMatrix) PROP_BORDER_STYLE(org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_BORDER_STYLE) SymbolImageProperties(org.csstudio.swt.widgets.symbol.SymbolImageProperties) PROP_WIDTH(org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_WIDTH) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler) ImageFigure(org.csstudio.opibuilder.widgets.figures.ImageFigure) ImageModel(org.csstudio.opibuilder.widgets.model.ImageModel)

Example 4 with PROP_WIDTH

use of org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_WIDTH in project yamcs-studio by yamcs.

the class KnobEditPart method registerPropertyChangeHandlers.

@Override
protected void registerPropertyChangeHandlers() {
    registerCommonPropertyChangeHandlers();
    setPropertyChangeHandler(PROP_KNOB_COLOR, (oldValue, newValue, refreshableFigure) -> {
        var knob = (KnobFigure) refreshableFigure;
        knob.setBulbColor(((OPIColor) newValue).getSWTColor());
        return false;
    });
    setPropertyChangeHandler(PROP_THUMB_COLOR, (oldValue, newValue, refreshableFigure) -> {
        var knob = (KnobFigure) refreshableFigure;
        knob.setThumbColor(((OPIColor) newValue).getSWTColor());
        return false;
    });
    setPropertyChangeHandler(PROP_EFFECT3D, (oldValue, newValue, refreshableFigure) -> {
        var knob = (KnobFigure) refreshableFigure;
        knob.setEffect3D((Boolean) newValue);
        return false;
    });
    setPropertyChangeHandler(PROP_SHOW_VALUE_LABEL, (oldValue, newValue, refreshableFigure) -> {
        var knob = (KnobFigure) refreshableFigure;
        knob.setValueLabelVisibility((Boolean) newValue);
        return false;
    });
    setPropertyChangeHandler(PROP_RAMP_GRADIENT, (oldValue, newValue, refreshableFigure) -> {
        var knob = (KnobFigure) refreshableFigure;
        knob.setGradient((Boolean) newValue);
        return false;
    });
    setPropertyChangeHandler(PROP_INCREMENT, (oldValue, newValue, refreshableFigure) -> {
        var knob = (KnobFigure) refreshableFigure;
        knob.setIncrement((Double) newValue);
        return false;
    });
    // force square size
    IWidgetPropertyChangeHandler sizeHandler = (oldValue, newValue, figure) -> {
        if (((Integer) newValue) < KnobModel.MINIMUM_SIZE) {
            newValue = KnobModel.MINIMUM_SIZE;
        }
        getWidgetModel().setSize((Integer) newValue, (Integer) newValue);
        return false;
    };
    PropertyChangeListener sizeListener = evt -> sizeHandler.handleChange(evt.getOldValue(), evt.getNewValue(), getFigure());
    getWidgetModel().getProperty(PROP_WIDTH).addPropertyChangeListener(sizeListener);
    getWidgetModel().getProperty(PROP_HEIGHT).addPropertyChangeListener(sizeListener);
}
Also used : PROP_PVVALUE(org.csstudio.opibuilder.model.IPVWidgetModel.PROP_PVVALUE) PROP_EFFECT3D(org.csstudio.opibuilder.widgets.model.KnobModel.PROP_EFFECT3D) PROP_THUMB_COLOR(org.csstudio.opibuilder.widgets.model.KnobModel.PROP_THUMB_COLOR) PROP_KNOB_COLOR(org.csstudio.opibuilder.widgets.model.KnobModel.PROP_KNOB_COLOR) PROP_RAMP_GRADIENT(org.csstudio.opibuilder.widgets.model.KnobModel.PROP_RAMP_GRADIENT) PROP_HEIGHT(org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_HEIGHT) PROP_INCREMENT(org.csstudio.opibuilder.widgets.model.KnobModel.PROP_INCREMENT) KnobFigure(org.csstudio.swt.widgets.figures.KnobFigure) PROP_PVNAME(org.csstudio.opibuilder.model.IPVWidgetModel.PROP_PVNAME) IFigure(org.eclipse.draw2d.IFigure) KnobModel(org.csstudio.opibuilder.widgets.model.KnobModel) PropertyChangeListener(java.beans.PropertyChangeListener) OPIColor(org.csstudio.opibuilder.util.OPIColor) PROP_SHOW_VALUE_LABEL(org.csstudio.opibuilder.widgets.model.KnobModel.PROP_SHOW_VALUE_LABEL) PROP_WIDTH(org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_WIDTH) ExecutionMode(org.csstudio.opibuilder.editparts.ExecutionMode) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler) PropertyChangeListener(java.beans.PropertyChangeListener) KnobFigure(org.csstudio.swt.widgets.figures.KnobFigure) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler)

Example 5 with PROP_WIDTH

use of org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_WIDTH in project yamcs-studio by yamcs.

the class GroupingContainerEditPart method registerPropertyChangeHandlers.

@Override
protected void registerPropertyChangeHandlers() {
    setPropertyChangeHandler(PROP_TRANSPARENT, (oldValue, newValue, figure) -> {
        figure.setOpaque(!(Boolean) newValue);
        return true;
    });
    setPropertyChangeHandler(PROP_ENABLED, (oldValue, newValue, figure) -> {
        for (var child : getWidgetModel().getChildren()) {
            child.setEnabled((Boolean) newValue);
        }
        return true;
    });
    setPropertyChangeHandler(PROP_LOCK_CHILDREN, (oldValue, newValue, figure) -> {
        lockChildren((Boolean) newValue);
        return true;
    });
    lockChildren(getWidgetModel().isLocked());
    if (getWidgetModel().getParent() instanceof TabModel) {
        removeAllPropertyChangeHandlers(PROP_VISIBLE);
        setPropertyChangeHandler(PROP_VISIBLE, (oldValue, newValue, refreshableFigure) -> {
            boolean visible = (Boolean) newValue;
            var figure = getFigure();
            figure.setVisible(visible);
            return true;
        });
    }
    setPropertyChangeHandler(PROP_SHOW_SCROLLBAR, (oldValue, newValue, refreshableFigure) -> {
        ((GroupingContainerFigure) refreshableFigure).setShowScrollBar((Boolean) newValue);
        return true;
    });
    IWidgetPropertyChangeHandler fowardColorHandler = (oldValue, newValue, refreshableFigure) -> {
        if (getWidgetModel().isForwardColors()) {
            forwardColors();
        }
        return true;
    };
    setPropertyChangeHandler(PROP_FORWARD_COLORS, fowardColorHandler);
    setPropertyChangeHandler(PROP_COLOR_BACKGROUND, fowardColorHandler);
    setPropertyChangeHandler(PROP_COLOR_FOREGROUND, fowardColorHandler);
    // use property listener because it doesn't need to be queued in GUIRefreshThread.
    getWidgetModel().getProperty(PROP_WIDTH).addPropertyChangeListener(evt -> resizeChildren((Integer) (evt.getNewValue()), (Integer) (evt.getOldValue()), true));
    getWidgetModel().getProperty(PROP_HEIGHT).addPropertyChangeListener(evt -> resizeChildren((Integer) (evt.getNewValue()), (Integer) (evt.getOldValue()), false));
}
Also used : PROP_HEIGHT(org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_HEIGHT) PROP_ENABLED(org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_ENABLED) AbstractBaseEditPart(org.csstudio.opibuilder.editparts.AbstractBaseEditPart) PROP_TRANSPARENT(org.csstudio.opibuilder.widgets.model.GroupingContainerModel.PROP_TRANSPARENT) IFigure(org.eclipse.draw2d.IFigure) PROP_FORWARD_COLORS(org.csstudio.opibuilder.widgets.model.GroupingContainerModel.PROP_FORWARD_COLORS) TabModel(org.csstudio.opibuilder.widgets.model.TabModel) PROP_COLOR_FOREGROUND(org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_COLOR_FOREGROUND) PROP_SHOW_SCROLLBAR(org.csstudio.opibuilder.widgets.model.GroupingContainerModel.PROP_SHOW_SCROLLBAR) PROP_COLOR_BACKGROUND(org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_COLOR_BACKGROUND) PROP_LOCK_CHILDREN(org.csstudio.opibuilder.widgets.model.GroupingContainerModel.PROP_LOCK_CHILDREN) GroupingContainerFigure(org.csstudio.swt.widgets.figures.GroupingContainerFigure) AbstractContainerEditpart(org.csstudio.opibuilder.editparts.AbstractContainerEditpart) IActionFilter(org.eclipse.ui.IActionFilter) EditPolicy(org.eclipse.gef.EditPolicy) GroupingContainerModel(org.csstudio.opibuilder.widgets.model.GroupingContainerModel) EditPart(org.eclipse.gef.EditPart) PROP_VISIBLE(org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_VISIBLE) PROP_WIDTH(org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_WIDTH) ExecutionMode(org.csstudio.opibuilder.editparts.ExecutionMode) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler) GroupingContainerFigure(org.csstudio.swt.widgets.figures.GroupingContainerFigure) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler) TabModel(org.csstudio.opibuilder.widgets.model.TabModel)

Aggregations

PROP_HEIGHT (org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_HEIGHT)11 PROP_WIDTH (org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_WIDTH)11 IWidgetPropertyChangeHandler (org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler)11 IFigure (org.eclipse.draw2d.IFigure)11 ExecutionMode (org.csstudio.opibuilder.editparts.ExecutionMode)6 PROP_BORDER_WIDTH (org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_BORDER_WIDTH)6 PROP_BORDER_STYLE (org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_BORDER_STYLE)5 Path (org.eclipse.core.runtime.Path)5 PropertyChangeListener (java.beans.PropertyChangeListener)4 ResourceUtil (org.csstudio.opibuilder.util.ResourceUtil)4 Color (org.eclipse.swt.graphics.Color)4 AbstractBaseEditPart (org.csstudio.opibuilder.editparts.AbstractBaseEditPart)3 AbstractContainerEditpart (org.csstudio.opibuilder.editparts.AbstractContainerEditpart)3 PROP_PVNAME (org.csstudio.opibuilder.model.IPVWidgetModel.PROP_PVNAME)3 PROP_PVVALUE (org.csstudio.opibuilder.model.IPVWidgetModel.PROP_PVVALUE)3 OPIColor (org.csstudio.opibuilder.util.OPIColor)3 FigureTransparencyHelper (org.csstudio.opibuilder.widgets.FigureTransparencyHelper)3 Arrays (java.util.Arrays)2 List (java.util.List)2 PROP_VISIBLE (org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_VISIBLE)2