Search in sources :

Example 1 with IWidgetPropertyChangeHandler

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

the class AbstractContainerEditpart method registerBasePropertyChangeHandlers.

@Override
protected void registerBasePropertyChangeHandlers() {
    super.registerBasePropertyChangeHandlers();
    IWidgetPropertyChangeHandler handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            MacrosInput macrosInput = (MacrosInput) newValue;
            LinkedHashMap<String, String> macrosMap = new LinkedHashMap<String, String>();
            if (macrosInput.isInclude_parent_macros()) {
                macrosMap.putAll(getWidgetModel().getParentMacroMap());
            }
            macrosMap.putAll(macrosInput.getMacrosMap());
            getWidgetModel().setMacroMap(macrosMap);
            return false;
        }
    };
    setPropertyChangeHandler(AbstractContainerModel.PROP_MACROS, handler);
    layout();
    childrenPropertyChangeListener = new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            if (evt.getOldValue() instanceof Integer) {
                addChild(createChild(evt.getNewValue()), ((Integer) evt.getOldValue()).intValue());
                layout();
            } else if (evt.getOldValue() instanceof AbstractWidgetModel) {
                EditPart child = (EditPart) getViewer().getEditPartRegistry().get(evt.getOldValue());
                if (child != null) {
                    removeChild(child);
                    layout();
                }
            } else
                refreshChildren();
        }
    };
    getWidgetModel().getChildrenProperty().addPropertyChangeListener(childrenPropertyChangeListener);
    if (getExecutionMode() == ExecutionMode.EDIT_MODE) {
        selectionPropertyChangeListener = new PropertyChangeListener() {

            @SuppressWarnings("unchecked")
            @Override
            public void propertyChange(PropertyChangeEvent evt) {
                List<AbstractWidgetModel> widgets = (List<AbstractWidgetModel>) evt.getNewValue();
                List<EditPart> widgetEditparts = new ArrayList<EditPart>();
                for (AbstractWidgetModel w : widgets) {
                    EditPart e = (EditPart) getViewer().getEditPartRegistry().get(w);
                    if (e != null)
                        widgetEditparts.add(e);
                }
                if (!(Boolean) evt.getOldValue()) {
                    // append
                    getViewer().deselectAll();
                }
                for (EditPart editpart : widgetEditparts) {
                    if (editpart.isSelectable())
                        getViewer().appendSelection(editpart);
                }
            }
        };
        getWidgetModel().getSelectionProperty().addPropertyChangeListener(selectionPropertyChangeListener);
    }
}
Also used : MacrosInput(org.csstudio.opibuilder.util.MacrosInput) PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener) EditPart(org.eclipse.gef.EditPart) LinkedHashMap(java.util.LinkedHashMap) AbstractWidgetModel(org.csstudio.opibuilder.model.AbstractWidgetModel) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler) ArrayList(java.util.ArrayList) List(java.util.List) IFigure(org.eclipse.draw2d.IFigure)

Example 2 with IWidgetPropertyChangeHandler

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

use of org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler 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 4 with IWidgetPropertyChangeHandler

use of org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler 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 5 with IWidgetPropertyChangeHandler

use of org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler 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)

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