Search in sources :

Example 1 with TankFigure

use of org.csstudio.swt.widgets.figures.TankFigure 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 2 with TankFigure

use of org.csstudio.swt.widgets.figures.TankFigure in project yamcs-studio by yamcs.

the class TankEditPart method doCreateFigure.

/**
 * {@inheritDoc}
 */
@Override
protected IFigure doCreateFigure() {
    TankModel model = getWidgetModel();
    TankFigure tank = new TankFigure();
    initializeCommonFigureProperties(tank, model);
    tank.setFillColor(model.getFillColor());
    tank.setEffect3D(model.isEffect3D());
    tank.setFillBackgroundColor(model.getFillbackgroundColor());
    return tank;
}
Also used : TankFigure(org.csstudio.swt.widgets.figures.TankFigure) TankModel(org.csstudio.opibuilder.widgets.model.TankModel)

Aggregations

TankFigure (org.csstudio.swt.widgets.figures.TankFigure)2 AlarmSeverityListener (org.csstudio.opibuilder.editparts.AlarmSeverityListener)1 IWidgetPropertyChangeHandler (org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler)1 TankModel (org.csstudio.opibuilder.widgets.model.TankModel)1 AlarmSeverity (org.diirt.vtype.AlarmSeverity)1 IFigure (org.eclipse.draw2d.IFigure)1