Search in sources :

Example 11 with IWidgetPropertyChangeHandler

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

the class TankEditPart method registerPropertyChangeHandlers.

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

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            TankFigure tank = (TankFigure) refreshableFigure;
            tank.setFillColor(((OPIColor) newValue).getSWTColor());
            return false;
        }
    };
    setPropertyChangeHandler(TankModel.PROP_FILL_COLOR, fillColorHandler);
    // fillBackgroundColor
    IWidgetPropertyChangeHandler fillBackColorHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            TankFigure tank = (TankFigure) refreshableFigure;
            tank.setFillBackgroundColor(((OPIColor) newValue).getSWTColor());
            return false;
        }
    };
    setPropertyChangeHandler(TankModel.PROP_FILLBACKGROUND_COLOR, fillBackColorHandler);
    // effect 3D
    IWidgetPropertyChangeHandler effect3DHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            TankFigure tank = (TankFigure) refreshableFigure;
            tank.setEffect3D((Boolean) newValue);
            return false;
        }
    };
    setPropertyChangeHandler(TankModel.PROP_EFFECT3D, effect3DHandler);
    // Change fill color when "FillColor Alarm Sensitive" property changes.
    IWidgetPropertyChangeHandler fillColorAlarmSensitiveHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure refreshableFigure) {
            TankFigure figure = (TankFigure) refreshableFigure;
            boolean sensitive = (Boolean) newValue;
            figure.setFillColor(delegate.calculateAlarmColor(sensitive, getWidgetModel().getFillColor()));
            return true;
        }
    };
    setPropertyChangeHandler(TankModel.PROP_FILLCOLOR_ALARM_SENSITIVE, fillColorAlarmSensitiveHandler);
    // Change fill color when alarm severity changes.
    delegate.addAlarmSeverityListener(new AlarmSeverityListener() {

        @Override
        public boolean severityChanged(AlarmSeverity severity, IFigure figure) {
            if (!getWidgetModel().isFillColorAlarmSensitive())
                return false;
            TankFigure tank = (TankFigure) figure;
            tank.setFillColor(delegate.calculateAlarmColor(getWidgetModel().isFillColorAlarmSensitive(), getWidgetModel().getFillColor()));
            return true;
        }
    });
}
Also used : TankFigure(org.csstudio.swt.widgets.figures.TankFigure) AlarmSeverity(org.diirt.vtype.AlarmSeverity) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler) AlarmSeverityListener(org.csstudio.opibuilder.editparts.AlarmSeverityListener) IFigure(org.eclipse.draw2d.IFigure)

Example 12 with IWidgetPropertyChangeHandler

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

the class TextInputEditpart method registerPropertyChangeHandlers.

@Override
protected void registerPropertyChangeHandlers() {
    super.registerPropertyChangeHandlers();
    if (getExecutionMode() == ExecutionMode.RUN_MODE) {
        removeAllPropertyChangeHandlers(LabelModel.PROP_TEXT);
        IWidgetPropertyChangeHandler handler = new IWidgetPropertyChangeHandler() {

            @Override
            public boolean handleChange(Object oldValue, Object newValue, final IFigure figure) {
                String text = (String) newValue;
                if (getPV() == null) {
                    setFigureText(text);
                    if (getWidgetModel().isAutoSize()) {
                        Display.getCurrent().timerExec(10, new Runnable() {

                            @Override
                            public void run() {
                                performAutoSize();
                            }
                        });
                    }
                }
                // Output pv value even if pv name is empty, so setPVValuelistener can be triggered.
                outputPVValue(text);
                return false;
            }
        };
        setPropertyChangeHandler(LabelModel.PROP_TEXT, handler);
    }
    IWidgetPropertyChangeHandler pvNameHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            registerLoadLimitsListener();
            return false;
        }
    };
    setPropertyChangeHandler(AbstractPVWidgetModel.PROP_PVNAME, pvNameHandler);
    PropertyChangeListener updatePropSheetListener = new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent arg0) {
            updatePropSheet();
        }
    };
    getWidgetModel().getProperty(TextInputModel.PROP_LIMITS_FROM_PV).addPropertyChangeListener(updatePropSheetListener);
    getWidgetModel().getProperty(TextInputModel.PROP_SELECTOR_TYPE).addPropertyChangeListener(updatePropSheetListener);
    PropertyChangeListener reCreateWidgetListener = new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            reCreateWidget();
        }
    };
    getWidgetModel().getProperty(TextInputModel.PROP_STYLE).addPropertyChangeListener(reCreateWidgetListener);
    delegate.registerPropertyChangeHandlers();
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler) IFigure(org.eclipse.draw2d.IFigure)

