use of org.eclipse.ui.internal.editors.text.TextEditorDefaultsPreferencePage.EnumeratedDomain.EnumValue 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;
}
use of org.eclipse.ui.internal.editors.text.TextEditorDefaultsPreferencePage.EnumeratedDomain.EnumValue in project eclipse.platform.text by eclipse.
the class TextEditorDefaultsPreferencePage method addSpinner.
/**
* Adds a spinner for the given preference and domain. Assumes that the
* <code>EnumeratedDomain</code> contains only numeric values in a
* continuous range, no custom entries (use <code>addCombo</code> in that
* case).
*
* @param composite the parent composite
* @param preference the preference
* @param domain its domain
* @param indentation the indentation
* @return the created controls, a <code>Label</code> and a
* <code>Spinner</code> control
*/
Control[] addSpinner(Composite composite, final Preference preference, final EnumeratedDomain domain, int indentation) {
Label labelControl = new Label(composite, SWT.NONE);
labelControl.setText(preference.getName());
GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
gd.horizontalIndent = indentation;
labelControl.setLayoutData(gd);
final Spinner spinner = new Spinner(composite, SWT.READ_ONLY | SWT.BORDER);
gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
spinner.setLayoutData(gd);
spinner.setToolTipText(preference.getDescription());
spinner.setMinimum(domain.getMinimumValue().getIntValue());
spinner.setMaximum(domain.getMaximumValue().getIntValue());
spinner.setIncrement(1);
spinner.setPageIncrement(4);
spinner.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
int index = spinner.getSelection();
EnumValue value = domain.getValueByInteger(index);
IStatus status = domain.validate(value);
if (!status.matches(IStatus.ERROR))
fOverlayStore.setValue(preference.getKey(), value.getIntValue());
updateStatus(status);
}
});
fInitializers.add(fInitializerFactory.create(preference, spinner, domain));
return new Control[] { labelControl, spinner };
}
use of org.eclipse.ui.internal.editors.text.TextEditorDefaultsPreferencePage.EnumeratedDomain.EnumValue in project eclipse.platform.text by eclipse.
the class TextEditorDefaultsPreferencePage method addCombo.
Control[] addCombo(Composite composite, final Preference preference, final EnumeratedDomain domain, int indentation) {
Label labelControl = new Label(composite, SWT.NONE);
labelControl.setText(preference.getName());
GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
gd.horizontalIndent = indentation;
labelControl.setLayoutData(gd);
final Combo combo = new Combo(composite, SWT.DROP_DOWN | SWT.READ_ONLY);
gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
combo.setLayoutData(gd);
combo.setToolTipText(preference.getDescription());
for (Iterator<EnumValue> it = domain.fItems.iterator(); it.hasNext(); ) {
EnumValue value = it.next();
combo.add(value.getLabel());
}
combo.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
int index = combo.getSelectionIndex();
EnumValue value = domain.getValueByIndex(index);
IStatus status = domain.validate(value);
if (!status.matches(IStatus.ERROR))
fOverlayStore.setValue(preference.getKey(), value.getIntValue());
updateStatus(status);
}
});
fInitializers.add(fInitializerFactory.create(preference, combo, domain));
return new Control[] { labelControl, combo };
}
Aggregations