Search in sources :

Example 1 with PROP_OFF_IMAGE

use of org.csstudio.opibuilder.widgets.model.ImageBoolIndicatorModel.PROP_OFF_IMAGE 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)

Aggregations

PROP_BORDER_STYLE (org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_BORDER_STYLE)1 PROP_BORDER_WIDTH (org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_BORDER_WIDTH)1 PROP_HEIGHT (org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_HEIGHT)1 PROP_WIDTH (org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_WIDTH)1 IWidgetPropertyChangeHandler (org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler)1 ResourceUtil (org.csstudio.opibuilder.util.ResourceUtil)1 FigureTransparencyHelper (org.csstudio.opibuilder.widgets.FigureTransparencyHelper)1 ImageBoolButtonFigure (org.csstudio.opibuilder.widgets.figures.ImageBoolButtonFigure)1 ImageBoolIndicatorModel (org.csstudio.opibuilder.widgets.model.ImageBoolIndicatorModel)1 PROP_ALIGN_TO_NEAREST_SECOND (org.csstudio.opibuilder.widgets.model.ImageBoolIndicatorModel.PROP_ALIGN_TO_NEAREST_SECOND)1 PROP_AUTOSIZE (org.csstudio.opibuilder.widgets.model.ImageBoolIndicatorModel.PROP_AUTOSIZE)1 PROP_NO_ANIMATION (org.csstudio.opibuilder.widgets.model.ImageBoolIndicatorModel.PROP_NO_ANIMATION)1 PROP_OFF_IMAGE (org.csstudio.opibuilder.widgets.model.ImageBoolIndicatorModel.PROP_OFF_IMAGE)1 PROP_ON_IMAGE (org.csstudio.opibuilder.widgets.model.ImageBoolIndicatorModel.PROP_ON_IMAGE)1 PROP_STRETCH (org.csstudio.opibuilder.widgets.model.ImageBoolIndicatorModel.PROP_STRETCH)1 SymbolImageProperties (org.csstudio.swt.widgets.symbol.SymbolImageProperties)1 Path (org.eclipse.core.runtime.Path)1 IFigure (org.eclipse.draw2d.IFigure)1 Color (org.eclipse.swt.graphics.Color)1 Display (org.eclipse.swt.widgets.Display)1