diff options
author | Steven Spungin | 2014-05-29 03:40:54 +0000 |
---|---|---|
committer | Wim Jongman | 2014-05-30 22:51:42 +0000 |
commit | e602a5bfffbc33679367d0a2c71b59e149c0b7ac (patch) | |
tree | c22af668c3daf87e172d9e74a0df003828d08f5b | |
parent | 45816c9039a8696e9449004eb6d15764bbc7ba6e (diff) | |
download | eclipse.platform.ui.tools-e602a5bfffbc33679367d0a2c71b59e149c0b7ac.tar.gz eclipse.platform.ui.tools-e602a5bfffbc33679367d0a2c71b59e149c0b7ac.tar.xz eclipse.platform.ui.tools-e602a5bfffbc33679367d0a2c71b59e149c0b7ac.zip |
Bug 436132 - [target platform search] Clicking the Target platform radio
button freezes the ui for a few seconds before the dialog window with
the job kicks in
Bug 436133 - [target platform search] Clearing cache while search in
progress causes CME
Other notable changes:
Added borders to TableViewers.
Refactored constants for more results hint parameter of
ContributionResultHandler
Change-Id: I31a96a09f8fa6b88794d2897131c097895fd3041
Signed-off-by: Steven Spungin <steven@spungin.tv>
5 files changed, 51 insertions, 15 deletions
diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/common/IClassContributionProvider.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/common/IClassContributionProvider.java index 16f3e60c..a7fd6cdf 100644 --- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/common/IClassContributionProvider.java +++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/common/IClassContributionProvider.java @@ -51,15 +51,27 @@ public interface IClassContributionProvider { } public interface ContributionResultHandler { + // hints for flags paramter + /** + * There are more results to display, but the amount is not known + */ + static public final int MORE_UNKNOWN = -1; + /** + * The operation was canceled. There may be additional results. + */ + static public final int MORE_CANCELED = -2; + public void result(ContributionData data); /** * This method is called at the end of a search. If the search * terminated because maxResults was exceeded, the hint parameter will - * contain the number of additional results, or -1 if there are an - * unspecified number of additional results. + * contain the number of additional results, or MORE_UNKNOWN if there + * are an unspecified number of additional results. + * + * If the search was cancelled, the hint will be MORE_CANCELED * - * No there are no additional results, hint will be 0. + * If there are no additional results, hint will be 0 */ public void moreResults(int hint, Filter filter); } diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/dialogs/AbstractIconDialogWithHardcodedScope.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/dialogs/AbstractIconDialogWithHardcodedScope.java index 8fb47c6d..4304f641 100644 --- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/dialogs/AbstractIconDialogWithHardcodedScope.java +++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/dialogs/AbstractIconDialogWithHardcodedScope.java @@ -155,7 +155,7 @@ public abstract class AbstractIconDialogWithHardcodedScope extends TitleAreaDial new Label(container, SWT.NONE); - viewer = new TableViewer(container, SWT.FULL_SELECTION); + viewer = new TableViewer(container, SWT.FULL_SELECTION | SWT.BORDER); GridData gd = new GridData(GridData.FILL_BOTH); viewer.getControl().setLayoutData(gd); viewer.setContentProvider(new ObservableListContentProvider()); diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/dialogs/FilteredContributionDialog.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/dialogs/FilteredContributionDialog.java index 6ce706ed..5b894dcc 100644 --- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/dialogs/FilteredContributionDialog.java +++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/dialogs/FilteredContributionDialog.java @@ -167,7 +167,11 @@ public abstract class FilteredContributionDialog extends TitleAreaDialog { // dlg.setStatus("More than " + filter.maxResults + // " items were found and have not been displayed"); if (hint != 0) { - dlg.setMessage("More than " + filter.maxResults + " items were found. Not all results have been displayed."); + if (hint == ContributionResultHandler.MORE_CANCELED) { + dlg.setMessage("The search was cancelled. Not all results may have been displayed."); + } else { + dlg.setMessage("More than " + filter.maxResults + " items were found. Not all results have been displayed."); + } } else { dlg.setMessage(""); } @@ -727,7 +731,7 @@ public abstract class FilteredContributionDialog extends TitleAreaDialog { viewerList = new WritableList(); TableViewer oldViewer = viewer; - viewer = new TableViewer(compOptions, SWT.FULL_SELECTION); + viewer = new TableViewer(compOptions, SWT.FULL_SELECTION | SWT.BORDER); if (oldViewer != null) { viewer.getTable().moveAbove(oldViewer.getTable()); oldViewer.getTable().dispose(); diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/resourcelocator/TargetPlatformContributionCollector.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/resourcelocator/TargetPlatformContributionCollector.java index 68a7b704..f4d8c5ba 100644 --- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/resourcelocator/TargetPlatformContributionCollector.java +++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/resourcelocator/TargetPlatformContributionCollector.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Steven Spungin <steven@spungin.tv> - initial API and implementation, Bug 424730, Bug 435625 + * Steven Spungin <steven@spungin.tv> - initial API and implementation, Bug 424730, Bug 435625, Bug 436133, Bug 436132 *******************************************************************************/ package org.eclipse.e4.tools.emf.ui.internal.common.resourcelocator; @@ -25,6 +25,7 @@ import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.zip.ZipEntry; @@ -72,12 +73,13 @@ import org.w3c.dom.NodeList; */ public abstract class TargetPlatformContributionCollector extends ClassContributionCollector { - ArrayList<Entry> cacheEntry = new ArrayList<Entry>(); + CopyOnWriteArrayList<Entry> cacheEntry = new CopyOnWriteArrayList<Entry>(); HashSet<String> cacheBundleId = new HashSet<String>(); HashSet<String> cachePackage = new HashSet<String>(); HashSet<String> cacheLocation = new HashSet<String>(); private Pattern patternFile; protected String cacheName; + protected boolean stopFiltering; static class Entry { String name; @@ -113,14 +115,19 @@ public abstract class TargetPlatformContributionCollector extends ClassContribut int found = 0; boolean more = false; - for (Entry e : cacheEntry) { + stopFiltering = false; + for (Entry e : cacheEntry) { + if (stopFiltering) { + break; + } // Check for FilterEx filters if (filter instanceof FilterEx) { FilterEx filterEx = (FilterEx) filter; IProgressMonitor monitor = filterEx.getProgressMonitor(); if (monitor != null) { if (monitor.isCanceled()) { + stopFiltering = true; break; } else { monitor.subTask("Searching " + e.installLocation); @@ -178,7 +185,7 @@ public abstract class TargetPlatformContributionCollector extends ClassContribut found++; if (found > maxResults) { more = true; - handler.moreResults(-1, filter); + handler.moreResults(ContributionResultHandler.MORE_UNKNOWN, filter); break; } else { handler.result(makeData(e)); @@ -187,7 +194,11 @@ public abstract class TargetPlatformContributionCollector extends ClassContribut } if (!more) { - handler.moreResults(0, filter); + if (stopFiltering) { + handler.moreResults(ContributionResultHandler.MORE_CANCELED, filter); + } else { + handler.moreResults(0, filter); + } } } }); @@ -201,6 +212,7 @@ public abstract class TargetPlatformContributionCollector extends ClassContribut @Override public void clearCache() { + stopFiltering = true; cacheEntry.clear(); cacheBundleId.clear(); cachePackage.clear(); @@ -290,17 +302,22 @@ public abstract class TargetPlatformContributionCollector extends ClassContribut public void run(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { // load workspace projects - for (final IProject pj : PDECore.getWorkspace().getRoot().getProjects()) { + IProject[] projects = PDECore.getWorkspace().getRoot().getProjects(); + IPluginModelBase[] models = TargetPlatformHelper.getPDEState().getTargetModels(); + int total = projects.length + models.length; + monitor.beginTask(Messages.TargetPlatformContributionCollector_updatingTargetPlatformCache + cacheName + ")", total); //$NON-NLS-1$ + + for (final IProject pj : projects) { if (monitor.isCanceled()) { break; } String rootDirectory = pj.getLocation().toOSString(); + monitor.subTask(rootDirectory); + monitor.worked(1); TargetPlatformContributionCollector.this.visit(monitor, FilteredContributionDialog.getBundle(rootDirectory), rootDirectory, new File(rootDirectory)); } // load target platform bundles - IPluginModelBase[] models = TargetPlatformHelper.getPDEState().getTargetModels(); - monitor.beginTask(Messages.TargetPlatformContributionCollector_updatingTargetPlatformCache + cacheName + ")", models.length); //$NON-NLS-1$ for (IPluginModelBase pluginModelBase : models) { monitor.subTask(pluginModelBase.getPluginBase().getId()); monitor.worked(1); @@ -434,6 +451,9 @@ public abstract class TargetPlatformContributionCollector extends ClassContribut protected void visit(IProgressMonitor monitor, String bundleName, String installLocation, File file) { for (File fChild : file.listFiles()) { + if (monitor.isCanceled()) { + break; + } if (fChild.isDirectory()) { visit(monitor, bundleName, installLocation, fChild); } else { diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/resourcelocator/dialogs/FindContributionDialog.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/resourcelocator/dialogs/FindContributionDialog.java index 7a42234e..463bea0b 100644 --- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/resourcelocator/dialogs/FindContributionDialog.java +++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/resourcelocator/dialogs/FindContributionDialog.java @@ -137,7 +137,7 @@ public class FindContributionDialog extends TitleAreaDialog { new Label(container, SWT.NONE); - viewer = new TableViewer(container, SWT.FULL_SELECTION); + viewer = new TableViewer(container, SWT.FULL_SELECTION | SWT.BORDER); GridData gd = new GridData(GridData.FILL_BOTH); viewer.getControl().setLayoutData(gd); viewer.setContentProvider(new ObservableListContentProvider()); |