Search in sources :

Example 6 with OPIColor

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

the class ProgressBarModel 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_FILLCOLOR_ALARM_SENSITIVE, "FillColor Alarm Sensitive", WidgetPropertyCategory.Display, false));
    addProperty(new BooleanProperty(PROP_EFFECT3D, "3D Effect", WidgetPropertyCategory.Display, true));
    addProperty(new BooleanProperty(PROP_SHOW_LABEL, "Show Label", WidgetPropertyCategory.Display, true));
    addProperty(new BooleanProperty(PROP_HORIZONTAL, "Horizontal", WidgetPropertyCategory.Display, true));
    addProperty(new ColorProperty(PROP_FILLBACKGROUND_COLOR, "Color Fillbackground", WidgetPropertyCategory.Display, DEFAULT_FILLBACKGROUND_COLOR));
    addProperty(new DoubleProperty(PROP_ORIGIN, "Origin", WidgetPropertyCategory.Behavior, 0));
    addProperty(new BooleanProperty(PROP_ORIGIN_IGNORED, "Origin Ignored", WidgetPropertyCategory.Behavior, true));
    addProperty(new BooleanProperty(PROP_INDICATOR_MODE, "Indicator Mode", WidgetPropertyCategory.Display, false));
    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)

Example 7 with OPIColor

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

the class AbstractBoolEditPart method registerCommonPropertyChangeHandlers.

/**
 * Registers property change handlers for the properties defined in
 * {@link AbstractBoolWidgetModel}. This method is provided for the convenience
 * of subclasses, which can call this method in their implementation of
 * {@link #registerPropertyChangeHandlers()}.
 */
protected void registerCommonPropertyChangeHandlers() {
    // value
    IWidgetPropertyChangeHandler handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            if (newValue == null || !(newValue instanceof VType))
                return false;
            AbstractBoolFigure figure = (AbstractBoolFigure) 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;
            }
            updateFromValue((VType) newValue, figure);
            return true;
        }
    };
    setPropertyChangeHandler(AbstractPVWidgetModel.PROP_PVVALUE, handler);
    // bit
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            if (getWidgetModel().getDataType() != 0)
                return false;
            AbstractBoolFigure figure = (AbstractBoolFigure) refreshableFigure;
            figure.setBit((Integer) newValue);
            updateFromValue(getPVValue(AbstractPVWidgetModel.PROP_PVNAME), figure);
            return true;
        }
    };
    setPropertyChangeHandler(AbstractBoolWidgetModel.PROP_BIT, handler);
    // data type
    final IWidgetPropertyChangeHandler dataTypeHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure refreshableFigure) {
            AbstractBoolFigure figure = (AbstractBoolFigure) refreshableFigure;
            if ((Integer) newValue == 0)
                figure.setBit(getWidgetModel().getBit());
            else
                figure.setBit(-1);
            updateFromValue(getPVValue(AbstractPVWidgetModel.PROP_PVNAME), figure);
            updatePropSheet((Integer) newValue);
            return true;
        }
    };
    getWidgetModel().getProperty(AbstractBoolWidgetModel.PROP_DATA_TYPE).addPropertyChangeListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            dataTypeHandler.handleChange(evt.getOldValue(), evt.getNewValue(), getFigure());
        }
    });
    // on state
    handler = new IWidgetPropertyChangeHandler() {

        public boolean handleChange(Object oldValue, Object newValue, IFigure refreshableFigure) {
            AbstractBoolFigure figure = (AbstractBoolFigure) refreshableFigure;
            updateFromValue(getPVValue(AbstractPVWidgetModel.PROP_PVNAME), figure);
            return true;
        }
    };
    setPropertyChangeHandler(AbstractBoolWidgetModel.PROP_ON_STATE, handler);
    // show bool label
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            AbstractBoolFigure figure = (AbstractBoolFigure) refreshableFigure;
            figure.setShowBooleanLabel((Boolean) newValue);
            return true;
        }
    };
    setPropertyChangeHandler(AbstractBoolWidgetModel.PROP_SHOW_BOOL_LABEL, handler);
    // bool label position
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            AbstractBoolFigure figure = (AbstractBoolFigure) refreshableFigure;
            figure.setBoolLabelPosition(BoolLabelPosition.values()[(Integer) newValue]);
            return false;
        }
    };
    setPropertyChangeHandler(AbstractBoolWidgetModel.PROP_BOOL_LABEL_POS, handler);
    // on label
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            AbstractBoolFigure figure = (AbstractBoolFigure) refreshableFigure;
            figure.setOnLabel((String) newValue);
            return true;
        }
    };
    setPropertyChangeHandler(AbstractBoolWidgetModel.PROP_ON_LABEL, handler);
    // off label
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            AbstractBoolFigure figure = (AbstractBoolFigure) refreshableFigure;
            figure.setOffLabel((String) newValue);
            return true;
        }
    };
    setPropertyChangeHandler(AbstractBoolWidgetModel.PROP_OFF_LABEL, handler);
    // on color
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            AbstractBoolFigure figure = (AbstractBoolFigure) refreshableFigure;
            figure.setOnColor(((OPIColor) newValue).getSWTColor());
            return true;
        }
    };
    setPropertyChangeHandler(AbstractBoolWidgetModel.PROP_ON_COLOR, handler);
    // off color
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            AbstractBoolFigure figure = (AbstractBoolFigure) refreshableFigure;
            figure.setOffColor(((OPIColor) newValue).getSWTColor());
            return true;
        }
    };
    setPropertyChangeHandler(AbstractBoolWidgetModel.PROP_OFF_COLOR, handler);
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) VType(org.diirt.vtype.VType) PropertyChangeListener(java.beans.PropertyChangeListener) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler) AbstractBoolFigure(org.csstudio.swt.widgets.figures.AbstractBoolFigure) OPIColor(org.csstudio.opibuilder.util.OPIColor) IFigure(org.eclipse.draw2d.IFigure)

