Search in sources :

Example 1 with TextFigure

use of org.csstudio.swt.widgets.figures.TextFigure in project yamcs-studio by yamcs.

the class SpinnerEditpart method doCreateFigure.

@Override
protected IFigure doCreateFigure() {
    SpinnerFigure spinner = new SpinnerFigure();
    TextFigure labelFigure = spinner.getLabelFigure();
    labelFigure.setFont(getWidgetModel().getFont().getSWTFont());
    labelFigure.setFontPixels(getWidgetModel().getFont().isSizeInPixels());
    labelFigure.setOpaque(!getWidgetModel().isTransparent());
    labelFigure.setHorizontalAlignment(getWidgetModel().getHorizontalAlignment());
    labelFigure.setVerticalAlignment(getWidgetModel().getVerticalAlignment());
    spinner.setMax(getWidgetModel().getMaximum());
    spinner.setMin(getWidgetModel().getMinimum());
    spinner.setStepIncrement(getWidgetModel().getStepIncrement());
    spinner.setPageIncrement(getWidgetModel().getPageIncrement());
    spinner.setFormatType(getWidgetModel().getFormat());
    spinner.setPrecision((Integer) getPropertyValue(SpinnerModel.PROP_PRECISION));
    spinner.setArrowButtonsOnLeft(getWidgetModel().isButtonsOnLeft());
    spinner.setArrowButtonsHorizontal(getWidgetModel().isHorizontalButtonsLayout());
    spinner.showText(getWidgetModel().showText());
    if (getExecutionMode() == ExecutionMode.RUN_MODE) {
        spinner.addManualValueChangeListener(new IManualValueChangeListener() {

            @Override
            public void manualValueChanged(double newValue) {
                setPVValue(SpinnerModel.PROP_PVNAME, newValue);
                getWidgetModel().setText(((SpinnerFigure) getFigure()).getLabelFigure().getText(), false);
            }
        });
    }
    return spinner;
}
Also used : IManualValueChangeListener(org.csstudio.swt.widgets.datadefinition.IManualValueChangeListener) SpinnerFigure(org.csstudio.swt.widgets.figures.SpinnerFigure) ITextFigure(org.csstudio.swt.widgets.figures.ITextFigure) TextFigure(org.csstudio.swt.widgets.figures.TextFigure)

Example 2 with TextFigure

use of org.csstudio.swt.widgets.figures.TextFigure in project yamcs-studio by yamcs.

the class LabelEditPart method doCreateFigure.

@Override
protected IFigure doCreateFigure() {
    TextFigure labelFigure = createTextFigure();
    labelFigure.setOpaque(!getWidgetModel().isTransparent());
    labelFigure.setHorizontalAlignment(getWidgetModel().getHorizontalAlignment());
    labelFigure.setVerticalAlignment(getWidgetModel().getVerticalAlignment());
    labelFigure.setSelectable(determinSelectable());
    labelFigure.setText(getWidgetModel().getText());
    labelFigure.setFontPixels(getWidgetModel().getFont().isSizeInPixels());
    if (labelFigure instanceof WrappableTextFigure)
        ((WrappableTextFigure) labelFigure).setShowScrollbar(getWidgetModel().isShowScrollbar());
    updatePropertyVisibility();
    return labelFigure;
}
Also used : WrappableTextFigure(org.csstudio.swt.widgets.figures.WrappableTextFigure) ITextFigure(org.csstudio.swt.widgets.figures.ITextFigure) TextFigure(org.csstudio.swt.widgets.figures.TextFigure) WrappableTextFigure(org.csstudio.swt.widgets.figures.WrappableTextFigure)

Example 3 with TextFigure

use of org.csstudio.swt.widgets.figures.TextFigure in project yamcs-studio by yamcs.

the class LabelEditPart method registerPropertyChangeHandlers.

