Search in sources :

Example 11 with OPIColor

use of org.csstudio.opibuilder.util.OPIColor 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 12 with OPIColor

use of org.csstudio.opibuilder.util.OPIColor 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 13 with OPIColor

use of org.csstudio.opibuilder.util.OPIColor in project yamcs-studio by yamcs.

the class TabEditPart method setTabFigureProperty.

private void setTabFigureProperty(int index, TabProperty tabProperty, final Object newValue) {
    Label label = getTabFigure().getTabLabel(index);
    switch(tabProperty) {
        case TITLE:
            label.setText((String) newValue);
            updateTabAreaSize();
            break;
        case FONT:
            label.setFont(((OPIFont) newValue).getSWTFont());
            updateTabAreaSize();
            break;
        case BACKCOLOR:
            getTabFigure().setTabColor(index, ((OPIColor) newValue).getSWTColor());
            break;
        case FORECOLOR:
            label.setForegroundColor(CustomMediaFactory.getInstance().getColor(((OPIColor) newValue).getRGBValue()));
            break;
        case ENABLED:
            getTabFigure().setTabEnabled(index, (Boolean) newValue);
            break;
        case ICON_PATH:
            getTabFigure().setIconPath(index, getWidgetModel().toAbsolutePath((IPath) newValue), new IJobErrorHandler() {

                @Override
                public void handleError(Exception e) {
                    String message = "Failed to load image from " + newValue + "\n" + e;
                    Activator.getLogger().log(Level.WARNING, message, e);
                    ConsoleService.getInstance().writeError(message);
                }
            });
            break;
        default:
            break;
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) Label(org.eclipse.draw2d.Label) IJobErrorHandler(org.csstudio.swt.widgets.util.IJobErrorHandler) OPIColor(org.csstudio.opibuilder.util.OPIColor)

Example 14 with OPIColor

use of org.csstudio.opibuilder.util.OPIColor in project yamcs-studio by yamcs.

the class ThumbWheelEditPart method registerPropertyChangeHandlers.

/**
 * {@inheritDoc}
 */
@Override
protected void registerPropertyChangeHandlers() {
    // PV value
    IWidgetPropertyChangeHandler pvhandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            if (newValue != null) {
                double doubleValue = VTypeHelper.getDouble((VType) newValue);
                logic.setValue(doubleValue);
                updateWheelValues();
            }
            return true;
        }
    };
    setPropertyChangeHandler(ThumbWheelModel.PROP_PVVALUE, pvhandler);
    IWidgetPropertyChangeHandler pvNameHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            registerLoadLimitsListener();
            return false;
        }
    };
    setPropertyChangeHandler(AbstractPVWidgetModel.PROP_PVNAME, pvNameHandler);
    // decimal wheels
    IWidgetPropertyChangeHandler handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            ThumbWheelFigure figure = (ThumbWheelFigure) refreshableFigure;
            logic.setDecimalWheels((Integer) newValue);
            figure.setDecimalDigits(logic.getDecimalWheels());
            model.setDecimalPartDigits(logic.getDecimalWheels());
            updateWheelValues();
            return true;
        }
    };
    setPropertyChangeHandler(ThumbWheelModel.PROP_DECIMAL_DIGITS_PART, handler);
    // integer wheels
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            ThumbWheelFigure figure = (ThumbWheelFigure) refreshableFigure;
            logic.setIntegerWheels((Integer) newValue);
            figure.setIntegerDigits(logic.getIntegerWheels());
            model.setWholePartDigits(logic.getIntegerWheels());
            updateWheelValues();
            return true;
        }
    };
    setPropertyChangeHandler(ThumbWheelModel.PROP_INTEGER_DIGITS_PART, handler);
    // min
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            logic.setMin((Double) newValue);
            updateWheelValues();
            return true;
        }
    };
    setPropertyChangeHandler(ThumbWheelModel.PROP_MIN, handler);
    // max
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            logic.setMax((Double) newValue);
            updateWheelValues();
            return true;
        }
    };
    setPropertyChangeHandler(ThumbWheelModel.PROP_MAX, handler);
    // value
    // handler = new IWidgetPropertyChangeHandler() {
    // public boolean handleChange(final Object oldValue,
    // final Object newValue, final IFigure refreshableFigure) {
    // logic.setValue((Double) newValue);
    // updateWheelValues();
    // return true;
    // }
    // };
    // setPropertyChangeHandler(ThumbWheelModel.PROP_VALUE, handler);
    // font
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            ThumbWheelFigure figure = (ThumbWheelFigure) refreshableFigure;
            FontData fontData = ((OPIFont) newValue).getFontData();
            figure.setWheelFont(CustomMediaFactory.getInstance().getFont(fontData.getName(), fontData.getHeight(), fontData.getStyle()));
            return true;
        }
    };
    setPropertyChangeHandler(ThumbWheelModel.PROP_FONT, handler);
    // border color
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            ThumbWheelFigure figure = (ThumbWheelFigure) refreshableFigure;
            figure.setInternalBorderColor(((OPIColor) newValue).getSWTColor());
            return true;
        }
    };
    setPropertyChangeHandler(ThumbWheelModel.PROP_INTERNAL_FRAME_COLOR, handler);
    // focused border color
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            ThumbWheelFigure figure = (ThumbWheelFigure) refreshableFigure;
            figure.setInternalFocusedBorderColor(((OPIColor) newValue).getSWTColor());
            return true;
        }
    };
    setPropertyChangeHandler(ThumbWheelModel.PROP_INTERNAL_FOCUSED_FRAME_COLOR, handler);
    // border width
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            ThumbWheelFigure figure = (ThumbWheelFigure) refreshableFigure;
            figure.setInternalBorderThickness((Integer) newValue);
            return true;
        }
    };
    setPropertyChangeHandler(ThumbWheelModel.PROP_INTERNAL_FRAME_THICKNESS, handler);
    // show button
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            ThumbWheelFigure figure = (ThumbWheelFigure) refreshableFigure;
            figure.setButtonVisibility((Boolean) newValue);
            return true;
        }
    };
    setPropertyChangeHandler(ThumbWheelModel.PROP_SHOW_BUTTONS, handler);
}
Also used : ThumbWheelFigure(org.csstudio.swt.widgets.figures.ThumbWheelFigure) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler) FontData(org.eclipse.swt.graphics.FontData) OPIColor(org.csstudio.opibuilder.util.OPIColor) IFigure(org.eclipse.draw2d.IFigure)

