Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDani Megert2015-09-11 13:47:48 +0000
committerDani Megert2015-09-11 13:47:48 +0000
commit8adb5b1fd09f49220df849992b9e5647453275ea (patch)
tree9ec17b3d0d9561e326b50924fada394ba9710737
parentf7be1826b98bdd4c3b0a141ab0435c92fbde1759 (diff)
downloadeclipse.platform.text-8adb5b1fd09f49220df849992b9e5647453275ea.tar.gz
eclipse.platform.text-8adb5b1fd09f49220df849992b9e5647453275ea.tar.xz
eclipse.platform.text-8adb5b1fd09f49220df849992b9e5647453275ea.zip
Fixed bug 475602: No way to search for text with * in text files only
-rw-r--r--org.eclipse.search/META-INF/MANIFEST.MF2
-rw-r--r--org.eclipse.search/new search/org/eclipse/search/ui/text/TextSearchQueryProvider.java12
-rw-r--r--org.eclipse.search/new search/org/eclipse/search2/internal/ui/text2/DefaultTextSearchQueryProvider.java3
-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.properties7
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileSearchQuery.java12
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/text/TextSearchPage.java44
8 files changed, 68 insertions, 18 deletions
diff --git a/org.eclipse.search/META-INF/MANIFEST.MF b/org.eclipse.search/META-INF/MANIFEST.MF
index 71023d213..198757ccd 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.10.100.qualifier
+Bundle-Version: 3.11.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 ea4246f48..7cc4be52f 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
@@ -77,6 +77,18 @@ public abstract class TextSearchQueryProvider {
}
/**
+ * Returns whether binary files are searched.
+ *
+ * This implementation returns <code>false</code>, subclasses can override.
+ *
+ * @return <code>true</code> if binary files are searched
+ * @since 3.11
+ */
+ public boolean searchInBinaries() {
+ 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 8ea251257..4d7adb347 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
@@ -34,8 +34,9 @@ public class DefaultTextSearchQueryProvider extends TextSearchQueryProvider {
boolean regEx= input.isRegExSearch();
boolean caseSensitive= input.isCaseSensitiveSearch();
boolean wholeWord= input.isWholeWordSearch();
+ boolean searchInBinaries= input.searchInBinaries();
Assert.isLegal(!(wholeWord && regEx));
- return new FileSearchQuery(text, regEx, caseSensitive, wholeWord, scope);
+ return new FileSearchQuery(text, regEx, caseSensitive, wholeWord, searchInBinaries, scope);
}
/* (non-Javadoc)
diff --git a/org.eclipse.search/pom.xml b/org.eclipse.search/pom.xml
index 3e368d21d..c23ec27b6 100644
--- a/org.eclipse.search/pom.xml
+++ b/org.eclipse.search/pom.xml
@@ -18,6 +18,6 @@
</parent>
<groupId>org.eclipse.search</groupId>
<artifactId>org.eclipse.search</artifactId>
- <version>3.10.100-SNAPSHOT</version>
+ <version>3.11.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 2c0f9c69a..c54890ddb 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, 2013 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 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
@@ -126,7 +126,9 @@ public final class SearchMessages extends NLS {
public static String TextSearchEngine_statusMessage;
public static String TextSearchPage_replace_querycreationproblem_message;
public static String TextSearchPage_replace_runproblem_message;
+ public static String TextSearchPage_searchIn_label;
public static String TextSearchPage_searchDerived_label;
+ public static String TextSearchPage_searchBinary_label;
public static String TextSearchVisitor_filesearch_task_label;
public static String TextSearchVisitor_patterntoocomplex0;
public static String TextSearchVisitor_progress_updating_job;
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 4eee867ea..71e778e88 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, 2013 IBM Corporation and others.
+# Copyright (c) 2000, 2015 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
@@ -91,7 +91,10 @@ SearchPage_regularExpression= Regular e&xpression
SearchPage_wholeWord= Who&le word
TextSearchEngine_statusMessage= Problems encountered during text search.
-TextSearchPage_searchDerived_label=Consider deri&ved resources
+
+TextSearchPage_searchIn_label=Search In
+TextSearchPage_searchDerived_label=Deri&ved resources
+TextSearchPage_searchBinary_label=&Binary resources
TextSearchVisitor_scanning= Scanning file {1} of {2}: {0}
TextSearchVisitor_error= File ''{1}'' has been skipped, problem while reading: (''{0}'').
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 4b3a8cbe3..6f2ae63e4 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
@@ -215,20 +215,21 @@ public class FileSearchQuery implements ISearchQuery {
private final boolean fIsRegEx;
private final boolean fIsCaseSensitive;
private final boolean fIsWholeWord;
-
private FileSearchResult fResult;
+ private boolean fSearchInBinaries;
public FileSearchQuery(String searchText, boolean isRegEx, boolean isCaseSensitive, FileTextSearchScope scope) {
- this(searchText, isRegEx, isCaseSensitive, false, scope);
+ this(searchText, isRegEx, isCaseSensitive, false, false, scope);
}
- public FileSearchQuery(String searchText, boolean isRegEx, boolean isCaseSensitive, boolean isWholeWord, FileTextSearchScope scope) {
+ public FileSearchQuery(String searchText, boolean isRegEx, boolean isCaseSensitive, boolean isWholeWord, boolean searchInBinaries, FileTextSearchScope scope) {
fSearchText= searchText;
fIsRegEx= isRegEx;
fIsCaseSensitive= isCaseSensitive;
fIsWholeWord= isWholeWord;
fScope= scope;
+ fSearchInBinaries= searchInBinaries;
}
public FileTextSearchScope getSearchScope() {
@@ -244,9 +245,8 @@ public class FileSearchQuery implements ISearchQuery {
textResult.removeAll();
Pattern searchPattern= getSearchPattern();
- boolean searchInBinaries= true; // see bug 229897
- TextSearchResultCollector collector= new TextSearchResultCollector(textResult, isFileNameSearch(), searchInBinaries);
+ TextSearchResultCollector collector= new TextSearchResultCollector(textResult, isFileNameSearch(), fSearchInBinaries);
return TextSearchEngine.create().search(fScope, collector, searchPattern, monitor);
}
@@ -311,7 +311,7 @@ public class FileSearchQuery implements ISearchQuery {
FileTextSearchScope scope= FileTextSearchScope.newSearchScope(new IResource[] { file }, new String[] { "*" }, true); //$NON-NLS-1$
Pattern searchPattern= getSearchPattern();
- TextSearchResultCollector collector= new TextSearchResultCollector(result, isFileNameSearch(), true);
+ TextSearchResultCollector collector= new TextSearchResultCollector(result, isFileNameSearch(), fSearchInBinaries);
return TextSearchEngine.create().search(scope, collector, searchPattern, monitor);
}
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 2ad0bf2e3..cc28a426f 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, 2013 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 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
@@ -37,6 +37,7 @@ import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.core.runtime.Assert;
@@ -101,6 +102,7 @@ public class TextSearchPage extends DialogPage implements ISearchPage, IReplaceP
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_SEARCH_IN_BINARIES = "SEARCH_IN_BINARIES"; //$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$
@@ -117,6 +119,7 @@ public class TextSearchPage extends DialogPage implements ISearchPage, IReplaceP
private boolean fIsRegExSearch;
private boolean fIsWholeWord;
private boolean fSearchDerived;
+ private boolean fSearchBinaries;
private Combo fPattern;
private Button fIsCaseSensitiveCheckbox;
@@ -125,6 +128,7 @@ public class TextSearchPage extends DialogPage implements ISearchPage, IReplaceP
private Button fIsWholeWordCheckbox;
private CLabel fStatusLabel;
private Button fSearchDerivedCheckbox;
+ private Button fSearchBinaryCheckbox;
private ISearchPageContainer fContainer;
private FileTypeEditor fFileTypeEditor;
@@ -215,13 +219,15 @@ public class TextSearchPage extends DialogPage implements ISearchPage, IReplaceP
private final boolean fIsCaseSensitive;
private final boolean fIsRegEx;
private final boolean fIsWholeWord;
+ private final boolean fSearchInBinaries;
private final FileTextSearchScope fScope;
- public TextSearchPageInput(String searchText, boolean isCaseSensitive, boolean isRegEx, boolean isWholeWord, FileTextSearchScope scope) {
+ public TextSearchPageInput(String searchText, boolean isCaseSensitive, boolean isRegEx, boolean isWholeWord, boolean searchInBinaries, FileTextSearchScope scope) {
fSearchText= searchText;
fIsCaseSensitive= isCaseSensitive;
fIsRegEx= isRegEx;
fIsWholeWord= isWholeWord;
+ fSearchInBinaries= searchInBinaries;
fScope= scope;
}
@@ -241,16 +247,21 @@ public class TextSearchPage extends DialogPage implements ISearchPage, IReplaceP
return fIsWholeWord;
}
+ public boolean searchInBinaries() {
+ return fSearchInBinaries;
+ }
+
public FileTextSearchScope getScope() {
return fScope;
}
}
+
//---- Action Handling ------------------------------------------------
private ISearchQuery newQuery() throws CoreException {
SearchPatternData data= getPatternData();
- TextSearchPageInput input= new TextSearchPageInput(data.textPattern, data.isCaseSensitive, data.isRegExSearch, data.isWholeWord && !data.isRegExSearch, createTextSearchScope());
+ TextSearchPageInput input= new TextSearchPageInput(data.textPattern, data.isCaseSensitive, data.isRegExSearch, data.isWholeWord && !data.isRegExSearch, fSearchBinaries, createTextSearchScope());
return TextSearchQueryProvider.getPreferred().createQuery(input);
}
@@ -730,7 +741,13 @@ public class TextSearchPage extends DialogPage implements ISearchPage, IReplaceP
description.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1));
description.setFont(group.getFont());
- fSearchDerivedCheckbox= new Button(group, SWT.CHECK);
+
+ Group searchInGroup= new Group(group, SWT.NONE);
+ searchInGroup.setText(SearchMessages.TextSearchPage_searchIn_label);
+ searchInGroup.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
+ searchInGroup.setLayout(new GridLayout(2, false));
+
+ fSearchDerivedCheckbox= new Button(searchInGroup, SWT.CHECK);
fSearchDerivedCheckbox.setText(SearchMessages.TextSearchPage_searchDerived_label);
fSearchDerivedCheckbox.setSelection(fSearchDerived);
@@ -740,8 +757,21 @@ public class TextSearchPage extends DialogPage implements ISearchPage, IReplaceP
writeConfiguration();
}
});
- fSearchDerivedCheckbox.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1));
- fSearchDerivedCheckbox.setFont(group.getFont());
+ fSearchDerivedCheckbox.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false, 1, 1));
+ fSearchDerivedCheckbox.setFont(searchInGroup.getFont());
+
+ fSearchBinaryCheckbox= new Button(searchInGroup, SWT.CHECK);
+ fSearchBinaryCheckbox.setText(SearchMessages.TextSearchPage_searchBinary_label);
+
+ fSearchBinaryCheckbox.setSelection(fSearchBinaries);
+ fSearchBinaryCheckbox.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ fSearchBinaries= fSearchBinaryCheckbox.getSelection();
+ writeConfiguration();
+ }
+ });
+ fSearchBinaryCheckbox.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false, 1, 1));
+ fSearchBinaryCheckbox.setFont(searchInGroup.getFont());
}
/**
@@ -790,6 +820,7 @@ public class TextSearchPage extends DialogPage implements ISearchPage, IReplaceP
fIsRegExSearch= s.getBoolean(STORE_IS_REG_EX_SEARCH);
fIsWholeWord= s.getBoolean(STORE_IS_WHOLE_WORD);
fSearchDerived= s.getBoolean(STORE_SEARCH_DERIVED);
+ fSearchBinaries= s.getBoolean(STORE_SEARCH_IN_BINARIES);
try {
int historySize= s.getInt(STORE_HISTORY_SIZE);
@@ -831,6 +862,7 @@ public class TextSearchPage extends DialogPage implements ISearchPage, IReplaceP
s.put(STORE_IS_REG_EX_SEARCH, fIsRegExSearch);
s.put(STORE_IS_WHOLE_WORD, fIsWholeWord);
s.put(STORE_SEARCH_DERIVED, fSearchDerived);
+ s.put(STORE_SEARCH_IN_BINARIES, fSearchBinaries);
int historySize= Math.min(fPreviousSearchPatterns.size(), HISTORY_SIZE);
s.put(STORE_HISTORY_SIZE, historySize);

Back to the top