Search in sources :

Example 1 with PROP_OFF_IMAGE

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

the class ImageBoolButtonEditPart method registerPropertyChangeHandlers.

@Override
protected void registerPropertyChangeHandlers() {
    registerCommonPropertyChangeHandlers();
    // 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;
    // //figure.setValue(ValueUtil.getDouble((IValue)newValue));
    // 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;
    });
    FigureTransparencyHelper.addHandler(this, figure);
    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);
}
Also used : PROP_OFF_IMAGE(org.csstudio.opibuilder.widgets.model.ImageBoolButtonModel.PROP_OFF_IMAGE) PROP_BORDER_WIDTH(org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_BORDER_WIDTH) PROP_NO_ANIMATION(org.csstudio.opibuilder.widgets.model.ImageBoolButtonModel.PROP_NO_ANIMATION) PROP_HEIGHT(org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_HEIGHT) ImageBoolButtonModel(org.csstudio.opibuilder.widgets.model.ImageBoolButtonModel) 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.ImageBoolButtonModel.PROP_ON_IMAGE) PROP_AUTOSIZE(org.csstudio.opibuilder.widgets.model.ImageBoolButtonModel.PROP_AUTOSIZE) PROP_STRETCH(org.csstudio.opibuilder.widgets.model.ImageBoolButtonModel.PROP_STRETCH) Color(org.eclipse.swt.graphics.Color) PROP_ALIGN_TO_NEAREST_SECOND(org.csstudio.opibuilder.widgets.model.ImageBoolButtonModel.PROP_ALIGN_TO_NEAREST_SECOND) Path(org.eclipse.core.runtime.Path) FigureTransparencyHelper(org.csstudio.opibuilder.widgets.FigureTransparencyHelper) 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) ExecutionMode(org.csstudio.opibuilder.editparts.ExecutionMode) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler) ImageBoolButtonFigure(org.csstudio.opibuilder.widgets.figures.ImageBoolButtonFigure)

Aggregations

ExecutionMode (org.csstudio.opibuilder.editparts.ExecutionMode)1 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 ImageBoolButtonModel (org.csstudio.opibuilder.widgets.model.ImageBoolButtonModel)1 PROP_ALIGN_TO_NEAREST_SECOND (org.csstudio.opibuilder.widgets.model.ImageBoolButtonModel.PROP_ALIGN_TO_NEAREST_SECOND)1 PROP_AUTOSIZE (org.csstudio.opibuilder.widgets.model.ImageBoolButtonModel.PROP_AUTOSIZE)1 PROP_NO_ANIMATION (org.csstudio.opibuilder.widgets.model.ImageBoolButtonModel.PROP_NO_ANIMATION)1 PROP_OFF_IMAGE (org.csstudio.opibuilder.widgets.model.ImageBoolButtonModel.PROP_OFF_IMAGE)1 PROP_ON_IMAGE (org.csstudio.opibuilder.widgets.model.ImageBoolButtonModel.PROP_ON_IMAGE)1 PROP_STRETCH (org.csstudio.opibuilder.widgets.model.ImageBoolButtonModel.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