Search in sources :

Example 66 with FontData

use of org.eclipse.swt.graphics.FontData in project tdi-studio-se by Talend.

the class ProcessComposite method setConsoleFont.

/**
     * DOC chuang Comment method "setConsoleFont".
     */
private void setConsoleFont() {
    IPreferenceStore preferenceStore = CorePlugin.getDefault().getPreferenceStore();
    FontData fontData = PreferenceConverter.getFontData(preferenceStore, TalendDesignerPrefConstants.CONSOLT_TEXT_FONT);
    if (fontData != null) {
        if (consoleText.getFont() != null) {
            FontData oldFont = consoleText.getFont().getFontData()[0];
            // font is same
            if (!oldFont.equals(fontData)) {
                Font font = new Font(this.getDisplay(), fontData);
                consoleText.setFont(font);
            }
        // else no need to change the font it is the same
        } else {
            Font font = new Font(this.getDisplay(), fontData);
            consoleText.setFont(font);
        }
    } else {
        // should never happend
        //$NON-NLS-1$
        log.info("Could not find default font for the console");
    }
}
Also used : FontData(org.eclipse.swt.graphics.FontData) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) Font(org.eclipse.swt.graphics.Font)

Example 67 with FontData

use of org.eclipse.swt.graphics.FontData in project tdi-studio-se by Talend.

the class TraceDebugProcessComposite method setConsoleFont.

private boolean setConsoleFont() {
    IPreferenceStore preferenceStore = CorePlugin.getDefault().getPreferenceStore();
    String fontType = preferenceStore.getString(RunProcessPrefsConstants.CONSOLE_FONT);
    if (StringUtils.isNotEmpty(fontType)) {
        FontData fontData = new FontData(fontType);
        if (consoleText.getFont() != null) {
            FontData oldFont = consoleText.getFont().getFontData()[0];
            // font is same
            if (oldFont.equals(fontData)) {
                return false;
            }
        }
        Font font = new Font(this.getDisplay(), fontData);
        consoleText.setFont(font);
        return true;
    }
    return false;
}
Also used : FontData(org.eclipse.swt.graphics.FontData) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) Font(org.eclipse.swt.graphics.Font)

Example 68 with FontData

use of org.eclipse.swt.graphics.FontData 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 69 with FontData

use of org.eclipse.swt.graphics.FontData 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)

Example 70 with FontData

use of org.eclipse.swt.graphics.FontData in project tdi-studio-se by Talend.

the class SQLTextViewer method adaptToPreferenceChange.

void adaptToPreferenceChange(PropertyChangeEvent event) {
    if (event.getProperty().equals(IConstants.FONT)) {
        FontData[] fData = PreferenceConverter.getFontDataArray(store, IConstants.FONT);
        String des = store.getString(IConstants.FONT);
        JFaceResources.getFontRegistry().put(des, fData);
        Control ctrl = this.getControl();
        if (ctrl != null) {
            ctrl.setFont(JFaceResources.getFontRegistry().get(des));
        }
    }
}
Also used : DefaultInformationControl(org.eclipse.jface.text.DefaultInformationControl) IInformationControl(org.eclipse.jface.text.IInformationControl) Control(org.eclipse.swt.widgets.Control) FontData(org.eclipse.swt.graphics.FontData)

Aggregations

FontData (org.eclipse.swt.graphics.FontData)70 Font (org.eclipse.swt.graphics.Font)38 FontStyle (org.eclipse.gmf.runtime.notation.FontStyle)14 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)11 GridData (org.eclipse.swt.layout.GridData)11 GridLayout (org.eclipse.swt.layout.GridLayout)9 Composite (org.eclipse.swt.widgets.Composite)9 Point (org.eclipse.swt.graphics.Point)8 Label (org.eclipse.swt.widgets.Label)8 Text (org.eclipse.swt.widgets.Text)5 ColorStyledText (org.talend.commons.ui.swt.colorstyledtext.ColorStyledText)5 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)4 SelectionEvent (org.eclipse.swt.events.SelectionEvent)4 Color (org.eclipse.swt.graphics.Color)4 GC (org.eclipse.swt.graphics.GC)4 IFigure (org.eclipse.draw2d.IFigure)3 Dimension (org.eclipse.draw2d.geometry.Dimension)3 DecoratedField (org.eclipse.jface.fieldassist.DecoratedField)3 FormAttachment (org.eclipse.swt.layout.FormAttachment)3 FormData (org.eclipse.swt.layout.FormData)3