Search in sources :

Example 1 with ColorSelector

use of org.eclipse.jface.preference.ColorSelector in project dbeaver by serge-rider.

the class ColorSettingsDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    getShell().setText("Customize row coloring");
    Composite composite = (Composite) super.createDialogArea(parent);
    Composite mainGroup = new Composite(composite, SWT.NONE);
    mainGroup.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_BOTH));
    mainGroup.setLayout(new GridLayout(2, false));
    {
        Group colorsGroup = new Group(mainGroup, SWT.NONE);
        colorsGroup.setText("Colors");
        colorsGroup.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_BOTH));
        colorsGroup.setLayout(new GridLayout(1, false));
        colorsViewer = CheckboxTableViewer.newCheckList(colorsGroup, SWT.SINGLE | SWT.BORDER);
        colorsViewer.getTable().setLayoutData(new GridData(GridData.FILL_BOTH));
        ToolBar toolbar = new ToolBar(colorsGroup, SWT.FLAT | SWT.HORIZONTAL);
        final ToolItem newButton = new ToolItem(toolbar, SWT.NONE);
        newButton.setText("Add");
        newButton.setImage(DBeaverIcons.getImage(UIIcon.ROW_ADD));
        final ToolItem deleteButton = new ToolItem(toolbar, SWT.NONE);
        deleteButton.setText("Delete");
        deleteButton.setImage(DBeaverIcons.getImage(UIIcon.ROW_DELETE));
    }
    {
        Group settingsGroup = new Group(mainGroup, SWT.NONE);
        settingsGroup.setText("Settings");
        settingsGroup.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_BOTH));
        settingsGroup.setLayout(new GridLayout(2, false));
        UIUtils.createLabelText(settingsGroup, "Title", "");
        UIUtils.createLabelCombo(settingsGroup, "Attribute", SWT.READ_ONLY | SWT.DROP_DOWN);
        UIUtils.createLabelCombo(settingsGroup, "Criteria", SWT.READ_ONLY | SWT.DROP_DOWN);
        UIUtils.createLabelText(settingsGroup, "Value", "");
        UIUtils.createControlLabel(settingsGroup, "Foreground");
        new ColorSelector(settingsGroup);
        UIUtils.createControlLabel(settingsGroup, "Background");
        new ColorSelector(settingsGroup);
    }
    return parent;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) GridData(org.eclipse.swt.layout.GridData) ColorSelector(org.eclipse.jface.preference.ColorSelector)

Example 2 with ColorSelector

use of org.eclipse.jface.preference.ColorSelector in project cubrid-manager by CUBRID.

the class ChartSettingDlg method createTtlTab.

/**
	 * create chart title tab item
	 * 
	 */
public void createTtlTab() {
    CTabItem ttlItem = new CTabItem(folder, SWT.NONE);
    ttlItem.setText(Messages.tabItemChartTtl);
    Composite tabComp = new Composite(folder, SWT.NONE);
    tabComp.setLayout(new GridLayout());
    tabComp.setLayoutData(GridData.FILL_BOTH);
    ttlItem.setControl(tabComp);
    if (showTitlteContent) {
        Group contentGrp = new Group(tabComp, SWT.NONE);
        contentGrp.setLayout(new GridLayout(2, false));
        contentGrp.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
        contentGrp.setText(Messages.chartTtlContentGrp);
        Label contentLbl = new Label(contentGrp, SWT.NONE);
        contentLbl.setText(Messages.chartTtlName);
        contentTxt = new Text(contentGrp, SWT.BORDER);
        final GridData gdContentTxt = new GridData(SWT.FILL, SWT.CENTER, true, false);
        contentTxt.setLayoutData(gdContentTxt);
        if (titleName != null) {
            contentTxt.setText(titleName);
        }
    }
    Group colorGroup = new Group(tabComp, SWT.NONE);
    colorGroup.setLayout(new GridLayout(2, false));
    colorGroup.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    colorGroup.setText(Messages.chartTtlGroupTxt);
    Label bgColorLbl = new Label(colorGroup, SWT.NONE);
    bgColorLbl.setText(Messages.chartTtlBgLbl);
    colorSelector = new ColorSelector(colorGroup);
    colorSelector.getButton().setLayoutData(new GridData());
    if (ttlBgColor != null) {
        RGB rgb = StringConverter.asRGB(ttlBgColor);
        colorSelector.setColorValue(rgb);
    }
    fontGroup = new FontGroup(tabComp);
    fontGroup.setFontName(ttlFontName);
    fontGroup.setFontSize(ttlFontSize);
    fontGroup.setChosenRgb(StringConverter.asRGB(ttlFontColor));
    fontGroup.loadContent();
}
Also used : Group(org.eclipse.swt.widgets.Group) GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) ColorSelector(org.eclipse.jface.preference.ColorSelector) RGB(org.eclipse.swt.graphics.RGB) CTabItem(org.eclipse.swt.custom.CTabItem)

