Search in sources :

Example 21 with IWidgetPropertyChangeHandler

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

the class CheckBoxEditPart method registerPropertyChangeHandlers.

@Override
protected void registerPropertyChangeHandlers() {
    // value
    IWidgetPropertyChangeHandler handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            if (newValue == null)
                return false;
            CheckBoxFigure figure = (CheckBoxFigure) refreshableFigure;
            switch(VTypeHelper.getBasicDataType((VType) newValue)) {
                case SHORT:
                    figure.setTotalBits(TotalBits.BITS_16);
                    break;
                case INT:
                case ENUM:
                    figure.setTotalBits(TotalBits.BITS_32);
                    break;
                default:
                    break;
            }
            figure.setValue(VTypeHelper.getDouble((VType) newValue));
            return true;
        }
    };
    setPropertyChangeHandler(AbstractPVWidgetModel.PROP_PVVALUE, handler);
    // bit
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            CheckBoxFigure figure = (CheckBoxFigure) refreshableFigure;
            figure.setBit((Integer) newValue);
            return true;
        }
    };
    setPropertyChangeHandler(CheckBoxModel.PROP_BIT, handler);
    // label
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            CheckBoxFigure figure = (CheckBoxFigure) refreshableFigure;
            figure.setText((String) newValue);
            Display.getCurrent().timerExec(10, new Runnable() {

                @Override
                public void run() {
                    if (getWidgetModel().isAutoSize())
                        performAutoSize(refreshableFigure);
                }
            });
            return true;
        }
    };
    setPropertyChangeHandler(CheckBoxModel.PROP_LABEL, handler);
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            if ((Boolean) newValue) {
                performAutoSize(figure);
                figure.revalidate();
            }
            return true;
        }
    };
    setPropertyChangeHandler(CheckBoxModel.PROP_AUTOSIZE, handler);
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            ((CheckBoxFigure) figure).setSelectedColor(getWidgetModel().getSelectedColor().getSWTColor());
            return true;
        }
    };
    setPropertyChangeHandler(CheckBoxModel.PROP_SELECTED_COLOR, handler);
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, final IFigure figure) {
            Display.getCurrent().timerExec(10, new Runnable() {

                @Override
                public void run() {
                    if (getWidgetModel().isAutoSize()) {
                        performAutoSize(figure);
                        figure.revalidate();
                    }
                }
            });
            return true;
        }
    };
    setPropertyChangeHandler(CheckBoxModel.PROP_FONT, handler);
    setPropertyChangeHandler(AbstractWidgetModel.PROP_BORDER_STYLE, handler);
    setPropertyChangeHandler(AbstractWidgetModel.PROP_BORDER_WIDTH, handler);
}
Also used : VType(org.diirt.vtype.VType) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler) CheckBoxFigure(org.csstudio.swt.widgets.figures.CheckBoxFigure) IFigure(org.eclipse.draw2d.IFigure)

Example 22 with IWidgetPropertyChangeHandler

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

the class GroupingContainerEditPart method registerPropertyChangeHandlers.

@Override
protected void registerPropertyChangeHandlers() {
    IWidgetPropertyChangeHandler handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            figure.setOpaque(!(Boolean) newValue);
            return true;
        }
    };
    setPropertyChangeHandler(GroupingContainerModel.PROP_TRANSPARENT, handler);
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            for (AbstractWidgetModel child : getWidgetModel().getChildren()) {
                child.setEnabled((Boolean) newValue);
            }
            return true;
        }
    };
    setPropertyChangeHandler(AbstractWidgetModel.PROP_ENABLED, handler);
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            lockChildren((Boolean) newValue);
            return true;
        }
    };
    setPropertyChangeHandler(GroupingContainerModel.PROP_LOCK_CHILDREN, handler);
    lockChildren(getWidgetModel().isLocked());
    if (getWidgetModel().getParent() instanceof TabModel) {
        removeAllPropertyChangeHandlers(AbstractWidgetModel.PROP_VISIBLE);
        IWidgetPropertyChangeHandler visibilityHandler = new IWidgetPropertyChangeHandler() {

            @Override
            public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
                boolean visible = (Boolean) newValue;
                final IFigure figure = getFigure();
                figure.setVisible(visible);
                return true;
            }
        };
        setPropertyChangeHandler(AbstractWidgetModel.PROP_VISIBLE, visibilityHandler);
    }
    IWidgetPropertyChangeHandler showBarHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            ((GroupingContainerFigure) refreshableFigure).setShowScrollBar((Boolean) newValue);
            return true;
        }
    };
    setPropertyChangeHandler(GroupingContainerModel.PROP_SHOW_SCROLLBAR, showBarHandler);
    IWidgetPropertyChangeHandler fowardColorHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            if (getWidgetModel().isForwardColors())
                forwardColors();
            return true;
        }
    };
    setPropertyChangeHandler(GroupingContainerModel.PROP_FORWARD_COLORS, fowardColorHandler);
    setPropertyChangeHandler(GroupingContainerModel.PROP_COLOR_BACKGROUND, fowardColorHandler);
    setPropertyChangeHandler(GroupingContainerModel.PROP_COLOR_FOREGROUND, fowardColorHandler);
    // use property listener because it doesn't need to be queued in GUIRefreshThread.
    getWidgetModel().getProperty(AbstractWidgetModel.PROP_WIDTH).addPropertyChangeListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            resizeChildren((Integer) (evt.getNewValue()), (Integer) (evt.getOldValue()), true);
        }
    });
    getWidgetModel().getProperty(AbstractWidgetModel.PROP_HEIGHT).addPropertyChangeListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            resizeChildren((Integer) (evt.getNewValue()), (Integer) (evt.getOldValue()), false);
        }
    });
}
Also used : GroupingContainerFigure(org.csstudio.swt.widgets.figures.GroupingContainerFigure) PropertyChangeEvent(java.beans.PropertyChangeEvent) AbstractWidgetModel(org.csstudio.opibuilder.model.AbstractWidgetModel) PropertyChangeListener(java.beans.PropertyChangeListener) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler) IFigure(org.eclipse.draw2d.IFigure) TabModel(org.csstudio.opibuilder.widgets.model.TabModel)

