Search in sources :

Example 1 with FontFieldEditor

use of org.eclipse.jface.preference.FontFieldEditor in project tdi-studio-se by Talend.

the class PropertiesPreferencePage method addFontAndColorFields.

protected void addFontAndColorFields(Composite composite) {
    memoFontEditor = new FontFieldEditor(TalendDesignerPrefConstants.MEMO_TEXT_FONT, Messages.getString("PropertiesPreferencePage.textFont"), //$NON-NLS-1$
    composite);
    addField(memoFontEditor);
}
Also used : FontFieldEditor(org.eclipse.jface.preference.FontFieldEditor)

Example 2 with FontFieldEditor

use of org.eclipse.jface.preference.FontFieldEditor in project tdq-studio-se by Talend.

the class SQLPreferencePage method createFieldEditors.

/*
     * (non-JavaDoc)
     * 
     * @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors()
     */
protected void createFieldEditors() {
    try {
        // Font picker
        fontFieldEditor = new FontFieldEditor(IConstants.FONT, Messages.getString("Text_Font__3"), getFieldEditorParent());
        // MOD by zshen for bug 12046,save the font size.
        fontFieldEditor.setPreferenceStore(getPreferenceStore());
        addField(fontFieldEditor);
        // ~12046
        /*
             * Text Properties group
             */
        Group colorGroup = new Group(getFieldEditorParent(), SWT.NULL);
        colorGroup.setLayout(new GridLayout());
        GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
        gd.horizontalSpan = 3;
        colorGroup.setLayoutData(gd);
        colorGroup.setText(Messages.getString("Text_Properties_6"));
        Composite editorComposite = new Composite(colorGroup, SWT.NONE);
        GridLayout layout = new GridLayout();
        layout.numColumns = 2;
        layout.marginHeight = 0;
        layout.marginWidth = 0;
        editorComposite.setLayout(layout);
        gd = new GridData(GridData.FILL_BOTH);
        editorComposite.setLayoutData(gd);
        final List syntaxColorList = new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER);
        gd = new GridData(GridData.FILL_BOTH);
        gd.heightHint = convertHeightInCharsToPixels(5);
        syntaxColorList.setLayoutData(gd);
        for (int i = 0; i < highlights.length; i++) syntaxColorList.add(highlights[i].caption);
        Composite stylesComposite = new Composite(editorComposite, SWT.NONE);
        layout = new GridLayout();
        layout.marginHeight = 0;
        layout.marginWidth = 0;
        layout.numColumns = 2;
        stylesComposite.setLayout(layout);
        stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
        Label label = new Label(stylesComposite, SWT.LEFT);
        label.setText(Messages.getString("Color_9"));
        gd = new GridData();
        gd.horizontalAlignment = GridData.BEGINNING;
        label.setLayoutData(gd);
        final ColorEditor syntaxForegroundColorEditor = new ColorEditor(stylesComposite);
        Button foregroundColorButton = syntaxForegroundColorEditor.getButton();
        gd = new GridData(GridData.FILL_HORIZONTAL);
        gd.horizontalAlignment = GridData.BEGINNING;
        foregroundColorButton.setLayoutData(gd);
        foregroundColorButton.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent e) {
                int i = syntaxColorList.getSelectionIndex();
                if (i >= 0) {
                    // text attribute List has been select.
                    PreferenceConverter.setValue(getPreferenceStore(), highlights[i].id, syntaxForegroundColorEditor.getColorValue());
                }
            }
        });
        final Button boldCheckBox = new Button(stylesComposite, SWT.CHECK);
        boldCheckBox.setText(Messages.getString("Bold_10"));
        gd = new GridData(GridData.FILL_HORIZONTAL);
        gd.horizontalAlignment = GridData.BEGINNING;
        gd.horizontalSpan = 2;
        boldCheckBox.setLayoutData(gd);
        boldCheckBox.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent e) {
                int i = syntaxColorList.getSelectionIndex();
                getPreferenceStore().setValue(highlights[i].id + BOLD, boldCheckBox.getSelection());
            }
        });
        syntaxColorList.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent e) {
                int i = syntaxColorList.getSelectionIndex();
                if (i > -1) {
                    boldCheckBox.setSelection(getPreferenceStore().getBoolean(highlights[i].id + BOLD));
                    syntaxForegroundColorEditor.setColorValue(PreferenceConverter.getColor(getPreferenceStore(), highlights[i].id));
                }
            }
        });
        /*
             * Preview group
             */
        Group previewGroup = new Group(getFieldEditorParent(), SWT.NULL);
        previewGroup.setLayout(new GridLayout());
        gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
        gd.horizontalSpan = 3;
        previewGroup.setLayoutData(gd);
        previewGroup.setText(Messages.getString("Preview_7"));
        Control previewer = createPreviewer(previewGroup);
        gd = new GridData(GridData.FILL_BOTH);
        previewer.setLayoutData(gd);
        /*
             * Export To Clipboard group
             */
        Group exportGroup = new Group(getFieldEditorParent(), SWT.NULL);
        exportGroup.setLayout(new GridLayout());
        exportGroup.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
        exportGroup.setText(Messages.getString("Export_to_Clipboard_1"));
        Label lbt1 = new Label(exportGroup, SWT.NULL);
        lbt1.setText("Separator");
        final Button semiColon = new Button(exportGroup, SWT.RADIO);
        semiColon.setText(";");
        final Button pipe = new Button(exportGroup, SWT.RADIO);
        pipe.setText("|");
        final Button tab = new Button(exportGroup, SWT.RADIO);
        tab.setText("\\t [TAB]");
        addAccessor(new Accessor() {

            public void load() {
                String value = getPreferenceStore().getString(IConstants.CLIP_EXPORT_SEPARATOR);
                if (value == null || value.length() < 1)
                    value = ";";
                loadValue(value.charAt(0));
            }

            public void loadDefaults() {
                String value = getPreferenceStore().getDefaultString(IConstants.CLIP_EXPORT_SEPARATOR);
                if (value == null || value.length() < 1)
                    value = ";";
                loadValue(value.charAt(0));
            }

            private void loadValue(char c) {
                semiColon.setSelection(c == ';');
                pipe.setSelection(c == '|');
                tab.setSelection(c == '\t');
            }

            public void store() {
                String separator;
                if (semiColon.getSelection())
                    separator = ";";
                else if (semiColon.getSelection())
                    separator = "|";
                else
                    separator = "\t";
                getPreferenceStore().setValue(IConstants.CLIP_EXPORT_SEPARATOR, separator);
            }
        });
        addField(new BooleanFieldEditor(IConstants.CLIP_EXPORT_COLUMNS, "Export column names", exportGroup));
    } catch (Exception e) {
        SQLExplorerPlugin.error("Could not create SQL preference page", e);
        throw new RuntimeException(e);
    }
}
Also used : Group(org.eclipse.swt.widgets.Group) FontFieldEditor(org.eclipse.jface.preference.FontFieldEditor) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) BooleanFieldEditor(org.eclipse.jface.preference.BooleanFieldEditor) GridLayout(org.eclipse.swt.layout.GridLayout) Control(org.eclipse.swt.widgets.Control) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) List(org.eclipse.swt.widgets.List)