Example 3 with ColorSelector

use of org.eclipse.jface.preference.ColorSelector in project eclipse.platform.text by eclipse.

the class AnnotationsConfigurationBlock method createControl.

@Override
public Control createControl(Composite parent) {
    PixelConverter pixelConverter = new PixelConverter(parent);
    Composite composite = new Composite(parent, SWT.NULL);
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    composite.setLayout(layout);
    Label label = new Label(composite, SWT.LEFT);
    label.setText(TextEditorMessages.AnnotationsConfigurationBlock_annotationPresentationOptions);
    GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    gd.horizontalSpan = 2;
    label.setLayoutData(gd);
    Composite editorComposite = new Composite(composite, SWT.NONE);
    layout = new GridLayout();
    layout.numColumns = 2;
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    editorComposite.setLayout(layout);
    gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL);
    gd.horizontalSpan = 2;
    editorComposite.setLayoutData(gd);
    fAnnotationTypeViewer = new TableViewer(editorComposite, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION);
    fAnnotationTypeViewer.setLabelProvider(new ItemLabelProvider());
    fAnnotationTypeViewer.setContentProvider(new ItemContentProvider());
    gd = new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false);
    gd.heightHint = pixelConverter.convertHeightInCharsToPixels(20);
    fAnnotationTypeViewer.getControl().setLayoutData(gd);
    Composite optionsComposite = new Composite(editorComposite, SWT.NONE);
    layout = new GridLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.numColumns = 2;
    optionsComposite.setLayout(layout);
    optionsComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
    label = new Label(optionsComposite, SWT.LEFT);
    label.setText(TextEditorMessages.AnnotationsConfigurationBlock_labels_showIn);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalAlignment = GridData.BEGINNING;
    gd.horizontalSpan = 2;
    label.setLayoutData(gd);
    fShowInVerticalRulerCheckBox = new Button(optionsComposite, SWT.CHECK);
    fShowInVerticalRulerCheckBox.setText(TextEditorMessages.AnnotationsConfigurationBlock_showInVerticalRuler);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalAlignment = GridData.BEGINNING;
    gd.horizontalSpan = 2;
    gd.horizontalIndent = 20;
    fShowInVerticalRulerCheckBox.setLayoutData(gd);
    fShowInOverviewRulerCheckBox = new Button(optionsComposite, SWT.CHECK);
    fShowInOverviewRulerCheckBox.setText(TextEditorMessages.AnnotationsConfigurationBlock_showInOverviewRuler);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalAlignment = GridData.BEGINNING;
    gd.horizontalSpan = 2;
    gd.horizontalIndent = 20;
    fShowInOverviewRulerCheckBox.setLayoutData(gd);
    fShowInTextCheckBox = new Button(optionsComposite, SWT.CHECK);
    fShowInTextCheckBox.setText(TextEditorMessages.AnnotationsConfigurationBlock_showInText);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalAlignment = GridData.BEGINNING;
    gd.horizontalIndent = 20;
    fShowInTextCheckBox.setLayoutData(gd);
    fDecorationViewer = new ComboViewer(optionsComposite, SWT.READ_ONLY);
    fDecorationViewer.setContentProvider(new ArrayContentProvider());
    fDecorationViewer.setLabelProvider(new ArrayLabelProvider());
    fDecorationViewer.setComparator(new ViewerComparator(Collator.getInstance()));
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalAlignment = GridData.BEGINNING;
    fDecorationViewer.getControl().setLayoutData(gd);
    fDecorationViewer.setInput(new Object[] { HIGHLIGHT, SQUIGGLES, BOX, DASHED_BOX, UNDERLINE, PROBLEM_UNDERLINE, IBEAM });
    fDecorationViewer.getCombo().setVisibleItemCount(fDecorationViewer.getCombo().getItemCount());
    label = new Label(optionsComposite, SWT.LEFT);
    label.setText(TextEditorMessages.AnnotationsConfigurationBlock_color);
    gd = new GridData();
    gd.horizontalAlignment = GridData.BEGINNING;
    gd.horizontalIndent = 20;
    label.setLayoutData(gd);
    fAnnotationForegroundColorEditor = new ColorSelector(optionsComposite);
    Button foregroundColorButton = fAnnotationForegroundColorEditor.getButton();
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalAlignment = GridData.BEGINNING;
    foregroundColorButton.setLayoutData(gd);
    addFiller(optionsComposite);
    fIsNextPreviousTargetCheckBox = new Button(optionsComposite, SWT.CHECK);
    fIsNextPreviousTargetCheckBox.setText(TextEditorMessages.AnnotationsConfigurationBlock_isNavigationTarget);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalAlignment = GridData.BEGINNING;
    gd.horizontalSpan = 2;
    gd.horizontalIndent = 0;
    fIsNextPreviousTargetCheckBox.setLayoutData(gd);
    fAnnotationTypeViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            handleAnnotationListSelection();
        }
    });
    fShowInTextCheckBox.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
        // do nothing
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            ListItem item = getSelectedItem();
            final boolean value = fShowInTextCheckBox.getSelection();
            if (value) {
                // enable whatever is in the combo
                String[] decoration = (String[]) ((IStructuredSelection) fDecorationViewer.getSelection()).getFirstElement();
                if (HIGHLIGHT.equals(decoration))
                    fStore.setValue(item.highlightKey, true);
                else
                    fStore.setValue(item.textKey, true);
            } else {
                // disable both
                if (item.textKey != null)
                    fStore.setValue(item.textKey, false);
                if (item.highlightKey != null)
                    fStore.setValue(item.highlightKey, false);
            }
            fStore.setValue(item.textKey, value);
            updateDecorationViewer(item, false);
            fAnnotationTypeViewer.refresh(item);
        }
    });
    fShowInOverviewRulerCheckBox.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
        // do nothing
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            ListItem item = getSelectedItem();
            fStore.setValue(item.overviewRulerKey, fShowInOverviewRulerCheckBox.getSelection());
            fAnnotationTypeViewer.refresh(item);
        }
    });
    fShowInVerticalRulerCheckBox.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
        // do nothing
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            ListItem item = getSelectedItem();
            fStore.setValue(item.verticalRulerKey, fShowInVerticalRulerCheckBox.getSelection());
            fAnnotationTypeViewer.refresh(item);
        }
    });
    fIsNextPreviousTargetCheckBox.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
        // do nothing
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            ListItem item = getSelectedItem();
            fStore.setValue(item.isNextPreviousNavigationKey, fIsNextPreviousTargetCheckBox.getSelection());
            fAnnotationTypeViewer.refresh(item);
        }
    });
    foregroundColorButton.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
        // do nothing
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            ListItem item = getSelectedItem();
            PreferenceConverter.setValue(fStore, item.colorKey, fAnnotationForegroundColorEditor.getColorValue());
            fAnnotationTypeViewer.refresh(item);
        }
    });
    fDecorationViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            String[] decoration = (String[]) ((IStructuredSelection) fDecorationViewer.getSelection()).getFirstElement();
            ListItem item = getSelectedItem();
            if (fShowInTextCheckBox.getSelection()) {
                if (HIGHLIGHT.equals(decoration)) {
                    fStore.setValue(item.highlightKey, true);
                    if (item.textKey != null) {
                        fStore.setValue(item.textKey, false);
                        if (item.textStyleKey != null)
                            fStore.setValue(item.textStyleKey, AnnotationPreference.STYLE_NONE);
                    }
                } else {
                    if (item.highlightKey != null)
                        fStore.setValue(item.highlightKey, false);
                    if (item.textKey != null) {
                        fStore.setValue(item.textKey, true);
                        if (item.textStyleKey != null)
                            fStore.setValue(item.textStyleKey, decoration[1]);
                    }
                }
            }
            fAnnotationTypeViewer.refresh(item);
        }
    });
    composite.layout();
    return composite;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ViewerComparator(org.eclipse.jface.viewers.ViewerComparator) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Label(org.eclipse.swt.widgets.Label) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) ComboViewer(org.eclipse.jface.viewers.ComboViewer) PixelConverter(org.eclipse.jface.layout.PixelConverter) GridData(org.eclipse.swt.layout.GridData) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ColorSelector(org.eclipse.jface.preference.ColorSelector) TableViewer(org.eclipse.jface.viewers.TableViewer) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 4 with ColorSelector

