Search in sources :

Example 41 with IWidgetPropertyChangeHandler

use of org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler in project yamcs-studio by yamcs.

the class Draw2DTextInputEditpartDelegate method registerPropertyChangeHandlers.

@Override
public void registerPropertyChangeHandlers() {
    IWidgetPropertyChangeHandler selectorTypeHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            ((TextInputFigure) figure).setSelectorType(model.getSelectorType());
            return false;
        }
    };
    editpart.setPropertyChangeHandler(TextInputModel.PROP_SELECTOR_TYPE, selectorTypeHandler);
    IWidgetPropertyChangeHandler dateTimeFormatHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            ((TextInputFigure) figure).setDateTimeFormat((String) newValue);
            return false;
        }
    };
    editpart.setPropertyChangeHandler(TextInputModel.PROP_DATETIME_FORMAT, dateTimeFormatHandler);
    IWidgetPropertyChangeHandler fileSourceHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            ((TextInputFigure) figure).setFileSource(FileSource.values()[(Integer) newValue]);
            return false;
        }
    };
    editpart.setPropertyChangeHandler(TextInputModel.PROP_FILE_SOURCE, fileSourceHandler);
    IWidgetPropertyChangeHandler fileReturnPartHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            ((TextInputFigure) figure).setFileReturnPart(FileReturnPart.values()[(Integer) newValue]);
            return false;
        }
    };
    editpart.setPropertyChangeHandler(TextInputModel.PROP_FILE_RETURN_PART, fileReturnPartHandler);
}
Also used : IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler) TextInputFigure(org.csstudio.swt.widgets.figures.TextInputFigure) IFigure(org.eclipse.draw2d.IFigure)

Example 42 with IWidgetPropertyChangeHandler

use of org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler in project yamcs-studio by yamcs.

the class EllipseEditpart method registerPropertyChangeHandlers.

@Override
protected void registerPropertyChangeHandlers() {
    super.registerPropertyChangeHandlers();
    // fill
    IWidgetPropertyChangeHandler fillHandler = new IWidgetPropertyChangeHandler() {

        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            EllipseFigure ellipseFigure = (EllipseFigure) refreshableFigure;
            ellipseFigure.setFill((Double) newValue);
            return true;
        }
    };
    setPropertyChangeHandler(AbstractShapeModel.PROP_FILL_LEVEL, fillHandler);
    // fill orientaion
    IWidgetPropertyChangeHandler fillOrientHandler = new IWidgetPropertyChangeHandler() {

        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            EllipseFigure ellipseFigure = (EllipseFigure) refreshableFigure;
            ellipseFigure.setHorizontalFill((Boolean) newValue);
            return true;
        }
    };
    setPropertyChangeHandler(AbstractShapeModel.PROP_HORIZONTAL_FILL, fillOrientHandler);
    // transparent
    IWidgetPropertyChangeHandler transparentHandler = new IWidgetPropertyChangeHandler() {

        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            EllipseFigure ellipseFigure = (EllipseFigure) refreshableFigure;
            ellipseFigure.setTransparent((Boolean) newValue);
            return true;
        }
    };
    setPropertyChangeHandler(AbstractShapeModel.PROP_TRANSPARENT, transparentHandler);
    // line color
    IWidgetPropertyChangeHandler lineColorHandler = new IWidgetPropertyChangeHandler() {

        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            ((EllipseFigure) refreshableFigure).setLineColor(((OPIColor) newValue).getSWTColor());
            return true;
        }
    };
    setPropertyChangeHandler(AbstractShapeModel.PROP_LINE_COLOR, lineColorHandler);
    IWidgetPropertyChangeHandler handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            ((EllipseFigure) figure).setGradient((Boolean) newValue);
            return false;
        }
    };
    setPropertyChangeHandler(EllipseModel.PROP_GRADIENT, handler);
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            ((EllipseFigure) figure).setBackGradientStartColor(((OPIColor) newValue).getSWTColor());
            return false;
        }
    };
    setPropertyChangeHandler(EllipseModel.PROP_BACKGROUND_GRADIENT_START_COLOR, handler);
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            ((EllipseFigure) figure).setForeGradientStartColor(((OPIColor) newValue).getSWTColor());
            return false;
        }
    };
    setPropertyChangeHandler(EllipseModel.PROP_FOREGROUND_GRADIENT_START_COLOR, handler);
}
Also used : IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler) EllipseFigure(org.csstudio.swt.widgets.figures.EllipseFigure) OPIColor(org.csstudio.opibuilder.util.OPIColor) IFigure(org.eclipse.draw2d.IFigure)

Example 43 with IWidgetPropertyChangeHandler

use of org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler in project yamcs-studio by yamcs.

the class GaugeEditPart method registerPropertyChangeHandlers.

/**
 * {@inheritDoc}
 */
