Search in sources :

Example 76 with IFigure

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

the class NativeButtonEditPart method registerPropertyChangeHandlers.

/**
 * {@inheritDoc}
 */
@Override
protected void registerPropertyChangeHandlers() {
    // text
    IWidgetPropertyChangeHandler textHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            button.setText(newValue.toString());
            button.setSize(button.getSize());
            return true;
        }
    };
    setPropertyChangeHandler(ActionButtonModel.PROP_TEXT, textHandler);
    // image
    IWidgetPropertyChangeHandler imageHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            NativeButtonFigure figure = (NativeButtonFigure) refreshableFigure;
            IPath absolutePath = (IPath) newValue;
            if (absolutePath != null && !absolutePath.isEmpty() && !absolutePath.isAbsolute())
                absolutePath = ResourceUtil.buildAbsolutePath(getWidgetModel(), absolutePath);
            figure.setImagePath(absolutePath);
            return true;
        }
    };
    setPropertyChangeHandler(ActionButtonModel.PROP_IMAGE, imageHandler);
    // button style
    final IWidgetPropertyChangeHandler buttonStyleHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            updatePropSheet((Boolean) newValue);
            return true;
        }
    };
    getWidgetModel().getProperty(ActionButtonModel.PROP_TOGGLE_BUTTON).addPropertyChangeListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            buttonStyleHandler.handleChange(evt.getOldValue(), evt.getNewValue(), getFigure());
        }
    });
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) IPath(org.eclipse.core.runtime.IPath) PropertyChangeListener(java.beans.PropertyChangeListener) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler) NativeButtonFigure(org.csstudio.opibuilder.widgets.figures.NativeButtonFigure) IFigure(org.eclipse.draw2d.IFigure)

Example 77 with IFigure

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

the class NativeButtonEditPartDelegate method registerPropertyChangeHandlers.

/**
 * {@inheritDoc}
 */
@Override
public void registerPropertyChangeHandlers() {
    // text
    IWidgetPropertyChangeHandler textHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            button.setText(newValue.toString());
            button.setSize(button.getSize());
            return true;
        }
    };
    editpart.setPropertyChangeHandler(ActionButtonModel.PROP_TEXT, textHandler);
    // image
    IWidgetPropertyChangeHandler imageHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            NativeButtonFigure figure = (NativeButtonFigure) refreshableFigure;
            IPath absolutePath = (IPath) newValue;
            if (absolutePath != null && !absolutePath.isEmpty() && !absolutePath.isAbsolute())
                absolutePath = ResourceUtil.buildAbsolutePath(editpart.getWidgetModel(), absolutePath);
            figure.setImagePath(absolutePath);
            return true;
        }
    };
    editpart.setPropertyChangeHandler(ActionButtonModel.PROP_IMAGE, imageHandler);
    // button style
    final IWidgetPropertyChangeHandler buttonStyleHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            editpart.updatePropSheet();
            return true;
        }
    };
    editpart.getWidgetModel().getProperty(ActionButtonModel.PROP_TOGGLE_BUTTON).addPropertyChangeListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            buttonStyleHandler.handleChange(evt.getOldValue(), evt.getNewValue(), editpart.getFigure());
        }
    });
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) IPath(org.eclipse.core.runtime.IPath) PropertyChangeListener(java.beans.PropertyChangeListener) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler) NativeButtonFigure(org.csstudio.opibuilder.widgets.figures.NativeButtonFigure) IFigure(org.eclipse.draw2d.IFigure)

Example 78 with IFigure

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

the class NativeTextEditpart method registerPropertyChangeHandlers.

@Override
protected void registerPropertyChangeHandlers() {
    super.registerPropertyChangeHandlers();
    removeAllPropertyChangeHandlers(NativeTextModel.PROP_ALIGN_H);
    PropertyChangeListener updatePropSheetListener = new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            updatePropSheet();
        }
    };
    getWidgetModel().getProperty(NativeTextModel.PROP_MULTILINE_INPUT).addPropertyChangeListener(updatePropSheetListener);
    IWidgetPropertyChangeHandler handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            AbstractWidgetModel model = getWidgetModel();
            AbstractContainerModel parent = model.getParent();
            parent.removeChild(model);
            parent.addChild(model);
            parent.selectWidget(model, true);
            return false;
        }
    };
    setPropertyChangeHandler(NativeTextModel.PROP_SHOW_NATIVE_BORDER, handler);
    setPropertyChangeHandler(NativeTextModel.PROP_MULTILINE_INPUT, handler);
    setPropertyChangeHandler(NativeTextModel.PROP_WRAP_WORDS, handler);
    setPropertyChangeHandler(NativeTextModel.PROP_SHOW_H_SCROLL, handler);
    setPropertyChangeHandler(NativeTextModel.PROP_SHOW_V_SCROLL, handler);
    setPropertyChangeHandler(NativeTextModel.PROP_PASSWORD_INPUT, handler);
    setPropertyChangeHandler(NativeTextModel.PROP_ALIGN_H, handler);
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) AbstractWidgetModel(org.csstudio.opibuilder.model.AbstractWidgetModel) AbstractContainerModel(org.csstudio.opibuilder.model.AbstractContainerModel) PropertyChangeListener(java.beans.PropertyChangeListener) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler) IFigure(org.eclipse.draw2d.IFigure)

Example 79 with IFigure

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

the class NativeTextEditpartDelegate method registerPropertyChangeHandlers.

@Override
public void registerPropertyChangeHandlers() {
    editpart.removeAllPropertyChangeHandlers(TextInputModel.PROP_ALIGN_H);
    PropertyChangeListener updatePropSheetListener = new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            updatePropSheet();
        }
    };
    model.getProperty(TextInputModel.PROP_MULTILINE_INPUT).addPropertyChangeListener(updatePropSheetListener);
    IWidgetPropertyChangeHandler handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            AbstractContainerModel parent = model.getParent();
            parent.removeChild(model);
            parent.addChild(model);
            parent.selectWidget(model, true);
            return false;
        }
    };
    editpart.setPropertyChangeHandler(TextInputModel.PROP_SHOW_NATIVE_BORDER, handler);
    editpart.setPropertyChangeHandler(TextInputModel.PROP_MULTILINE_INPUT, handler);
    editpart.setPropertyChangeHandler(TextInputModel.PROP_WRAP_WORDS, handler);
    editpart.setPropertyChangeHandler(TextInputModel.PROP_SHOW_H_SCROLL, handler);
    editpart.setPropertyChangeHandler(TextInputModel.PROP_SHOW_V_SCROLL, handler);
    editpart.setPropertyChangeHandler(TextInputModel.PROP_PASSWORD_INPUT, handler);
    editpart.setPropertyChangeHandler(TextInputModel.PROP_ALIGN_H, handler);
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) AbstractContainerModel(org.csstudio.opibuilder.model.AbstractContainerModel) PropertyChangeListener(java.beans.PropertyChangeListener) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler) IFigure(org.eclipse.draw2d.IFigure)

Example 80 with IFigure

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

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