diff options
author | Philipp Bumann | 2015-09-18 20:08:49 +0000 |
---|---|---|
committer | Matthias Sohn | 2015-09-21 22:32:44 +0000 |
commit | 9a8d4c9b9856abe9b3e19a89d1a08773d93bd517 (patch) | |
tree | de520bfb899de989facfe905fa4b249e2d4b9dbd | |
parent | 6e4bb5c683663313a0a714593bd90dc9bf6153ea (diff) | |
download | egit-9a8d4c9b9856abe9b3e19a89d1a08773d93bd517.tar.gz egit-9a8d4c9b9856abe9b3e19a89d1a08773d93bd517.tar.xz egit-9a8d4c9b9856abe9b3e19a89d1a08773d93bd517.zip |
Change usage of SubProgressMonitor to SubMonitor in org.eclipse.egit.ui
SubProgressMonitor has bad performance characteristics and SubMonitor
was offered 2007 as replacement for it. Platform recently deprecated
SubProgressMonitor and continues to improve performance of SubMonitor
For the ui.project packages. Other packages will be done in separate
Gerrit reviews, planned for the Eclipse Hamburg Hackathon taking place
right now.
Bug: 477696
Change-Id: I38b3af64621ac2fe905d1f7065cf3cc8cd09d40e
Signed-off-by: Philipp Bumann <bumannp@gmail.com>
-rw-r--r-- | org.eclipse.egit.ui/src/org/eclipse/egit/ui/Activator.java | 13 | ||||
-rw-r--r-- | org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clean/CleanRepositoryPage.java | 11 |
2 files changed, 14 insertions, 10 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/Activator.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/Activator.java index 09834a2bca..57a27d36ce 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/Activator.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/Activator.java @@ -3,6 +3,7 @@ * Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org> * Copyright (C) 2010, Mathias Kinzler <mathias.kinzler@sap.com> * Copyright (C) 2012, Matthias Sohn <matthias.sohn@sap.com> + * Copyright (C) 2015, Philipp Bumann <bumannp@gmail.com> * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -32,7 +33,7 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.SubProgressMonitor; +import org.eclipse.core.runtime.SubMonitor; import org.eclipse.core.runtime.jobs.ISchedulingRule; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.egit.core.RepositoryCache; @@ -430,18 +431,20 @@ public class Activator extends AbstractUIPlugin implements DebugOptionsListener workspace.run(new IWorkspaceRunnable() { @Override public void run(IProgressMonitor m) throws CoreException { - m.beginTask(UIText.Activator_refreshingProjects, + SubMonitor subMonitor = SubMonitor.convert(m, + UIText.Activator_refreshingProjects, toRefresh.size()); for (IProject p : toRefresh) { - if (m.isCanceled()) { + if (subMonitor.isCanceled()) { return; } ISchedulingRule rule = p.getWorkspace().getRuleFactory().refreshRule(p); try { - getJobManager().beginRule(rule, m); + getJobManager().beginRule(rule, subMonitor); // handle missing projects after branch switch if (p.isAccessible()) { - p.refreshLocal(IResource.DEPTH_INFINITE, new SubProgressMonitor(m, 1)); + p.refreshLocal(IResource.DEPTH_INFINITE, + subMonitor.newChild(1)); } } catch (CoreException e) { handleError(UIText.Activator_refreshFailed, e, false); diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clean/CleanRepositoryPage.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clean/CleanRepositoryPage.java index 2b77bb8f19..e9747c2fb4 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clean/CleanRepositoryPage.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clean/CleanRepositoryPage.java @@ -1,5 +1,6 @@ /******************************************************************************* * Copyright (C) 2012, Markus Duft <markus.duft@salomon.at> + * Copyright (C) 2015, Philipp Bumann <bumannp@gmail.com> * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -16,7 +17,7 @@ import java.util.TreeSet; import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.SubProgressMonitor; +import org.eclipse.core.runtime.SubMonitor; import org.eclipse.egit.core.internal.util.ProjectUtil; import org.eclipse.egit.ui.Activator; import org.eclipse.egit.ui.internal.UIText; @@ -258,7 +259,8 @@ public class CleanRepositoryPage extends WizardPage { @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - monitor.beginTask(UIText.CleanRepositoryPage_cleaningItems, IProgressMonitor.UNKNOWN); + SubMonitor subMonitor = SubMonitor.convert(monitor, + UIText.CleanRepositoryPage_cleaningItems, 1); Git git = Git.wrap(repository); CleanCommand command = git.clean().setDryRun(false); @@ -273,12 +275,11 @@ public class CleanRepositoryPage extends WizardPage { try { IProject[] projects = ProjectUtil.getProjectsContaining(repository, itemsToClean); - ProjectUtil.refreshResources(projects, new SubProgressMonitor(monitor, 1)); + ProjectUtil.refreshResources(projects, + subMonitor.newChild(1)); } catch (CoreException e) { // could not refresh... not a "real" problem } - - monitor.done(); } }); } catch (Exception e) { |