diff options
author | Dani Megert | 2010-09-29 15:21:51 +0000 |
---|---|---|
committer | Dani Megert | 2010-09-29 15:21:51 +0000 |
commit | 4e35de8a7fc4957dac9ae6d4fcbac843f16e4c0d (patch) | |
tree | bc172f9b4fab67c21610fd7a8228b166eeb89689 /org.eclipse.ui.editors | |
parent | b62b548fcf5fffc14cd6604565608dfc2f2b427e (diff) | |
download | eclipse.platform.text-4e35de8a7fc4957dac9ae6d4fcbac843f16e4c0d.tar.gz eclipse.platform.text-4e35de8a7fc4957dac9ae6d4fcbac843f16e4c0d.tar.xz eclipse.platform.text-4e35de8a7fc4957dac9ae6d4fcbac843f16e4c0d.zip |
Committed Deepak's patch to fix bug 257313: [preferences][painting] More options to configure "Show Whitespace Characters"v20101005-0800
Diffstat (limited to 'org.eclipse.ui.editors')
5 files changed, 489 insertions, 20 deletions
diff --git a/org.eclipse.ui.editors/META-INF/MANIFEST.MF b/org.eclipse.ui.editors/META-INF/MANIFEST.MF index 72e49b06e86..1799bdd6cb1 100644 --- a/org.eclipse.ui.editors/META-INF/MANIFEST.MF +++ b/org.eclipse.ui.editors/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.ui.editors; singleton:=true -Bundle-Version: 3.6.100.qualifier +Bundle-Version: 3.7.0.qualifier Bundle-Activator: org.eclipse.ui.internal.editors.text.EditorsPlugin Bundle-ActivationPolicy: lazy Bundle-Vendor: %providerName @@ -18,8 +18,8 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.5.0,4.0.0)", org.eclipse.ui.ide;bundle-version="[3.5.0,4.0.0)", org.eclipse.ui;bundle-version="[3.5.0,4.0.0)", - org.eclipse.jface.text;bundle-version="[3.5.0,4.0.0)", - org.eclipse.ui.workbench.texteditor;bundle-version="[3.6.0,4.0.0)", + org.eclipse.jface.text;bundle-version="[3.7.0,4.0.0)", + org.eclipse.ui.workbench.texteditor;bundle-version="[3.7.0,4.0.0)", org.eclipse.core.filebuffers;visibility:=reexport;bundle-version="[3.5.0,4.0.0)", org.eclipse.core.resources;bundle-version="[3.5.0,4.0.0)", org.eclipse.core.filesystem;bundle-version="[1.2.0,2.0.0)" diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorDefaultsPreferencePage.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorDefaultsPreferencePage.java index 02cecbd914b..feced74a4c9 100644 --- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorDefaultsPreferencePage.java +++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorDefaultsPreferencePage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -19,11 +19,19 @@ import java.util.Map; import java.util.Set; import org.eclipse.swt.SWT; +import org.eclipse.swt.accessibility.AccessibleAdapter; +import org.eclipse.swt.accessibility.AccessibleEvent; +import org.eclipse.swt.events.FocusAdapter; +import org.eclipse.swt.events.FocusEvent; import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.events.MouseAdapter; +import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.events.TraverseEvent; +import org.eclipse.swt.events.TraverseListener; import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; @@ -31,20 +39,24 @@ import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Link; import org.eclipse.swt.widgets.List; +import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Spinner; import org.eclipse.swt.widgets.Text; import org.eclipse.core.runtime.Assert; import org.eclipse.core.runtime.IStatus; +import org.eclipse.jface.action.LegacyActionTools; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.DialogPage; import org.eclipse.jface.dialogs.IMessageProvider; import org.eclipse.jface.layout.PixelConverter; import org.eclipse.jface.preference.ColorSelector; +import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.PreferenceConverter; import org.eclipse.jface.preference.PreferencePage; @@ -81,7 +93,14 @@ public class TextEditorDefaultsPreferencePage extends PreferencePage implements } - public final class InitializerFactory { + public static final class InitializerFactory { + + private final IPreferenceStore fPreferenceStore; + + public InitializerFactory(IPreferenceStore preferenceStore) { + fPreferenceStore= preferenceStore; + } + private class TextInitializer extends Initializer { private final Text fText; @@ -90,7 +109,7 @@ public class TextEditorDefaultsPreferencePage extends PreferencePage implements fText= control; } public void initialize() { - String value= fOverlayStore.getString(fPreference.getKey()); + String value= fPreferenceStore.getString(fPreference.getKey()); fText.setText(value); } } @@ -103,7 +122,7 @@ public class TextEditorDefaultsPreferencePage extends PreferencePage implements fControl= control; } public void initialize() { - boolean value= fOverlayStore.getBoolean(fPreference.getKey()); + boolean value= fPreferenceStore.getBoolean(fPreference.getKey()); fControl.setSelection(value); } } @@ -118,7 +137,7 @@ public class TextEditorDefaultsPreferencePage extends PreferencePage implements fDomain= domain; } public void initialize() { - int value= fOverlayStore.getInt(fPreference.getKey()); + int value= fPreferenceStore.getInt(fPreference.getKey()); EnumValue enumValue= fDomain.getValueByInteger(value); if (enumValue != null) { int index= fDomain.getIndex(enumValue); @@ -138,7 +157,7 @@ public class TextEditorDefaultsPreferencePage extends PreferencePage implements fDomain= domain; } public void initialize() { - int value= fOverlayStore.getInt(fPreference.getKey()); + int value= fPreferenceStore.getInt(fPreference.getKey()); EnumValue enumValue= fDomain.getValueByInteger(value); if (enumValue != null) { fControl.setSelection(value); @@ -368,6 +387,181 @@ public class TextEditorDefaultsPreferencePage extends PreferencePage implements } } + private static class WhitespaceCharacterPainterOptionsDialog extends Dialog { + + private java.util.List fDialogInitializers= new ArrayList(); + + private OverlayPreferenceStore fDialogOverlayStore; + + private final IPreferenceStore fParentPreferenceStore; + + private InitializerFactory fDialogInitializerFactory; + + protected WhitespaceCharacterPainterOptionsDialog(Shell parentShell, IPreferenceStore parent) { + super(parentShell); + fParentPreferenceStore= parent; + fDialogOverlayStore= createDialogOverlayStore(); + fDialogInitializerFactory= new InitializerFactory(fDialogOverlayStore); + } + + private OverlayPreferenceStore createDialogOverlayStore() { + ArrayList overlayKeys= new ArrayList(); + + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SHOW_LEADING_SPACES)); + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SHOW_ENCLOSED_SPACES)); + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SHOW_TRAILING_SPACES)); + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SHOW_LEADING_IDEOGRAPHIC_SPACES)); + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SHOW_ENCLOSED_IDEOGRAPHIC_SPACES)); + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SHOW_TRAILING_IDEOGRAPHIC_SPACES)); + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SHOW_LEADING_TABS)); + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SHOW_ENCLOSED_TABS)); + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SHOW_TRAILING_TABS)); + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SHOW_CARRIAGE_RETURN)); + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SHOW_LINE_FEED)); + + OverlayPreferenceStore.OverlayKey[] keys= new OverlayPreferenceStore.OverlayKey[overlayKeys.size()]; + overlayKeys.toArray(keys); + return new OverlayPreferenceStore(fParentPreferenceStore, keys); + } + + protected void configureShell(Shell newShell) { + super.configureShell(newShell); + newShell.setText(TextEditorMessages.TextEditorDefaultsPreferencePage_showWhitespaceCharactersDialogTitle); + } + + protected Control createContents(Composite parent) { + Control contents= super.createContents(parent); + Dialog.applyDialogFont(contents); + fDialogOverlayStore.load(); + fDialogOverlayStore.start(); + initializeShowWhitespaceCharactersPreferences(); + return contents; + } + + private void initializeShowWhitespaceCharactersPreferences() { + for (Iterator it= fDialogInitializers.iterator(); it.hasNext();) { + Initializer initializer= (Initializer)it.next(); + initializer.initialize(); + } + } + + protected Control createDialogArea(Composite parent) { + Composite composite= (Composite)super.createDialogArea(parent); + + Label description= new Label(composite, SWT.NONE); + description.setText(TextEditorMessages.TextEditorDefaultsPreferencePage_configureWhitespaceCharacterPainterProperties); + description.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false)); + + Composite tabularComposite= new Composite(composite, SWT.NONE); + GridLayout layout= new GridLayout(); + layout.numColumns= 4; + layout.marginHeight= 0; + layout.marginWidth= 0; + layout.makeColumnsEqualWidth= true; + tabularComposite.setLayout(layout); + + Label label; + Button checkbox; + Preference preference; + + label= new Label(tabularComposite, SWT.NONE); + label.setText(""); //$NON-NLS-1$ + label.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false)); + + label= new Label(tabularComposite, SWT.NONE); + label.setText(TextEditorMessages.TextEditorDefaultsPreferencePage_leading); + label.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false)); + + label= new Label(tabularComposite, SWT.NONE); + label.setText(TextEditorMessages.TextEditorDefaultsPreferencePage_enclosed); + label.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false)); + + label= new Label(tabularComposite, SWT.NONE); + label.setText(TextEditorMessages.TextEditorDefaultsPreferencePage_trailing); + label.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false)); + + label= new Label(tabularComposite, SWT.NONE); + label.setText(TextEditorMessages.TextEditorDefaultsPreferencePage_space); + label.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false)); + preference= new Preference(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SHOW_LEADING_SPACES, "", null); //$NON-NLS-1$ + addCheckBox(tabularComposite, preference, new BooleanDomain(), 0); + preference= new Preference(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SHOW_ENCLOSED_SPACES, "", null); //$NON-NLS-1$ + addCheckBox(tabularComposite, preference, new BooleanDomain(), 0); + preference= new Preference(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SHOW_TRAILING_SPACES, "", null); //$NON-NLS-1$ + addCheckBox(tabularComposite, preference, new BooleanDomain(), 0); + + label= new Label(tabularComposite, SWT.NONE); + label.setText(TextEditorMessages.TextEditorDefaultsPreferencePage_ideographicSpace); + label.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false)); + preference= new Preference(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SHOW_LEADING_IDEOGRAPHIC_SPACES, "", null); //$NON-NLS-1$ + addCheckBox(tabularComposite, preference, new BooleanDomain(), 0); + preference= new Preference(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SHOW_ENCLOSED_IDEOGRAPHIC_SPACES, "", null); //$NON-NLS-1$ + addCheckBox(tabularComposite, preference, new BooleanDomain(), 0); + preference= new Preference(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SHOW_TRAILING_IDEOGRAPHIC_SPACES, "", null); //$NON-NLS-1$ + addCheckBox(tabularComposite, preference, new BooleanDomain(), 0); + + label= new Label(tabularComposite, SWT.NONE); + label.setText(TextEditorMessages.TextEditorDefaultsPreferencePage_tab); + label.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false)); + preference= new Preference(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SHOW_LEADING_TABS, "", null); //$NON-NLS-1$ + addCheckBox(tabularComposite, preference, new BooleanDomain(), 0); + preference= new Preference(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SHOW_ENCLOSED_TABS, "", null); //$NON-NLS-1$ + addCheckBox(tabularComposite, preference, new BooleanDomain(), 0); + preference= new Preference(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SHOW_TRAILING_TABS, "", null); //$NON-NLS-1$ + addCheckBox(tabularComposite, preference, new BooleanDomain(), 0); + + label= new Label(tabularComposite, SWT.NONE); + label.setText(TextEditorMessages.TextEditorDefaultsPreferencePage_carriageReturn); + label.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false)); + checkbox= new Button(tabularComposite, SWT.CHECK); + checkbox.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false)); + checkbox.setEnabled(false); + checkbox= new Button(tabularComposite, SWT.CHECK); + checkbox.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false)); + checkbox.setEnabled(false); + preference= new Preference(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SHOW_CARRIAGE_RETURN, "", null); //$NON-NLS-1$ + addCheckBox(tabularComposite, preference, new BooleanDomain(), 0); + + label= new Label(tabularComposite, SWT.NONE); + label.setText(TextEditorMessages.TextEditorDefaultsPreferencePage_lineFeed); + label.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false)); + checkbox= new Button(tabularComposite, SWT.CHECK); + checkbox.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false)); + checkbox.setEnabled(false); + checkbox= new Button(tabularComposite, SWT.CHECK); + checkbox.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false)); + checkbox.setEnabled(false); + preference= new Preference(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SHOW_LINE_FEED, "", null); //$NON-NLS-1$ + addCheckBox(tabularComposite, preference, new BooleanDomain(), 0); + + return composite; + } + + private Button addCheckBox(Composite composite, final Preference preference, final Domain domain, int indentation) { + final Button checkBox= new Button(composite, SWT.CHECK); + checkBox.setToolTipText(preference.getDescription()); + + GridData gd= new GridData(SWT.CENTER, SWT.CENTER, false, false); + gd.horizontalIndent= indentation; + checkBox.setLayoutData(gd); + checkBox.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + boolean value= checkBox.getSelection(); + IStatus status= domain.validate(Boolean.valueOf(value)); + if (!status.matches(IStatus.ERROR)) + fDialogOverlayStore.setValue(preference.getKey(), value); + } + }); + + fDialogInitializers.add(fDialogInitializerFactory.create(preference, checkBox)); + return checkBox; + } + + protected void okPressed() { + super.okPressed(); + fDialogOverlayStore.propagate(); + } + } private final String[][] fAppearanceColorListModel= new String[][] { {TextEditorMessages.TextEditorPreferencePage_lineNumberForegroundColor, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR, null}, @@ -396,7 +590,7 @@ public class TextEditorDefaultsPreferencePage extends PreferencePage implements private java.util.List fInitializers= new ArrayList(); - private InitializerFactory fInitializerFactory= new InitializerFactory(); + private InitializerFactory fInitializerFactory; private Map fDomains= new HashMap(); @@ -405,6 +599,7 @@ public class TextEditorDefaultsPreferencePage extends PreferencePage implements setPreferenceStore(EditorsPlugin.getDefault().getPreferenceStore()); fOverlayStore= createOverlayStore(); + fInitializerFactory= new InitializerFactory(fOverlayStore); } private OverlayPreferenceStore createOverlayStore() { @@ -452,6 +647,18 @@ public class TextEditorDefaultsPreferencePage extends PreferencePage implements overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SHOW_TEXT_HOVER_AFFORDANCE)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_HOVER_ENRICH_MODE)); + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SHOW_LEADING_SPACES)); + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SHOW_ENCLOSED_SPACES)); + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SHOW_TRAILING_SPACES)); + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SHOW_LEADING_IDEOGRAPHIC_SPACES)); + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SHOW_ENCLOSED_IDEOGRAPHIC_SPACES)); + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SHOW_TRAILING_IDEOGRAPHIC_SPACES)); + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SHOW_LEADING_TABS)); + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SHOW_ENCLOSED_TABS)); + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SHOW_TRAILING_TABS)); + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SHOW_CARRIAGE_RETURN)); + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SHOW_LINE_FEED)); + OverlayPreferenceStore.OverlayKey[] keys= new OverlayPreferenceStore.OverlayKey[overlayKeys.size()]; overlayKeys.toArray(keys); return new OverlayPreferenceStore(getPreferenceStore(), keys); @@ -551,7 +758,12 @@ public class TextEditorDefaultsPreferencePage extends PreferencePage implements label= TextEditorMessages.TextEditorDefaultsPreferencePage_showWhitespaceCharacters; Preference showWhitespaceCharacters= new Preference(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SHOW_WHITESPACE_CHARACTERS, label, null); - addCheckBox(appearanceComposite, showWhitespaceCharacters, new BooleanDomain(), 0); + addCheckBoxWithLink(appearanceComposite, showWhitespaceCharacters, new BooleanDomain(), 0, new SelectionAdapter() { + 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); @@ -814,6 +1026,14 @@ public class TextEditorDefaultsPreferencePage extends PreferencePage implements filler.setLayoutData(gd); } + private void checkboxControlChanged(final Preference preference, final Domain domain, final Button checkBox) { + boolean value= checkBox.getSelection(); + IStatus status= domain.validate(Boolean.valueOf(value)); + if (!status.matches(IStatus.ERROR)) + fOverlayStore.setValue(preference.getKey(), value); + updateStatus(status); + } + Button addCheckBox(Composite composite, final Preference preference, final Domain domain, int indentation) { final Button checkBox= new Button(composite, SWT.CHECK); checkBox.setText(preference.getName()); @@ -825,11 +1045,7 @@ public class TextEditorDefaultsPreferencePage extends PreferencePage implements checkBox.setLayoutData(gd); checkBox.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { - boolean value= checkBox.getSelection(); - IStatus status= domain.validate(Boolean.valueOf(value)); - if (!status.matches(IStatus.ERROR)) - fOverlayStore.setValue(preference.getKey(), value); - updateStatus(status); + checkboxControlChanged(preference, domain, checkBox); } }); @@ -838,6 +1054,84 @@ public class TextEditorDefaultsPreferencePage extends PreferencePage implements return checkBox; } + Button addCheckBoxWithLink(Composite parent, final Preference preference, final Domain domain, int indentation, SelectionListener listener) { + GridData gd= new GridData(GridData.FILL, GridData.FILL, true, false); + gd.horizontalSpan= 3; + gd.horizontalIndent= indentation; + + Composite composite= new Composite(parent, SWT.NONE); + GridLayout layout= new GridLayout(); + layout.marginHeight= 0; + layout.marginWidth= 0; + layout.numColumns= 2; + composite.setLayout(layout); + composite.setLayoutData(gd); + + final Button checkBox= new Button(composite, SWT.CHECK); + checkBox.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, false, false)); + checkBox.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + checkboxControlChanged(preference, domain, checkBox); + } + }); + checkBox.getAccessible().addAccessibleListener(new AccessibleAdapter() { + public void getName(AccessibleEvent e) { + e.result= LegacyActionTools.removeMnemonics(preference.getName().replaceAll("</?[aA][^>]*>", "")); //$NON-NLS-1$ //$NON-NLS-2$ + } + }); + + gd= new GridData(GridData.FILL, GridData.CENTER, false, false); + gd.horizontalIndent= -2; + + Link link= new Link(composite, SWT.NONE); + link.setText(preference.getName()); + link.setLayoutData(gd); + if (listener != null) { + link.addSelectionListener(listener); + } + + // toggle checkbox when user clicks unlinked text in link: + final boolean[] linkSelected= { false }; + link.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + linkSelected[0]= true; + } + }); + //Focus listener is required when the link opens a dialog + link.addFocusListener(new FocusAdapter() { + public void focusLost(FocusEvent e) { + linkSelected[0]= true; + } + }); + link.addMouseListener(new MouseAdapter() { + public void mouseDown(MouseEvent e) { + linkSelected[0]= false; + } + public void mouseUp(MouseEvent e) { + if (!linkSelected[0]) { + checkBox.setSelection(!checkBox.getSelection()); + checkBox.setFocus(); + linkSelected[0]= false; + checkboxControlChanged(preference, domain, checkBox); + } + } + }); + link.addTraverseListener(new TraverseListener() { + public void keyTraversed(TraverseEvent e) { + if (e.detail == SWT.TRAVERSE_MNEMONIC && e.doit == true) { + e.detail= SWT.TRAVERSE_NONE; + checkBox.setSelection(!checkBox.getSelection()); + checkBox.setFocus(); + linkSelected[0]= false; + checkboxControlChanged(preference, domain, checkBox); + } + } + }); + + fInitializers.add(fInitializerFactory.create(preference, checkBox)); + return checkBox; + } + Control[] addCombo(Composite composite, final Preference preference, final EnumeratedDomain domain, int indentation) { Label labelControl= new Label(composite, SWT.NONE); labelControl.setText(preference.getName()); diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorMessages.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorMessages.java index 18d1328eed7..a71f6126ac9 100644 --- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorMessages.java +++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorMessages.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -125,16 +125,26 @@ final class TextEditorMessages extends NLS { NLS.initializeMessages(BUNDLE_NAME, TextEditorMessages.class); } + public static String TextEditorDefaultsPreferencePage_carriageReturn; + public static String TextEditorDefaultsPreferencePage_configureWhitespaceCharacterPainterProperties; + public static String TextEditorDefaultsPreferencePage_enclosed; public static String TextEditorDefaultsPreferencePage_enrichHoverMode; public static String TextEditorDefaultsPreferencePage_enrichHover_immediately; public static String TextEditorDefaultsPreferencePage_enrichHover_afterDelay; public static String TextEditorDefaultsPreferencePage_enrichHover_disabled; public static String TextEditorDefaultsPreferencePage_enrichHover_onClick; + public static String TextEditorDefaultsPreferencePage_ideographicSpace; + public static String TextEditorDefaultsPreferencePage_leading; + public static String TextEditorDefaultsPreferencePage_lineFeed; public static String TextEditorDefaultsPreferencePage_range_indicator; public static String TextEditorDefaultsPreferencePage_smartHomeEnd; public static String TextEditorDefaultsPreferencePage_warn_if_derived; public static String TextEditorDefaultsPreferencePage_showWhitespaceCharacters; + public static String TextEditorDefaultsPreferencePage_showWhitespaceCharactersDialogTitle; + public static String TextEditorDefaultsPreferencePage_space; + public static String TextEditorDefaultsPreferencePage_tab; public static String TextEditorDefaultsPreferencePage_textDragAndDrop; + public static String TextEditorDefaultsPreferencePage_trailing; public static String LinkedModeConfigurationBlock_annotationPresentationOptions; public static String LinkedModeConfigurationBlock_SQUIGGLES; public static String LinkedModeConfigurationBlock_UNDERLINE; diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorMessages.properties b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorMessages.properties index fff316536b6..3235e888ca1 100644 --- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorMessages.properties +++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorMessages.properties @@ -29,16 +29,26 @@ TextEditorPreferencePage_backgroundColor=Background color TextEditorPreferencePage_findScopeColor=Find scope TextEditorPreferencePage_accessibility_disableCustomCarets= Use &custom caret TextEditorPreferencePage_accessibility_wideCaret= &Enable thick caret +TextEditorDefaultsPreferencePage_carriageReturn=Carriage Return ( \u00a4 ) +TextEditorDefaultsPreferencePage_configureWhitespaceCharacterPainterProperties=Configure visibility of whitespace characters in different regions of a line of text: +TextEditorDefaultsPreferencePage_enclosed=Enclosed TextEditorDefaultsPreferencePage_enrichHoverMode=When mouse mo&ved into hover: TextEditorDefaultsPreferencePage_enrichHover_afterDelay=Enrich after delay TextEditorDefaultsPreferencePage_enrichHover_disabled=Close hover TextEditorDefaultsPreferencePage_enrichHover_immediately=Enrich immediately TextEditorDefaultsPreferencePage_enrichHover_onClick=Enrich on click +TextEditorDefaultsPreferencePage_ideographicSpace=Ideographic space ( \u00b0 ) +TextEditorDefaultsPreferencePage_leading=Leading +TextEditorDefaultsPreferencePage_lineFeed=Line Feed ( \u00b6 ) TextEditorDefaultsPreferencePage_range_indicator=Show &range indicator TextEditorDefaultsPreferencePage_warn_if_derived= War&n before editing a derived file TextEditorDefaultsPreferencePage_smartHomeEnd= &Smart caret positioning at line start and end -TextEditorDefaultsPreferencePage_showWhitespaceCharacters= Sh&ow whitespace characters +TextEditorDefaultsPreferencePage_showWhitespaceCharacters= Sh&ow <a>whitespace characters</a> +TextEditorDefaultsPreferencePage_showWhitespaceCharactersDialogTitle=Show Whitespace Characters +TextEditorDefaultsPreferencePage_space=Space ( \u00b7 ) +TextEditorDefaultsPreferencePage_tab=Tab ( \u00bb ) TextEditorDefaultsPreferencePage_textDragAndDrop= Enable drag and dro&p of text +TextEditorDefaultsPreferencePage_trailing=Trailing TextEditorPreferencePage_colorsAndFonts_link= More colors can be configured on the <a>Colors and Fonts</a> preference page. TextEditorPreferencePage_colorsAndFonts_link_tooltip= Show the Colors and Fonts preferences diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractDecoratedTextEditorPreferenceConstants.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractDecoratedTextEditorPreferenceConstants.java index fd2b44421f7..44b595949e9 100644 --- a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractDecoratedTextEditorPreferenceConstants.java +++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractDecoratedTextEditorPreferenceConstants.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. + * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -394,12 +394,154 @@ public class AbstractDecoratedTextEditorPreferenceConstants { * <p> * Value is of type <code>Boolean</code>. * </p> - * + * + * <p> + * The following preferences can be used for fine-grained configuration when enabled. + * <ul> + * <li>{@link #EDITOR_SHOW_LEADING_SPACES}</li> + * <li>{@link #EDITOR_SHOW_ENCLOSED_SPACES}</li> + * <li>{@link #EDITOR_SHOW_TRAILING_SPACES}</li> + * <li>{@link #EDITOR_SHOW_LEADING_IDEOGRAPHIC_SPACES}</li> + * <li>{@link #EDITOR_SHOW_ENCLOSED_IDEOGRAPHIC_SPACES}</li> + * <li>{@link #EDITOR_SHOW_TRAILING_IDEOGRAPHIC_SPACES}</li> + * <li>{@link #EDITOR_SHOW_LEADING_TABS}</li> + * <li>{@link #EDITOR_SHOW_ENCLOSED_TABS}</li> + * <li>{@link #EDITOR_SHOW_TRAILING_TABS}</li> + * <li>{@link #EDITOR_SHOW_CARRIAGE_RETURN}</li> + * <li>{@link #EDITOR_SHOW_LINE_FEED}</li> + * </ul> + * </p> + * * @since 3.3 */ public static final String EDITOR_SHOW_WHITESPACE_CHARACTERS= AbstractTextEditor.PREFERENCE_SHOW_WHITESPACE_CHARACTERS; /** + * A named preference that controls the display of leading Space characters. The value is used + * only if the value of {@link #EDITOR_SHOW_WHITESPACE_CHARACTERS} is <code>true</code>. + * <p> + * Value is of type <code>Boolean</code>. + * </p> + * + * @since 3.7 + */ + public static final String EDITOR_SHOW_LEADING_SPACES= AbstractTextEditor.PREFERENCE_SHOW_LEADING_SPACES; + + /** + * A named preference that controls the display of enclosed Space characters. The value is used + * only if the value of {@link #EDITOR_SHOW_WHITESPACE_CHARACTERS} is <code>true</code>. + * <p> + * Value is of type <code>Boolean</code>. + * </p> + * + * @since 3.7 + */ + public static final String EDITOR_SHOW_ENCLOSED_SPACES= AbstractTextEditor.PREFERENCE_SHOW_ENCLOSED_SPACES; + + /** + * A named preference that controls the display of trailing Space characters. The value is used + * only if the value of {@link #EDITOR_SHOW_WHITESPACE_CHARACTERS} is <code>true</code>. + * <p> + * Value is of type <code>Boolean</code>. + * </p> + * + * @since 3.7 + */ + public static final String EDITOR_SHOW_TRAILING_SPACES= AbstractTextEditor.PREFERENCE_SHOW_TRAILING_SPACES; + + /** + * A named preference that controls the display of leading Ideographic Space characters. The + * value is used only if the value of {@link #EDITOR_SHOW_WHITESPACE_CHARACTERS} is + * <code>true</code>. + * <p> + * Value is of type <code>Boolean</code>. + * </p> + * + * @since 3.7 + */ + public static final String EDITOR_SHOW_LEADING_IDEOGRAPHIC_SPACES= AbstractTextEditor.PREFERENCE_SHOW_LEADING_IDEOGRAPHIC_SPACES; + + /** + * A named preference that controls the display of enclosed Ideographic Space characters. The + * value is used only if the value of {@link #EDITOR_SHOW_WHITESPACE_CHARACTERS} is + * <code>true</code>. + * <p> + * Value is of type <code>Boolean</code>. + * </p> + * + * @since 3.7 + */ + public static final String EDITOR_SHOW_ENCLOSED_IDEOGRAPHIC_SPACES= AbstractTextEditor.PREFERENCE_SHOW_ENCLOSED_IDEOGRAPHIC_SPACES; + + /** + * A named preference that controls the display of trailing Ideographic Space characters. The + * value is used only if the value of {@link #EDITOR_SHOW_WHITESPACE_CHARACTERS} is + * <code>true</code>. + * <p> + * Value is of type <code>Boolean</code>. + * </p> + * + * @since 3.7 + */ + public static final String EDITOR_SHOW_TRAILING_IDEOGRAPHIC_SPACES= AbstractTextEditor.PREFERENCE_SHOW_TRAILING_IDEOGRAPHIC_SPACES; + + /** + * A named preference that controls the display of leading Tab characters. The value is used + * only if the value of {@link #EDITOR_SHOW_WHITESPACE_CHARACTERS} is <code>true</code>. + * <p> + * Value is of type <code>Boolean</code>. + * </p> + * + * @since 3.7 + */ + public static final String EDITOR_SHOW_LEADING_TABS= AbstractTextEditor.PREFERENCE_SHOW_LEADING_TABS; + + /** + * A named preference that controls the display of enclosed Tab characters. The value is used + * only if the value of {@link #EDITOR_SHOW_WHITESPACE_CHARACTERS} is <code>true</code>. + * <p> + * Value is of type <code>Boolean</code>. + * </p> + * + * @since 3.7 + */ + public static final String EDITOR_SHOW_ENCLOSED_TABS= AbstractTextEditor.PREFERENCE_SHOW_ENCLOSED_TABS; + + /** + * A named preference that controls the display of trailing Tab characters. The value is used + * only if the value of {@link #EDITOR_SHOW_WHITESPACE_CHARACTERS} is <code>true</code>. + * <p> + * Value is of type <code>Boolean</code>. + * </p> + * + * @since 3.7 + */ + public static final String EDITOR_SHOW_TRAILING_TABS= AbstractTextEditor.PREFERENCE_SHOW_TRAILING_TABS; + + /** + * A named preference that controls the display of Carriage Return characters. The value is used + * only if the value of {@link #EDITOR_SHOW_WHITESPACE_CHARACTERS} is <code>true</code>. + * <p> + * Value is of type <code>Boolean</code>. + * </p> + * + * @since 3.7 + */ + public static final String EDITOR_SHOW_CARRIAGE_RETURN= AbstractTextEditor.PREFERENCE_SHOW_CARRIAGE_RETURN; + + /** + * A named preference that controls the display of Line Feed characters. The value is used only + * if the value of {@link #EDITOR_SHOW_WHITESPACE_CHARACTERS} is <code>true</code>. + * <p> + * Value is of type <code>Boolean</code>. + * </p> + * + * @since 3.7 + */ + public static final String EDITOR_SHOW_LINE_FEED= AbstractTextEditor.PREFERENCE_SHOW_LINE_FEED; + + + /** * A named preference that controls the display of the range indicator. * <p> * Value is of type <code>Boolean</code>. @@ -568,7 +710,20 @@ public class AbstractDecoratedTextEditorPreferenceConstants { store.setDefault(EDITOR_WARN_IF_INPUT_DERIVED, true); store.setDefault(EDITOR_SMART_HOME_END, true); + store.setDefault(EDITOR_SHOW_WHITESPACE_CHARACTERS, false); + store.setDefault(EDITOR_SHOW_LEADING_SPACES, true); + store.setDefault(EDITOR_SHOW_ENCLOSED_SPACES, true); + store.setDefault(EDITOR_SHOW_TRAILING_SPACES, true); + store.setDefault(EDITOR_SHOW_LEADING_IDEOGRAPHIC_SPACES, true); + store.setDefault(EDITOR_SHOW_ENCLOSED_IDEOGRAPHIC_SPACES, true); + store.setDefault(EDITOR_SHOW_TRAILING_IDEOGRAPHIC_SPACES, true); + store.setDefault(EDITOR_SHOW_LEADING_TABS, true); + store.setDefault(EDITOR_SHOW_ENCLOSED_TABS, true); + store.setDefault(EDITOR_SHOW_TRAILING_TABS, true); + store.setDefault(EDITOR_SHOW_CARRIAGE_RETURN, true); + store.setDefault(EDITOR_SHOW_LINE_FEED, true); + store.setDefault(EDITOR_TEXT_DRAG_AND_DROP_ENABLED, true); store.setDefault(EDITOR_SHOW_TEXT_HOVER_AFFORDANCE, true); store.setDefault(EDITOR_HOVER_ENRICH_MODE, 0); |