Example 8 with OPIColor

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

the class ByteMonitorEditPart method registerPropertyChangeHandlers.

/* (non-Javadoc)
     * @see org.csstudio.opibuilder.editparts.AbstractBaseEditPart#registerPropertyChangeHandlers()
     */
@Override
protected void registerPropertyChangeHandlers() {
    super.registerBasePropertyChangeHandlers();
    getFigure().setEnabled(getWidgetModel().isEnabled() && (getExecutionMode() == ExecutionMode.RUN_MODE));
    removeAllPropertyChangeHandlers(AbstractWidgetModel.PROP_ENABLED);
    // enable
    IWidgetPropertyChangeHandler enableHandler = new IWidgetPropertyChangeHandler() {

        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            if (getExecutionMode() == ExecutionMode.RUN_MODE)
                figure.setEnabled((Boolean) newValue);
            return false;
        }
    };
    setPropertyChangeHandler(AbstractWidgetModel.PROP_ENABLED, enableHandler);
    // PV_Value
    IWidgetPropertyChangeHandler pvhandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            boolean succeed = true;
            if ((newValue != null) && (newValue instanceof VType)) {
                Number number = VTypeHelper.getNumber(((VType) newValue));
                if (number != null) {
                    setValue(number);
                } else
                    succeed = false;
            } else {
                succeed = false;
            }
            if (!succeed) {
                setValue(0);
                ConsoleUtil.writeError(NLS.bind("{0} does not accept non-numeric value.", getWidgetModel().getName()));
            }
            return false;
        }
    };
    setPropertyChangeHandler(ByteMonitorModel.PROP_PVVALUE, pvhandler);
    // on color
    IWidgetPropertyChangeHandler colorHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            ByteMonitorFigure figure = (ByteMonitorFigure) refreshableFigure;
            figure.setOnColor(((OPIColor) newValue).getSWTColor());
            figure.drawValue();
            return true;
        }
    };
    setPropertyChangeHandler(ByteMonitorModel.PROP_ON_COLOR, colorHandler);
    // off color
    colorHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            ByteMonitorFigure figure = (ByteMonitorFigure) refreshableFigure;
            figure.setOffColor(((OPIColor) newValue).getSWTColor());
            figure.drawValue();
            return true;
        }
    };
    setPropertyChangeHandler(ByteMonitorModel.PROP_OFF_COLOR, colorHandler);
    // change orientation of the bit display
    IWidgetPropertyChangeHandler horizontalHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure refreshableFigure) {
            ByteMonitorFigure figure = (ByteMonitorFigure) refreshableFigure;
            figure.setHorizontal((Boolean) newValue);
            ByteMonitorModel model = getWidgetModel();
            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);
            figure.drawValue();
            return true;
        }
    };
    setPropertyChangeHandler(ByteMonitorModel.PROP_HORIZONTAL, horizontalHandler);
    // change the display order of the bits
    IWidgetPropertyChangeHandler reverseBitsHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure refreshableFigure) {
            ByteMonitorFigure figure = (ByteMonitorFigure) refreshableFigure;
            figure.setReverseBits((Boolean) newValue);
            figure.drawValue();
            return true;
        }
    };
    setPropertyChangeHandler(ByteMonitorModel.PROP_BIT_REVERSE, reverseBitsHandler);
    // Set the bit to use as a starting point
    IWidgetPropertyChangeHandler startBitHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure refreshableFigure) {
            ByteMonitorFigure figure = (ByteMonitorFigure) refreshableFigure;
            figure.setStartBit((Integer) newValue);
            figure.drawValue();
            return true;
        }
    };
    setPropertyChangeHandler(ByteMonitorModel.PROP_START_BIT, startBitHandler);
    // Set the number of bits to display
    IWidgetPropertyChangeHandler numBitsHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure refreshableFigure) {
            ByteMonitorFigure figure = (ByteMonitorFigure) refreshableFigure;
            figure.setNumBits((Integer) newValue);
            figure.drawValue();
            return true;
        }
    };
    setPropertyChangeHandler(ByteMonitorModel.PROP_NUM_BITS, numBitsHandler);
    // Square LED
    IWidgetPropertyChangeHandler squareLEDHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            ByteMonitorFigure bm = (ByteMonitorFigure) refreshableFigure;
            bm.setSquareLED((Boolean) newValue);
            return true;
        }
    };
    setPropertyChangeHandler(ByteMonitorModel.PROP_SQUARE_LED, squareLEDHandler);
    // LED spacing
    IWidgetPropertyChangeHandler ledBorderWidthHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            ByteMonitorFigure bm = (ByteMonitorFigure) refreshableFigure;
            bm.setLedBorderWidth((int) newValue);
            return true;
        }
    };
    setPropertyChangeHandler(ByteMonitorModel.PROP_LED_BORDER, ledBorderWidthHandler);
    // LED border color
    IWidgetPropertyChangeHandler ledBorderColorHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            ByteMonitorFigure bm = (ByteMonitorFigure) refreshableFigure;
            bm.setLedBorderColor(((OPIColor) newValue).getSWTColor());
            return true;
        }
    };
    setPropertyChangeHandler(ByteMonitorModel.PROP_LED_BORDER_COLOR, ledBorderColorHandler);
    // effect 3D
    IWidgetPropertyChangeHandler effect3DHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            ByteMonitorFigure bmFig = (ByteMonitorFigure) refreshableFigure;
            bmFig.setEffect3D((Boolean) newValue);
            return true;
        }
    };
    setPropertyChangeHandler(ByteMonitorModel.PROP_EFFECT3D, effect3DHandler);
    // labels
    IWidgetPropertyChangeHandler labelsHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            ByteMonitorFigure bmFig = (ByteMonitorFigure) refreshableFigure;
            ByteMonitorModel model = getWidgetModel();
            bmFig.setLabels(model.getLabels());
            return true;
        }
    };
    setPropertyChangeHandler(ByteMonitorModel.PROP_LABELS, labelsHandler);
    // Set the LED rendering style
    IWidgetPropertyChangeHandler packHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure refreshableFigure) {
            ByteMonitorFigure figure = (ByteMonitorFigure) refreshableFigure;
            figure.setPackedLEDs((Boolean) newValue);
            figure.drawValue();
            return true;
        }
    };
    setPropertyChangeHandler(ByteMonitorModel.PROP_PACK_LEDS, packHandler);
}
Also used : ByteMonitorFigure(org.csstudio.swt.widgets.figures.ByteMonitorFigure) VType(org.diirt.vtype.VType) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler) ByteMonitorModel(org.csstudio.opibuilder.widgets.model.ByteMonitorModel) OPIColor(org.csstudio.opibuilder.util.OPIColor) IFigure(org.eclipse.draw2d.IFigure)

