Search in sources :

Example 1 with PROP_ALIGN_V

use of org.csstudio.opibuilder.widgets.model.LabelModel.PROP_ALIGN_V in project yamcs-studio by yamcs.

the class LabelEditPart method registerPropertyChangeHandlers.

@Override
protected void registerPropertyChangeHandlers() {
    setPropertyChangeHandler(PROP_TEXT, (oldValue, newValue, figure) -> {
        ((TextFigure) figure).setText((String) newValue);
        Display.getCurrent().timerExec(10, () -> {
            if (getWidgetModel().isAutoSize()) {
                getWidgetModel().setSize(((TextFigure) figure).getAutoSizeDimension());
            }
        });
        return true;
    });
    setPropertyChangeHandler(PROP_ACTIONS, (oldValue, newValue, figure) -> {
        ((TextFigure) figure).setSelectable(determinSelectable());
        return false;
    });
    setPropertyChangeHandler(PROP_TOOLTIP, (oldValue, newValue, figure) -> {
        ((TextFigure) figure).setSelectable(determinSelectable());
        return false;
    });
    IWidgetPropertyChangeHandler handler = (oldValue, newValue, figure) -> {
        Display.getCurrent().timerExec(10, () -> {
            if (getWidgetModel().isAutoSize()) {
                getWidgetModel().setSize(((TextFigure) figure).getAutoSizeDimension());
                figure.revalidate();
            }
        });
        return true;
    };
    setPropertyChangeHandler(PROP_FONT, handler);
    setPropertyChangeHandler(PROP_BORDER_STYLE, handler);
    setPropertyChangeHandler(PROP_BORDER_WIDTH, handler);
    setPropertyChangeHandler(PROP_TRANSPARENT, (oldValue, newValue, figure) -> {
        ((TextFigure) figure).setOpaque(!(Boolean) newValue);
        return true;
    });
    setPropertyChangeHandler(PROP_AUTOSIZE, (oldValue, newValue, figure) -> {
        if ((Boolean) newValue) {
            getWidgetModel().setSize(((TextFigure) figure).getAutoSizeDimension());
            figure.revalidate();
        }
        return true;
    });
    setPropertyChangeHandler(PROP_ALIGN_H, (oldValue, newValue, figure) -> {
        ((TextFigure) figure).setHorizontalAlignment(H_ALIGN.values()[(Integer) newValue]);
        return true;
    });
    setPropertyChangeHandler(PROP_ALIGN_V, (oldValue, newValue, figure) -> {
        ((TextFigure) figure).setVerticalAlignment(V_ALIGN.values()[(Integer) 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;
    });
    getWidgetModel().getProperty(PROP_WRAP_WORDS).addPropertyChangeListener(evt -> updatePropertyVisibility());
    setPropertyChangeHandler(PROP_SHOW_SCROLLBAR, (oldValue, newValue, figure) -> {
        if (figure instanceof WrappableTextFigure) {
            ((WrappableTextFigure) figure).setShowScrollbar((Boolean) newValue);
        }
        return false;
    });
}
Also used : WrappableTextFigure(org.csstudio.swt.widgets.figures.WrappableTextFigure) PROP_ALIGN_H(org.csstudio.opibuilder.widgets.model.LabelModel.PROP_ALIGN_H) PROP_TOOLTIP(org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_TOOLTIP) AbstractWidgetEditPart(org.csstudio.opibuilder.editparts.AbstractWidgetEditPart) PROP_BORDER_WIDTH(org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_BORDER_WIDTH) PROP_ACTIONS(org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_ACTIONS) AbstractWidgetModel(org.csstudio.opibuilder.model.AbstractWidgetModel) RequestConstants(org.eclipse.gef.RequestConstants) IFigure(org.eclipse.draw2d.IFigure) ITextFigure(org.csstudio.swt.widgets.figures.ITextFigure) 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) H_ALIGN(org.csstudio.swt.widgets.figures.TextFigure.H_ALIGN) PROP_WRAP_WORDS(org.csstudio.opibuilder.widgets.model.LabelModel.PROP_WRAP_WORDS) ExecutionMode(org.csstudio.opibuilder.editparts.ExecutionMode) LabelModel(org.csstudio.opibuilder.widgets.model.LabelModel) Display(org.eclipse.swt.widgets.Display) PROP_FONT(org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_FONT) TextFigure(org.csstudio.swt.widgets.figures.TextFigure) V_ALIGN(org.csstudio.swt.widgets.figures.TextFigure.V_ALIGN) PROP_SHOW_SCROLLBAR(org.csstudio.opibuilder.widgets.model.LabelModel.PROP_SHOW_SCROLLBAR) PROP_TRANSPARENT(org.csstudio.opibuilder.widgets.model.LabelModel.PROP_TRANSPARENT) EditPolicy(org.eclipse.gef.EditPolicy) PROP_BORDER_STYLE(org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_BORDER_STYLE) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler) AbstractWidgetModel(org.csstudio.opibuilder.model.AbstractWidgetModel) WrappableTextFigure(org.csstudio.swt.widgets.figures.WrappableTextFigure) ITextFigure(org.csstudio.swt.widgets.figures.ITextFigure) TextFigure(org.csstudio.swt.widgets.figures.TextFigure) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler) WrappableTextFigure(org.csstudio.swt.widgets.figures.WrappableTextFigure)

Example 2 with PROP_ALIGN_V

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

ExecutionMode (org.csstudio.opibuilder.editparts.ExecutionMode)2 AbstractWidgetModel (org.csstudio.opibuilder.model.AbstractWidgetModel)2 PROP_BORDER_STYLE (org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_BORDER_STYLE)2 PROP_BORDER_WIDTH (org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_BORDER_WIDTH)2 PROP_FONT (org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_FONT)2 IWidgetPropertyChangeHandler (org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler)2 PROP_ALIGN_H (org.csstudio.opibuilder.widgets.model.LabelModel.PROP_ALIGN_H)2 PROP_ALIGN_V (org.csstudio.opibuilder.widgets.model.LabelModel.PROP_ALIGN_V)2 PROP_AUTOSIZE (org.csstudio.opibuilder.widgets.model.LabelModel.PROP_AUTOSIZE)2 PROP_TEXT (org.csstudio.opibuilder.widgets.model.LabelModel.PROP_TEXT)2 PROP_TRANSPARENT (org.csstudio.opibuilder.widgets.model.LabelModel.PROP_TRANSPARENT)2 PROP_WRAP_WORDS (org.csstudio.opibuilder.widgets.model.LabelModel.PROP_WRAP_WORDS)2 ITextFigure (org.csstudio.swt.widgets.figures.ITextFigure)2 TextFigure (org.csstudio.swt.widgets.figures.TextFigure)2 H_ALIGN (org.csstudio.swt.widgets.figures.TextFigure.H_ALIGN)2 V_ALIGN (org.csstudio.swt.widgets.figures.TextFigure.V_ALIGN)2 WrappableTextFigure (org.csstudio.swt.widgets.figures.WrappableTextFigure)2 IFigure (org.eclipse.draw2d.IFigure)2 EditPolicy (org.eclipse.gef.EditPolicy)2 Request (org.eclipse.gef.Request)2