summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Walther2013-02-28 09:18:32 (EST)
committerDani Megert2013-02-28 09:18:32 (EST)
commit2b7c70a9bcc6df6731f39436fd7ca0ab7c0a2fab (patch)
tree66924639b07f73262b9898cd79b5cf18f6370b30
parent168945abdb58d24ea316224ce2b4db735b5b1559 (diff)
downloadeclipse.platform.text-2b7c70a9bcc6df6731f39436fd7ca0ab7c0a2fab.zip
eclipse.platform.text-2b7c70a9bcc6df6731f39436fd7ca0ab7c0a2fab.tar.gz
eclipse.platform.text-2b7c70a9bcc6df6731f39436fd7ca0ab7c0a2fab.tar.bz2
Fixed bug 399094: Add "whole word" option to file searchv20130228-141832I20130228-2000
-rw-r--r--org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/FileSearchTests.java56
-rw-r--r--org.eclipse.search/META-INF/MANIFEST.MF2
-rw-r--r--org.eclipse.search/new search/org/eclipse/search/ui/text/TextSearchQueryProvider.java18
-rw-r--r--org.eclipse.search/new search/org/eclipse/search2/internal/ui/text2/DefaultTextSearchQueryProvider.java8
-rw-r--r--org.eclipse.search/pom.xml2
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/SearchMessages.java4
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/SearchMessages.properties4
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileSearchQuery.java16
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/text/TextSearchPage.java61
9 files changed, 144 insertions, 27 deletions
diff --git a/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/FileSearchTests.java b/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/FileSearchTests.java
index b4c29d9..bf7dbdc 100644
--- a/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/FileSearchTests.java
+++ b/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/FileSearchTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * Copyright (c) 2000, 2013 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
@@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Christian Walther (Indel AG) - Bug 399094: Add whole word option to file search
*******************************************************************************/
package org.eclipse.search.tests.filesearch;
@@ -203,7 +204,60 @@ public class FileSearchTests extends TestCase {
}
+ public void testWholeWord() throws Exception {
+ StringBuffer buf= new StringBuffer();
+ // nothing after
+ buf.append("hell\n"); // nothing before
+ buf.append("hill\n"); // nothing before
+ buf.append("$hell\n"); // non-word char before
+ buf.append("shell\n"); // word char before
+ // non-word char after
+ buf.append("hell.freeze()\n"); // nothing before
+ buf.append("freeze(hell)\n"); // non-word char before
+ buf.append("shell-script\n"); // word char before
+ // word char after
+ buf.append("hello\n"); // nothing before
+ buf.append("world.hello()\n"); // non-word char before
+ buf.append("shilling\n"); // word char before
+ buf.append("holler\n"); // nothing before
+ IFolder folder= ResourceHelper.createFolder(fProject.getFolder("folder1"));
+ ResourceHelper.createFile(folder, "file1", buf.toString());
+ ResourceHelper.createFile(folder, "file2", buf.toString());
+
+ TextSearchEngine engine= TextSearchEngine.create();
+ FileTextSearchScope scope= FileTextSearchScope.newSearchScope(new IResource[] { fProject }, (String[])null, false);
+
+ {
+ // wildcards, whole word = false: match all lines
+ Pattern searchPattern= PatternConstructor.createPattern("h?ll", false, true, false, false);
+ TestResultCollector collector= new TestResultCollector();
+ engine.search(scope, collector, searchPattern, null);
+ assertEquals("Number of partial-word results", 22, collector.getNumberOfResults());
+ }
+ {
+ // wildcards, whole word = true: match only nothing and non-word chars before and after
+ Pattern searchPattern= PatternConstructor.createPattern("h?ll", false, true, false, true);
+ TestResultCollector collector= new TestResultCollector();
+ engine.search(scope, collector, searchPattern, null);
+ assertEquals("Number of whole-word results", 10, collector.getNumberOfResults());
+ }
+ {
+ // regexp, whole word = false: match all lines
+ Pattern searchPattern= PatternConstructor.createPattern("h[eio]ll", true, true, false, false);
+ TestResultCollector collector= new TestResultCollector();
+ engine.search(scope, collector, searchPattern, null);
+ assertEquals("Number of partial-word results", 22, collector.getNumberOfResults());
+ }
+ {
+ // regexp, whole word = true: match only nothing and non-word chars before and after
+ Pattern searchPattern= PatternConstructor.createPattern("h[eio]ll", true, true, false, true);
+ TestResultCollector collector= new TestResultCollector();
+ engine.search(scope, collector, searchPattern, null);
+ assertEquals("Number of whole-word results", 10, collector.getNumberOfResults());
+ }
+ }
+
public void testFileOpenInEditor() throws Exception {
StringBuffer buf= new StringBuffer();
buf.append("File1\n");
diff --git a/org.eclipse.search/META-INF/MANIFEST.MF b/org.eclipse.search/META-INF/MANIFEST.MF
index 097a9a0..458dbb6 100644
--- a/org.eclipse.search/META-INF/MANIFEST.MF
+++ b/org.eclipse.search/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.search; singleton:=true
-Bundle-Version: 3.8.100.qualifier
+Bundle-Version: 3.9.0.qualifier
Bundle-Activator: org.eclipse.search.internal.ui.SearchPlugin
Bundle-ActivationPolicy: lazy
Bundle-Vendor: %providerName
diff --git a/org.eclipse.search/new search/org/eclipse/search/ui/text/TextSearchQueryProvider.java b/org.eclipse.search/new search/org/eclipse/search/ui/text/TextSearchQueryProvider.java
index d5b8275..810d56e 100644
--- a/org.eclipse.search/new search/org/eclipse/search/ui/text/TextSearchQueryProvider.java
+++ b/org.eclipse.search/new search/org/eclipse/search/ui/text/TextSearchQueryProvider.java
@@ -1,12 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2006, 2008 Wind River Systems and others.
+ * Copyright (c) 2006, 2013 Wind River Systems 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
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Markus Schorn - initial API and implementation
+ * Markus Schorn - initial API and implementation
+ * Christian Walther (Indel AG) - Bug 399094: Add whole word option to file search
*******************************************************************************/
package org.eclipse.search.ui.text;
@@ -60,6 +61,19 @@ public abstract class TextSearchQueryProvider {
public abstract boolean isRegExSearch();
/**
+ * Returns whether to require a word boundary at the beginning and end of the pattern,
+ * excluding matches that only match part of a word.
+ *
+ * This implementation returns <code>false</code>, subclasses can override.
+ *
+ * @return <code>true</code> if the pattern should match only whole words
+ * @since 3.9
+ */
+ public boolean isWholeWordSearch() {
+ return false;
+ }
+
+ /**
* Returns the scope for the search
*
* @return the scope for the search
diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text2/DefaultTextSearchQueryProvider.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text2/DefaultTextSearchQueryProvider.java
index 96332ed..4f7f859 100644
--- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text2/DefaultTextSearchQueryProvider.java
+++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text2/DefaultTextSearchQueryProvider.java
@@ -1,12 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2006, 2008 Wind River Systems, IBM Corporation and others.
+ * Copyright (c) 2006, 2013 Wind River Systems, 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
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Markus Schorn - initial API and implementation
+ * Markus Schorn - initial API and implementation
+ * Christian Walther (Indel AG) - Bug 399094: Add whole word option to file search
*******************************************************************************/
package org.eclipse.search2.internal.ui.text2;
@@ -30,7 +31,8 @@ public class DefaultTextSearchQueryProvider extends TextSearchQueryProvider {
String text= input.getSearchText();
boolean regEx= input.isRegExSearch();
boolean caseSensitive= input.isCaseSensitiveSearch();
- return new FileSearchQuery(text, regEx, caseSensitive, scope);
+ boolean wholeWord= input.isWholeWordSearch();
+ return new FileSearchQuery(text, regEx, caseSensitive, wholeWord, scope);
}
/* (non-Javadoc)
diff --git a/org.eclipse.search/pom.xml b/org.eclipse.search/pom.xml
index 0aea8f3..db49b1b 100644
--- a/org.eclipse.search/pom.xml
+++ b/org.eclipse.search/pom.xml
@@ -20,6 +20,6 @@
</parent>
<groupId>org.eclipse.search</groupId>
<artifactId>org.eclipse.search</artifactId>
- <version>3.8.100-SNAPSHOT</version>
+ <version>3.9.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchMessages.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchMessages.java
index 2478aa4..321145f 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchMessages.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchMessages.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2013 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
@@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Christian Walther (Indel AG) - Bug 399094: Add whole word option to file search
*******************************************************************************/
package org.eclipse.search.internal.ui;
@@ -119,6 +120,7 @@ public final class SearchMessages extends NLS {
public static String SearchPage_fileNamePatterns_hint;
public static String SearchPage_caseSensitive;
public static String SearchPage_regularExpression;
+ public static String SearchPage_wholeWord;
public static String TextSearchEngine_statusMessage;
public static String TextSearchPage_replace_querycreationproblem_message;
public static String TextSearchPage_replace_runproblem_message;
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 2eac4b5..0e9f81d 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
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2000, 2012 IBM Corporation and others.
+# Copyright (c) 2000, 2013 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
@@ -7,6 +7,7 @@
#
# Contributors:
# IBM Corporation - initial API and implementation
+# Christian Walther (Indel AG) - Bug 399094: Add whole word option to file search
###############################################################################
SearchDialog_title= Search
@@ -86,6 +87,7 @@ SearchPage_fileNamePatterns_text= File name &patterns (separated by comma):
SearchPage_fileNamePatterns_hint= (* = any string, ? = any character, !x = excluding x)
SearchPage_caseSensitive= &Case sensitive
SearchPage_regularExpression= Regular e&xpression
+SearchPage_wholeWord= Who&le word
TextSearchEngine_statusMessage= Problems encountered during text search.
TextSearchPage_searchDerived_label=Consider deri&ved resources
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileSearchQuery.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileSearchQuery.java
index add0cdc..be3e5c1 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileSearchQuery.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileSearchQuery.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2013 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
@@ -10,6 +10,7 @@
* Juerg Billeter, juergbi@ethz.ch - 47136 Search view should show match objects
* Ulrich Etter, etteru@ethz.ch - 47136 Search view should show match objects
* Roman Fuchs, fuchsro@ethz.ch - 47136 Search view should show match objects
+ * Christian Walther (Indel AG) - Bug 399094: Add whole word option to file search
*******************************************************************************/
package org.eclipse.search.internal.ui.text;
@@ -153,13 +154,20 @@ public class FileSearchQuery implements ISearchQuery {
private final String fSearchText;
private final boolean fIsRegEx;
private final boolean fIsCaseSensitive;
+ private final boolean fIsWholeWord;
private FileSearchResult fResult;
+
public FileSearchQuery(String searchText, boolean isRegEx, boolean isCaseSensitive, FileTextSearchScope scope) {
+ this(searchText, isRegEx, isCaseSensitive, false, scope);
+ }
+
+ public FileSearchQuery(String searchText, boolean isRegEx, boolean isCaseSensitive, boolean isWholeWord, FileTextSearchScope scope) {
fSearchText= searchText;
fIsRegEx= isRegEx;
fIsCaseSensitive= isCaseSensitive;
+ fIsWholeWord= isWholeWord;
fScope= scope;
}
@@ -249,7 +257,7 @@ public class FileSearchQuery implements ISearchQuery {
}
protected Pattern getSearchPattern() {
- return PatternConstructor.createPattern(fSearchText, fIsCaseSensitive, fIsRegEx);
+ return PatternConstructor.createPattern(fSearchText, fIsRegEx, true, fIsCaseSensitive, fIsWholeWord);
}
public boolean isFileNameSearch() {
@@ -264,6 +272,10 @@ public class FileSearchQuery implements ISearchQuery {
return fIsCaseSensitive;
}
+ public boolean isWholeWord() {
+ return fIsWholeWord;
+ }
+
public boolean canRerun() {
return true;
}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/TextSearchPage.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/TextSearchPage.java
index de128fa..89f28e6 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/TextSearchPage.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/TextSearchPage.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2013 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
@@ -10,6 +10,7 @@
* Juerg Billeter, juergbi@ethz.ch - 47136 Search view should show match objects
* Ulrich Etter, etteru@ethz.ch - 47136 Search view should show match objects
* Roman Fuchs, fuchsro@ethz.ch - 47136 Search view should show match objects
+ * Christian Walther (Indel AG) - Bug 399094: Add whole word option to file search
*******************************************************************************/
package org.eclipse.search.internal.ui.text;
@@ -98,6 +99,7 @@ public class TextSearchPage extends DialogPage implements ISearchPage, IReplaceP
private static final String PAGE_NAME= "TextSearchPage"; //$NON-NLS-1$
private static final String STORE_CASE_SENSITIVE= "CASE_SENSITIVE"; //$NON-NLS-1$
private static final String STORE_IS_REG_EX_SEARCH= "REG_EX_SEARCH"; //$NON-NLS-1$
+ private static final String STORE_IS_WHOLE_WORD= "WHOLE_WORD"; //$NON-NLS-1$
private static final String STORE_SEARCH_DERIVED = "SEARCH_DERIVED"; //$NON-NLS-1$
private static final String STORE_HISTORY= "HISTORY"; //$NON-NLS-1$
private static final String STORE_HISTORY_SIZE= "HISTORY_SIZE"; //$NON-NLS-1$
@@ -113,12 +115,14 @@ public class TextSearchPage extends DialogPage implements ISearchPage, IReplaceP
private boolean fFirstTime= true;
private boolean fIsCaseSensitive;
private boolean fIsRegExSearch;
+ private boolean fIsWholeWord;
private boolean fSearchDerived;
private Combo fPattern;
private Button fIsCaseSensitiveCheckbox;
private Combo fExtensions;
private Button fIsRegExCheckbox;
+ private Button fIsWholeWordCheckbox;
private CLabel fStatusLabel;
private Button fSearchDerivedCheckbox;
@@ -137,15 +141,17 @@ public class TextSearchPage extends DialogPage implements ISearchPage, IReplaceP
private static class SearchPatternData {
public final boolean isCaseSensitive;
public final boolean isRegExSearch;
+ public final boolean isWholeWord;
public final String textPattern;
public final String[] fileNamePatterns;
public final int scope;
public final IWorkingSet[] workingSets;
- public SearchPatternData(String textPattern, boolean isCaseSensitive, boolean isRegExSearch, String[] fileNamePatterns, int scope, IWorkingSet[] workingSets) {
+ public SearchPatternData(String textPattern, boolean isCaseSensitive, boolean isRegExSearch, boolean isWholeWord, String[] fileNamePatterns, int scope, IWorkingSet[] workingSets) {
Assert.isNotNull(fileNamePatterns);
this.isCaseSensitive= isCaseSensitive;
this.isRegExSearch= isRegExSearch;
+ this.isWholeWord= isWholeWord;
this.textPattern= textPattern;
this.fileNamePatterns= fileNamePatterns;
this.scope= scope;
@@ -155,6 +161,7 @@ public class TextSearchPage extends DialogPage implements ISearchPage, IReplaceP
public void store(IDialogSettings settings) {
settings.put("ignoreCase", !isCaseSensitive); //$NON-NLS-1$
settings.put("isRegExSearch", isRegExSearch); //$NON-NLS-1$
+ settings.put("isWholeWord", isWholeWord); //$NON-NLS-1$
settings.put("textPattern", textPattern); //$NON-NLS-1$
settings.put("fileNamePatterns", fileNamePatterns); //$NON-NLS-1$
settings.put("scope", scope); //$NON-NLS-1$
@@ -192,8 +199,9 @@ public class TextSearchPage extends DialogPage implements ISearchPage, IReplaceP
int scope= settings.getInt("scope"); //$NON-NLS-1$
boolean isRegExSearch= settings.getBoolean("isRegExSearch"); //$NON-NLS-1$
boolean ignoreCase= settings.getBoolean("ignoreCase"); //$NON-NLS-1$
+ boolean isWholeWord= settings.getBoolean("isWholeWord"); //$NON-NLS-1$
- return new SearchPatternData(textPattern, !ignoreCase, isRegExSearch, fileNamePatterns, scope, workingSets);
+ return new SearchPatternData(textPattern, !ignoreCase, isRegExSearch, isWholeWord, fileNamePatterns, scope, workingSets);
} catch (NumberFormatException e) {
return null;
}
@@ -206,12 +214,14 @@ public class TextSearchPage extends DialogPage implements ISearchPage, IReplaceP
private final String fSearchText;
private final boolean fIsCaseSensitive;
private final boolean fIsRegEx;
+ private final boolean fIsWholeWord;
private final FileTextSearchScope fScope;
- public TextSearchPageInput(String searchText, boolean isCaseSensitive, boolean isRegEx, FileTextSearchScope scope) {
+ public TextSearchPageInput(String searchText, boolean isCaseSensitive, boolean isRegEx, boolean isWholeWord, FileTextSearchScope scope) {
fSearchText= searchText;
fIsCaseSensitive= isCaseSensitive;
fIsRegEx= isRegEx;
+ fIsWholeWord= isWholeWord;
fScope= scope;
}
@@ -227,6 +237,10 @@ public class TextSearchPage extends DialogPage implements ISearchPage, IReplaceP
return fIsRegEx;
}
+ public boolean isWholeWordSearch() {
+ return fIsWholeWord;
+ }
+
public FileTextSearchScope getScope() {
return fScope;
}
@@ -236,7 +250,7 @@ public class TextSearchPage extends DialogPage implements ISearchPage, IReplaceP
private ISearchQuery newQuery() throws CoreException {
SearchPatternData data= getPatternData();
- TextSearchPageInput input= new TextSearchPageInput(data.textPattern, data.isCaseSensitive, data.isRegExSearch, createTextSearchScope());
+ TextSearchPageInput input= new TextSearchPageInput(data.textPattern, data.isCaseSensitive, data.isRegExSearch, data.isWholeWord, createTextSearchScope());
return TextSearchQueryProvider.getPreferred().createQuery(input);
}
@@ -381,6 +395,7 @@ public class TextSearchPage extends DialogPage implements ISearchPage, IReplaceP
getPattern(),
isCaseSensitive(),
fIsRegExCheckbox.getSelection(),
+ fIsWholeWordCheckbox.getSelection(),
getExtensions(),
getContainer().getSelectedScope(),
getContainer().getSelectedWorkingSets());
@@ -480,7 +495,7 @@ public class TextSearchPage extends DialogPage implements ISearchPage, IReplaceP
private boolean validateRegex() {
if (fIsRegExCheckbox.getSelection()) {
try {
- PatternConstructor.createPattern(fPattern.getText(), fIsCaseSensitive, true);
+ PatternConstructor.createPattern(fPattern.getText(), true, true, fIsCaseSensitive, fIsWholeWord);
} catch (PatternSyntaxException e) {
String locMessage= e.getLocalizedMessage();
int i= 0;
@@ -523,7 +538,7 @@ public class TextSearchPage extends DialogPage implements ISearchPage, IReplaceP
}
});
fPattern.setFont(group.getFont());
- GridData data= new GridData(GridData.FILL, GridData.FILL, true, false, 1, 1);
+ GridData data= new GridData(GridData.FILL, GridData.FILL, true, false, 1, 2);
data.widthHint= convertWidthInCharsToPixels(50);
fPattern.setLayoutData(data);
@@ -549,13 +564,6 @@ public class TextSearchPage extends DialogPage implements ISearchPage, IReplaceP
fIsCaseSensitiveCheckbox.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
fIsCaseSensitiveCheckbox.setFont(group.getFont());
- // Text line which explains the special characters
- fStatusLabel= new CLabel(group, SWT.LEAD);
- fStatusLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
- fStatusLabel.setFont(group.getFont());
- fStatusLabel.setAlignment(SWT.LEFT);
- fStatusLabel.setText(SearchMessages.SearchPage_containingText_hint);
-
// RegEx checkbox
fIsRegExCheckbox= new Button(group, SWT.CHECK);
fIsRegExCheckbox.setText(SearchMessages.SearchPage_regularExpression);
@@ -570,8 +578,27 @@ public class TextSearchPage extends DialogPage implements ISearchPage, IReplaceP
fPatterFieldContentAssist.setEnabled(fIsRegExSearch);
}
});
- fIsRegExCheckbox.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
+ fIsRegExCheckbox.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 2));
fIsRegExCheckbox.setFont(group.getFont());
+
+ // Text line which explains the special characters
+ fStatusLabel= new CLabel(group, SWT.LEAD);
+ fStatusLabel.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 1, 2));
+ fStatusLabel.setFont(group.getFont());
+ fStatusLabel.setAlignment(SWT.LEFT);
+ fStatusLabel.setText(SearchMessages.SearchPage_containingText_hint);
+
+ // Whole Word checkbox
+ fIsWholeWordCheckbox= new Button(group, SWT.CHECK);
+ fIsWholeWordCheckbox.setText(SearchMessages.SearchPage_wholeWord);
+ fIsWholeWordCheckbox.setSelection(fIsWholeWord);
+ fIsWholeWordCheckbox.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ fIsWholeWord= fIsWholeWordCheckbox.getSelection();
+ }
+ });
+ fIsWholeWordCheckbox.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
+ fIsWholeWordCheckbox.setFont(group.getFont());
}
private void handleWidgetSelected() {
@@ -585,6 +612,8 @@ public class TextSearchPage extends DialogPage implements ISearchPage, IReplaceP
fIsCaseSensitiveCheckbox.setSelection(patternData.isCaseSensitive);
fIsRegExSearch= patternData.isRegExSearch;
fIsRegExCheckbox.setSelection(fIsRegExSearch);
+ fIsWholeWord= patternData.isWholeWord;
+ fIsWholeWordCheckbox.setSelection(fIsWholeWord);
fPattern.setText(patternData.textPattern);
fPatterFieldContentAssist.setEnabled(fIsRegExSearch);
fFileTypeEditor.setFileTypes(patternData.fileNamePatterns);
@@ -756,6 +785,7 @@ public class TextSearchPage extends DialogPage implements ISearchPage, IReplaceP
IDialogSettings s= getDialogSettings();
fIsCaseSensitive= s.getBoolean(STORE_CASE_SENSITIVE);
fIsRegExSearch= s.getBoolean(STORE_IS_REG_EX_SEARCH);
+ fIsWholeWord= s.getBoolean(STORE_IS_WHOLE_WORD);
fSearchDerived= s.getBoolean(STORE_SEARCH_DERIVED);
try {
@@ -796,6 +826,7 @@ public class TextSearchPage extends DialogPage implements ISearchPage, IReplaceP
IDialogSettings s= getDialogSettings();
s.put(STORE_CASE_SENSITIVE, fIsCaseSensitive);
s.put(STORE_IS_REG_EX_SEARCH, fIsRegExSearch);
+ s.put(STORE_IS_WHOLE_WORD, fIsWholeWord);
s.put(STORE_SEARCH_DERIVED, fSearchDerived);
int historySize= Math.min(fPreviousSearchPatterns.size(), HISTORY_SIZE);