Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDani Megert2002-05-29 15:13:23 +0000
committerDani Megert2002-05-29 15:13:23 +0000
commit905ddc5f30d6e297f3adc627d84d15e68ab68471 (patch)
tree3e350d88734a3691e11ea5752490f3fd145c2330
parente1d7ae056e268c4fbcdacdec2308cdf871dd4830 (diff)
downloadeclipse.platform.text-905ddc5f30d6e297f3adc627d84d15e68ab68471.tar.gz
eclipse.platform.text-905ddc5f30d6e297f3adc627d84d15e68ab68471.tar.xz
eclipse.platform.text-905ddc5f30d6e297f3adc627d84d15e68ab68471.zip
Fixed 17433: Can't disable blue 'inexact' search highlighting
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/SearchMessages.properties1
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/SearchPreferencePage.java77
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultView.java2
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultViewer.java13
4 files changed, 74 insertions, 19 deletions
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchMessages.properties b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchMessages.properties
index be1bddff3..00a82d50b 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchMessages.properties
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchMessages.properties
@@ -152,6 +152,7 @@ CopyToClipboardAction.error.message= There was a problem when accessing the syst
ExceptionDialog.seeErrorLogMessage= See error log for more details
+SearchPreferencePage.emphasizePotentialMatches= &Emphasize inexact matches
SearchPreferencePage.potentialMatchFgColor= &Foreground color for inexact matches:
SearchPreferencePage.reuseEditor= &Reuse editors to show matches
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchPreferencePage.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchPreferencePage.java
index 4bcb4b3a6..c3f6d3278 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchPreferencePage.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchPreferencePage.java
@@ -4,6 +4,9 @@
*/
package org.eclipse.search.internal.ui;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.widgets.Composite;
@@ -22,18 +25,48 @@ import org.eclipse.ui.help.WorkbenchHelp;
*/
public class SearchPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
+ /*
+ * XXX: Need to subclass due to bug: 18183: setEnabled(...) for FieldEditors
+ */
+ private class ColorEditor extends ColorFieldEditor {
+ public ColorEditor(String name, String labelText, Composite parent) {
+ super(name, labelText, parent);
+ }
+ void setEnabled(boolean state) {
+ getLabelControl().setEnabled(state);
+ getChangeControl(getFieldEditorParent()).setEnabled(state);
+ }
+ }
+
+ /*
+ * XXX: Need to subclass due to bug 18182: BooleanFieldEditor gets out of synch after restoring defaults
+ */
+ private class BooleanEditor extends BooleanFieldEditor {
+ public BooleanEditor(String name, String labelText, Composite parent) {
+ super(name, labelText, parent);
+ }
+ void addSelectionListener(SelectionListener listener) {
+ getChangeControl(getFieldEditorParent()).addSelectionListener(listener);
+ }
+ }
+
+
+ public static final String EMPHASIZE_POTENTIAL_MATCHES= "org.eclipse.search.potentialMatch.emphasize"; //$NON-NLS-1$
public static final String POTENTIAL_MATCH_FG_COLOR= "org.eclipse.search.potentialMatch.fgColor"; //$NON-NLS-1$
public static final String REUSE_EDITOR= "org.eclipse.search.reuseEditor"; //$NON-NLS-1$
+ private ColorEditor fColorEditor;
+ private BooleanEditor fEmphasizedCheckbox;
+ private Composite fParent;
public SearchPreferencePage() {
super(GRID);
-
setPreferenceStore(SearchPlugin.getDefault().getPreferenceStore());
}
public static void initDefaults(IPreferenceStore store) {
RGB gray= new RGB(85, 85, 85);
+ store.setDefault(EMPHASIZE_POTENTIAL_MATCHES, true);
PreferenceConverter.setDefault(store, POTENTIAL_MATCH_FG_COLOR, gray);
store.setDefault(REUSE_EDITOR, false);
}
@@ -43,14 +76,16 @@ public class SearchPreferencePage extends FieldEditorPreferencePage implements I
return store.getBoolean(REUSE_EDITOR);
}
+ public static boolean arePotentialMatchesEmphasized() {
+ IPreferenceStore store= SearchPlugin.getDefault().getPreferenceStore();
+ return store.getBoolean(EMPHASIZE_POTENTIAL_MATCHES);
+ }
+
public static RGB getPotentialMatchBackgroundColor() {
IPreferenceStore store= SearchPlugin.getDefault().getPreferenceStore();
return PreferenceConverter.getColor(store, POTENTIAL_MATCH_FG_COLOR);
}
- /*
- * Method declared on PreferencePage
- */
public void createControl(Composite parent) {
super.createControl(parent);
WorkbenchHelp.setHelp(getControl(), ISearchHelpContextIds.SEARCH_PREFERENCE_PAGE);
@@ -59,24 +94,38 @@ public class SearchPreferencePage extends FieldEditorPreferencePage implements I
protected void createFieldEditors() {
Composite parent= getFieldEditorParent();
- ColorFieldEditor colorEditor= new ColorFieldEditor(
- POTENTIAL_MATCH_FG_COLOR,
- SearchMessages.getString("SearchPreferencePage.potentialMatchFgColor"), //$NON-NLS-1$
- parent
- );
- addField(colorEditor);
-
BooleanFieldEditor boolEditor= new BooleanFieldEditor(
REUSE_EDITOR,
SearchMessages.getString("SearchPreferencePage.reuseEditor"), //$NON-NLS-1$
parent
);
addField(boolEditor);
+
+ fEmphasizedCheckbox= new BooleanEditor(
+ EMPHASIZE_POTENTIAL_MATCHES,
+ SearchMessages.getString("SearchPreferencePage.emphasizePotentialMatches"), //$NON-NLS-1$
+ parent);
+ addField(fEmphasizedCheckbox);
+ fEmphasizedCheckbox.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ fColorEditor.setEnabled(fEmphasizedCheckbox.getBooleanValue());
+ }
+ });
+
+ fColorEditor= new ColorEditor(
+ POTENTIAL_MATCH_FG_COLOR,
+ SearchMessages.getString("SearchPreferencePage.potentialMatchFgColor"), //$NON-NLS-1$
+ parent
+ );
+ addField(fColorEditor);
+ fColorEditor.setEnabled(arePotentialMatchesEmphasized());
}
- /*
- * Method declared on IWorkbenchPreferencePage
- */
public void init(IWorkbench workbench) {
}
+
+ protected void performDefaults() {
+ super.performDefaults();
+ fColorEditor.setEnabled(fEmphasizedCheckbox.getBooleanValue());
+ }
}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultView.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultView.java
index 68a8a25f3..e4f29958a 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultView.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultView.java
@@ -85,7 +85,7 @@ public class SearchResultView extends ViewPart implements ISearchResultView {
fPropertyChangeListener= new IPropertyChangeListener() {
public void propertyChange(PropertyChangeEvent event) {
- if (event.getProperty() == SearchPreferencePage.POTENTIAL_MATCH_FG_COLOR)
+ if (event.getProperty() == SearchPreferencePage.POTENTIAL_MATCH_FG_COLOR || event.getProperty() == SearchPreferencePage.EMPHASIZE_POTENTIAL_MATCHES)
if (fViewer != null)
fViewer.updatedPotentialMatchBgColor();
}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultViewer.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultViewer.java
index 4cc265fd2..bda034e40 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultViewer.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchResultViewer.java
@@ -89,7 +89,8 @@ public class SearchResultViewer extends TableViewer {
fOuterPart= outerPart;
Assert.isNotNull(fOuterPart);
- fPotentialMatchFgColor= new Color(SearchPlugin.getDefault().getActiveWorkbenchShell().getDisplay(), SearchPreferencePage.getPotentialMatchBackgroundColor());
+ if (SearchPreferencePage.arePotentialMatchesEmphasized())
+ fPotentialMatchFgColor= new Color(SearchPlugin.getDefault().getActiveWorkbenchShell().getDisplay(), SearchPreferencePage.getPotentialMatchBackgroundColor());
setUseHashlookup(true);
setContentProvider(new SearchResultContentProvider());
@@ -482,8 +483,11 @@ public class SearchResultViewer extends TableViewer {
* Updates the background color for potential matches.
*/
void updatedPotentialMatchBgColor() {
- fPotentialMatchFgColor.dispose();
- fPotentialMatchFgColor= new Color(SearchPlugin.getDefault().getActiveWorkbenchShell().getDisplay(), SearchPreferencePage.getPotentialMatchBackgroundColor());
+ if (fPotentialMatchFgColor != null)
+ fPotentialMatchFgColor.dispose();
+ fPotentialMatchFgColor= null;
+ if (SearchPreferencePage.arePotentialMatchesEmphasized())
+ fPotentialMatchFgColor= new Color(SearchPlugin.getDefault().getActiveWorkbenchShell().getDisplay(), SearchPreferencePage.getPotentialMatchBackgroundColor());
refresh();
}
@@ -524,7 +528,8 @@ public class SearchResultViewer extends TableViewer {
Menu menu= getTable().getMenu();
if (menu != null)
menu.dispose();
- fPotentialMatchFgColor.dispose();
+ if (fPotentialMatchFgColor != null)
+ fPotentialMatchFgColor.dispose();
if (fActionGroup != null) {
fActionGroup.dispose();
fActionGroup= null;

Back to the top