Search in sources :

Example 51 with IWidgetPropertyChangeHandler

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

the class RectangleEditpart 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) {
            OPIRectangleFigure figure = (OPIRectangleFigure) refreshableFigure;
            figure.setFill((Double) newValue);
            return true;
        }
    };
    setPropertyChangeHandler(AbstractShapeModel.PROP_FILL_LEVEL, fillHandler);
    // fill orientaion
    IWidgetPropertyChangeHandler fillOrientHandler = new IWidgetPropertyChangeHandler() {

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

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            OPIRectangleFigure figure = (OPIRectangleFigure) refreshableFigure;
            figure.setTransparent((Boolean) newValue);
            return true;
        }
    };
    setPropertyChangeHandler(RectangleModel.PROP_TRANSPARENT, transparentHandler);
    // line color
    IWidgetPropertyChangeHandler lineColorHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            ((OPIRectangleFigure) 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) {
            ((OPIRectangleFigure) figure).setGradient((Boolean) newValue);
            return false;
        }
    };
    setPropertyChangeHandler(RectangleModel.PROP_GRADIENT, handler);
    handler = new IWidgetPropertyChangeHandler() {

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

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

Example 52 with IWidgetPropertyChangeHandler

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

the class RoundedRectangleEditpart method registerPropertyChangeHandlers.

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

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

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

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            RoundedRectangleFigure figure = (RoundedRectangleFigure) refreshableFigure;
            figure.setTransparent((Boolean) newValue);
            return true;
        }
    };
    setPropertyChangeHandler(RoundedRectangleModel.PROP_TRANSPARENT, transparentHandler);
    // line color
    IWidgetPropertyChangeHandler lineColorHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            ((RoundedRectangleFigure) refreshableFigure).setLineColor(((OPIColor) newValue).getSWTColor());
            return true;
        }
    };
    setPropertyChangeHandler(AbstractShapeModel.PROP_LINE_COLOR, lineColorHandler);
    // corner width
    IWidgetPropertyChangeHandler cornerWidthHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            RoundedRectangleFigure figure = (RoundedRectangleFigure) refreshableFigure;
            figure.setCornerWidth((Integer) newValue);
            return true;
        }
    };
    setPropertyChangeHandler(RoundedRectangleModel.PROP_CORNER_WIDTH, cornerWidthHandler);
    // corner height
    IWidgetPropertyChangeHandler cornerHeightHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            RoundedRectangleFigure figure = (RoundedRectangleFigure) refreshableFigure;
            figure.setCornerHeight((Integer) newValue);
            return true;
        }
    };
    setPropertyChangeHandler(RoundedRectangleModel.PROP_CORNER_HEIGHT, cornerHeightHandler);
    IWidgetPropertyChangeHandler handler = new IWidgetPropertyChangeHandler() {

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

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

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

Example 53 with IWidgetPropertyChangeHandler

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

the class ScaledSliderEditPart method registerPropertyChangeHandlers.

/**
 * {@inheritDoc}
 */
@Override
protected void registerPropertyChangeHandlers() {
    registerCommonPropertyChangeHandlers();
    // fillColor
    IWidgetPropertyChangeHandler fillColorHandler = new IWidgetPropertyChangeHandler() {

        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            ScaledSliderFigure slider = (ScaledSliderFigure) refreshableFigure;
            slider.setFillColor(((OPIColor) newValue).getSWTColor());
            return false;
        }
    };
    setPropertyChangeHandler(ScaledSliderModel.PROP_FILL_COLOR, fillColorHandler);
    // fillBackgroundColor
    IWidgetPropertyChangeHandler fillBackColorHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            ScaledSliderFigure slider = (ScaledSliderFigure) refreshableFigure;
            slider.setFillBackgroundColor(((OPIColor) newValue).getSWTColor());
            return false;
        }
    };
    setPropertyChangeHandler(ScaledSliderModel.PROP_FILLBACKGROUND_COLOR, fillBackColorHandler);
    // thumbColor
    IWidgetPropertyChangeHandler thumbColorHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            ScaledSliderFigure slider = (ScaledSliderFigure) refreshableFigure;
            slider.setThumbColor(((OPIColor) newValue).getSWTColor());
            return false;
        }
    };
    setPropertyChangeHandler(ScaledSliderModel.PROP_THUMB_COLOR, thumbColorHandler);
    // effect 3D
    IWidgetPropertyChangeHandler effect3DHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            ScaledSliderFigure slider = (ScaledSliderFigure) refreshableFigure;
            slider.setEffect3D((Boolean) newValue);
            return false;
        }
    };
    setPropertyChangeHandler(ScaledSliderModel.PROP_EFFECT3D, effect3DHandler);
    // horizontal
    IWidgetPropertyChangeHandler horizontalHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            ScaledSliderFigure slider = (ScaledSliderFigure) refreshableFigure;
            slider.setHorizontal((Boolean) newValue);
            ScaledSliderModel model = (ScaledSliderModel) getModel();
            if (// from vertical to horizontal
            (Boolean) newValue)
                model.setLocation(model.getLocation().x - model.getSize().height / 2 + model.getSize().width / 2, model.getLocation().y + model.getSize().height / 2 - model.getSize().width / 2);
            else
                // from horizontal to vertical
                model.setLocation(model.getLocation().x + model.getSize().width / 2 - model.getSize().height / 2, model.getLocation().y - model.getSize().width / 2 + model.getSize().height / 2);
            model.setSize(model.getSize().height, model.getSize().width);
            return false;
        }
    };
    setPropertyChangeHandler(ScaledSliderModel.PROP_HORIZONTAL, horizontalHandler);
    // enabled. WidgetBaseEditPart will force the widget as disabled in edit model,
    // which is not the case for the scaled slider
    IWidgetPropertyChangeHandler enableHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            ScaledSliderFigure slider = (ScaledSliderFigure) refreshableFigure;
            slider.setEnabled((Boolean) newValue);
            return false;
        }
    };
    setPropertyChangeHandler(ScaledSliderModel.PROP_ENABLED, enableHandler);
    IWidgetPropertyChangeHandler incrementHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            ScaledSliderFigure slider = (ScaledSliderFigure) refreshableFigure;
            slider.setStepIncrement((Double) newValue);
            return false;
        }
    };
    setPropertyChangeHandler(ScaledSliderModel.PROP_STEP_INCREMENT, incrementHandler);
    IWidgetPropertyChangeHandler pageIncrementHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            ScaledSliderFigure slider = (ScaledSliderFigure) refreshableFigure;
            slider.setPageIncrement((Double) newValue);
            return false;
        }
    };
    setPropertyChangeHandler(ScaledSliderModel.PROP_PAGE_INCREMENT, pageIncrementHandler);
}
Also used : ScaledSliderModel(org.csstudio.opibuilder.widgets.model.ScaledSliderModel) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler) ScaledSliderFigure(org.csstudio.swt.widgets.figures.ScaledSliderFigure) IFigure(org.eclipse.draw2d.IFigure)

