Search in sources :

Example 1 with PROP_PVVALUE

use of org.csstudio.opibuilder.model.IPVWidgetModel.PROP_PVVALUE in project yamcs-studio by yamcs.

the class ArrayEditPart method registerPropertyChangeHandlers.

@Override
protected void registerPropertyChangeHandlers() {
    IWidgetPropertyChangeHandler handler = (oldValue, newValue, figure) -> {
        for (var child : getWidgetModel().getAllChildren()) {
            child.setEnabled((Boolean) newValue);
        }
        return true;
    };
    setPropertyChangeHandler(AbstractWidgetModel.PROP_ENABLED, handler);
    handler = (oldValue, newValue, figure) -> {
        var value = (VType) newValue;
        if (value instanceof VNumberArray) {
            var wrappedArray = VTypeHelper.getWrappedArray((value));
            if (wrappedArray != null) {
                setValue(wrappedArray);
            } else {
                setValue(VTypeHelper.getDoubleArray(value));
            }
        } else {
            if (value instanceof VEnum) {
                setValue(new String[] { ((VEnum) value).getValue() });
            } else if (value instanceof VString) {
                setValue(new String[] { ((VString) value).getValue() });
            } else if (value instanceof VStringArray) {
                setValue(((VStringArray) value).getData().toArray());
            } else {
                setValue(VTypeHelper.getDoubleArray(value));
            }
        }
        return false;
    };
    setPropertyChangeHandler(PROP_PVVALUE, handler);
    getWidgetModel().getProperty(PROP_PVNAME).addPropertyChangeListener(evt -> updatePropSheet());
    handler = (oldValue, newValue, figure) -> {
        registerLoadPVDataTypeListener();
        return false;
    };
    setPropertyChangeHandler(PROP_PVNAME, handler);
    getWidgetModel().getProperty(PROP_DATA_TYPE).addPropertyChangeListener(evt -> initValueArray());
    handler = (oldValue, newValue, figure) -> {
        updateWidgetSize();
        return false;
    };
    setPropertyChangeHandler(PROP_BORDER_STYLE, handler);
    setPropertyChangeHandler(PROP_BORDER_WIDTH, handler);
    handler = (oldValue, newValue, figure) -> {
        getArrayFigure().setArrayLength((Integer) newValue);
        return false;
    };
    setPropertyChangeHandler(PROP_ARRAY_LENGTH, handler);
    handler = (oldValue, newValue, figure) -> {
        ((ArrayFigure) figure).setSpinnerWidth((Integer) newValue);
        keepElementSize = true;
        getWidgetModel().setSize(((ArrayFigure) figure).getPreferredSize());
        keepElementSize = false;
        return false;
    };
    setPropertyChangeHandler(PROP_SPINNER_WIDTH, handler);
    handler = (oldValue, newValue, figure) -> {
        ((ArrayFigure) figure).setHorizontal((Boolean) newValue);
        keepElementSize = true;
        getWidgetModel().setSize(((ArrayFigure) figure).getPreferredSize());
        keepElementSize = false;
        return false;
    };
    setPropertyChangeHandler(PROP_HORIZONTAL, handler);
    handler = (oldValue, newValue, figure) -> {
        ((ArrayFigure) figure).setShowScrollbar((Boolean) newValue);
        keepElementSize = true;
        getWidgetModel().setSize(((ArrayFigure) figure).getPreferredSize());
        keepElementSize = false;
        return false;
    };
    setPropertyChangeHandler(PROP_SHOW_SCROLLBAR, handler);
    handler = (oldValue, newValue, figure) -> {
        ((ArrayFigure) figure).setShowSpinner((Boolean) newValue);
        keepElementSize = true;
        getWidgetModel().setSize(((ArrayFigure) figure).getPreferredSize());
        keepElementSize = false;
        return false;
    };
    setPropertyChangeHandler(PROP_SHOW_SPINNER, handler);
    PropertyChangeListener sizePropertyChangeListener = evt -> {
        if (getWidgetModel().getChildren().size() == 0 || inSync || keepElementSize) {
            return;
        }
        var elementSize = getArrayFigure().getElementSize();
        var delta = (Integer) evt.getNewValue() - (Integer) evt.getOldValue();
        var elementWH = elementSize.height;
        var propID = evt.getPropertyName();
        var elementCountDirection = false;
        if (getWidgetModel().isHorizontal() && propID.equals(PROP_WIDTH)) {
            elementWH = elementSize.width;
            elementCountDirection = true;
        } else if (!getWidgetModel().isHorizontal() && propID.equals(PROP_HEIGHT)) {
            elementWH = elementSize.height;
            elementCountDirection = true;
        }
        if (elementCountDirection) {
            var deltaElementsCount = Math.round((float) delta / elementWH);
            var idelta = (Math.round((float) delta / elementWH) * elementWH);
            setPropertyValue(propID, (Integer) evt.getOldValue() + idelta, false);
            var visibleElementsCount = getArrayFigure().getVisibleElementsCount() + deltaElementsCount;
            setPropertyValue(PROP_VISIBLE_ELEMENTS_COUNT, visibleElementsCount);
            setValue(getValue());
        } else {
            int wh;
            if (propID.equals(PROP_WIDTH)) {
                wh = getArrayFigure().getElementSize().width;
            } else {
                wh = getArrayFigure().getElementSize().height;
            }
            syncAllChildrenProperties(propID, wh + delta);
        }
    };
    getWidgetModel().getProperty(PROP_WIDTH).addPropertyChangeListener(sizePropertyChangeListener);
    getWidgetModel().getProperty(PROP_HEIGHT).addPropertyChangeListener(sizePropertyChangeListener);
}
Also used : IPrimaryArrayWrapper(org.csstudio.swt.widgets.datadefinition.IPrimaryArrayWrapper) Arrays(java.util.Arrays) PROP_BORDER_WIDTH(org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_BORDER_WIDTH) ProcessVariable(org.csstudio.csdata.ProcessVariable) ByteArrayWrapper(org.csstudio.swt.widgets.datadefinition.ByteArrayWrapper) AbstractWidgetModel(org.csstudio.opibuilder.model.AbstractWidgetModel) ConnectionHandler(org.csstudio.opibuilder.editparts.ConnectionHandler) PROP_PVNAME(org.csstudio.opibuilder.model.IPVWidgetModel.PROP_PVNAME) PROP_VISIBLE_ELEMENTS_COUNT(org.csstudio.opibuilder.widgets.model.ArrayModel.PROP_VISIBLE_ELEMENTS_COUNT) IFigure(org.eclipse.draw2d.IFigure) ITextFigure(org.csstudio.swt.widgets.figures.ITextFigure) IPV(org.yamcs.studio.data.IPV) UIBundlingThread(org.csstudio.ui.util.thread.UIBundlingThread) Arrays.asList(java.util.Arrays.asList) ErrorHandlerUtil(org.csstudio.opibuilder.util.ErrorHandlerUtil) IPVListener(org.yamcs.studio.data.IPVListener) IPVWidgetEditpart(org.csstudio.opibuilder.editparts.IPVWidgetEditpart) IntArrayWrapper(org.csstudio.swt.widgets.datadefinition.IntArrayWrapper) LongArrayWrapper(org.csstudio.swt.widgets.datadefinition.LongArrayWrapper) ExecutionMode(org.csstudio.opibuilder.editparts.ExecutionMode) ArrayFigure(org.csstudio.swt.widgets.figures.ArrayFigure) SelectEditPartTracker(org.eclipse.gef.tools.SelectEditPartTracker) VTypeHelper(org.yamcs.studio.data.VTypeHelper) NLS(org.eclipse.osgi.util.NLS) PROP_FORECOLOR_ALARMSENSITIVE(org.csstudio.opibuilder.model.IPVWidgetModel.PROP_FORECOLOR_ALARMSENSITIVE) IWidgetInfoProvider(org.csstudio.opibuilder.model.IWidgetInfoProvider) PROP_ALARM_PULSING(org.csstudio.opibuilder.model.IPVWidgetModel.PROP_ALARM_PULSING) FloatArrayWrapper(org.csstudio.swt.widgets.datadefinition.FloatArrayWrapper) PROP_YPOS(org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_YPOS) MouseEvent(org.eclipse.swt.events.MouseEvent) List(java.util.List) VString(org.yamcs.studio.data.vtype.VString) PropertyChangeListener(java.beans.PropertyChangeListener) PROP_HORIZONTAL(org.csstudio.opibuilder.widgets.model.ArrayModel.PROP_HORIZONTAL) VType(org.yamcs.studio.data.vtype.VType) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) PROP_SHOW_SCROLLBAR(org.csstudio.opibuilder.widgets.model.ArrayModel.PROP_SHOW_SCROLLBAR) EditPart(org.eclipse.gef.EditPart) PROP_BORDER_STYLE(org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_BORDER_STYLE) PROP_WIDTH(org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_WIDTH) PROP_TOOLTIP(org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_TOOLTIP) PROP_PVVALUE(org.csstudio.opibuilder.model.IPVWidgetModel.PROP_PVVALUE) PROP_BACKCOLOR_ALARMSENSITIVE(org.csstudio.opibuilder.model.IPVWidgetModel.PROP_BACKCOLOR_ALARMSENSITIVE) EditPartViewer(org.eclipse.gef.EditPartViewer) VNumberArray(org.yamcs.studio.data.vtype.VNumberArray) PROP_HEIGHT(org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_HEIGHT) PROP_ARRAY_LENGTH(org.csstudio.opibuilder.widgets.model.ArrayModel.PROP_ARRAY_LENGTH) RequestConstants(org.eclipse.gef.RequestConstants) ArrayList(java.util.ArrayList) PROP_XPOS(org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_XPOS) ArrayModel(org.csstudio.opibuilder.widgets.model.ArrayModel) Border(org.eclipse.draw2d.Border) Request(org.eclipse.gef.Request) PROP_SPINNER_WIDTH(org.csstudio.opibuilder.widgets.model.ArrayModel.PROP_SPINNER_WIDTH) PROP_DATA_TYPE(org.csstudio.opibuilder.widgets.model.ArrayModel.PROP_DATA_TYPE) PVWidgetConnectionHandler(org.csstudio.opibuilder.editparts.PVWidgetConnectionHandler) PVWidgetEditpartDelegate(org.csstudio.opibuilder.editparts.PVWidgetEditpartDelegate) ShortArrayWrapper(org.csstudio.swt.widgets.datadefinition.ShortArrayWrapper) VEnum(org.yamcs.studio.data.vtype.VEnum) AbstractBaseEditPart(org.csstudio.opibuilder.editparts.AbstractBaseEditPart) PROP_SCALE_OPTIONS(org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_SCALE_OPTIONS) BasicDataType(org.yamcs.studio.data.BasicDataType) NonExistPropertyException(org.csstudio.opibuilder.model.NonExistPropertyException) DoubleArrayWrapper(org.csstudio.swt.widgets.datadefinition.DoubleArrayWrapper) ArrayDataType(org.csstudio.opibuilder.widgets.model.ArrayModel.ArrayDataType) DragTracker(org.eclipse.gef.DragTracker) AbstractContainerEditpart(org.csstudio.opibuilder.editparts.AbstractContainerEditpart) EditPolicy(org.eclipse.gef.EditPolicy) PROP_BORDER_ALARMSENSITIVE(org.csstudio.opibuilder.model.IPVWidgetModel.PROP_BORDER_ALARMSENSITIVE) PROP_SHOW_SPINNER(org.csstudio.opibuilder.widgets.model.ArrayModel.PROP_SHOW_SPINNER) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler) VStringArray(org.yamcs.studio.data.vtype.VStringArray) PropertyChangeListener(java.beans.PropertyChangeListener) VEnum(org.yamcs.studio.data.vtype.VEnum) VString(org.yamcs.studio.data.vtype.VString) VNumberArray(org.yamcs.studio.data.vtype.VNumberArray) VType(org.yamcs.studio.data.vtype.VType) ArrayFigure(org.csstudio.swt.widgets.figures.ArrayFigure) VString(org.yamcs.studio.data.vtype.VString) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler) VStringArray(org.yamcs.studio.data.vtype.VStringArray)