@Override
protected void registerPropertyChangeHandlers() {
    IWidgetPropertyChangeHandler handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, final IFigure figure) {
            ((TextFigure) figure).setText((String) newValue);
            Display.getCurrent().timerExec(10, new Runnable() {

                @Override
                public void run() {
                    if (getWidgetModel().isAutoSize())
                        getWidgetModel().setSize(((TextFigure) figure).getAutoSizeDimension());
                }
            });
            return true;
        }
    };
    setPropertyChangeHandler(LabelModel.PROP_TEXT, handler);
    IWidgetPropertyChangeHandler clickableHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            ((TextFigure) figure).setSelectable(determinSelectable());
            return false;
        }
    };
    setPropertyChangeHandler(LabelModel.PROP_ACTIONS, clickableHandler);
    setPropertyChangeHandler(LabelModel.PROP_TOOLTIP, clickableHandler);
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, final IFigure figure) {
            Display.getCurrent().timerExec(10, new Runnable() {

                @Override
                public void run() {
                    if (getWidgetModel().isAutoSize()) {
                        getWidgetModel().setSize(((TextFigure) figure).getAutoSizeDimension());
                        figure.revalidate();
                    }
                }
            });
            return true;
        }
    };
    setPropertyChangeHandler(LabelModel.PROP_FONT, handler);
    setPropertyChangeHandler(AbstractWidgetModel.PROP_BORDER_STYLE, handler);
    setPropertyChangeHandler(AbstractWidgetModel.PROP_BORDER_WIDTH, handler);
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            ((TextFigure) figure).setOpaque(!(Boolean) newValue);
            return true;
        }
    };
    setPropertyChangeHandler(LabelModel.PROP_TRANSPARENT, handler);
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            if ((Boolean) newValue) {
                getWidgetModel().setSize(((TextFigure) figure).getAutoSizeDimension());
                figure.revalidate();
            }
            return true;
        }
    };
    setPropertyChangeHandler(LabelModel.PROP_AUTOSIZE, handler);
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            ((TextFigure) figure).setHorizontalAlignment(H_ALIGN.values()[(Integer) newValue]);
            return true;
        }
    };
    setPropertyChangeHandler(LabelModel.PROP_ALIGN_H, handler);
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            ((TextFigure) figure).setVerticalAlignment(V_ALIGN.values()[(Integer) newValue]);
            return true;
        }
    };
    setPropertyChangeHandler(LabelModel.PROP_ALIGN_V, handler);
    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(LabelModel.PROP_WRAP_WORDS, handler);
    getWidgetModel().getProperty(LabelModel.PROP_WRAP_WORDS).addPropertyChangeListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            updatePropertyVisibility();
        }
    });
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            if (figure instanceof WrappableTextFigure)
                ((WrappableTextFigure) figure).setShowScrollbar((Boolean) newValue);
            return false;
        }
    };
    setPropertyChangeHandler(LabelModel.PROP_SHOW_SCROLLBAR, handler);
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) AbstractWidgetModel(org.csstudio.opibuilder.model.AbstractWidgetModel) AbstractContainerModel(org.csstudio.opibuilder.model.AbstractContainerModel) PropertyChangeListener(java.beans.PropertyChangeListener) 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) IFigure(org.eclipse.draw2d.IFigure)

Example 4 with TextFigure

use of org.csstudio.swt.widgets.figures.TextFigure in project yamcs-studio by yamcs.

the class TextUpdateEditPart method doCreateFigure.

@Override
protected IFigure doCreateFigure() {
    initFields();
    TextFigure labelFigure = createTextFigure();
    initTextFigure(labelFigure);
    return labelFigure;
}
Also used : 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)

Example 5 with TextFigure

use of org.csstudio.swt.widgets.figures.TextFigure in project yamcs-studio by yamcs.

the class TextUpdateEditPart method registerPropertyChangeHandlers.

