Search in sources :

Example 81 with IFigure

use of org.eclipse.draw2d.IFigure in project yamcs-studio by yamcs.

the class SashContainerEditPart method registerPropertyChangeHandlers.

@Override
protected void registerPropertyChangeHandlers() {
    IWidgetPropertyChangeHandler handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            getSashFigure().setSashPosition((Double) newValue);
            return false;
        }
    };
    setPropertyChangeHandler(SashContainerModel.PROP_SASH_POSITION, handler);
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            getSashFigure().setSashStyle(getWidgetModel().getSashStyle());
            return false;
        }
    };
    setPropertyChangeHandler(SashContainerModel.PROP_SASH_STYLE, handler);
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            getSashFigure().setSashWidth((Integer) newValue);
            return false;
        }
    };
    setPropertyChangeHandler(SashContainerModel.PROP_SASH_WIDTH, handler);
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            getSashFigure().setHorizontal((Boolean) newValue);
            return false;
        }
    };
    setPropertyChangeHandler(SashContainerModel.PROP_HORIZONTAL, handler);
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            getSashFigure().setOpaque(!(Boolean) newValue);
            return false;
        }
    };
    setPropertyChangeHandler(SashContainerModel.PROP_TRANSPARENT, handler);
}
Also used : IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler) IFigure(org.eclipse.draw2d.IFigure)

Example 82 with IFigure

use of org.eclipse.draw2d.IFigure in project yamcs-studio by yamcs.

the class ScrollbarEditPart method registerPropertyChangeHandlers.

@Override
protected void registerPropertyChangeHandlers() {
    IWidgetPropertyChangeHandler pvNameHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            registerLoadLimitsListener();
            return false;
        }
    };
    setPropertyChangeHandler(AbstractPVWidgetModel.PROP_PVNAME, pvNameHandler);
    ((ScrollbarFigure) getFigure()).setEnabled(getWidgetModel().isEnabled() && (getExecutionMode() == ExecutionMode.RUN_MODE));
    removeAllPropertyChangeHandlers(AbstractWidgetModel.PROP_ENABLED);
    // enable
    IWidgetPropertyChangeHandler enableHandler = new IWidgetPropertyChangeHandler() {

        @Override
        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);
    // value
    IWidgetPropertyChangeHandler valueHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            if (newValue == null)
                return false;
            ((ScrollbarFigure) refreshableFigure).setValue(VTypeHelper.getDouble((VType) newValue));
            return false;
        }
    };
    setPropertyChangeHandler(AbstractPVWidgetModel.PROP_PVVALUE, valueHandler);
    // minimum
    IWidgetPropertyChangeHandler minimumHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            ((ScrollbarFigure) refreshableFigure).setMinimum((Double) newValue);
            return false;
        }
    };
    setPropertyChangeHandler(ScrollBarModel.PROP_MIN, minimumHandler);
    // maximum
    IWidgetPropertyChangeHandler maximumHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            ((ScrollbarFigure) refreshableFigure).setMaximum((Double) newValue);
            return false;
        }
    };
    setPropertyChangeHandler(ScrollBarModel.PROP_MAX, maximumHandler);
    // page increment
    IWidgetPropertyChangeHandler pageIncrementHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            ((ScrollbarFigure) refreshableFigure).setPageIncrement((Double) newValue);
            return false;
        }
    };
    setPropertyChangeHandler(ScrollBarModel.PROP_PAGE_INCREMENT, pageIncrementHandler);
    // step increment
    IWidgetPropertyChangeHandler stepIncrementHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            ((ScrollbarFigure) refreshableFigure).setStepIncrement((Double) newValue);
            return false;
        }
    };
    setPropertyChangeHandler(ScrollBarModel.PROP_STEP_INCREMENT, stepIncrementHandler);
    // bar length
    IWidgetPropertyChangeHandler barLengthHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            ((ScrollbarFigure) refreshableFigure).setExtent((Double) newValue);
            return false;
        }
    };
    setPropertyChangeHandler(ScrollBarModel.PROP_BAR_LENGTH, barLengthHandler);
    // value tip
    IWidgetPropertyChangeHandler valueTipHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            ((ScrollbarFigure) refreshableFigure).setShowValueTip((Boolean) newValue);
            return false;
        }
    };
    setPropertyChangeHandler(ScrollBarModel.PROP_SHOW_VALUE_TIP, valueTipHandler);
    // horizontal
    IWidgetPropertyChangeHandler horizontalHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            ((ScrollbarFigure) refreshableFigure).setHorizontal((Boolean) newValue);
            ScrollBarModel 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);
            return false;
        }
    };
    setPropertyChangeHandler(ScrollBarModel.PROP_HORIZONTAL, horizontalHandler);
}
Also used : VType(org.diirt.vtype.VType) ScrollBarModel(org.csstudio.opibuilder.widgets.model.ScrollBarModel) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler) IFigure(org.eclipse.draw2d.IFigure) ScrollbarFigure(org.csstudio.swt.widgets.figures.ScrollbarFigure)

Example 83 with IFigure

use of org.eclipse.draw2d.IFigure in project yamcs-studio by yamcs.

the class SpinnerEditpart method registerPropertyChangeHandlers.