Example 2 with PROP_PVVALUE

use of org.csstudio.opibuilder.model.IPVWidgetModel.PROP_PVVALUE in project yamcs-studio by yamcs.

the class MenuButtonEditPart method registerPropertyChangeHandlers.

@Override
protected void registerPropertyChangeHandlers() {
    setPropertyChangeHandler(PROP_PVNAME, (oldValue, newValue, figure) -> {
        registerLoadActionsListener();
        return false;
    });
    setPropertyChangeHandler(PROP_PVVALUE, (oldValue, newValue, refreshableFigure) -> {
        if ((newValue != null) && (newValue instanceof Scalar)) {
            ((MenuButtonFigure) refreshableFigure).setText(VTypeHelper.getString((VType) newValue));
        }
        return true;
    });
    setPropertyChangeHandler(PROP_LABEL, (oldValue, newValue, refreshableFigure) -> {
        ((MenuButtonFigure) refreshableFigure).setText(newValue.toString());
        return true;
    });
    setPropertyChangeHandler(PROP_TRANSPARENT, (oldValue, newValue, refreshableFigure) -> {
        ((MenuButtonFigure) refreshableFigure).setOpaque(!(Boolean) newValue);
        return true;
    });
    setPropertyChangeHandler(PROP_SHOW_DOWN_ARROW, (oldValue, newValue, refreshableFigure) -> {
        ((MenuButtonFigure) refreshableFigure).setDownArrowVisible((boolean) newValue);
        return true;
    });
    IWidgetPropertyChangeHandler handler = (oldValue, newValue, refreshableFigure) -> {
        updatePropSheet((Boolean) newValue);
        return false;
    };
    getWidgetModel().getProperty(PROP_ACTIONS_FROM_PV).addPropertyChangeListener(evt -> handler.handleChange(evt.getOldValue(), evt.getNewValue(), getFigure()));
}
Also used : PROP_PVVALUE(org.csstudio.opibuilder.model.IPVWidgetModel.PROP_PVVALUE) WidgetActionMenuAction(org.csstudio.opibuilder.actions.WidgetActionMenuAction) PROP_TRANSPARENT(org.csstudio.opibuilder.widgets.model.MenuButtonModel.PROP_TRANSPARENT) PROP_ACTIONS(org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_ACTIONS) AbstractWidgetModel(org.csstudio.opibuilder.model.AbstractWidgetModel) PROP_PVNAME(org.csstudio.opibuilder.model.IPVWidgetModel.PROP_PVNAME) RequestConstants(org.eclipse.gef.RequestConstants) CustomMediaFactory(org.csstudio.ui.util.CustomMediaFactory) IFigure(org.eclipse.draw2d.IFigure) ITextFigure(org.csstudio.swt.widgets.figures.ITextFigure) PROP_SHOW_DOWN_ARROW(org.csstudio.opibuilder.widgets.model.MenuButtonModel.PROP_SHOW_DOWN_ARROW) IPV(org.yamcs.studio.data.IPV) Request(org.eclipse.gef.Request) RGB(org.eclipse.swt.graphics.RGB) IPVListener(org.yamcs.studio.data.IPVListener) ActionsInput(org.csstudio.opibuilder.widgetActions.ActionsInput) Scalar(org.yamcs.studio.data.vtype.Scalar) MouseMotionListener(org.eclipse.draw2d.MouseMotionListener) ExecutionMode(org.csstudio.opibuilder.editparts.ExecutionMode) VTypeHelper(org.yamcs.studio.data.VTypeHelper) PlatformUI(org.eclipse.ui.PlatformUI) Point(org.eclipse.draw2d.geometry.Point) MenuManager(org.eclipse.jface.action.MenuManager) VEnum(org.yamcs.studio.data.vtype.VEnum) MouseEvent(org.eclipse.draw2d.MouseEvent) PROP_ACTIONS_FROM_PV(org.csstudio.opibuilder.widgets.model.MenuButtonModel.PROP_ACTIONS_FROM_PV) MouseListener(org.eclipse.draw2d.MouseListener) Display(org.eclipse.swt.widgets.Display) PROP_LABEL(org.csstudio.opibuilder.widgets.model.MenuButtonModel.PROP_LABEL) MenuButtonFigure(org.csstudio.opibuilder.widgets.figures.MenuButtonFigure) List(java.util.List) WritePVAction(org.csstudio.opibuilder.widgetActions.WritePVAction) VType(org.yamcs.studio.data.vtype.VType) AbstractPVWidgetEditPart(org.csstudio.opibuilder.editparts.AbstractPVWidgetEditPart) MenuButtonModel(org.csstudio.opibuilder.widgets.model.MenuButtonModel) EditPolicy(org.eclipse.gef.EditPolicy) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler) GraphicsUtil(org.csstudio.swt.widgets.util.GraphicsUtil) MenuButtonFigure(org.csstudio.opibuilder.widgets.figures.MenuButtonFigure) VType(org.yamcs.studio.data.vtype.VType) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler) Scalar(org.yamcs.studio.data.vtype.Scalar)

