Search in sources :

Example 1 with ImageBoolButtonFigure

use of org.csstudio.opibuilder.widgets.figures.ImageBoolButtonFigure in project yamcs-studio by yamcs.

the class ImageBoolIndicatorEditPart method registerPropertyChangeHandlers.

/**
 * {@inheritDoc}
 */
@Override
protected void registerPropertyChangeHandlers() {
    registerCommonPropertyChangeHandlers();
    // Don't autosize to save CPU usage
    // removeAllPropertyChangeHandlers(AbstractPVWidgetModel.PROP_PVVALUE);
    // value
    // IWidgetPropertyChangeHandler handler = new IWidgetPropertyChangeHandler() {
    // public boolean handleChange(final 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);
    // changes to the on image property
    IWidgetPropertyChangeHandler handle = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure figure) {
            ImageBoolButtonFigure imageFigure = (ImageBoolButtonFigure) figure;
            IPath absolutePath = (IPath) newValue;
            if (!absolutePath.isAbsolute())
                absolutePath = ResourceUtil.buildAbsolutePath(getWidgetModel(), absolutePath);
            imageFigure.setOnImagePath(absolutePath);
            autoSizeWidget(imageFigure);
            return true;
        }
    };
    setPropertyChangeHandler(ImageBoolIndicatorModel.PROP_ON_IMAGE, handle);
    // changes to the off image property
    handle = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure figure) {
            ImageBoolButtonFigure imageFigure = (ImageBoolButtonFigure) figure;
            IPath absolutePath = (IPath) newValue;
            if (!absolutePath.isAbsolute())
                absolutePath = ResourceUtil.buildAbsolutePath(getWidgetModel(), absolutePath);
            imageFigure.setOffImagePath(absolutePath);
            autoSizeWidget(imageFigure);
            return true;
        }
    };
    setPropertyChangeHandler(ImageBoolIndicatorModel.PROP_OFF_IMAGE, handle);
    // changes to the stretch property
    handle = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure figure) {
            ImageBoolButtonFigure imageFigure = (ImageBoolButtonFigure) figure;
            imageFigure.setStretch((Boolean) newValue);
            autoSizeWidget(imageFigure);
            return true;
        }
    };
    setPropertyChangeHandler(ImageBoolIndicatorModel.PROP_STRETCH, handle);
    // changes to the autosize property
    handle = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure figure) {
            ImageBoolButtonFigure imageFigure = (ImageBoolButtonFigure) figure;
            autoSizeWidget(imageFigure);
            return true;
        }
    };
    setPropertyChangeHandler(ImageBoolIndicatorModel.PROP_AUTOSIZE, handle);
    // changes to the stop animation property
    handle = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure figure) {
            ImageBoolButtonFigure imageFigure = (ImageBoolButtonFigure) figure;
            imageFigure.setAnimationDisabled((Boolean) newValue);
            return false;
        }
    };
    setPropertyChangeHandler(ImageBoolIndicatorModel.PROP_NO_ANIMATION, handle);
    // changes to the align to nearest second property
    handle = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure figure) {
            ImageBoolButtonFigure imageFigure = (ImageBoolButtonFigure) figure;
            imageFigure.setAlignedToNearestSecond((Boolean) newValue);
            return false;
        }
    };
    setPropertyChangeHandler(ImageBoolIndicatorModel.PROP_ALIGN_TO_NEAREST_SECOND, handle);
    // changes to the border width property
    handle = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure figure) {
            ImageBoolButtonFigure imageFigure = (ImageBoolButtonFigure) figure;
            autoSizeWidget(imageFigure);
            return true;
        }
    };
    setPropertyChangeHandler(AbstractWidgetModel.PROP_BORDER_WIDTH, handle);
    setPropertyChangeHandler(AbstractWidgetModel.PROP_BORDER_STYLE, handle);
    // size change handlers - so we can stretch accordingly
    handle = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure figure) {
            ImageBoolButtonFigure imageFigure = (ImageBoolButtonFigure) figure;
            autoSizeWidget(imageFigure);
            return true;
        }
    };
    setPropertyChangeHandler(AbstractWidgetModel.PROP_HEIGHT, handle);
    setPropertyChangeHandler(AbstractWidgetModel.PROP_WIDTH, handle);
    FigureTransparencyHelper.addHandler(this, figure);
}
Also used : IPath(org.eclipse.core.runtime.IPath) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler) ImageBoolButtonFigure(org.csstudio.opibuilder.widgets.figures.ImageBoolButtonFigure) IFigure(org.eclipse.draw2d.IFigure)

Example 2 with ImageBoolButtonFigure

use of org.csstudio.opibuilder.widgets.figures.ImageBoolButtonFigure in project yamcs-studio by yamcs.

