diff --git a/team/bundles/org.eclipse.team.core/META-INF/MANIFEST.MF b/team/bundles/org.eclipse.team.core/META-INF/MANIFEST.MF index 0a67c9ef3dc..dddea179e58 100644 --- a/team/bundles/org.eclipse.team.core/META-INF/MANIFEST.MF +++ b/team/bundles/org.eclipse.team.core/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.team.core; singleton:=true -Bundle-Version: 3.10.1000.qualifier +Bundle-Version: 3.10.1100.qualifier Bundle-Activator: org.eclipse.team.internal.core.TeamPlugin Bundle-Vendor: %providerName Bundle-Localization: plugin diff --git a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/AbstractResourceVariantTree.java b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/AbstractResourceVariantTree.java index dd71e4becc6..8b13d9acb53 100644 --- a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/AbstractResourceVariantTree.java +++ b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/AbstractResourceVariantTree.java @@ -28,6 +28,7 @@ import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.SubMonitor; import org.eclipse.osgi.util.NLS; import org.eclipse.team.core.TeamException; import org.eclipse.team.internal.core.Messages; @@ -91,24 +92,18 @@ public IResource[] refresh(IResource[] resources, int depth, IProgressMonitor mo */ protected IResource[] refresh(IResource resource, int depth, IProgressMonitor monitor) throws TeamException { IResource[] changedResources = null; - monitor.beginTask(null, 100); + SubMonitor mon = SubMonitor.convert(monitor, 100); try { - monitor.setTaskName(NLS.bind(Messages.SynchronizationCacheRefreshOperation_0, + mon.setTaskName(NLS.bind(Messages.SynchronizationCacheRefreshOperation_0, resource.getFullPath().makeRelative().toString())); // build the remote tree only if an initial tree hasn't been provided - IResourceVariant tree = fetchVariant(resource, depth, Policy.subMonitorFor(monitor, 70)); + IResourceVariant tree = fetchVariant(resource, depth, mon.split(70)); // update the known remote handles - IProgressMonitor sub = Policy.infiniteSubMonitorFor(monitor, 30); - try { - sub.beginTask(null, 64); - changedResources = collectChanges(resource, tree, depth, Policy.subMonitorFor(sub, 64)); - } finally { - sub.done(); - } + changedResources = collectChanges(resource, tree, depth, mon.split(30)); } finally { - monitor.done(); + mon.done(); } if (changedResources == null) { return new IResource[0]; diff --git a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/BackgroundEventHandler.java b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/BackgroundEventHandler.java index fae376c16e5..de0e05c8f42 100644 --- a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/BackgroundEventHandler.java +++ b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/BackgroundEventHandler.java @@ -21,6 +21,7 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.SubMonitor; import org.eclipse.core.runtime.jobs.IJobChangeEvent; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.core.runtime.jobs.JobChangeAdapter; @@ -368,12 +369,7 @@ protected synchronized boolean isQueueEmpty() { protected IStatus processEvents(IProgressMonitor monitor) { errors.clear(); try { - // It's hard to know how much work is going to happen - // since the queue can grow. Use the current queue size as a hint to - // an infinite progress monitor - monitor.beginTask(null, IProgressMonitor.UNKNOWN); - IProgressMonitor subMonitor = Policy.infiniteSubMonitorFor(monitor, 90); - subMonitor.beginTask(null, 1024); + SubMonitor subMonitor = SubMonitor.convert(monitor, 1024); Event event; timeOfLastDispatch = System.currentTimeMillis(); diff --git a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/InfiniteSubProgressMonitor.java b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/InfiniteSubProgressMonitor.java deleted file mode 100644 index 3b3cd555264..00000000000 --- a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/InfiniteSubProgressMonitor.java +++ /dev/null @@ -1,93 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2017 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.core; - - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.SubProgressMonitor; - -/** - * Provides an infinite progress monitor by subdividing by half repeatedly. - * - * The ticks parameter represents the number of ticks shown in the progress dialog - * (or propogated up to a parent IProgressMonitor). The totalWork parameter provided - * in actually a hint used to determine how work is translated into ticks. - * The number of totalWork that can actually be worked is n*totalWork/2 where - * 2^n = totalWork. What this means is that if you provide a totalWork of 32 (2^5) than - * the maximum number of ticks is 5*32/2 = 80. - */ -public class InfiniteSubProgressMonitor extends SubProgressMonitor { - - int totalWork; - int halfWay; - int currentIncrement; - int nextProgress; - int worked; - - /** - * Constructor for InfiniteSubProgressMonitor. - */ - public InfiniteSubProgressMonitor(IProgressMonitor monitor, int ticks) { - this(monitor, ticks, 0); - } - - /** - * Constructor for InfiniteSubProgressMonitor. - */ - public InfiniteSubProgressMonitor(IProgressMonitor monitor, int ticks, int style) { - super(monitor, ticks, style); - } - - @Override - public void beginTask(String name, int totalWork) { - super.beginTask(name, totalWork); - this.totalWork = totalWork; - this.halfWay = totalWork / 2; - this.currentIncrement = 1; - this.nextProgress = currentIncrement; - this.worked = 0; - } - - @Override - public void worked(int work) { - if (worked >= totalWork) { - return; - } - if (--nextProgress <= 0) { - super.worked(1); - worked++; - if (worked >= halfWay) { - // we have passed the current halfway point, so double the - // increment and reset the halfway point. - currentIncrement *= 2; - halfWay += (totalWork - halfWay) / 2; - } - // reset the progress counter to another full increment - nextProgress = currentIncrement; - } - } - - /** - * Don't allow clearing of the subtask. This will stop the flickering - * of the subtask in the progress dialogs. - * - * @see IProgressMonitor#subTask(String) - */ - @Override - public void subTask(String name) { - if(name != null && ! name.isEmpty()) { - super.subTask(name); - } - } -} diff --git a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/Policy.java b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/Policy.java index 02f924fb1ba..55b914a48fb 100644 --- a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/Policy.java +++ b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/Policy.java @@ -63,13 +63,4 @@ public static IProgressMonitor subMonitorFor(IProgressMonitor monitor, int ticks return SubMonitor.convert(monitor, ticks); } - public static IProgressMonitor infiniteSubMonitorFor(IProgressMonitor monitor, int ticks) { - if (monitor == null) { - return new NullProgressMonitor(); - } - if (monitor instanceof NullProgressMonitor) { - return monitor; - } - return new InfiniteSubProgressMonitor(monitor, ticks); - } } diff --git a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SubscriberSyncInfoEventHandler.java b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SubscriberSyncInfoEventHandler.java index 3cf305c6b30..acdd1b8352c 100644 --- a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SubscriberSyncInfoEventHandler.java +++ b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SubscriberSyncInfoEventHandler.java @@ -20,7 +20,8 @@ import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.OperationCanceledException; -import org.eclipse.core.runtime.SubProgressMonitor; +import org.eclipse.core.runtime.ProgressMonitorWrapper; +import org.eclipse.core.runtime.SubMonitor; import org.eclipse.team.core.ITeamStatus; import org.eclipse.team.core.TeamException; import org.eclipse.team.core.TeamStatus; @@ -110,11 +111,11 @@ protected void collectAll( int depth, IProgressMonitor monitor) { - monitor.beginTask(null, IProgressMonitor.UNKNOWN); + SubMonitor subMonitor = SubMonitor.convert(monitor); try { // Create a monitor that will handle preemption and dispatch if required - IProgressMonitor collectionMonitor = new SubProgressMonitor(monitor, IProgressMonitor.UNKNOWN) { + IProgressMonitor collectionMonitor = new ProgressMonitorWrapper(subMonitor) { boolean dispatching = false; @Override public void subTask(String name) {