Example 3 with PROP_PVVALUE

use of org.csstudio.opibuilder.model.IPVWidgetModel.PROP_PVVALUE in project yamcs-studio by yamcs.

the class CheckBoxEditPart method registerPropertyChangeHandlers.

@Override
protected void registerPropertyChangeHandlers() {
    setPropertyChangeHandler(PROP_PVVALUE, (oldValue, newValue, refreshableFigure) -> {
        if (newValue == null) {
            return false;
        }
        var figure = (CheckBoxFigure) refreshableFigure;
        switch(VTypeHelper.getBasicDataType((VType) newValue)) {
            case SHORT:
                figure.setTotalBits(TotalBits.BITS_16);
                break;
            case INT:
            case ENUM:
                figure.setTotalBits(TotalBits.BITS_32);
                break;
            default:
                break;
        }
        figure.setValue(VTypeHelper.getDouble((VType) newValue));
        return true;
    });
    setPropertyChangeHandler(PROP_BIT, (oldValue, newValue, refreshableFigure) -> {
        var figure = (CheckBoxFigure) refreshableFigure;
        figure.setBit((Integer) newValue);
        return true;
    });
    setPropertyChangeHandler(PROP_LABEL, (oldValue, newValue, refreshableFigure) -> {
        var figure = (CheckBoxFigure) refreshableFigure;
        figure.setText((String) newValue);
        Display.getCurrent().timerExec(10, () -> {
            if (getWidgetModel().isAutoSize()) {
                performAutoSize(refreshableFigure);
            }
        });
        return true;
    });
    setPropertyChangeHandler(PROP_AUTOSIZE, (oldValue, newValue, figure) -> {
        if ((Boolean) newValue) {
            performAutoSize(figure);
            figure.revalidate();
        }
        return true;
    });
    setPropertyChangeHandler(PROP_SELECTED_COLOR, (oldValue, newValue, figure) -> {
        ((CheckBoxFigure) figure).setSelectedColor(getWidgetModel().getSelectedColor().getSWTColor());
        return true;
    });
    IWidgetPropertyChangeHandler handler = (oldValue, newValue, figure) -> {
        Display.getCurrent().timerExec(10, () -> {
            if (getWidgetModel().isAutoSize()) {
                performAutoSize(figure);
                figure.revalidate();
            }
        });
        return true;
    };
    setPropertyChangeHandler(PROP_FONT, handler);
    setPropertyChangeHandler(PROP_BORDER_STYLE, handler);
    setPropertyChangeHandler(PROP_BORDER_WIDTH, handler);
}
Also used : PROP_PVVALUE(org.csstudio.opibuilder.model.IPVWidgetModel.PROP_PVVALUE) VTypeHelper(org.yamcs.studio.data.VTypeHelper) PROP_BORDER_WIDTH(org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_BORDER_WIDTH) CheckBoxFigure(org.csstudio.swt.widgets.figures.CheckBoxFigure) PROP_LABEL(org.csstudio.opibuilder.widgets.model.CheckBoxModel.PROP_LABEL) PROP_PVNAME(org.csstudio.opibuilder.model.IPVWidgetModel.PROP_PVNAME) RequestConstants(org.eclipse.gef.RequestConstants) Display(org.eclipse.swt.widgets.Display) PROP_FONT(org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_FONT) IFigure(org.eclipse.draw2d.IFigure) ITextFigure(org.csstudio.swt.widgets.figures.ITextFigure) PROP_BIT(org.csstudio.opibuilder.widgets.model.CheckBoxModel.PROP_BIT) TotalBits(org.csstudio.swt.widgets.figures.AbstractBoolFigure.TotalBits) PROP_SELECTED_COLOR(org.csstudio.opibuilder.widgets.model.CheckBoxModel.PROP_SELECTED_COLOR) CheckBoxModel(org.csstudio.opibuilder.widgets.model.CheckBoxModel) Request(org.eclipse.gef.Request) VType(org.yamcs.studio.data.vtype.VType) AbstractPVWidgetEditPart(org.csstudio.opibuilder.editparts.AbstractPVWidgetEditPart) EditPolicy(org.eclipse.gef.EditPolicy) PROP_AUTOSIZE(org.csstudio.opibuilder.widgets.model.CheckBoxModel.PROP_AUTOSIZE) PROP_BORDER_STYLE(org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_BORDER_STYLE) ExecutionMode(org.csstudio.opibuilder.editparts.ExecutionMode) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler) VType(org.yamcs.studio.data.vtype.VType) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler) CheckBoxFigure(org.csstudio.swt.widgets.figures.CheckBoxFigure)

