Search in sources :

Example 1 with AlarmSeverityListener

use of org.csstudio.opibuilder.editparts.AlarmSeverityListener in project yamcs-studio by yamcs.

the class ProgressBarEditPart method registerPropertyChangeHandlers.

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

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            ((ProgressBarFigure) figure).setOrigin((Double) newValue);
            return false;
        }
    };
    setPropertyChangeHandler(ProgressBarModel.PROP_ORIGIN, originHandler);
    IWidgetPropertyChangeHandler originIgnoredHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            ((ProgressBarFigure) figure).setOriginIgnored((Boolean) newValue);
            return false;
        }
    };
    setPropertyChangeHandler(ProgressBarModel.PROP_ORIGIN_IGNORED, originIgnoredHandler);
    // fillColor
    IWidgetPropertyChangeHandler fillColorHandler = new IWidgetPropertyChangeHandler() {

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

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

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            ProgressBarFigure slider = (ProgressBarFigure) refreshableFigure;
            slider.setEffect3D((Boolean) newValue);
            return false;
        }
    };
    setPropertyChangeHandler(ProgressBarModel.PROP_EFFECT3D, effect3DHandler);
    // effect 3D
    IWidgetPropertyChangeHandler showLabelHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            ProgressBarFigure slider = (ProgressBarFigure) refreshableFigure;
            slider.setShowLabel((Boolean) newValue);
            return false;
        }
    };
    setPropertyChangeHandler(ProgressBarModel.PROP_SHOW_LABEL, showLabelHandler);
    IWidgetPropertyChangeHandler indicatorHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            ProgressBarFigure slider = (ProgressBarFigure) refreshableFigure;
            slider.setIndicatorMode((Boolean) newValue);
            return false;
        }
    };
    setPropertyChangeHandler(ProgressBarModel.PROP_INDICATOR_MODE, indicatorHandler);
    // horizontal
    IWidgetPropertyChangeHandler horizontalHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            ProgressBarFigure slider = (ProgressBarFigure) refreshableFigure;
            slider.setHorizontal((Boolean) newValue);
            ProgressBarModel model = (ProgressBarModel) 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(ProgressBarModel.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) {
            ProgressBarFigure slider = (ProgressBarFigure) refreshableFigure;
            slider.setEnabled((Boolean) newValue);
            return false;
        }
    };
    setPropertyChangeHandler(ProgressBarModel.PROP_ENABLED, enableHandler);
    // Change fill color when "FillColor Alarm Sensitive" property changes.
    IWidgetPropertyChangeHandler fillColorAlarmSensitiveHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure refreshableFigure) {
            ProgressBarFigure figure = (ProgressBarFigure) refreshableFigure;
            boolean sensitive = (Boolean) newValue;
            figure.setFillColor(delegate.calculateAlarmColor(sensitive, getWidgetModel().getFillColor()));
            return true;
        }
    };
    setPropertyChangeHandler(ProgressBarModel.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;
            ProgressBarFigure progress = (ProgressBarFigure) figure;
            progress.setFillColor(delegate.calculateAlarmColor(getWidgetModel().isFillColorAlarmSensitive(), getWidgetModel().getFillColor()));
            return true;
        }
    });
}
Also used : ProgressBarFigure(org.csstudio.swt.widgets.figures.ProgressBarFigure) ProgressBarModel(org.csstudio.opibuilder.widgets.model.ProgressBarModel) AlarmSeverity(org.diirt.vtype.AlarmSeverity) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler) AlarmSeverityListener(org.csstudio.opibuilder.editparts.AlarmSeverityListener) IFigure(org.eclipse.draw2d.IFigure)

Example 2 with AlarmSeverityListener

use of org.csstudio.opibuilder.editparts.AlarmSeverityListener 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 3 with AlarmSeverityListener

use of org.csstudio.opibuilder.editparts.AlarmSeverityListener 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)

Aggregations

AlarmSeverityListener (org.csstudio.opibuilder.editparts.AlarmSeverityListener)3 IWidgetPropertyChangeHandler (org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler)3 AlarmSeverity (org.diirt.vtype.AlarmSeverity)3 IFigure (org.eclipse.draw2d.IFigure)3 ProgressBarModel (org.csstudio.opibuilder.widgets.model.ProgressBarModel)1 ProgressBarFigure (org.csstudio.swt.widgets.figures.ProgressBarFigure)1 TankFigure (org.csstudio.swt.widgets.figures.TankFigure)1 ThermometerFigure (org.csstudio.swt.widgets.figures.ThermometerFigure)1