From 6cd03b77ff666533b43dc862a6a41cb8ba057cb7 Mon Sep 17 00:00:00 2001 From: Alain Magloire Date: Thu, 5 Feb 2004 20:39:07 +0000 Subject: [PATCH] Patch from Chris to catch Cancel exception --- core/org.eclipse.cdt.ui/ChangeLog | 7 +++++++ .../ui/opentype/TypeSearchOperation.java | 21 ++++++++++++------- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/core/org.eclipse.cdt.ui/ChangeLog b/core/org.eclipse.cdt.ui/ChangeLog index 6b876745e14..04151031187 100644 --- a/core/org.eclipse.cdt.ui/ChangeLog +++ b/core/org.eclipse.cdt.ui/ChangeLog @@ -1,3 +1,10 @@ +2004-02-05 Alain Magloire + + Patch from Chris Wiebe + Catch the Cancel exception. + + * src/org/eclipse/cdt/internal/ui/opentype/TypeSearchOperation.java + 2004-02-05 Alain Magloire PR 51221 Reformat Patch from Bogdan base on Thomas Fletcher original patch diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/opentype/TypeSearchOperation.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/opentype/TypeSearchOperation.java index d40ae6416ba..c0f000fa335 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/opentype/TypeSearchOperation.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/opentype/TypeSearchOperation.java @@ -16,11 +16,12 @@ import org.eclipse.cdt.core.search.SearchEngine; import org.eclipse.cdt.internal.core.search.matching.OrPattern; import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.OperationCanceledException; import org.eclipse.jface.operation.IRunnableWithProgress; public class TypeSearchOperation implements IRunnableWithProgress { - - private final TypeSearchResultCollector collector= new TypeSearchResultCollector(); + + private final TypeSearchResultCollector collector = new TypeSearchResultCollector(); private ICSearchScope scope; private IWorkspace workspace; @@ -31,22 +32,28 @@ public class TypeSearchOperation implements IRunnableWithProgress { this.workspace = workspace; this.scope = scope; this.engine = engine; - + // search for namespaces, classes, structs, unions, enums and typedefs pattern = new OrPattern(); pattern.addPattern(SearchEngine.createSearchPattern("*", ICSearchConstants.TYPE, ICSearchConstants.DECLARATIONS, false)); - pattern.addPattern(SearchEngine.createSearchPattern("*", ICSearchConstants.NAMESPACE, ICSearchConstants.DECLARATIONS, false)); + pattern.addPattern( + SearchEngine.createSearchPattern("*", ICSearchConstants.NAMESPACE, ICSearchConstants.DECLARATIONS, false)); pattern.addPattern(SearchEngine.createSearchPattern("*", ICSearchConstants.CLASS, ICSearchConstants.DECLARATIONS, false)); pattern.addPattern(SearchEngine.createSearchPattern("*", ICSearchConstants.STRUCT, ICSearchConstants.DECLARATIONS, false)); - pattern.addPattern(SearchEngine.createSearchPattern("*", ICSearchConstants.CLASS_STRUCT, ICSearchConstants.DECLARATIONS, false)); + pattern.addPattern( + SearchEngine.createSearchPattern("*", ICSearchConstants.CLASS_STRUCT, ICSearchConstants.DECLARATIONS, false)); pattern.addPattern(SearchEngine.createSearchPattern("*", ICSearchConstants.UNION, ICSearchConstants.DECLARATIONS, false)); pattern.addPattern(SearchEngine.createSearchPattern("*", ICSearchConstants.ENUM, ICSearchConstants.DECLARATIONS, false)); pattern.addPattern(SearchEngine.createSearchPattern("*", ICSearchConstants.TYPEDEF, ICSearchConstants.DECLARATIONS, false)); } - + public void run(IProgressMonitor monitor) throws InterruptedException { collector.setProgressMonitor(monitor); - engine.search(workspace, pattern, scope, collector, true); + try { + engine.search(workspace, pattern, scope, collector, true); + } catch (OperationCanceledException e) { + throw new InterruptedException(); + } if (monitor.isCanceled()) { throw new InterruptedException(); }