Example 54 with IWidgetPropertyChangeHandler

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

the class TabEditPart method registerPropertyChangeHandlers.

@Override
protected void registerPropertyChangeHandlers() {
    // init tabs
    int i = 0;
    for (AbstractWidgetModel child : getWidgetModel().getChildren()) {
        if (child instanceof GroupingContainerModel) {
            child.setPropertyValue(AbstractWidgetModel.PROP_VISIBLE, true);
            child.setPropertyValue(AbstractWidgetModel.PROP_VISIBLE, false);
            getTabFigure().addTab((String) getWidgetModel().getPropertyValue(TabModel.makeTabPropID(TabProperty.TITLE.propIDPre, i)));
            tabItemList.add(i, new TabItem(getWidgetModel(), i, (GroupingContainerModel) child));
            for (TabProperty tabProperty : TabProperty.values()) setTabProperty(i, tabProperty, getWidgetModel().getPropertyValue(TabModel.makeTabPropID(tabProperty.propIDPre, i)));
            i++;
        }
    }
    IWidgetPropertyChangeHandler relocContainerHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            updateTabAreaSize();
            refreshVisuals();
            return false;
        }
    };
    setPropertyChangeHandler(AbstractWidgetModel.PROP_WIDTH, relocContainerHandler);
    setPropertyChangeHandler(AbstractWidgetModel.PROP_HEIGHT, relocContainerHandler);
    IWidgetPropertyChangeHandler horizontalHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            ((TabFigure) figure).setHorizontal((Boolean) newValue);
            updateTabAreaSize();
            refreshVisuals();
            return false;
        }
    };
    setPropertyChangeHandler(TabModel.PROP_HORIZONTAL_TABS, horizontalHandler);
    IWidgetPropertyChangeHandler activeTabHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            ((TabFigure) figure).setActiveTabIndex((Integer) newValue);
            updateTabAreaSize();
            refreshVisuals();
            return false;
        }
    };
    setPropertyChangeHandler(TabModel.PROP_ACTIVE_TAB, activeTabHandler);
    IWidgetPropertyChangeHandler handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            ((TabFigure) figure).setMinimumTabHeight((Integer) newValue);
            return false;
        }
    };
    setPropertyChangeHandler(TabModel.PROP_MINIMUM_TAB_HEIGHT, handler);
    IWidgetPropertyChangeHandler updateTabAreaSizeHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            updateTabAreaSize();
            return false;
        }
    };
    setPropertyChangeHandler(TabModel.PROP_BORDER_WIDTH, updateTabAreaSizeHandler);
    registerTabPropertyChangeHandlers();
    registerTabsAmountChangeHandler();
}
Also used : GroupingContainerModel(org.csstudio.opibuilder.widgets.model.GroupingContainerModel) AbstractWidgetModel(org.csstudio.opibuilder.model.AbstractWidgetModel) TabProperty(org.csstudio.opibuilder.widgets.model.TabModel.TabProperty) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler) TabFigure(org.csstudio.swt.widgets.figures.TabFigure) IFigure(org.eclipse.draw2d.IFigure)