the class ImageBoolIndicatorEditPart method doCreateFigure.

/**
 * {@inheritDoc}
 */
@Override
protected IFigure doCreateFigure() {
    ImageBoolIndicatorModel model = getWidgetModel();
    // create AND initialize the view properly
    final ImageBoolButtonFigure figure = new ImageBoolButtonFigure(true);
    initializeCommonFigureProperties(figure, model);
    SymbolImageProperties sip = new SymbolImageProperties();
    sip.setStretch(model.isStretch());
    sip.setAutoSize(model.isAutoSize());
    sip.setAnimationDisabled(model.isStopAnimation());
    sip.setAlignedToNearestSecond(model.isAlignedToNearestSecond());
    sip.setBackgroundColor(new Color(Display.getDefault(), model.getBackgroundColor()));
    figure.setSymbolProperties(sip, model);
    figure.setImageLoadedListener(new IImageListener() {

        @Override
        public void imageResized(IFigure figure) {
            ImageBoolButtonFigure symbolFigure = (ImageBoolButtonFigure) figure;
            autoSizeWidget(symbolFigure);
        }
    });
    figure.setOnImagePath(model.getOnImagePath());
    figure.setOffImagePath(model.getOffImagePath());
    return figure;
}
Also used : SymbolImageProperties(org.csstudio.swt.widgets.symbol.SymbolImageProperties) ImageBoolIndicatorModel(org.csstudio.opibuilder.widgets.model.ImageBoolIndicatorModel) Color(org.eclipse.swt.graphics.Color) ImageBoolButtonFigure(org.csstudio.opibuilder.widgets.figures.ImageBoolButtonFigure) IImageListener(org.csstudio.swt.widgets.symbol.util.IImageListener) IFigure(org.eclipse.draw2d.IFigure)

Example 3 with ImageBoolButtonFigure

use of org.csstudio.opibuilder.widgets.figures.ImageBoolButtonFigure in project yamcs-studio by yamcs.

the class ImageBoolButtonEditPart method doCreateFigure.

/**
 * {@inheritDoc}
 */
@Override
protected IFigure doCreateFigure() {
    ImageBoolButtonModel model = getWidgetModel();
    // create AND initialize the view properly
    final ImageBoolButtonFigure figure = new ImageBoolButtonFigure();
    initializeCommonFigureProperties(figure, model);
    SymbolImageProperties sip = new SymbolImageProperties();
    sip.setStretch(model.isStretch());
    sip.setAutoSize(model.isAutoSize());
    sip.setAnimationDisabled(model.isStopAnimation());
    sip.setAlignedToNearestSecond(model.isAlignedToNearestSecond());
    sip.setBackgroundColor(new Color(Display.getDefault(), model.getBackgroundColor()));
    figure.setSymbolProperties(sip, model);
    figure.setImageLoadedListener(new IImageListener() {

        @Override
        public void imageResized(IFigure figure) {
            ImageBoolButtonFigure symbolFigure = (ImageBoolButtonFigure) figure;
            autoSizeWidget(symbolFigure);
        }
    });
    figure.addManualValueChangeListener(new IManualValueChangeListener() {

        @Override
        public void manualValueChanged(double newValue) {
            if (getExecutionMode() == ExecutionMode.RUN_MODE)
                autoSizeWidget(figure);
        }
    });
    figure.setOnImagePath(model.getOnImagePath());
    figure.setOffImagePath(model.getOffImagePath());
    return figure;
}
Also used : IManualValueChangeListener(org.csstudio.swt.widgets.datadefinition.IManualValueChangeListener) SymbolImageProperties(org.csstudio.swt.widgets.symbol.SymbolImageProperties) ImageBoolButtonModel(org.csstudio.opibuilder.widgets.model.ImageBoolButtonModel) Color(org.eclipse.swt.graphics.Color) ImageBoolButtonFigure(org.csstudio.opibuilder.widgets.figures.ImageBoolButtonFigure) IImageListener(org.csstudio.swt.widgets.symbol.util.IImageListener) IFigure(org.eclipse.draw2d.IFigure)

Example 4 with ImageBoolButtonFigure

use of org.csstudio.opibuilder.widgets.figures.ImageBoolButtonFigure in project yamcs-studio by yamcs.

the class ImageBoolButtonEditPart method registerPropertyChangeHandlers.

/**
 * {@inheritDoc}
 */
