Search in sources :

Example 6 with IControlCreator

use of org.eclipse.jface.fieldassist.IControlCreator in project tdi-studio-se by Talend.

the class AbstractLanguageMemoController method estimateRowSize.

/*
     * (non-Javadoc)
     * 
     * @see
     * org.talend.designer.core.ui.editor.properties.controllers.AbstractElementPropertySectionController#estimateRowSize
     * (org.eclipse.swt.widgets.Composite, org.talend.core.model.process.IElementParameter)
     */
@Override
public int estimateRowSize(Composite subComposite, IElementParameter param) {
    if (!estimateInitialized) {
        IControlCreator txtCtrl = new IControlCreator() {

            @Override
            public Control createControl(final Composite parent, final int style) {
                final ColorStyledText colorText = new ColorStyledText(parent, style, CorePlugin.getDefault().getPreferenceStore(), language);
                Display display = Display.getCurrent();
                if (display == null) {
                    display = Display.getDefault();
                }
                if (display != null) {
                    display.syncExec(new Runnable() {

                        @Override
                        public void run() {
                            IPreferenceStore preferenceStore = CorePlugin.getDefault().getPreferenceStore();
                            String fontType = preferenceStore.getString(TalendDesignerPrefConstants.MEMO_TEXT_FONT);
                            FontData fontData = new FontData(fontType);
                            Font font = new Font(parent.getDisplay(), fontData);
                            addResourceDisposeListener(colorText, font);
                            colorText.setFont(font);
                        }
                    });
                }
                return colorText;
            }
        };
        DecoratedField dField = null;
        if (param.getNbLines() != 1) {
            dField = new DecoratedField(subComposite, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL | SWT.WRAP, txtCtrl);
        } else {
            dField = new DecoratedField(subComposite, SWT.BORDER | SWT.WRAP, txtCtrl);
        }
        StyledText text = (StyledText) dField.getControl();
        FormData d = (FormData) text.getLayoutData();
        d.height = text.getLineHeight();
        text.getParent().setSize(subComposite.getSize().x, text.getLineHeight());
        rowSizeByLine = text.getLineHeight();
        Point initialSize = dField.getLayoutControl().computeSize(SWT.DEFAULT, SWT.DEFAULT);
        dField.getLayoutControl().dispose();
        rowSizeFixed = ITabbedPropertyConstants.VSPACE + (initialSize.y - rowSizeByLine);
        estimateInitialized = true;
    }
    return rowSizeFixed + (rowSizeByLine * param.getNbLines());
}
Also used : FormData(org.eclipse.swt.layout.FormData) StyledText(org.eclipse.swt.custom.StyledText) ColorStyledText(org.talend.commons.ui.swt.colorstyledtext.ColorStyledText) ReconcilerStyledText(org.talend.designer.core.ui.viewer.ReconcilerStyledText) Composite(org.eclipse.swt.widgets.Composite) FontData(org.eclipse.swt.graphics.FontData) DecoratedField(org.eclipse.jface.fieldassist.DecoratedField) Point(org.eclipse.swt.graphics.Point) Font(org.eclipse.swt.graphics.Font) IControlCreator(org.eclipse.jface.fieldassist.IControlCreator) ColorStyledText(org.talend.commons.ui.swt.colorstyledtext.ColorStyledText) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) Display(org.eclipse.swt.widgets.Display)

Example 7 with IControlCreator

use of org.eclipse.jface.fieldassist.IControlCreator in project tdi-studio-se by Talend.

the class CheckController method estimateRowSize.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.designer.core.ui.editor.properties.controllers.AbstractElementPropertySectionController#
     * estimateRowSize (org.eclipse.swt.widgets.Composite, org.talend.core.model.process.IElementParameter)
     */
@Override
public int estimateRowSize(Composite subComposite, final IElementParameter param) {
    final DecoratedField dField = new DecoratedField(subComposite, SWT.BORDER, new IControlCreator() {

        @Override
        public Control createControl(Composite parent, int style) {
            return getWidgetFactory().createButton(parent, param.getDisplayName(), SWT.CHECK);
        }
    });
    Point initialSize = dField.getLayoutControl().computeSize(SWT.DEFAULT, SWT.DEFAULT);
    dField.getLayoutControl().dispose();
    return initialSize.y + ITabbedPropertyConstants.VSPACE;
}
Also used : IControlCreator(org.eclipse.jface.fieldassist.IControlCreator) Control(org.eclipse.swt.widgets.Control) Composite(org.eclipse.swt.widgets.Composite) DecoratedField(org.eclipse.jface.fieldassist.DecoratedField) Point(org.eclipse.swt.graphics.Point) Point(org.eclipse.swt.graphics.Point)

Example 8 with IControlCreator

use of org.eclipse.jface.fieldassist.IControlCreator in project tdi-studio-se by Talend.

the class SqlMemoController method estimateRowSize.

/*
     * (non-Javadoc)
     * 
     * @see
     * org.talend.designer.core.ui.editor.properties.controllers.AbstractElementPropertySectionController#estimateRowSize
     * (org.eclipse.swt.widgets.Composite, org.talend.core.model.process.IElementParameter)
     */