Example 3 with FontFieldEditor

use of org.eclipse.jface.preference.FontFieldEditor in project whole by wholeplatform.

the class EditorPreferencePage method createContents.

protected Control createContents(Composite parent) {
    Label label;
    GridData gd;
    Composite topComposite = new Composite(parent, SWT.NONE);
    topComposite.setLayout(new GridLayout(1, false));
    topComposite.setFont(parent.getFont());
    gd = new GridData(GridData.FILL_BOTH);
    gd.horizontalSpan = 1;
    topComposite.setLayoutData(gd);
    Label fontsLabel = new Label(topComposite, SWT.LEFT);
    fontsLabel.setText("Font category:");
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = 2;
    fontsLabel.setLayoutData(gd);
    Composite fontComposite = new Composite(topComposite, SWT.BORDER);
    GridLayout fontLayout = new GridLayout(3, false);
    fontComposite.setLayout(fontLayout);
    fontComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    monospaceFont = new FontFieldEditor(PreferenceConstants.MONOSPACE_FONT, "Monospace", fontComposite);
    sanserifFont = new FontFieldEditor(PreferenceConstants.SANSERIF_FONT, "Sans Serif", fontComposite);
    serifFont = new FontFieldEditor(PreferenceConstants.SERIF_FONT, "Serif", fontComposite);
    GridLayout bgLayout = new GridLayout(2, false);
    bgLayout.marginHeight = 5;
    bgLayout.marginWidth = 10;
    topComposite.setLayout(bgLayout);
    Label bgLabel = new Label(topComposite, SWT.LEFT);
    bgLabel.setText("Hilight category:");
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = 2;
    bgLabel.setLayoutData(gd);
    bgCategoryTable = new TableViewer(topComposite, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER);
    bgCategoryTable.setContentProvider(new ArrayContentProvider());
    bgCategoryTable.setLabelProvider(new PresentationLabelProvider(bgCategoryTable));
    bgCategoryTable.setComparator(new ViewerComparator());
    gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_BOTH);
    gd.widthHint = convertWidthInCharsToPixels(25);
    // convertHeightInCharsToPixels(5);
    gd.heightHint = 90;
    bgCategoryTable.getControl().setLayoutData(gd);
    bgColumn = new TableColumn(bgCategoryTable.getTable(), SWT.LEFT);
    Composite bgStylesComposite = new Composite(topComposite, SWT.NONE);
    GridLayout bgStylesLayout = new GridLayout(2, false);
    bgStylesLayout.marginHeight = 0;
    bgStylesLayout.marginWidth = 0;
    bgStylesComposite.setLayout(bgStylesLayout);
    bgStylesComposite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
    label = new Label(bgStylesComposite, SWT.LEFT);
    label.setText("Color:");
    label.setLayoutData(new GridData());
    bgColorSelector = new ColorSelector(bgStylesComposite);
    Label fgLabel = new Label(topComposite, SWT.NONE);
    fgLabel.setText("Syntax category:");
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = 2;
    fgLabel.setLayoutData(gd);
    fgCategoryTable = new TableViewer(topComposite, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER);
    fgCategoryTable.setContentProvider(new ArrayContentProvider());
    fgCategoryTable.setLabelProvider(new PresentationLabelProvider(fgCategoryTable));
    fgCategoryTable.setComparator(new ViewerComparator());
    gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_BOTH);
    gd.widthHint = convertWidthInCharsToPixels(25);
    // convertHeightInCharsToPixels(4);
    gd.heightHint = 52;
    fgCategoryTable.getControl().setLayoutData(gd);
    fgColumn = new TableColumn(fgCategoryTable.getTable(), SWT.LEFT);
    Composite fgStylesComposite = new Composite(topComposite, SWT.NONE);
    GridLayout fgStylesLayout = new GridLayout(2, false);
    fgStylesLayout.marginHeight = 0;
    fgStylesLayout.marginWidth = 0;
    fgStylesComposite.setLayout(fgStylesLayout);
    fgStylesComposite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
    label = new Label(fgStylesComposite, SWT.LEFT);
    label.setText("Color:");
    label.setLayoutData(new GridData());
    fgColorSelector = new ColorSelector(fgStylesComposite);
    label = new Label(fgStylesComposite, SWT.LEFT);
    label.setText("Font:");
    label.setLayoutData(new GridData());
    classCombo = new Combo(fgStylesComposite, SWT.DROP_DOWN | SWT.READ_ONLY);
    classCombo.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
    label = new Label(fgStylesComposite, SWT.LEFT);
    label.setText("Style:");
    label.setLayoutData(new GridData());
    styleCombo = new Combo(fgStylesComposite, SWT.DROP_DOWN | SWT.READ_ONLY);
    styleCombo.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
    label = new Label(fgStylesComposite, SWT.LEFT);
    label.setText("Size:");
    label.setLayoutData(new GridData());
    sizeCombo = new Combo(fgStylesComposite, SWT.DROP_DOWN | SWT.READ_ONLY);
    sizeCombo.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
    bgCategoryTable.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            if (!event.getSelection().isEmpty()) {
                handleBgCategoryListSelection();
            }
        }
    });
    bgCategoryTable.getControl().addControlListener(new ControlAdapter() {

        public void controlResized(ControlEvent e) {
            bgColumn.setWidth(bgCategoryTable.getControl().getSize().x - 4);
        }
    });
    bgColorSelector.addListener(new IPropertyChangeListener() {

        public void propertyChange(PropertyChangeEvent event) {
            RGB newRGB = (RGB) event.getNewValue();
            String key = getSelectedKey(bgCategoryTable);
            if (key != null && newRGB != null && !newRGB.equals(event.getOldValue())) {
                store.putValue(key, StringConverter.asString(newRGB));
            }
        }
    });
    fgCategoryTable.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            if (!event.getSelection().isEmpty()) {
                handleFgCategoryListSelection();
            }
        }
    });
    fgCategoryTable.getControl().addControlListener(new ControlAdapter() {

        public void controlResized(ControlEvent e) {
            fgColumn.setWidth(fgCategoryTable.getControl().getSize().x - 24);
        }
    });
    fgColorSelector.addListener(new IPropertyChangeListener() {

        public void propertyChange(PropertyChangeEvent event) {
            RGB newRGB = (RGB) event.getNewValue();
            String key = getSelectedKey(fgCategoryTable);
            if (key != null && newRGB != null && !newRGB.equals(event.getOldValue())) {
                store.putValue(key, StringConverter.asString(newRGB));
            }
        }
    });
    classCombo.addSelectionListener(new SelectionListener() {

        public void widgetDefaultSelected(SelectionEvent e) {
        }

        public void widgetSelected(SelectionEvent e) {
            String key = getSelectedKey(fgCategoryTable);
            store.putValue(key + PreferenceConstants.CLASS, FontClass.nameOf(classCombo.getSelectionIndex()));
        }
    });
    styleCombo.addSelectionListener(new SelectionListener() {

        public void widgetDefaultSelected(SelectionEvent e) {
        }

        public void widgetSelected(SelectionEvent e) {
            String key = getSelectedKey(fgCategoryTable);
            store.putValue(key + PreferenceConstants.STYLE, FontStyle.nameOf(styleCombo.getSelectionIndex()));
        }
    });
    sizeCombo.addSelectionListener(new SelectionListener() {

        public void widgetDefaultSelected(SelectionEvent e) {
        }

        public void widgetSelected(SelectionEvent e) {
            String key = getSelectedKey(fgCategoryTable);
            store.putValue(key + PreferenceConstants.SIZE, FontSize.nameOf(sizeCombo.getSelectionIndex()));
        }
    });
    initialize();
    return topComposite;
}
Also used : IPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) PropertyChangeEvent(org.eclipse.jface.util.PropertyChangeEvent) Composite(org.eclipse.swt.widgets.Composite) FontFieldEditor(org.eclipse.jface.preference.FontFieldEditor) ControlAdapter(org.eclipse.swt.events.ControlAdapter) ViewerComparator(org.eclipse.jface.viewers.ViewerComparator) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Label(org.eclipse.swt.widgets.Label) Combo(org.eclipse.swt.widgets.Combo) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) RGB(org.eclipse.swt.graphics.RGB) TableColumn(org.eclipse.swt.widgets.TableColumn) GridLayout(org.eclipse.swt.layout.GridLayout) GridData(org.eclipse.swt.layout.GridData) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ColorSelector(org.eclipse.jface.preference.ColorSelector) ControlEvent(org.eclipse.swt.events.ControlEvent) TableViewer(org.eclipse.jface.viewers.TableViewer) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 4 with FontFieldEditor