Example 15 with OPIColor

use of org.csstudio.opibuilder.util.OPIColor in project yamcs-studio by yamcs.

the class ScaledSliderModel method configureProperties.

@Override
protected void configureProperties() {
    super.configureProperties();
    addProperty(new ColorProperty(PROP_FILL_COLOR, "Fill Color", WidgetPropertyCategory.Display, DEFAULT_FILL_COLOR));
    addProperty(new BooleanProperty(PROP_EFFECT3D, "3D Effect", WidgetPropertyCategory.Display, true));
    addProperty(new BooleanProperty(PROP_HORIZONTAL, "Horizontal", WidgetPropertyCategory.Display, false));
    addProperty(new ColorProperty(PROP_FILLBACKGROUND_COLOR, "Color Fillbackground", WidgetPropertyCategory.Display, DEFAULT_FILLBACKGROUND_COLOR));
    addProperty(new ColorProperty(PROP_THUMB_COLOR, "Thumb Color", WidgetPropertyCategory.Display, DEFAULT_THUMB_COLOR));
    addProperty(new DoubleProperty(PROP_STEP_INCREMENT, "Step_Increment", WidgetPropertyCategory.Behavior, DEFAULT_STEP_INCREMENT, 0, Double.MAX_VALUE), true);
    addProperty(new DoubleProperty(PROP_PAGE_INCREMENT, "Page_Increment", WidgetPropertyCategory.Behavior, DEFAULT_PAGE_INCREMENT, 0, Double.MAX_VALUE), true);
    setPropertyValue(PROP_LO_COLOR, new OPIColor(255, 128, 0));
    setPropertyValue(PROP_HI_COLOR, new OPIColor(255, 128, 0));
}
Also used : BooleanProperty(org.csstudio.opibuilder.properties.BooleanProperty) DoubleProperty(org.csstudio.opibuilder.properties.DoubleProperty) ColorProperty(org.csstudio.opibuilder.properties.ColorProperty) OPIColor(org.csstudio.opibuilder.util.OPIColor)

Aggregations

OPIColor (org.csstudio.opibuilder.util.OPIColor)18 IWidgetPropertyChangeHandler (org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler)10 IFigure (org.eclipse.draw2d.IFigure)10 PropertyChangeEvent (java.beans.PropertyChangeEvent)5 PropertyChangeListener (java.beans.PropertyChangeListener)5 VType (org.diirt.vtype.VType)3 RGB (org.eclipse.swt.graphics.RGB)3 BooleanProperty (org.csstudio.opibuilder.properties.BooleanProperty)2 ColorProperty (org.csstudio.opibuilder.properties.ColorProperty)2 DoubleProperty (org.csstudio.opibuilder.properties.DoubleProperty)2 Dimension (org.eclipse.draw2d.geometry.Dimension)2 Element (org.jdom.Element)2 WidgetIgnorableUITask (org.csstudio.opibuilder.datadefinition.WidgetIgnorableUITask)1 WidgetPropertyChangeListener (org.csstudio.opibuilder.properties.WidgetPropertyChangeListener)1 TooltipLabel (org.csstudio.opibuilder.visualparts.TooltipLabel)1 ByteMonitorModel (org.csstudio.opibuilder.widgets.model.ByteMonitorModel)1 ColorMap (org.csstudio.swt.widgets.datadefinition.ColorMap)1 PredefinedColorMap (org.csstudio.swt.widgets.datadefinition.ColorMap.PredefinedColorMap)1 AbstractBoolFigure (org.csstudio.swt.widgets.figures.AbstractBoolFigure)1 ByteMonitorFigure (org.csstudio.swt.widgets.figures.ByteMonitorFigure)1