@Override
protected void registerPropertyChangeHandlers() {
    registerCommonPropertyChangeHandlers();
    // Save CPU usage
    // removeAllPropertyChangeHandlers(AbstractPVWidgetModel.PROP_PVVALUE);
    // value
    // IWidgetPropertyChangeHandler handler = new IWidgetPropertyChangeHandler() {
    // public boolean handleChange(final 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);
    // changes to the on image property
    IWidgetPropertyChangeHandler handle = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure figure) {
            ImageBoolButtonFigure imageFigure = (ImageBoolButtonFigure) figure;
            IPath absolutePath = (IPath) newValue;
            if (!absolutePath.isAbsolute())
                absolutePath = ResourceUtil.buildAbsolutePath(getWidgetModel(), absolutePath);
            imageFigure.setOnImagePath(absolutePath);
            autoSizeWidget(imageFigure);
            return true;
        }
    };
    setPropertyChangeHandler(ImageBoolButtonModel.PROP_ON_IMAGE, handle);
    // changes to the off image property
    handle = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure figure) {
            ImageBoolButtonFigure imageFigure = (ImageBoolButtonFigure) figure;
            IPath absolutePath = (IPath) newValue;
            if (!absolutePath.isAbsolute())
                absolutePath = ResourceUtil.buildAbsolutePath(getWidgetModel(), absolutePath);
            imageFigure.setOffImagePath(absolutePath);
            autoSizeWidget(imageFigure);
            return true;
        }
    };
    setPropertyChangeHandler(ImageBoolButtonModel.PROP_OFF_IMAGE, handle);
    // changes to the stretch property
    handle = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure figure) {
            ImageBoolButtonFigure imageFigure = (ImageBoolButtonFigure) figure;
            imageFigure.setStretch((Boolean) newValue);
            autoSizeWidget(imageFigure);
            return true;
        }
    };
    setPropertyChangeHandler(ImageBoolButtonModel.PROP_STRETCH, handle);
    FigureTransparencyHelper.addHandler(this, figure);
    // changes to the autosize property
    handle = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure figure) {
            ImageBoolButtonFigure imageFigure = (ImageBoolButtonFigure) figure;
            autoSizeWidget(imageFigure);
            return true;
        }
    };
    setPropertyChangeHandler(ImageBoolButtonModel.PROP_AUTOSIZE, handle);
    // changes to the stop animation property
    handle = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure figure) {
            ImageBoolButtonFigure imageFigure = (ImageBoolButtonFigure) figure;
            imageFigure.setAnimationDisabled((Boolean) newValue);
            return false;
        }
    };
    setPropertyChangeHandler(ImageBoolButtonModel.PROP_NO_ANIMATION, handle);
    // changes to the align to nearest second property
    handle = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure figure) {
            ImageBoolButtonFigure imageFigure = (ImageBoolButtonFigure) figure;
            imageFigure.setAlignedToNearestSecond((Boolean) newValue);
            return false;
        }
    };
    setPropertyChangeHandler(ImageBoolButtonModel.PROP_ALIGN_TO_NEAREST_SECOND, handle);
    // changes to the border width property
    handle = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure figure) {
            ImageBoolButtonFigure imageFigure = (ImageBoolButtonFigure) figure;
            autoSizeWidget(imageFigure);
            return true;
        }
    };
    setPropertyChangeHandler(AbstractWidgetModel.PROP_BORDER_WIDTH, handle);
    setPropertyChangeHandler(AbstractWidgetModel.PROP_BORDER_STYLE, handle);
    // size change handlers - so we can stretch accordingly
    handle = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure figure) {
            ImageBoolButtonFigure imageFigure = (ImageBoolButtonFigure) figure;
            autoSizeWidget(imageFigure);
            return true;
        }
    };
    setPropertyChangeHandler(AbstractWidgetModel.PROP_HEIGHT, handle);
    setPropertyChangeHandler(AbstractWidgetModel.PROP_WIDTH, handle);
}
Also used : IPath(org.eclipse.core.runtime.IPath) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler) ImageBoolButtonFigure(org.csstudio.opibuilder.widgets.figures.ImageBoolButtonFigure) IFigure(org.eclipse.draw2d.IFigure)

Aggregations

ImageBoolButtonFigure (org.csstudio.opibuilder.widgets.figures.ImageBoolButtonFigure)4 IFigure (org.eclipse.draw2d.IFigure)4 IWidgetPropertyChangeHandler (org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler)2 SymbolImageProperties (org.csstudio.swt.widgets.symbol.SymbolImageProperties)2 IImageListener (org.csstudio.swt.widgets.symbol.util.IImageListener)2 IPath (org.eclipse.core.runtime.IPath)2 Color (org.eclipse.swt.graphics.Color)2 ImageBoolButtonModel (org.csstudio.opibuilder.widgets.model.ImageBoolButtonModel)1 ImageBoolIndicatorModel (org.csstudio.opibuilder.widgets.model.ImageBoolIndicatorModel)1 IManualValueChangeListener (org.csstudio.swt.widgets.datadefinition.IManualValueChangeListener)1