use of org.eclipse.jface.preference.FontFieldEditor in project tdi-studio-se by Talend.

the class OutputConsolePreferencePage method addFontAndColorFields.

protected void addFontAndColorFields(Composite composite) {
    consoleFontField = new FontFieldEditor(OutputConsolePreferencePage.CONSOLE_FONT, Messages.getString("OutputConsolePreferencePage.consoleFont"), //$NON-NLS-1$
    composite);
    addField(consoleFontField);
}
Also used : FontFieldEditor(org.eclipse.jface.preference.FontFieldEditor)

Example 5 with FontFieldEditor

use of org.eclipse.jface.preference.FontFieldEditor in project tdi-studio-se by Talend.

the class AppearancePreferencePage method addFontAndColorFields.

protected void addFontAndColorFields(Composite composite) {
    memoFontEditor = new FontFieldEditor(TalendDesignerPrefConstants.MEMO_TEXT_FONT, Messages.getString("AppearancePreferencePage.textFont"), //$NON-NLS-1$
    composite);
    addField(memoFontEditor);
    consoleFontField = new FontFieldEditor(TalendDesignerPrefConstants.CONSOLT_TEXT_FONT, Messages.getString("AppearancePreferencePage.consoleFont"), //$NON-NLS-1$
    composite);
    addField(consoleFontField);
}
Also used : FontFieldEditor(org.eclipse.jface.preference.FontFieldEditor)

Aggregations

FontFieldEditor (org.eclipse.jface.preference.FontFieldEditor)6 BooleanFieldEditor (org.eclipse.jface.preference.BooleanFieldEditor)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 GridData (org.eclipse.swt.layout.GridData)2 GridLayout (org.eclipse.swt.layout.GridLayout)2 Composite (org.eclipse.swt.widgets.Composite)2 Label (org.eclipse.swt.widgets.Label)2 ColorFieldEditor (org.eclipse.jface.preference.ColorFieldEditor)1 ColorSelector (org.eclipse.jface.preference.ColorSelector)1 IPropertyChangeListener (org.eclipse.jface.util.IPropertyChangeListener)1 PropertyChangeEvent (org.eclipse.jface.util.PropertyChangeEvent)1 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)1 TableViewer (org.eclipse.jface.viewers.TableViewer)1 ViewerComparator (org.eclipse.jface.viewers.ViewerComparator)1 ControlAdapter (org.eclipse.swt.events.ControlAdapter)1 ControlEvent (org.eclipse.swt.events.ControlEvent)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionListener (org.eclipse.swt.events.SelectionListener)1