Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDani Megert2002-08-09 09:12:23 +0000
committerDani Megert2002-08-09 09:12:23 +0000
commit7168730999c557e68df2934a8630a6d2e3b0e023 (patch)
tree1cf2619545874ef85022c81fc269fe62dd65d16e
parent606f29bc0d0818a69fad2f7dd240dc22ff3f54aa (diff)
downloadeclipse.platform.text-7168730999c557e68df2934a8630a6d2e3b0e023.tar.gz
eclipse.platform.text-7168730999c557e68df2934a8630a6d2e3b0e023.tar.xz
eclipse.platform.text-7168730999c557e68df2934a8630a6d2e3b0e023.zip
Fixed bug 15390: Show file count in progress monitor during text search
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/core/text/TextSearchEngine.java8
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/core/text/TextSearchVisitor.java31
2 files changed, 32 insertions, 7 deletions
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/core/text/TextSearchEngine.java b/org.eclipse.search/search/org/eclipse/search/internal/core/text/TextSearchEngine.java
index 78230dbad..cb1f8ae5f 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/core/text/TextSearchEngine.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/core/text/TextSearchEngine.java
@@ -46,9 +46,13 @@ public class TextSearchEngine {
if (!openProjects.isEmpty()) {
int amountOfWork= (new AmountOfWorkCalculator(status)).process(openProjects, scope);
try {
- monitor.beginTask(SearchMessages.getString("TextSearchEngine.scanning"), amountOfWork); //$NON-NLS-1$
+ monitor.beginTask("", amountOfWork); //$NON-NLS-1$
+ if (amountOfWork > 0) {
+ Integer[] args= new Integer[] {new Integer(1), new Integer(amountOfWork)};
+ monitor.setTaskName(SearchMessages.getFormattedString("TextSearchEngine.scanning", args)); //$NON-NLS-1$
+ }
collector.aboutToStart();
- TextSearchVisitor visitor= new TextSearchVisitor(pattern, options, scope, collector, status);
+ TextSearchVisitor visitor= new TextSearchVisitor(pattern, options, scope, collector, status, amountOfWork);
visitor.process(openProjects);
} catch (CoreException ex) {
status.add(ex.getStatus());
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/core/text/TextSearchVisitor.java b/org.eclipse.search/search/org/eclipse/search/internal/core/text/TextSearchVisitor.java
index 714b76099..7a4158586 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/core/text/TextSearchVisitor.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/core/text/TextSearchVisitor.java
@@ -1,5 +1,5 @@
/*
- * (c) Copyright IBM Corp. 2000, 2001.
+ * (c) Copyright IBM Corp. 2000, 2002.
* All Rights Reserved.
*/
package org.eclipse.search.internal.core.text;
@@ -59,12 +59,17 @@ public class TextSearchVisitor extends TypedResourceVisitor {
private IProgressMonitor fProgressMonitor;
private StringMatcher fMatcher;
private String fErrorMessage;
+ private Integer[] fMessageFormatArgs;
+
+ private int fNumberOfScannedFiles;
+ private int fNumberOfFilesToScan;
+ private long fLastUpdateTime;
protected int fPushbackChar;
protected boolean fPushback;
- public TextSearchVisitor(String pattern, String options, ISearchScope scope, ITextSearchResultCollector collector, MultiStatus status) {
+ public TextSearchVisitor(String pattern, String options, ISearchScope scope, ITextSearchResultCollector collector, MultiStatus status, int fileCount) {
super(status);
fPattern= pattern;
fScope= scope;
@@ -77,6 +82,9 @@ public class TextSearchVisitor extends TypedResourceVisitor {
fProgressMonitor= collector.getProgressMonitor();
fMatcher= new StringMatcher(pattern, options.indexOf('i') != -1, false);
+ fNumberOfScannedFiles= 0;
+ fNumberOfFilesToScan= fileCount;
+ fMessageFormatArgs= new Integer[] { new Integer(0), new Integer(fileCount) };
}
public void process(Collection projects) {
@@ -130,6 +138,7 @@ public class TextSearchVisitor extends TypedResourceVisitor {
if (fPattern.length() == 0) {
fCollector.accept(file, "", -1, 0, -1); //$NON-NLS-1$
+ updateProgressMonitor();
return true;
}
@@ -179,13 +188,25 @@ public class TextSearchVisitor extends TypedResourceVisitor {
throw new CoreException(new Status(IStatus.ERROR, SearchUI.PLUGIN_ID, Platform.PLUGIN_ERROR, message, e));
}
finally {
- fProgressMonitor.worked(1);
- if (fProgressMonitor.isCanceled())
- throw new OperationCanceledException(SearchMessages.getString("TextSearchVisitor.canceled")); //$NON-NLS-1$
+ updateProgressMonitor();
}
return true;
}
+ private void updateProgressMonitor() {
+ fNumberOfScannedFiles++;
+ if (fNumberOfScannedFiles < fNumberOfFilesToScan) {
+ if (System.currentTimeMillis() - fLastUpdateTime > 1000) {
+ fMessageFormatArgs[0]= new Integer(fNumberOfScannedFiles+1);
+ fProgressMonitor.setTaskName(SearchMessages.getFormattedString("TextSearchVisitor.scanning", fMessageFormatArgs)); //$NON-NLS-1$
+ fLastUpdateTime= System.currentTimeMillis();
+ }
+ }
+ fProgressMonitor.worked(1);
+ if (fProgressMonitor.isCanceled())
+ throw new OperationCanceledException(SearchMessages.getString("TextSearchVisitor.canceled")); //$NON-NLS-1$
+ }
+
private ITextEditor findDirtyEditorFor(IFile file) {
int i= 0;
while (i < fDirtyEditors.length) {

Back to the top