use of org.eclipse.jface.preference.ColorSelector in project eclipse.platform.text by eclipse.

the class QuickDiffConfigurationBlock method createControl.

/**
 * Creates page for hover preferences.
 *
 * @param parent the parent composite
 * @return the created child composite
 */
@Override
public Control createControl(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    composite.setLayout(layout);
    String label = TextEditorMessages.QuickDiffConfigurationBlock_showForNewEditors;
    fEnablementCheckbox = addCheckBox(composite, label, AbstractDecoratedTextEditorPreferenceConstants.QUICK_DIFF_ALWAYS_ON, 0);
    fEnablementCheckbox.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            boolean enabled = fEnablementCheckbox.getSelection();
            fStore.setValue(SpellingService.PREFERENCE_SPELLING_ENABLED, enabled);
            updateEnablement();
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
        }
    });
    addFiller(composite);
    label = TextEditorMessages.QuickDiffConfigurationBlock_showInOverviewRuler;
    fQuickDiffOverviewRulerCheckBox = new Button(composite, SWT.CHECK);
    fQuickDiffOverviewRulerCheckBox.setText(label);
    GridData gd = new GridData(SWT.BEGINNING, SWT.CENTER, false, false);
    gd.horizontalIndent = 0;
    gd.horizontalSpan = 2;
    gd.horizontalIndent = 10;
    fQuickDiffOverviewRulerCheckBox.setLayoutData(gd);
    fQuickDiffOverviewRulerCheckBox.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            for (int i = 0; i < fQuickDiffModel.length; i++) {
                fStore.setValue(fQuickDiffModel[i][1], fQuickDiffOverviewRulerCheckBox.getSelection());
            }
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
        }
    });
    // spacer
    Label l = new Label(composite, SWT.LEFT);
    gd = new GridData(SWT.FILL, SWT.CENTER, false, false);
    gd.horizontalSpan = 2;
    gd.horizontalIndent = 10;
    gd.heightHint = 5;
    l.setLayoutData(gd);
    Group group = new Group(composite, SWT.NONE);
    group.setText(TextEditorMessages.QuickDiffConfigurationBlock_colorTitle);
    layout = new GridLayout();
    layout.numColumns = 2;
    group.setLayout(layout);
    gd = new GridData(SWT.BEGINNING, SWT.CENTER, false, false);
    gd.horizontalSpan = 2;
    gd.horizontalIndent = 10;
    group.setLayoutData(gd);
    fQuickDiffColorEditors = new ColorSelector[3];
    for (int i = 0; i < fQuickDiffModel.length; i++) {
        label = fQuickDiffModel[i][2];
        l = new Label(group, SWT.LEFT);
        l.setText(label);
        final ColorSelector editor = new ColorSelector(group);
        fQuickDiffColorEditors[i] = editor;
        Button changeColorButton = editor.getButton();
        gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
        gd.horizontalAlignment = GridData.BEGINNING;
        changeColorButton.setLayoutData(gd);
        final int index = i;
        changeColorButton.addSelectionListener(new SelectionListener() {

            @Override
            public void widgetDefaultSelected(SelectionEvent e) {
            // do nothing
            }

            @Override
            public void widgetSelected(SelectionEvent e) {
                String key = fQuickDiffModel[index][0];
                PreferenceConverter.setValue(fStore, key, editor.getColorValue());
            }
        });
    }
    addFiller(composite);
    l = new Label(composite, SWT.LEFT);
    l.setText(TextEditorMessages.QuickDiffConfigurationBlock_referenceProviderTitle);
    gd = new GridData(SWT.FILL, SWT.CENTER, false, false);
    gd.horizontalSpan = 2;
    gd.horizontalIndent = 10;
    l.setLayoutData(gd);
    Composite editorComposite = new Composite(composite, SWT.NONE);
    layout = new GridLayout();
    layout.numColumns = 2;
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    editorComposite.setLayout(layout);
    gd = new GridData(SWT.FILL, SWT.FILL, false, true);
    gd.horizontalSpan = 2;
    gd.horizontalIndent = 10;
    editorComposite.setLayoutData(gd);
    fQuickDiffProviderCombo = new Combo(editorComposite, SWT.DROP_DOWN | SWT.READ_ONLY);
    gd = new GridData(SWT.FILL, SWT.BEGINNING, true, false);
    fQuickDiffProviderCombo.setLayoutData(gd);
    fQuickDiffProviderCombo.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
        // do nothing
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            int i = fQuickDiffProviderCombo.getSelectionIndex();
            fStore.setValue(AbstractDecoratedTextEditorPreferenceConstants.QUICK_DIFF_DEFAULT_PROVIDER, fQuickDiffProviderListModel[i][0]);
        }
    });
    fQuickDiffProviderNote = createNoteComposite(parent.getFont(), editorComposite, TextEditorMessages.QuickDiffConfigurationBlock_referenceProviderNoteTitle, TextEditorMessages.QuickDiffConfigurationBlock_referenceProviderNoteMessage);
    gd = new GridData(SWT.BEGINNING, SWT.FILL, false, true);
    gd.horizontalSpan = 2;
    fQuickDiffProviderNote.setLayoutData(gd);
    return composite;
}
Also used : Group(org.eclipse.swt.widgets.Group) Composite(org.eclipse.swt.widgets.Composite) Label(org.eclipse.swt.widgets.Label) Combo(org.eclipse.swt.widgets.Combo) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) GridData(org.eclipse.swt.layout.GridData) ColorSelector(org.eclipse.jface.preference.ColorSelector) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 5 with ColorSelector