@Override
protected void registerPropertyChangeHandlers() {
    IWidgetPropertyChangeHandler handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, final IFigure figure) {
            setFigureText((String) newValue);
            if (isAutoSize) {
                Display.getCurrent().timerExec(10, new Runnable() {

                    @Override
                    public void run() {
                        performAutoSize();
                    }
                });
            }
            return true;
        }
    };
    setPropertyChangeHandler(TextUpdateModel.PROP_TEXT, handler);
    IWidgetPropertyChangeHandler fontHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            figure.setFont(CustomMediaFactory.getInstance().getFont(((OPIFont) newValue).getFontData()));
            return true;
        }
    };
    setPropertyChangeHandler(LabelModel.PROP_FONT, fontHandler);
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, final IFigure figure) {
            Display.getCurrent().timerExec(10, new Runnable() {

                @Override
                public void run() {
                    if (getWidgetModel().isAutoSize()) {
                        performAutoSize();
                        figure.revalidate();
                    }
                }
            });
            return true;
        }
    };
    setPropertyChangeHandler(LabelModel.PROP_FONT, handler);
    setPropertyChangeHandler(AbstractWidgetModel.PROP_BORDER_STYLE, handler);
    setPropertyChangeHandler(AbstractWidgetModel.PROP_BORDER_WIDTH, handler);
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            figure.setOpaque(!(Boolean) newValue);
            return true;
        }
    };
    setPropertyChangeHandler(LabelModel.PROP_TRANSPARENT, handler);
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            isAutoSize = (Boolean) newValue;
            if ((Boolean) newValue) {
                performAutoSize();
                figure.revalidate();
            }
            return true;
        }
    };
    setPropertyChangeHandler(LabelModel.PROP_AUTOSIZE, handler);
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            if (figure instanceof TextFigure)
                ((TextFigure) figure).setHorizontalAlignment(H_ALIGN.values()[(Integer) newValue]);
            return true;
        }
    };
    setPropertyChangeHandler(LabelModel.PROP_ALIGN_H, handler);
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            if (figure instanceof TextFigure)
                ((TextFigure) figure).setVerticalAlignment(V_ALIGN.values()[(Integer) newValue]);
            return true;
        }
    };
    setPropertyChangeHandler(LabelModel.PROP_ALIGN_V, handler);
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, final IFigure figure) {
            if (newValue == null)
                return false;
            formatValue(newValue, AbstractPVWidgetModel.PROP_PVVALUE);
            return false;
        }
    };
    setPropertyChangeHandler(AbstractPVWidgetModel.PROP_PVVALUE, handler);
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, final IFigure figure) {
            format = FormatEnum.values()[(Integer) newValue];
            formatValue(newValue, TextUpdateModel.PROP_FORMAT_TYPE);
            return true;
        }
    };
    setPropertyChangeHandler(TextUpdateModel.PROP_FORMAT_TYPE, handler);
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, final IFigure figure) {
            precision = (Integer) newValue;
            formatValue(newValue, TextUpdateModel.PROP_PRECISION);
            return true;
        }
    };
    setPropertyChangeHandler(TextUpdateModel.PROP_PRECISION, handler);
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, final IFigure figure) {
            isPrecisionFromDB = (Boolean) newValue;
            formatValue(newValue, TextUpdateModel.PROP_PRECISION_FROM_DB);
            return true;
        }
    };
    setPropertyChangeHandler(TextUpdateModel.PROP_PRECISION_FROM_DB, handler);
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, final IFigure figure) {
            isShowUnits = (Boolean) newValue;
            formatValue(newValue, TextUpdateModel.PROP_SHOW_UNITS);
            return true;
        }
    };
    setPropertyChangeHandler(TextUpdateModel.PROP_SHOW_UNITS, handler);
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, final IFigure figure) {
            if (figure instanceof TextFigure)
                ((TextFigure) figure).setRotate((Double) newValue);
            return true;
        }
    };
    setPropertyChangeHandler(TextUpdateModel.PROP_ROTATION, handler);
    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(TextUpdateModel.PROP_WRAP_WORDS, handler);
}
Also used : OPIFont(org.csstudio.opibuilder.util.OPIFont) AbstractWidgetModel(org.csstudio.opibuilder.model.AbstractWidgetModel) AbstractContainerModel(org.csstudio.opibuilder.model.AbstractContainerModel) 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) IFigure(org.eclipse.draw2d.IFigure)

Aggregations

ITextFigure (org.csstudio.swt.widgets.figures.ITextFigure)5 TextFigure (org.csstudio.swt.widgets.figures.TextFigure)5 WrappableTextFigure (org.csstudio.swt.widgets.figures.WrappableTextFigure)4 AbstractContainerModel (org.csstudio.opibuilder.model.AbstractContainerModel)2 AbstractWidgetModel (org.csstudio.opibuilder.model.AbstractWidgetModel)2 IWidgetPropertyChangeHandler (org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler)2 NativeTextFigure (org.csstudio.opibuilder.widgets.figures.NativeTextFigure)2 IFigure (org.eclipse.draw2d.IFigure)2 PropertyChangeEvent (java.beans.PropertyChangeEvent)1 PropertyChangeListener (java.beans.PropertyChangeListener)1 OPIFont (org.csstudio.opibuilder.util.OPIFont)1 IManualValueChangeListener (org.csstudio.swt.widgets.datadefinition.IManualValueChangeListener)1 SpinnerFigure (org.csstudio.swt.widgets.figures.SpinnerFigure)1