Search in sources :

Example 1 with PROP_AUTOSIZE

use of org.csstudio.opibuilder.widgets.model.CheckBoxModel.PROP_AUTOSIZE 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)

Aggregations

AbstractPVWidgetEditPart (org.csstudio.opibuilder.editparts.AbstractPVWidgetEditPart)1 ExecutionMode (org.csstudio.opibuilder.editparts.ExecutionMode)1 PROP_BORDER_STYLE (org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_BORDER_STYLE)1 PROP_BORDER_WIDTH (org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_BORDER_WIDTH)1 PROP_FONT (org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_FONT)1 PROP_PVNAME (org.csstudio.opibuilder.model.IPVWidgetModel.PROP_PVNAME)1 PROP_PVVALUE (org.csstudio.opibuilder.model.IPVWidgetModel.PROP_PVVALUE)1 IWidgetPropertyChangeHandler (org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler)1 CheckBoxModel (org.csstudio.opibuilder.widgets.model.CheckBoxModel)1 PROP_AUTOSIZE (org.csstudio.opibuilder.widgets.model.CheckBoxModel.PROP_AUTOSIZE)1 PROP_BIT (org.csstudio.opibuilder.widgets.model.CheckBoxModel.PROP_BIT)1 PROP_LABEL (org.csstudio.opibuilder.widgets.model.CheckBoxModel.PROP_LABEL)1 PROP_SELECTED_COLOR (org.csstudio.opibuilder.widgets.model.CheckBoxModel.PROP_SELECTED_COLOR)1 TotalBits (org.csstudio.swt.widgets.figures.AbstractBoolFigure.TotalBits)1 CheckBoxFigure (org.csstudio.swt.widgets.figures.CheckBoxFigure)1 ITextFigure (org.csstudio.swt.widgets.figures.ITextFigure)1 IFigure (org.eclipse.draw2d.IFigure)1 EditPolicy (org.eclipse.gef.EditPolicy)1 Request (org.eclipse.gef.Request)1 RequestConstants (org.eclipse.gef.RequestConstants)1