use of org.eclipse.jface.preference.ColorSelector in project eclipse.platform.text by eclipse.

the class TextEditorDefaultsPreferencePage method createAppearancePage.

private Control createAppearancePage(Composite parent) {
    Composite appearanceComposite = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    appearanceComposite.setLayout(layout);
    Link fontLink = new Link(appearanceComposite, SWT.NONE);
    fontLink.setText(TextEditorMessages.TextEditorPreferencePage_Font_link);
    fontLink.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            // $NON-NLS-1$ //$NON-NLS-2$
            PreferencesUtil.createPreferenceDialogOn(getShell(), "org.eclipse.ui.preferencePages.ColorsAndFonts", null, "selectFont:" + JFaceResources.TEXT_FONT);
        }
    });
    GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    gd.horizontalSpan = 2;
    fontLink.setLayoutData(gd);
    addFiller(appearanceComposite, 2);
    String label = TextEditorMessages.TextEditorPreferencePage_undoHistorySize;
    Preference undoHistorySize = new Preference(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_UNDO_HISTORY_SIZE, label, null);
    IntegerDomain undoHistorySizeDomain = new IntegerDomain(0, 99999);
    addTextField(appearanceComposite, undoHistorySize, undoHistorySizeDomain, 15, 0);
    label = TextEditorMessages.TextEditorPreferencePage_displayedTabWidth;
    Preference tabWidth = new Preference(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH, label, null);
    IntegerDomain tabWidthDomain = new IntegerDomain(1, 16);
    addTextField(appearanceComposite, tabWidth, tabWidthDomain, 15, 0);
    if (isWordWrapPreferenceAllowed()) {
        label = TextEditorMessages.TextEditorPreferencePage_enableWordWrap;
        Preference enableWordWrap = new Preference(AbstractTextEditor.PREFERENCE_WORD_WRAP_ENABLED, label, null);
        addCheckBox(appearanceComposite, enableWordWrap, new BooleanDomain(), 0);
    }
    label = TextEditorMessages.TextEditorPreferencePage_convertTabsToSpaces;
    Preference spacesForTabs = new Preference(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SPACES_FOR_TABS, label, null);
    addCheckBox(appearanceComposite, spacesForTabs, new BooleanDomain(), 0);
    label = TextEditorMessages.TextEditorPreferencePage_highlightCurrentLine;
    Preference highlightCurrentLine = new Preference(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE, label, null);
    addCheckBox(appearanceComposite, highlightCurrentLine, new BooleanDomain(), 0);
    label = TextEditorMessages.TextEditorPreferencePage_showPrintMargin;
    Preference showPrintMargin = new Preference(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN, label, null);
    final Button showPrintMarginButton = addCheckBox(appearanceComposite, showPrintMargin, new BooleanDomain(), 0);
    label = TextEditorMessages.TextEditorPreferencePage_printMarginColumn;
    Preference printMarginColumn = new Preference(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN, label, null);
    final IntegerDomain printMarginDomain = new IntegerDomain(20, 200);
    final Control[] printMarginControls = addTextField(appearanceComposite, printMarginColumn, printMarginDomain, 15, 20);
    createDependency(showPrintMarginButton, showPrintMargin, printMarginControls);
    showPrintMarginButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            updateStatus(printMarginDomain);
        }
    });
    label = TextEditorMessages.TextEditorPreferencePage_showLineNumbers;
    Preference showLineNumbers = new Preference(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER, label, null);
    addCheckBox(appearanceComposite, showLineNumbers, new BooleanDomain(), 0);
    label = TextEditorMessages.TextEditorDefaultsPreferencePage_range_indicator;
    Preference showMagnet = new Preference(AbstractDecoratedTextEditorPreferenceConstants.SHOW_RANGE_INDICATOR, label, null);
    addCheckBox(appearanceComposite, showMagnet, new BooleanDomain(), 0);
    label = TextEditorMessages.TextEditorDefaultsPreferencePage_showWhitespaceCharacters;
    String linkText = TextEditorMessages.TextEditorDefaultsPreferencePage_showWhitespaceCharactersLinkText;
    Preference showWhitespaceCharacters = new Preference(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SHOW_WHITESPACE_CHARACTERS, label, null);
    addCheckBoxWithLink(appearanceComposite, showWhitespaceCharacters, linkText, new BooleanDomain(), 0, new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            Dialog dialog = new WhitespaceCharacterPainterOptionsDialog(Display.getDefault().getActiveShell(), fOverlayStore);
            dialog.open();
        }
    });
    label = TextEditorMessages.TextEditorPreferencePage_showAffordance;
    Preference showAffordance = new Preference(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SHOW_TEXT_HOVER_AFFORDANCE, label, null);
    addCheckBox(appearanceComposite, showAffordance, new BooleanDomain(), 0);
    label = TextEditorMessages.TextEditorDefaultsPreferencePage_enrichHoverMode;
    Preference hoverReplace = new Preference(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_HOVER_ENRICH_MODE, label, null);
    EnumeratedDomain hoverReplaceDomain = new EnumeratedDomain();
    hoverReplaceDomain.addValue(new EnumValue(-1, TextEditorMessages.TextEditorDefaultsPreferencePage_enrichHover_disabled));
    hoverReplaceDomain.addValue(new EnumValue(1, TextEditorMessages.TextEditorDefaultsPreferencePage_enrichHover_immediately));
    hoverReplaceDomain.addValue(new EnumValue(0, TextEditorMessages.TextEditorDefaultsPreferencePage_enrichHover_afterDelay));
    hoverReplaceDomain.addValue(new EnumValue(2, TextEditorMessages.TextEditorDefaultsPreferencePage_enrichHover_onClick));
    addCombo(appearanceComposite, hoverReplace, hoverReplaceDomain, 0);
    label = TextEditorMessages.TextEditorDefaultsPreferencePage_textDragAndDrop;
    Preference textDragAndDrop = new Preference(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TEXT_DRAG_AND_DROP_ENABLED, label, null);
    addCheckBox(appearanceComposite, textDragAndDrop, new BooleanDomain(), 0);
    label = TextEditorMessages.TextEditorDefaultsPreferencePage_warn_if_derived;
    Preference warnIfDerived = new Preference(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_WARN_IF_INPUT_DERIVED, label, null);
    addCheckBox(appearanceComposite, warnIfDerived, new BooleanDomain(), 0);
    label = TextEditorMessages.TextEditorDefaultsPreferencePage_smartHomeEnd;
    Preference smartHomeEnd = new Preference(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SMART_HOME_END, label, null);
    addCheckBox(appearanceComposite, smartHomeEnd, new BooleanDomain(), 0);
    addFiller(appearanceComposite, 2);
    Label l = new Label(appearanceComposite, SWT.LEFT);
    l.setText(TextEditorMessages.TextEditorPreferencePage_appearanceOptions);
    gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    gd.horizontalSpan = 2;
    l.setLayoutData(gd);
    Composite editorComposite = new Composite(appearanceComposite, SWT.NONE);
    layout = new GridLayout();
    layout.numColumns = 2;
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    editorComposite.setLayout(layout);
    gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL);
    gd.horizontalSpan = 2;
    editorComposite.setLayoutData(gd);
    fAppearanceColorList = new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER);
    gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_BOTH);
    gd.heightHint = fAppearanceColorList.getItemHeight() * 8;
    fAppearanceColorList.setLayoutData(gd);
    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));
    l = new Label(stylesComposite, SWT.LEFT);
    l.setText(TextEditorMessages.TextEditorPreferencePage_color);
    gd = new GridData();
    gd.horizontalAlignment = GridData.BEGINNING;
    l.setLayoutData(gd);
    fAppearanceColorEditor = new ColorSelector(stylesComposite);
    Button foregroundColorButton = fAppearanceColorEditor.getButton();
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalAlignment = GridData.BEGINNING;
    foregroundColorButton.setLayoutData(gd);
    SelectionListener colorDefaultSelectionListener = new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            boolean systemDefault = fAppearanceColorDefault.getSelection();
            fAppearanceColorEditor.getButton().setEnabled(!systemDefault);
            int i = fAppearanceColorList.getSelectionIndex();
            if (i == -1)
                return;
            String key = fAppearanceColorListModel[i][2];
            if (key != null)
                fOverlayStore.setValue(key, systemDefault);
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
        }
    };
    fAppearanceColorDefault = new Button(stylesComposite, SWT.CHECK);
    fAppearanceColorDefault.setText(TextEditorMessages.TextEditorPreferencePage_systemDefault);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalAlignment = GridData.BEGINNING;
    gd.horizontalSpan = 2;
    fAppearanceColorDefault.setLayoutData(gd);
    fAppearanceColorDefault.setVisible(false);
    fAppearanceColorDefault.addSelectionListener(colorDefaultSelectionListener);
    fAppearanceColorList.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
        // do nothing
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            handleAppearanceColorListSelection();
        }
    });
    foregroundColorButton.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
        // do nothing
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            int i = fAppearanceColorList.getSelectionIndex();
            if (i == -1)
                return;
            String key = fAppearanceColorListModel[i][1];
            PreferenceConverter.setValue(fOverlayStore, key, fAppearanceColorEditor.getColorValue());
        }
    });
    Link link = new Link(appearanceComposite, SWT.NONE);
    link.setText(TextEditorMessages.TextEditorPreferencePage_colorsAndFonts_link);
    link.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            // $NON-NLS-1$ //$NON-NLS-2$
            PreferencesUtil.createPreferenceDialogOn(getShell(), "org.eclipse.ui.preferencePages.ColorsAndFonts", null, "selectCategory:org.eclipse.ui.workbenchMisc");
        }
    });
    GridData gridData = new GridData(SWT.FILL, SWT.BEGINNING, true, false);
    // only expand further if anyone else requires it
    gridData.widthHint = 150;
    gridData.horizontalSpan = 2;
    link.setLayoutData(gridData);
    addFiller(appearanceComposite, 2);
    appearanceComposite.layout();
    return appearanceComposite;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) EnumValue(org.eclipse.ui.internal.editors.text.TextEditorDefaultsPreferencePage.EnumeratedDomain.EnumValue) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) GridLayout(org.eclipse.swt.layout.GridLayout) Control(org.eclipse.swt.widgets.Control) Button(org.eclipse.swt.widgets.Button) Dialog(org.eclipse.jface.dialogs.Dialog) SelectionEvent(org.eclipse.swt.events.SelectionEvent) GridData(org.eclipse.swt.layout.GridData) ArrayList(java.util.ArrayList) List(org.eclipse.swt.widgets.List) ColorSelector(org.eclipse.jface.preference.ColorSelector) Link(org.eclipse.swt.widgets.Link) SelectionListener(org.eclipse.swt.events.SelectionListener)

Aggregations

ColorSelector (org.eclipse.jface.preference.ColorSelector)39 GridData (org.eclipse.swt.layout.GridData)37 Composite (org.eclipse.swt.widgets.Composite)31 GridLayout (org.eclipse.swt.layout.GridLayout)27 Label (org.eclipse.swt.widgets.Label)27 SelectionEvent (org.eclipse.swt.events.SelectionEvent)25 Button (org.eclipse.swt.widgets.Button)20 IPropertyChangeListener (org.eclipse.jface.util.IPropertyChangeListener)14 PropertyChangeEvent (org.eclipse.jface.util.PropertyChangeEvent)14 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)14 SelectionListener (org.eclipse.swt.events.SelectionListener)14 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)13 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)12 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)12 Group (org.eclipse.swt.widgets.Group)11 Link (org.eclipse.swt.widgets.Link)10 SashForm (org.eclipse.swt.custom.SashForm)9 RGB (org.eclipse.swt.graphics.RGB)8 Iterator (java.util.Iterator)7 SourceViewer (org.eclipse.jface.text.source.SourceViewer)7