Search in sources :

Example 1 with ColorStyledText

use of org.talend.commons.ui.swt.colorstyledtext.ColorStyledText in project tdi-studio-se by Talend.

the class MessageMemoController method refresh.

/*
     * (non-Javadoc)
     * 
     * @see
     * org.talend.designer.core.ui.editor.properties.controllers.AbstractElementPropertySectionController#refresh(org
     * .talend.core.model.process.IElementParameter, boolean)
     */
@Override
public void refresh(IElementParameter param, boolean check) {
    ColorStyledText labelText = (ColorStyledText) hashCurControls.get(param.getName());
    if (labelText == null || labelText.isDisposed()) {
        return;
    }
    Object value = param.getValue();
    boolean valueChanged = false;
    if (value == null) {
        //$NON-NLS-1$
        labelText.setText("");
    } else {
        if (!value.equals(labelText.getText())) {
            labelText.setText((String) value);
            valueChanged = true;
        }
    }
    if (check || valueChanged) {
        checkErrorsForPropertiesOnly(labelText);
    }
    fixedCursorPosition(param, labelText, value, valueChanged);
}
Also used : ColorStyledText(org.talend.commons.ui.swt.colorstyledtext.ColorStyledText)

Example 2 with ColorStyledText

use of org.talend.commons.ui.swt.colorstyledtext.ColorStyledText 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 3 with ColorStyledText

use of org.talend.commons.ui.swt.colorstyledtext.ColorStyledText 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 4 with ColorStyledText

use of org.talend.commons.ui.swt.colorstyledtext.ColorStyledText in project tdi-studio-se by Talend.

the class ErDiagramComposite method addErDiagramEditor.

/**
     * admin Comment method "addErDiagramEditor".
     */
//$NON-NLS-1$
@SuppressWarnings("unchecked")
private void addErDiagramEditor(boolean isShowDesignerPage) {
    GridData gridData = new GridData(GridData.FILL_BOTH);
    this.setLayoutData(gridData);
    GridLayout layout = new GridLayout();
    layout.verticalSpacing = 0;
    layout.marginLeft = 0;
    layout.marginRight = 0;
    layout.marginBottom = 0;
    layout.marginTop = 0;
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.numColumns = 1;
    this.setLayout(layout);
    editor = new ErdiagramDiagramEditor();
    editor.createPartControl(this);
    editor.getViewer().setContents(createErDiagram(isShowDesignerPage));
    Control control = editor.getGraphicalControl();
    if (control != null) {
        control.setParent(this);
        control.setLayoutData(gridData);
    }
    layout = new GridLayout();
    layout.marginLeft = 0;
    layout.marginRight = 0;
    layout.marginBottom = 0;
    layout.marginTop = 0;
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.heightHint = 30;
    int textstyle = SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL;
    sqlText = new ColorStyledText(this, textstyle, CorePlugin.getDefault().getPreferenceStore(), language);
    sqlText.setLayoutData(gridData);
    //$NON-NLS-1$
    sqlText.setText("");
    sqlText.setBackground(getBackground());
    sqlText.addModifyListener(new ModifyListener() {

        /*
             * (non-Javadoc)
             * 
             * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
             */
        public void modifyText(ModifyEvent e) {
            sqlString = sqlText.getText();
        }
    });
}
Also used : ErdiagramDiagramEditor(org.talend.sqlbuilder.erdiagram.ui.editor.ErdiagramDiagramEditor) GridLayout(org.eclipse.swt.layout.GridLayout) Control(org.eclipse.swt.widgets.Control) ModifyEvent(org.eclipse.swt.events.ModifyEvent) ModifyListener(org.eclipse.swt.events.ModifyListener) GridData(org.eclipse.swt.layout.GridData) ColorStyledText(org.talend.commons.ui.swt.colorstyledtext.ColorStyledText)

Example 5 with ColorStyledText

use of org.talend.commons.ui.swt.colorstyledtext.ColorStyledText in project tdi-studio-se by Talend.

the class MessageMemoController method createColorStyledText.

private ColorStyledText createColorStyledText(final Composite parent, final int style) {
    IPreferenceStore preferenceStore = CorePlugin.getDefault().getPreferenceStore();
    //$NON-NLS-1$
    ColorStyledText colorText = new ColorStyledText(parent, style, preferenceStore, "tsql");
    String fontType = preferenceStore.getString(TalendDesignerPrefConstants.MEMO_TEXT_FONT);
    FontData fontData = new FontData(fontType);
    Font font = new Font(parent.getDisplay(), fontData);
    // Font font = new Font(null, "courier", 8, SWT.NONE); //$NON-NLS-1$
    addResourceDisposeListener(colorText, font);
    colorText.setFont(font);
    return colorText;
}
Also used : FontData(org.eclipse.swt.graphics.FontData) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) ColorStyledText(org.talend.commons.ui.swt.colorstyledtext.ColorStyledText) Font(org.eclipse.swt.graphics.Font)

Aggregations

ColorStyledText (org.talend.commons.ui.swt.colorstyledtext.ColorStyledText)12 Composite (org.eclipse.swt.widgets.Composite)7 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)6 Font (org.eclipse.swt.graphics.Font)6 FontData (org.eclipse.swt.graphics.FontData)6 DecoratedField (org.eclipse.jface.fieldassist.DecoratedField)5 IControlCreator (org.eclipse.jface.fieldassist.IControlCreator)5 Point (org.eclipse.swt.graphics.Point)5 FormData (org.eclipse.swt.layout.FormData)5 ModifyEvent (org.eclipse.swt.events.ModifyEvent)3 ModifyListener (org.eclipse.swt.events.ModifyListener)3 GridData (org.eclipse.swt.layout.GridData)3 GridLayout (org.eclipse.swt.layout.GridLayout)3 Control (org.eclipse.swt.widgets.Control)3 FieldDecoration (org.eclipse.jface.fieldassist.FieldDecoration)2 CLabel (org.eclipse.swt.custom.CLabel)2 StyledText (org.eclipse.swt.custom.StyledText)2 GC (org.eclipse.swt.graphics.GC)2 FormAttachment (org.eclipse.swt.layout.FormAttachment)2 Display (org.eclipse.swt.widgets.Display)2