Example 55 with IWidgetPropertyChangeHandler

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

the class TabEditPart method registerTabsAmountChangeHandler.

private void registerTabsAmountChangeHandler() {
    final IWidgetPropertyChangeHandler handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure refreshableFigure) {
            TabModel model = getWidgetModel();
            TabFigure figure = (TabFigure) refreshableFigure;
            int currentTabAmount = figure.getTabAmount();
            // add tabs
            if ((Integer) newValue > currentTabAmount) {
                for (int i = 0; i < (Integer) newValue - currentTabAmount; i++) {
                    for (TabProperty tabProperty : TabProperty.values()) {
                        String propID = TabModel.makeTabPropID(tabProperty.propIDPre, i + currentTabAmount);
                        model.setPropertyVisible(propID, true);
                    }
                    addTab();
                }
            } else if ((Integer) newValue < currentTabAmount) {
                // remove tabs
                for (int i = currentTabAmount - 1; i >= (Integer) newValue; i--) {
                    for (TabProperty tabProperty : TabProperty.values()) {
                        String propID = TabModel.makeTabPropID(tabProperty.propIDPre, i);
                        model.setPropertyVisible(propID, false);
                    }
                    removeTab();
                }
                setActiveTabIndex(0);
            }
            return true;
        }
    };
    getWidgetModel().getProperty(TabModel.PROP_TAB_COUNT).addPropertyChangeListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            handler.handleChange(evt.getOldValue(), evt.getNewValue(), getFigure());
        }
    });
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) TabProperty(org.csstudio.opibuilder.widgets.model.TabModel.TabProperty) PropertyChangeListener(java.beans.PropertyChangeListener) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler) TabFigure(org.csstudio.swt.widgets.figures.TabFigure) IFigure(org.eclipse.draw2d.IFigure) TabModel(org.csstudio.opibuilder.widgets.model.TabModel)

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