Example 4 with PROP_PVVALUE

use of org.csstudio.opibuilder.model.IPVWidgetModel.PROP_PVVALUE in project yamcs-studio by yamcs.

the class AbstractBoolEditPart method registerCommonPropertyChangeHandlers.

/**
 * Registers property change handlers for the properties defined in {@link AbstractBoolWidgetModel}. This method is
 * provided for the convenience of subclasses, which can call this method in their implementation of
 * {@link #registerPropertyChangeHandlers()}.
 */
protected void registerCommonPropertyChangeHandlers() {
    setPropertyChangeHandler(PROP_PVVALUE, (oldValue, newValue, refreshableFigure) -> {
        if (newValue == null || !(newValue instanceof VType)) {
            return false;
        }
        var figure = (AbstractBoolFigure) refreshableFigure;
        switch(VTypeHelper.getBasicDataType((VType) newValue)) {
            case SHORT:
                figure.setTotalBits(TotalBits.BITS_16);
                break;
            case INT:
            case ENUM:
                figure.setTotalBits(TotalBits.BITS_32);
                break;
            default:
                break;
        }
        updateFromValue((VType) newValue, figure);
        return true;
    });
    setPropertyChangeHandler(PROP_BIT, (oldValue, newValue, refreshableFigure) -> {
        if (getWidgetModel().getDataType() != 0) {
            return false;
        }
        var figure = (AbstractBoolFigure) refreshableFigure;
        figure.setBit((Integer) newValue);
        updateFromValue(getPVValue(PROP_PVNAME), figure);
        return true;
    });
    IWidgetPropertyChangeHandler dataTypeHandler = (oldValue, newValue, refreshableFigure) -> {
        var figure = (AbstractBoolFigure) refreshableFigure;
        if ((Integer) newValue == 0) {
            figure.setBit(getWidgetModel().getBit());
        } else {
            figure.setBit(-1);
        }
        updateFromValue(getPVValue(PROP_PVNAME), figure);
        updatePropSheet((Integer) newValue);
        return true;
    };
    getWidgetModel().getProperty(PROP_DATA_TYPE).addPropertyChangeListener(evt -> dataTypeHandler.handleChange(evt.getOldValue(), evt.getNewValue(), getFigure()));
    setPropertyChangeHandler(PROP_ON_STATE, (oldValue, newValue, refreshableFigure) -> {
        var figure = (AbstractBoolFigure) refreshableFigure;
        updateFromValue(getPVValue(PROP_PVNAME), figure);
        return true;
    });
    setPropertyChangeHandler(PROP_SHOW_BOOL_LABEL, (oldValue, newValue, refreshableFigure) -> {
        var figure = (AbstractBoolFigure) refreshableFigure;
        figure.setShowBooleanLabel((Boolean) newValue);
        return true;
    });
    setPropertyChangeHandler(PROP_BOOL_LABEL_POS, (oldValue, newValue, refreshableFigure) -> {
        var figure = (AbstractBoolFigure) refreshableFigure;
        figure.setBoolLabelPosition(BoolLabelPosition.values()[(Integer) newValue]);
        return false;
    });
    setPropertyChangeHandler(PROP_ON_LABEL, (oldValue, newValue, refreshableFigure) -> {
        var figure = (AbstractBoolFigure) refreshableFigure;
        figure.setOnLabel((String) newValue);
        return true;
    });
    setPropertyChangeHandler(PROP_OFF_LABEL, (oldValue, newValue, refreshableFigure) -> {
        var figure = (AbstractBoolFigure) refreshableFigure;
        figure.setOffLabel((String) newValue);
        return true;
    });
    setPropertyChangeHandler(PROP_ON_COLOR, (oldValue, newValue, refreshableFigure) -> {
        var figure = (AbstractBoolFigure) refreshableFigure;
        figure.setOnColor(((OPIColor) newValue).getSWTColor());
        return true;
    });
    setPropertyChangeHandler(PROP_OFF_COLOR, (oldValue, newValue, refreshableFigure) -> {
        var figure = (AbstractBoolFigure) refreshableFigure;
        figure.setOffColor(((OPIColor) newValue).getSWTColor());
        return true;
    });
}
Also used : PROP_PVVALUE(org.csstudio.opibuilder.model.IPVWidgetModel.PROP_PVVALUE) PROP_BOOL_LABEL_POS(org.csstudio.opibuilder.widgets.model.AbstractBoolWidgetModel.PROP_BOOL_LABEL_POS) PROP_ON_COLOR(org.csstudio.opibuilder.widgets.model.AbstractBoolWidgetModel.PROP_ON_COLOR) VTypeHelper(org.yamcs.studio.data.VTypeHelper) PROP_OFF_STATE(org.csstudio.opibuilder.widgets.model.AbstractBoolWidgetModel.PROP_OFF_STATE) AbstractBoolFigure(org.csstudio.swt.widgets.figures.AbstractBoolFigure) AbstractBaseEditPart(org.csstudio.opibuilder.editparts.AbstractBaseEditPart) PROP_PVNAME(org.csstudio.opibuilder.model.IPVWidgetModel.PROP_PVNAME) PROP_OFF_LABEL(org.csstudio.opibuilder.widgets.model.AbstractBoolWidgetModel.PROP_OFF_LABEL) CustomMediaFactory(org.csstudio.ui.util.CustomMediaFactory) BoolLabelPosition(org.csstudio.swt.widgets.figures.AbstractBoolFigure.BoolLabelPosition) PROP_BIT(org.csstudio.opibuilder.widgets.model.AbstractBoolWidgetModel.PROP_BIT) AbstractBoolWidgetModel(org.csstudio.opibuilder.widgets.model.AbstractBoolWidgetModel) PROP_DATA_TYPE(org.csstudio.opibuilder.widgets.model.AbstractBoolWidgetModel.PROP_DATA_TYPE) PROP_OFF_COLOR(org.csstudio.opibuilder.widgets.model.AbstractBoolWidgetModel.PROP_OFF_COLOR) TotalBits(org.csstudio.swt.widgets.figures.AbstractBoolFigure.TotalBits) VType(org.yamcs.studio.data.vtype.VType) PROP_ON_LABEL(org.csstudio.opibuilder.widgets.model.AbstractBoolWidgetModel.PROP_ON_LABEL) AbstractPVWidgetEditPart(org.csstudio.opibuilder.editparts.AbstractPVWidgetEditPart) PROP_ON_STATE(org.csstudio.opibuilder.widgets.model.AbstractBoolWidgetModel.PROP_ON_STATE) PROP_SHOW_BOOL_LABEL(org.csstudio.opibuilder.widgets.model.AbstractBoolWidgetModel.PROP_SHOW_BOOL_LABEL) OPIColor(org.csstudio.opibuilder.util.OPIColor) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler) VType(org.yamcs.studio.data.vtype.VType) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler) AbstractBoolFigure(org.csstudio.swt.widgets.figures.AbstractBoolFigure)