@Override
protected void registerPropertyChangeHandlers() {
    // text
    IWidgetPropertyChangeHandler handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            String text = (String) newValue;
            try {
                // $NON-NLS-1$ //$NON-NLS-2$
                text = text.replace("e", "E");
                double value = new DecimalFormat().parse(text).doubleValue();
                // coerce value in range
                value = Math.max(((SpinnerFigure) figure).getMin(), Math.min(((SpinnerFigure) figure).getMax(), value));
                ((SpinnerFigure) figure).setValue(value);
                if (getExecutionMode() == ExecutionMode.RUN_MODE)
                    setPVValue(AbstractPVWidgetModel.PROP_PVNAME, value);
                getWidgetModel().setText(((SpinnerFigure) figure).getLabelFigure().getText(), false);
                return false;
            } catch (Exception e) {
                return false;
            }
        }
    };
    setPropertyChangeHandler(SpinnerModel.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);
    // pv value
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            if (newValue == null)
                return false;
            double value = VTypeHelper.getDouble((VType) newValue);
            ((SpinnerFigure) figure).setDisplayValue(value);
            getWidgetModel().setText(((SpinnerFigure) figure).getLabelFigure().getText(), false);
            return false;
        }
    };
    setPropertyChangeHandler(SpinnerModel.PROP_PVVALUE, handler);
    // min
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            ((SpinnerFigure) figure).setMin((Double) newValue);
            return false;
        }
    };
    setPropertyChangeHandler(SpinnerModel.PROP_MIN, handler);
    // max
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            ((SpinnerFigure) figure).setMax((Double) newValue);
            return false;
        }
    };
    setPropertyChangeHandler(SpinnerModel.PROP_MAX, handler);
    // step increment
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            ((SpinnerFigure) figure).setStepIncrement((Double) newValue);
            return false;
        }
    };
    setPropertyChangeHandler(SpinnerModel.PROP_STEP_INCREMENT, handler);
    // page increment
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            ((SpinnerFigure) figure).setPageIncrement((Double) newValue);
            return false;
        }
    };
    setPropertyChangeHandler(SpinnerModel.PROP_PAGE_INCREMENT, handler);
    // font
    IWidgetPropertyChangeHandler fontHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            ((SpinnerFigure) figure).getLabelFigure().setFont(CustomMediaFactory.getInstance().getFont(((OPIFont) newValue).getFontData()));
            return true;
        }
    };
    setPropertyChangeHandler(LabelModel.PROP_FONT, fontHandler);
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            ((SpinnerFigure) figure).getLabelFigure().setHorizontalAlignment(H_ALIGN.values()[(Integer) newValue]);
            return true;
        }
    };
    setPropertyChangeHandler(LabelModel.PROP_ALIGN_H, handler);
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            ((SpinnerFigure) figure).getLabelFigure().setVerticalAlignment(V_ALIGN.values()[(Integer) newValue]);
            return true;
        }
    };
    setPropertyChangeHandler(LabelModel.PROP_ALIGN_V, handler);
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            ((SpinnerFigure) figure).getLabelFigure().setOpaque(!(Boolean) newValue);
            return true;
        }
    };
    setPropertyChangeHandler(LabelModel.PROP_TRANSPARENT, handler);
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            ((SpinnerFigure) figure).setFormatType(NumericFormatType.values()[(Integer) newValue]);
            return false;
        }
    };
    setPropertyChangeHandler(SpinnerModel.PROP_FORMAT, handler);
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            ((SpinnerFigure) figure).setPrecision((Integer) newValue);
            return false;
        }
    };
    setPropertyChangeHandler(SpinnerModel.PROP_PRECISION, handler);
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            ((SpinnerFigure) figure).setArrowButtonsOnLeft((Boolean) newValue);
            return false;
        }
    };
    setPropertyChangeHandler(SpinnerModel.PROP_BUTTONS_ON_LEFT, handler);
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            ((SpinnerFigure) figure).setArrowButtonsHorizontal((Boolean) newValue);
            return false;
        }
    };
    setPropertyChangeHandler(SpinnerModel.PROP_HORIZONTAL_BUTTONS_LAYOUT, handler);
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            ((SpinnerFigure) figure).showText((Boolean) newValue);
            return false;
        }
    };
    setPropertyChangeHandler(SpinnerModel.PROP_SHOW_TEXT, handler);
}
Also used : OPIFont(org.csstudio.opibuilder.util.OPIFont) SpinnerFigure(org.csstudio.swt.widgets.figures.SpinnerFigure) DecimalFormat(java.text.DecimalFormat) VType(org.diirt.vtype.VType) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler) IFigure(org.eclipse.draw2d.IFigure)

Example 84 with IFigure

use of org.eclipse.draw2d.IFigure 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 85 with IFigure

use of org.eclipse.draw2d.IFigure 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)

Aggregations

IFigure (org.eclipse.draw2d.IFigure)225 IWidgetPropertyChangeHandler (org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler)61 Rectangle (org.eclipse.draw2d.geometry.Rectangle)42 Point (org.eclipse.draw2d.geometry.Point)36 Dimension (org.eclipse.draw2d.geometry.Dimension)30 PropertyChangeEvent (java.beans.PropertyChangeEvent)25 PropertyChangeListener (java.beans.PropertyChangeListener)25 List (java.util.List)20 Figure (org.eclipse.draw2d.Figure)17 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)13 DefaultSizeNodeFigure (org.eclipse.gmf.runtime.gef.ui.figures.DefaultSizeNodeFigure)12 NodeFigure (org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure)12 StackLayout (org.eclipse.draw2d.StackLayout)11 Iterator (java.util.Iterator)10 VType (org.diirt.vtype.VType)10 AbstractWidgetModel (org.csstudio.opibuilder.model.AbstractWidgetModel)9 OPIColor (org.csstudio.opibuilder.util.OPIColor)9 EditPart (org.eclipse.gef.EditPart)9 ArrayList (java.util.ArrayList)7 Label (org.eclipse.draw2d.Label)7