Example 13 with IWidgetPropertyChangeHandler

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

the class ThermometerEditPart method registerPropertyChangeHandlers.

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

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            ThermometerFigure thermometer = (ThermometerFigure) refreshableFigure;
            thermometer.setFillColor(((OPIColor) newValue).getSWTColor());
            return false;
        }
    };
    setPropertyChangeHandler(ThermometerModel.PROP_FILL_COLOR, fillColorHandler);
    // fillBackgroundColor
    IWidgetPropertyChangeHandler fillBackColorHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            ThermometerFigure thermometer = (ThermometerFigure) refreshableFigure;
            thermometer.setFillBackgroundColor(((OPIColor) newValue).getSWTColor());
            return false;
        }
    };
    setPropertyChangeHandler(ThermometerModel.PROP_FILLBACKGROUND_COLOR, fillBackColorHandler);
    // show bulb
    IWidgetPropertyChangeHandler showBulbHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            ThermometerFigure thermometer = (ThermometerFigure) refreshableFigure;
            thermometer.setShowBulb((Boolean) newValue);
            return false;
        }
    };
    setPropertyChangeHandler(ThermometerModel.PROP_SHOW_BULB, showBulbHandler);
    // unit
    IWidgetPropertyChangeHandler fahrenheitHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            ThermometerFigure thermometer = (ThermometerFigure) refreshableFigure;
            thermometer.setTemperatureUnit(TemperatureUnit.values()[(Integer) newValue]);
            return false;
        }
    };
    setPropertyChangeHandler(ThermometerModel.PROP_UNIT, fahrenheitHandler);
    // effect 3D
    IWidgetPropertyChangeHandler effect3DHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            ThermometerFigure thermo = (ThermometerFigure) refreshableFigure;
            thermo.setEffect3D((Boolean) newValue);
            return false;
        }
    };
    setPropertyChangeHandler(ThermometerModel.PROP_EFFECT3D, effect3DHandler);
    // Change fill color when "FillColor Alarm Sensitive" property changes.
    IWidgetPropertyChangeHandler fillColorAlarmSensitiveHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure refreshableFigure) {
            ThermometerFigure figure = (ThermometerFigure) refreshableFigure;
            boolean sensitive = (Boolean) newValue;
            figure.setFillColor(delegate.calculateAlarmColor(sensitive, getWidgetModel().getFillColor()));
            return true;
        }
    };
    setPropertyChangeHandler(ThermometerModel.PROP_FILLCOLOR_ALARM_SENSITIVE, fillColorAlarmSensitiveHandler);
    // Change fill color when alarm severity changes.
    delegate.addAlarmSeverityListener(new AlarmSeverityListener() {

        @Override
        public boolean severityChanged(AlarmSeverity severity, IFigure figure) {
            if (!getWidgetModel().isFillColorAlarmSensitive())
                return false;
            ThermometerFigure thermo = (ThermometerFigure) figure;
            thermo.setFillColor(delegate.calculateAlarmColor(getWidgetModel().isFillColorAlarmSensitive(), getWidgetModel().getFillColor()));
            return true;
        }
    });
}
Also used : ThermometerFigure(org.csstudio.swt.widgets.figures.ThermometerFigure) AlarmSeverity(org.diirt.vtype.AlarmSeverity) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler) AlarmSeverityListener(org.csstudio.opibuilder.editparts.AlarmSeverityListener) IFigure(org.eclipse.draw2d.IFigure)