@Override
protected void registerPropertyChangeHandlers() {
    registerCommonPropertyChangeHandlers();
    // needle Color
    IWidgetPropertyChangeHandler needleColorColorHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            GaugeFigure gauge = (GaugeFigure) refreshableFigure;
            gauge.setNeedleColor(((OPIColor) newValue).getSWTColor());
            return false;
        }
    };
    setPropertyChangeHandler(GaugeModel.PROP_NEEDLE_COLOR, needleColorColorHandler);
    // effect 3D
    IWidgetPropertyChangeHandler effect3DHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            GaugeFigure gauge = (GaugeFigure) refreshableFigure;
            gauge.setEffect3D((Boolean) newValue);
            return false;
        }
    };
    setPropertyChangeHandler(GaugeModel.PROP_EFFECT3D, effect3DHandler);
    // Ramp gradient
    IWidgetPropertyChangeHandler gradientHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            GaugeFigure gauge = (GaugeFigure) refreshableFigure;
            gauge.setGradient((Boolean) newValue);
            return false;
        }
    };
    setPropertyChangeHandler(GaugeModel.PROP_RAMP_GRADIENT, gradientHandler);
    final IWidgetPropertyChangeHandler sizeHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            if (((Integer) newValue) < GaugeModel.MINIMUM_SIZE)
                newValue = GaugeModel.MINIMUM_SIZE;
            getWidgetModel().setSize((Integer) newValue, (Integer) newValue);
            return false;
        }
    };
    PropertyChangeListener sizeListener = new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            sizeHandler.handleChange(evt.getOldValue(), evt.getNewValue(), getFigure());
        }
    };
    getWidgetModel().getProperty(AbstractWidgetModel.PROP_WIDTH).addPropertyChangeListener(sizeListener);
    getWidgetModel().getProperty(AbstractWidgetModel.PROP_HEIGHT).addPropertyChangeListener(sizeListener);
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler) IFigure(org.eclipse.draw2d.IFigure) GaugeFigure(org.csstudio.swt.widgets.figures.GaugeFigure)

Example 44 with IWidgetPropertyChangeHandler

use of org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler 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)

Example 45 with IWidgetPropertyChangeHandler

use of org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler in project yamcs-studio by yamcs.

the class ImageEditPart method registerCropPropertyHandlers.

/**
 * Register change handlers for the four crop properties.
 */
protected void registerCropPropertyHandlers() {
    // top
    IWidgetPropertyChangeHandler handle = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure figure) {
            ImageFigure imageFigure = (ImageFigure) figure;
            imageFigure.setTopCrop((Integer) newValue);
            autoSizeWidget(imageFigure);
            return false;
        }
    };
    setPropertyChangeHandler(ImageModel.PROP_TOPCROP, handle);
    // bottom
    handle = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure figure) {
            ImageFigure imageFigure = (ImageFigure) figure;
            imageFigure.setBottomCrop((Integer) newValue);
            autoSizeWidget(imageFigure);
            return false;
        }
    };
    setPropertyChangeHandler(ImageModel.PROP_BOTTOMCROP, handle);
    // left
    handle = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure figure) {
            ImageFigure imageFigure = (ImageFigure) figure;
            imageFigure.setLeftCrop((Integer) newValue);
            autoSizeWidget(imageFigure);
            return false;
        }
    };
    setPropertyChangeHandler(ImageModel.PROP_LEFTCROP, handle);
    // right
    handle = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure figure) {
            ImageFigure imageFigure = (ImageFigure) figure;
            imageFigure.setRightCrop((Integer) newValue);
            autoSizeWidget(imageFigure);
            return false;
        }
    };
    setPropertyChangeHandler(ImageModel.PROP_RIGHTCROP, handle);
}
Also used : IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler) ImageFigure(org.csstudio.opibuilder.widgets.figures.ImageFigure) IFigure(org.eclipse.draw2d.IFigure)

Aggregations

IWidgetPropertyChangeHandler (org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler)65 IFigure (org.eclipse.draw2d.IFigure)61 PropertyChangeEvent (java.beans.PropertyChangeEvent)27 PropertyChangeListener (java.beans.PropertyChangeListener)27 OPIColor (org.csstudio.opibuilder.util.OPIColor)10 VType (org.diirt.vtype.VType)10 AbstractWidgetModel (org.csstudio.opibuilder.model.AbstractWidgetModel)7 IPath (org.eclipse.core.runtime.IPath)7 AbstractContainerModel (org.csstudio.opibuilder.model.AbstractContainerModel)4 XYGraphModel (org.csstudio.opibuilder.widgets.model.XYGraphModel)4 List (java.util.List)3 AlarmSeverityListener (org.csstudio.opibuilder.editparts.AlarmSeverityListener)3 ImageFigure (org.csstudio.opibuilder.widgets.figures.ImageFigure)3 TabProperty (org.csstudio.opibuilder.widgets.model.TabModel.TabProperty)3 AlarmSeverity (org.diirt.vtype.AlarmSeverity)3 Dimension (org.eclipse.draw2d.geometry.Dimension)3 OPIFont (org.csstudio.opibuilder.util.OPIFont)2 ImageBoolButtonFigure (org.csstudio.opibuilder.widgets.figures.ImageBoolButtonFigure)2 NativeButtonFigure (org.csstudio.opibuilder.widgets.figures.NativeButtonFigure)2 TabModel (org.csstudio.opibuilder.widgets.model.TabModel)2