Example 5 with PROP_PVVALUE

use of org.csstudio.opibuilder.model.IPVWidgetModel.PROP_PVVALUE in project yamcs-studio by yamcs.

the class TextUpdateEditPart method registerPropertyChangeHandlers.

@Override
protected void registerPropertyChangeHandlers() {
    setPropertyChangeHandler(PROP_TEXT, (oldValue, newValue, figure) -> {
        setFigureText((String) newValue);
        if (isAutoSize) {
            Display.getCurrent().timerExec(10, this::performAutoSize);
        }
        return true;
    });
    setPropertyChangeHandler(PROP_FONT, (oldValue, newValue, figure) -> {
        figure.setFont(CustomMediaFactory.getInstance().getFont(((OPIFont) newValue).getFontData()));
        return true;
    });
    IWidgetPropertyChangeHandler handler = (oldValue, newValue, figure) -> {
        Display.getCurrent().timerExec(10, () -> {
            if (getWidgetModel().isAutoSize()) {
                performAutoSize();
                figure.revalidate();
            }
        });
        return true;
    };
    setPropertyChangeHandler(PROP_FONT, handler);
    setPropertyChangeHandler(PROP_BORDER_STYLE, handler);
    setPropertyChangeHandler(PROP_BORDER_WIDTH, handler);
    setPropertyChangeHandler(PROP_TRANSPARENT, (oldValue, newValue, figure) -> {
        figure.setOpaque(!(Boolean) newValue);
        return true;
    });
    setPropertyChangeHandler(PROP_AUTOSIZE, (oldValue, newValue, figure) -> {
        isAutoSize = (Boolean) newValue;
        if ((Boolean) newValue) {
            performAutoSize();
            figure.revalidate();
        }
        return true;
    });
    setPropertyChangeHandler(PROP_ALIGN_H, (oldValue, newValue, figure) -> {
        if (figure instanceof TextFigure) {
            ((TextFigure) figure).setHorizontalAlignment(H_ALIGN.values()[(Integer) newValue]);
        }
        return true;
    });
    setPropertyChangeHandler(PROP_ALIGN_V, (oldValue, newValue, figure) -> {
        if (figure instanceof TextFigure) {
            ((TextFigure) figure).setVerticalAlignment(V_ALIGN.values()[(Integer) newValue]);
        }
        return true;
    });
    setPropertyChangeHandler(PROP_PVVALUE, (oldValue, newValue, figure) -> {
        if (newValue == null) {
            return false;
        }
        formatValue(newValue, PROP_PVVALUE);
        return false;
    });
    setPropertyChangeHandler(PROP_FORMAT_TYPE, (oldValue, newValue, figure) -> {
        format = FormatEnum.values()[(Integer) newValue];
        formatValue(newValue, PROP_FORMAT_TYPE);
        return true;
    });
    setPropertyChangeHandler(PROP_PRECISION, (oldValue, newValue, figure) -> {
        precision = (Integer) newValue;
        formatValue(newValue, PROP_PRECISION);
        return true;
    });
    setPropertyChangeHandler(PROP_PRECISION_FROM_DB, (oldValue, newValue, figure) -> {
        isPrecisionFromDB = (Boolean) newValue;
        formatValue(newValue, PROP_PRECISION_FROM_DB);
        return true;
    });
    setPropertyChangeHandler(PROP_SHOW_UNITS, (oldValue, newValue, figure) -> {
        isShowUnits = (Boolean) newValue;
        formatValue(newValue, PROP_SHOW_UNITS);
        return true;
    });
    setPropertyChangeHandler(PROP_ROTATION, (oldValue, newValue, figure) -> {
        if (figure instanceof TextFigure) {
            ((TextFigure) figure).setRotate((Double) newValue);
        }
        return true;
    });
    setPropertyChangeHandler(PROP_WRAP_WORDS, (oldValue, newValue, figure) -> {
        AbstractWidgetModel model = getWidgetModel();
        var parent = model.getParent();
        parent.removeChild(model);
        parent.addChild(model);
        parent.selectWidget(model, true);
        return false;
    });
}
Also used : WrappableTextFigure(org.csstudio.swt.widgets.figures.WrappableTextFigure) PROP_ALIGN_H(org.csstudio.opibuilder.widgets.model.LabelModel.PROP_ALIGN_H) PROP_PVVALUE(org.csstudio.opibuilder.model.IPVWidgetModel.PROP_PVVALUE) PROP_BORDER_WIDTH(org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_BORDER_WIDTH) AbstractWidgetModel(org.csstudio.opibuilder.model.AbstractWidgetModel) PROP_PVNAME(org.csstudio.opibuilder.model.IPVWidgetModel.PROP_PVNAME) PROP_SHOW_UNITS(org.csstudio.opibuilder.widgets.model.TextUpdateModel.PROP_SHOW_UNITS) RequestConstants(org.eclipse.gef.RequestConstants) CustomMediaFactory(org.csstudio.ui.util.CustomMediaFactory) IFigure(org.eclipse.draw2d.IFigure) PROP_PRECISION(org.csstudio.opibuilder.widgets.model.TextUpdateModel.PROP_PRECISION) ITextFigure(org.csstudio.swt.widgets.figures.ITextFigure) ValueFactory(org.yamcs.studio.data.vtype.ValueFactory) FormatEnum(org.yamcs.studio.data.FormatEnum) PROP_ALIGN_V(org.csstudio.opibuilder.widgets.model.LabelModel.PROP_ALIGN_V) Request(org.eclipse.gef.Request) PROP_AUTOSIZE(org.csstudio.opibuilder.widgets.model.LabelModel.PROP_AUTOSIZE) PROP_TEXT(org.csstudio.opibuilder.widgets.model.LabelModel.PROP_TEXT) NativeTextFigure(org.csstudio.opibuilder.widgets.figures.NativeTextFigure) H_ALIGN(org.csstudio.swt.widgets.figures.TextFigure.H_ALIGN) TextUpdateModel(org.csstudio.opibuilder.widgets.model.TextUpdateModel) PROP_WRAP_WORDS(org.csstudio.opibuilder.widgets.model.LabelModel.PROP_WRAP_WORDS) ExecutionMode(org.csstudio.opibuilder.editparts.ExecutionMode) PROP_PRECISION_FROM_DB(org.csstudio.opibuilder.widgets.model.TextUpdateModel.PROP_PRECISION_FROM_DB) PROP_ROTATION(org.csstudio.opibuilder.widgets.model.TextUpdateModel.PROP_ROTATION) VTypeHelper(org.yamcs.studio.data.VTypeHelper) Display(org.eclipse.swt.widgets.Display) PROP_FONT(org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_FONT) PROP_FORMAT_TYPE(org.csstudio.opibuilder.widgets.model.TextUpdateModel.PROP_FORMAT_TYPE) TextFigure(org.csstudio.swt.widgets.figures.TextFigure) V_ALIGN(org.csstudio.swt.widgets.figures.TextFigure.V_ALIGN) PROP_TRANSPARENT(org.csstudio.opibuilder.widgets.model.LabelModel.PROP_TRANSPARENT) VType(org.yamcs.studio.data.vtype.VType) AbstractPVWidgetEditPart(org.csstudio.opibuilder.editparts.AbstractPVWidgetEditPart) OPIFont(org.csstudio.opibuilder.util.OPIFont) EditPolicy(org.eclipse.gef.EditPolicy) PROP_BORDER_STYLE(org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_BORDER_STYLE) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler) OPIFont(org.csstudio.opibuilder.util.OPIFont) AbstractWidgetModel(org.csstudio.opibuilder.model.AbstractWidgetModel) WrappableTextFigure(org.csstudio.swt.widgets.figures.WrappableTextFigure) ITextFigure(org.csstudio.swt.widgets.figures.ITextFigure) NativeTextFigure(org.csstudio.opibuilder.widgets.figures.NativeTextFigure) TextFigure(org.csstudio.swt.widgets.figures.TextFigure) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler)