@Override
public int estimateRowSize(Composite subComposite, IElementParameter param) {
    IControlCreator txtCtrl = new IControlCreator() {

        @Override
        public Control createControl(final Composite parent, final int style) {
            return createColorStyledText(parent, style);
        }
    };
    DecoratedField dField = null;
    if (param.getNbLines() != 1) {
        dField = new DecoratedField(subComposite, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL, txtCtrl);
    } else {
        dField = new DecoratedField(subComposite, SWT.BORDER, txtCtrl);
    }
    ColorStyledText text = (ColorStyledText) dField.getControl();
    FormData d = (FormData) text.getLayoutData();
    d.height = text.getLineHeight() * param.getNbLines();
    text.getParent().setSize(subComposite.getSize().x, text.getLineHeight() * param.getNbLines());
    Point initialSize = dField.getLayoutControl().computeSize(SWT.DEFAULT, SWT.DEFAULT);
    dField.getLayoutControl().dispose();
    return initialSize.y + ITabbedPropertyConstants.VSPACE;
}
Also used : FormData(org.eclipse.swt.layout.FormData) IControlCreator(org.eclipse.jface.fieldassist.IControlCreator) Composite(org.eclipse.swt.widgets.Composite) DecoratedField(org.eclipse.jface.fieldassist.DecoratedField) Point(org.eclipse.swt.graphics.Point) ColorStyledText(org.talend.commons.ui.swt.colorstyledtext.ColorStyledText)

Example 9 with IControlCreator

use of org.eclipse.jface.fieldassist.IControlCreator in project tdi-studio-se by Talend.

the class RadioController method estimateRowSize.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.designer.core.ui.editor.properties.controllers.AbstractElementPropertySectionController#estimateRowSize(org.eclipse.swt.widgets.Composite,
     * org.talend.core.model.process.IElementParameter)
     */
@Override
public int estimateRowSize(Composite subComposite, final IElementParameter param) {
    final DecoratedField dField = new DecoratedField(subComposite, SWT.BORDER, new IControlCreator() {

        public Control createControl(Composite parent, int style) {
            return getWidgetFactory().createButton(parent, param.getDisplayName(), SWT.RADIO);
        }
    });
    Point initialSize = dField.getLayoutControl().computeSize(SWT.DEFAULT, SWT.DEFAULT);
    dField.getLayoutControl().dispose();
    return initialSize.y + ITabbedPropertyConstants.VSPACE;
}
Also used : IControlCreator(org.eclipse.jface.fieldassist.IControlCreator) Control(org.eclipse.swt.widgets.Control) Composite(org.eclipse.swt.widgets.Composite) DecoratedField(org.eclipse.jface.fieldassist.DecoratedField) Point(org.eclipse.swt.graphics.Point) Point(org.eclipse.swt.graphics.Point)

Example 10 with IControlCreator

use of org.eclipse.jface.fieldassist.IControlCreator in project tdi-studio-se by Talend.

the class MessageMemoController method estimateRowSize.

/*
     * (non-Javadoc)
     * 
     * @see
     * org.talend.designer.core.ui.editor.properties.controllers.AbstractElementPropertySectionController#estimateRowSize
     * (org.eclipse.swt.widgets.Composite, org.talend.core.model.process.IElementParameter)
     */
@Override
public int estimateRowSize(Composite subComposite, IElementParameter param) {
    IControlCreator txtCtrl = new IControlCreator() {

        @Override
        public Control createControl(final Composite parent, final int style) {
            return createColorStyledText(parent, style);
        }
    };
    DecoratedField dField = null;
    if (param.getNbLines() != 1) {
        dField = new DecoratedField(subComposite, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL, txtCtrl);
    } else {
        dField = new DecoratedField(subComposite, SWT.BORDER, txtCtrl);
    }
    ColorStyledText text = (ColorStyledText) dField.getControl();
    FormData d = (FormData) text.getLayoutData();
    d.height = text.getLineHeight() * param.getNbLines();
    text.getParent().setSize(subComposite.getSize().x, text.getLineHeight() * param.getNbLines());
    Point initialSize = dField.getLayoutControl().computeSize(SWT.DEFAULT, SWT.DEFAULT);
    dField.getLayoutControl().dispose();
    return initialSize.y + ITabbedPropertyConstants.VSPACE;
}
Also used : FormData(org.eclipse.swt.layout.FormData) IControlCreator(org.eclipse.jface.fieldassist.IControlCreator) Composite(org.eclipse.swt.widgets.Composite) DecoratedField(org.eclipse.jface.fieldassist.DecoratedField) Point(org.eclipse.swt.graphics.Point) ColorStyledText(org.talend.commons.ui.swt.colorstyledtext.ColorStyledText)

Aggregations

DecoratedField (org.eclipse.jface.fieldassist.DecoratedField)21 IControlCreator (org.eclipse.jface.fieldassist.IControlCreator)21 Composite (org.eclipse.swt.widgets.Composite)21 Point (org.eclipse.swt.graphics.Point)20 Control (org.eclipse.swt.widgets.Control)18 FormData (org.eclipse.swt.layout.FormData)12 FormAttachment (org.eclipse.swt.layout.FormAttachment)9 Button (org.eclipse.swt.widgets.Button)9 FieldDecoration (org.eclipse.jface.fieldassist.FieldDecoration)7 CLabel (org.eclipse.swt.custom.CLabel)6 Node (org.talend.designer.core.ui.editor.nodes.Node)6 GC (org.eclipse.swt.graphics.GC)5 ColorStyledText (org.talend.commons.ui.swt.colorstyledtext.ColorStyledText)5 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)2 StyledText (org.eclipse.swt.custom.StyledText)2 Font (org.eclipse.swt.graphics.Font)2 FontData (org.eclipse.swt.graphics.FontData)2 FormLayout (org.eclipse.swt.layout.FormLayout)2 Display (org.eclipse.swt.widgets.Display)2 Label (org.eclipse.swt.widgets.Label)2