Example 9 with OPIColor

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

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

the class LEDEditPart method registerPropertyChangeHandlers.

@Override
protected void registerPropertyChangeHandlers() {
    registerCommonPropertyChangeHandlers();
    // effect 3D
    IWidgetPropertyChangeHandler handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            LEDFigure led = (LEDFigure) refreshableFigure;
            led.setEffect3D((Boolean) newValue);
            return true;
        }
    };
    setPropertyChangeHandler(LEDModel.PROP_EFFECT3D, handler);
    // Sqaure LED
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            LEDFigure led = (LEDFigure) refreshableFigure;
            led.setSquareLED((Boolean) newValue);
            if (!(Boolean) newValue) {
                int width = Math.min(getWidgetModel().getWidth(), getWidgetModel().getHeight());
                getWidgetModel().setSize(width, width);
            }
            return true;
        }
    };
    setPropertyChangeHandler(LEDModel.PROP_SQUARE_LED, handler);
    // force square size
    final IWidgetPropertyChangeHandler sizeHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            if (getWidgetModel().isSquareLED())
                return false;
            if (((Integer) newValue) < LEDModel.MINIMUM_SIZE)
                newValue = LEDModel.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);
    // nStates
    getWidgetModel().getProperty(LEDModel.PROP_NSTATES).addPropertyChangeListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            initializeNStatesProperties((Integer) evt.getOldValue(), (Integer) evt.getNewValue(), (LEDFigure) getFigure(), getWidgetModel());
        }
    });
    // stateFallbackLabel
    getWidgetModel().getProperty(LEDModel.PROP_STATE_FALLBACK_LABEL).addPropertyChangeListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            initializeStateFallbackLabel((String) evt.getOldValue(), (String) evt.getNewValue(), (LEDFigure) getFigure(), getWidgetModel());
        }
    });
    // stateFallbackColor
    getWidgetModel().getProperty(LEDModel.PROP_STATE_FALLBACK_COLOR).addPropertyChangeListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            initializeStateFallbackColor(((OPIColor) evt.getOldValue()).getSWTColor(), ((OPIColor) evt.getNewValue()).getSWTColor(), (LEDFigure) getFigure(), getWidgetModel());
        }
    });
    // bulbBorderWidth
    getWidgetModel().getProperty(LEDModel.PROP_BULB_BORDER).addPropertyChangeListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            initializeStateBulbBorderWidth((Integer) evt.getNewValue(), (LEDFigure) getFigure(), getWidgetModel());
        }
    });
    // bulbBorderColor
    getWidgetModel().getProperty(LEDModel.PROP_BULB_BORDER_COLOR).addPropertyChangeListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            initializeStateBulbBorderColor(((OPIColor) evt.getNewValue()).getSWTColor(), (LEDFigure) getFigure(), getWidgetModel());
        }
    });
    for (int idx = 0; idx < LEDFigure.MAX_NSTATES; idx++) {
        final int state = idx;
        // stateLabelN
        getWidgetModel().getProperty(String.format(LEDModel.PROP_STATE_LABEL, state)).addPropertyChangeListener(new PropertyChangeListener() {

            @Override
            public void propertyChange(PropertyChangeEvent evt) {
                initializeStateLabel(state, (String) evt.getOldValue(), (String) evt.getNewValue(), (LEDFigure) getFigure(), getWidgetModel());
            }
        });
        // stateColorN
        getWidgetModel().getProperty(String.format(LEDModel.PROP_STATE_COLOR, state)).addPropertyChangeListener(new PropertyChangeListener() {

            @Override
            public void propertyChange(PropertyChangeEvent evt) {
                initializeStateColor(state, ((OPIColor) evt.getOldValue()).getSWTColor(), ((OPIColor) evt.getNewValue()).getSWTColor(), (LEDFigure) getFigure(), getWidgetModel());
            }
        });
        // stateValueN
        getWidgetModel().getProperty(String.format(LEDModel.PROP_STATE_VALUE, state)).addPropertyChangeListener(new PropertyChangeListener() {

            @Override
            public void propertyChange(PropertyChangeEvent evt) {
                initializeStateValue(state, (Double) evt.getOldValue(), (Double) evt.getNewValue(), (LEDFigure) getFigure(), getWidgetModel());
            }
        });
    }
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler) LEDFigure(org.csstudio.swt.widgets.figures.LEDFigure) OPIColor(org.csstudio.opibuilder.util.OPIColor) IFigure(org.eclipse.draw2d.IFigure)

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