Aggregations

PROP_PVNAME (org.csstudio.opibuilder.model.IPVWidgetModel.PROP_PVNAME)7 PROP_PVVALUE (org.csstudio.opibuilder.model.IPVWidgetModel.PROP_PVVALUE)7 IWidgetPropertyChangeHandler (org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler)7 VTypeHelper (org.yamcs.studio.data.VTypeHelper)7 VType (org.yamcs.studio.data.vtype.VType)7 AbstractPVWidgetEditPart (org.csstudio.opibuilder.editparts.AbstractPVWidgetEditPart)6 ExecutionMode (org.csstudio.opibuilder.editparts.ExecutionMode)6 IFigure (org.eclipse.draw2d.IFigure)6 List (java.util.List)4 PROP_BORDER_STYLE (org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_BORDER_STYLE)4 PROP_BORDER_WIDTH (org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_BORDER_WIDTH)4 IPV (org.yamcs.studio.data.IPV)4 IPVListener (org.yamcs.studio.data.IPVListener)4 VEnum (org.yamcs.studio.data.vtype.VEnum)4 AbstractWidgetModel (org.csstudio.opibuilder.model.AbstractWidgetModel)3 PROP_FONT (org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_FONT)3 ITextFigure (org.csstudio.swt.widgets.figures.ITextFigure)3 CustomMediaFactory (org.csstudio.ui.util.CustomMediaFactory)3 EditPolicy (org.eclipse.gef.EditPolicy)3 Request (org.eclipse.gef.Request)3