Search in sources :

Example 11 with ColorStyledText

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

the class SqlEditDialog method createDialogArea.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
     */
@Override
protected Control createDialogArea(Composite parent) {
    Composite control = (Composite) super.createDialogArea(parent);
    // create text viewer
    GridData gid = new GridData();
    gid.grabExcessHorizontalSpace = true;
    gid.grabExcessVerticalSpace = true;
    gid.horizontalAlignment = GridData.FILL;
    gid.verticalAlignment = GridData.FILL;
    control.setLayoutData(gid);
    GridLayout gridLayout = new GridLayout();
    gridLayout.marginBottom = 0;
    gridLayout.marginHeight = 0;
    gridLayout.marginLeft = 0;
    gridLayout.marginRight = 0;
    gridLayout.marginTop = 0;
    gridLayout.marginWidth = 0;
    control.setLayout(gridLayout);
    colorText = new ColorStyledText(control, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL, CorePlugin.getDefault().getPreferenceStore(), language);
    IPreferenceStore preferenceStore = CorePlugin.getDefault().getPreferenceStore();
    String fontType = preferenceStore.getString(TalendDesignerPrefConstants.MEMO_TEXT_FONT);
    FontData fontData = new FontData(fontType);
    Font font = new Font(null, fontData);
    addResourceDisposeListener(colorText, font);
    colorText.setFont(font);
    GridData gd = new GridData(GridData.FILL_BOTH);
    colorText.setLayoutData(gd);
    colorText.setText(sql);
    colorText.addModifyListener(new ModifyListener() {

        /*
             * (non-Javadoc)
             * 
             * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
             */
        @Override
        public void modifyText(ModifyEvent e) {
            sql = colorText.getText();
        }
    });
    createEditorProposal();
    return control;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) FontData(org.eclipse.swt.graphics.FontData) GridData(org.eclipse.swt.layout.GridData) ColorStyledText(org.talend.commons.ui.swt.colorstyledtext.ColorStyledText) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) Font(org.eclipse.swt.graphics.Font)

Example 12 with ColorStyledText

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

the class SQLBuilderEditorComposite method createEditorArea.

/**
     * Creates UI for editor.
     * 
     * @param parent
     */
private void createEditorArea(Composite parent) {
    // create divider line
    Composite div1 = new Composite(parent, SWT.NONE);
    GridData lgid = new GridData();
    lgid.grabExcessHorizontalSpace = true;
    lgid.horizontalAlignment = GridData.FILL;
    lgid.heightHint = 1;
    lgid.verticalIndent = 1;
    div1.setLayoutData(lgid);
    div1.setBackground(parent.getShell().getDisplay().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW));
    // create text viewer
    GridData gid = new GridData();
    gid.grabExcessHorizontalSpace = true;
    gid.grabExcessVerticalSpace = true;
    gid.horizontalAlignment = GridData.FILL;
    gid.verticalAlignment = GridData.FILL;
    colorText = new ColorStyledText(parent, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL, CorePlugin.getDefault().getPreferenceStore(), language);
    IPreferenceStore preferenceStore = CorePlugin.getDefault().getPreferenceStore();
    String fontType = preferenceStore.getString(TalendDesignerPrefConstants.MEMO_TEXT_FONT);
    FontData fontData = new FontData(fontType);
    Font font = new Font(null, fontData);
    addResourceDisposeListener(colorText, font);
    colorText.setFont(font);
    GridData gd = new GridData(GridData.FILL_BOTH);
    colorText.setLayoutData(gd);
    colorText.setText(this.connParam.getQuery());
    colorText.addVerifyKeyListener(new VerifyKeyListener() {

        @Override
        public void verifyKey(VerifyEvent event) {
            if (event.stateMask == SWT.CTRL && event.keyCode == 13) {
                event.doit = false;
                execSQLAction.run();
            }
        }
    });
    colorText.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            isModified = true;
        }
    });
}
Also used : ModifyEvent(org.eclipse.swt.events.ModifyEvent) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) VerifyKeyListener(org.eclipse.swt.custom.VerifyKeyListener) FontData(org.eclipse.swt.graphics.FontData) GridData(org.eclipse.swt.layout.GridData) ColorStyledText(org.talend.commons.ui.swt.colorstyledtext.ColorStyledText) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) VerifyEvent(org.eclipse.swt.events.VerifyEvent) 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