Search in sources :

Example 1 with PROP_ROTATION

use of org.csstudio.opibuilder.widgets.model.TextUpdateModel.PROP_ROTATION 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

AbstractPVWidgetEditPart (org.csstudio.opibuilder.editparts.AbstractPVWidgetEditPart)1 ExecutionMode (org.csstudio.opibuilder.editparts.ExecutionMode)1 AbstractWidgetModel (org.csstudio.opibuilder.model.AbstractWidgetModel)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 OPIFont (org.csstudio.opibuilder.util.OPIFont)1 NativeTextFigure (org.csstudio.opibuilder.widgets.figures.NativeTextFigure)1 PROP_ALIGN_H (org.csstudio.opibuilder.widgets.model.LabelModel.PROP_ALIGN_H)1 PROP_ALIGN_V (org.csstudio.opibuilder.widgets.model.LabelModel.PROP_ALIGN_V)1 PROP_AUTOSIZE (org.csstudio.opibuilder.widgets.model.LabelModel.PROP_AUTOSIZE)1 PROP_TEXT (org.csstudio.opibuilder.widgets.model.LabelModel.PROP_TEXT)1 PROP_TRANSPARENT (org.csstudio.opibuilder.widgets.model.LabelModel.PROP_TRANSPARENT)1 PROP_WRAP_WORDS (org.csstudio.opibuilder.widgets.model.LabelModel.PROP_WRAP_WORDS)1 TextUpdateModel (org.csstudio.opibuilder.widgets.model.TextUpdateModel)1 PROP_FORMAT_TYPE (org.csstudio.opibuilder.widgets.model.TextUpdateModel.PROP_FORMAT_TYPE)1 PROP_PRECISION (org.csstudio.opibuilder.widgets.model.TextUpdateModel.PROP_PRECISION)1