Example 23 with IWidgetPropertyChangeHandler

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

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

the class ImageEditPart method registerPropertyChangeHandlers.

/**
 * {@inheritDoc}
 */
@Override
protected void registerPropertyChangeHandlers() {
    // changes to the filename property
    IWidgetPropertyChangeHandler handle = new IWidgetPropertyChangeHandler() {

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

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

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure figure) {
            ImageFigure imageFigure = (ImageFigure) figure;
            imageFigure.setAutoSize((Boolean) newValue);
            ImageModel model = (ImageModel) getModel();
            Dimension d = imageFigure.getAutoSizedDimension();
            if ((Boolean) newValue && !model.getStretch() && d != null)
                model.setSize(d.width, d.height);
            return false;
        }
    };
    setPropertyChangeHandler(ImageModel.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) {
            ImageFigure imageFigure = (ImageFigure) figure;
            imageFigure.setAnimationDisabled((Boolean) newValue);
            return false;
        }
    };
    setPropertyChangeHandler(ImageModel.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) {
            ImageFigure imageFigure = (ImageFigure) figure;
            imageFigure.setAlignedToNearestSecond((Boolean) newValue);
            return false;
        }
    };
    setPropertyChangeHandler(ImageModel.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) {
            ImageFigure imageFigure = (ImageFigure) figure;
            imageFigure.resizeImage();
            autoSizeWidget(imageFigure);
            return false;
        }
    };
    setPropertyChangeHandler(ImageModel.PROP_BORDER_WIDTH, handle);
    setPropertyChangeHandler(ImageModel.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) {
            ImageFigure imageFigure = (ImageFigure) figure;
            imageFigure.resizeImage();
            autoSizeWidget(imageFigure);
            return false;
        }
    };
    setPropertyChangeHandler(ImageModel.PROP_HEIGHT, handle);
    setPropertyChangeHandler(ImageModel.PROP_WIDTH, handle);
    FigureTransparencyHelper.addHandler(this, figure);
    registerCropPropertyHandlers();
    registerImageRotationPropertyHandlers();
}
Also used : IPath(org.eclipse.core.runtime.IPath) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler) ImageFigure(org.csstudio.opibuilder.widgets.figures.ImageFigure) Dimension(org.eclipse.draw2d.geometry.Dimension) ImageModel(org.csstudio.opibuilder.widgets.model.ImageModel) IFigure(org.eclipse.draw2d.IFigure)

Example 25 with IWidgetPropertyChangeHandler

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

the class IntensityGraphEditPart method registerROIPropertyChangeHandlers.

private void registerROIPropertyChangeHandlers() {
    for (int i = 0; i < IntensityGraphModel.MAX_ROIS_AMOUNT; i++) {
        final String roiName = getROIName(i);
        for (final ROIProperty roiProperty : ROIProperty.values()) {
            String propID = IntensityGraphModel.makeROIPropID(roiProperty.propIDPre, i);
            if (i >= (Integer) getPropertyValue(IntensityGraphModel.PROP_ROI_COUNT)) {
                getWidgetModel().setPropertyVisible(propID, false);
            }
            setPropertyChangeHandler(propID, new IWidgetPropertyChangeHandler() {

                @Override
                public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
                    setROIProperty(roiName, roiProperty, newValue);
                    return false;
                }
            });
        }
    }
}
Also used : ROIProperty(org.csstudio.opibuilder.widgets.model.IntensityGraphModel.ROIProperty) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler) 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