Example 14 with IWidgetPropertyChangeHandler

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

the class XYGraphEditPart method registerAxisPropertyChangeHandlers.

private void registerAxisPropertyChangeHandlers() {
    XYGraphModel model = (XYGraphModel) getModel();
    // set prop handlers and init all the potential axes
    for (int i = 0; i < XYGraphModel.MAX_AXES_AMOUNT; i++) {
        for (AxisProperty axisProperty : AxisProperty.values()) {
            // there is no primary and y-axis property for primary axes.
            if (i < 2 && (axisProperty == AxisProperty.PRIMARY || axisProperty == AxisProperty.Y_AXIS)) {
                continue;
            }
            String propID = XYGraphModel.makeAxisPropID(axisProperty.propIDPre, i);
            IWidgetPropertyChangeHandler handler = new AxisPropertyChangeHandler(i, axisProperty);
            setPropertyChangeHandler(propID, handler);
        }
    }
    for (int i = XYGraphModel.MAX_AXES_AMOUNT - 1; i >= model.getAxesAmount(); i--) {
        for (AxisProperty axisProperty : AxisProperty.values()) {
            String propID = XYGraphModel.makeAxisPropID(axisProperty.propIDPre, i);
            model.setPropertyVisible(propID, false);
        }
    }
}
Also used : AxisProperty(org.csstudio.opibuilder.widgets.model.XYGraphModel.AxisProperty) XYGraphModel(org.csstudio.opibuilder.widgets.model.XYGraphModel) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler)

Example 15 with IWidgetPropertyChangeHandler

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

the class XYGraphEditPart method registerAxesAmountChangeHandler.

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

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure refreshableFigure) {
            XYGraphModel model = (XYGraphModel) getModel();
            IXYGraph xyGraph = ((ToolbarArmedXYGraph) refreshableFigure).getXYGraph();
            int currentAxisAmount = xyGraph.getAxisList().size();
            // add axis
            if ((Integer) newValue > currentAxisAmount) {
                for (int i = 0; i < (Integer) newValue - currentAxisAmount; i++) {
                    for (AxisProperty axisProperty : AxisProperty.values()) {
                        String propID = XYGraphModel.makeAxisPropID(axisProperty.propIDPre, i + currentAxisAmount);
                        model.setPropertyVisible(propID, true);
                    }
                    xyGraph.addAxis(axisList.get(i + currentAxisAmount));
                }
            } else if ((Integer) newValue < currentAxisAmount) {
                // remove axis
                for (int i = 0; i < currentAxisAmount - (Integer) newValue; i++) {
                    for (AxisProperty axisProperty : AxisProperty.values()) {
                        String propID = XYGraphModel.makeAxisPropID(axisProperty.propIDPre, i + (Integer) newValue);
                        model.setPropertyVisible(propID, false);
                    }
                    xyGraph.removeAxis(axisList.get(i + (Integer) newValue));
                }
            }
            return true;
        }
    };
    getWidgetModel().getProperty(XYGraphModel.PROP_AXIS_COUNT).addPropertyChangeListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            handler.handleChange(evt.getOldValue(), evt.getNewValue(), getFigure());
        }
    });
// setPropertyChangeHandler(XYGraphModel.PROP_AXES_AMOUNT, handler);
}
Also used : AxisProperty(org.csstudio.opibuilder.widgets.model.XYGraphModel.AxisProperty) PropertyChangeEvent(java.beans.PropertyChangeEvent) XYGraphModel(org.csstudio.opibuilder.widgets.model.XYGraphModel) ToolbarArmedXYGraph(org.eclipse.nebula.visualization.xygraph.figures.ToolbarArmedXYGraph) PropertyChangeListener(java.beans.PropertyChangeListener) IXYGraph(org.eclipse.nebula.visualization.xygraph.figures.IXYGraph) 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