Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Vogel2015-10-11 18:01:25 +0000
committerLars Vogel2016-09-09 08:42:58 +0000
commit17c9cb2d257048b6cbfc5a6c7afa89680da4864c (patch)
tree32680f1eecd99dd52c351696f2af168283560be5 /org.eclipse.core.filebuffers
parent0dee869f44d2139c7f5121007528e4c249dee786 (diff)
downloadeclipse.platform.text-17c9cb2d257048b6cbfc5a6c7afa89680da4864c.tar.gz
eclipse.platform.text-17c9cb2d257048b6cbfc5a6c7afa89680da4864c.tar.xz
eclipse.platform.text-17c9cb2d257048b6cbfc5a6c7afa89680da4864c.zip
Bug 479523 - Replace usage of SubProgressMonitor with SubMonitor in
eclipse.platform.text SubProgressMonitor has been deprecated and SubMonitor shows much better performance characteristics and has a simpler API This commit replaces the usage except for Progress which has internal methods for creating SubProgressMonitor, will be handled by another commit Change-Id: I8637366a18fa2f55c8993407f479ed454e0ffe01 Signed-off-by: Lars Vogel <Lars.Vogel@vogella.com>
Diffstat (limited to 'org.eclipse.core.filebuffers')
-rw-r--r--org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/manipulation/ContainerCreator.java38
1 files changed, 12 insertions, 26 deletions
diff --git a/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/manipulation/ContainerCreator.java b/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/manipulation/ContainerCreator.java
index 4dfbaaf1d..b57a918bf 100644
--- a/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/manipulation/ContainerCreator.java
+++ b/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/manipulation/ContainerCreator.java
@@ -20,7 +20,7 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFolder;
@@ -68,7 +68,7 @@ public class ContainerCreator {
IWorkspaceRunnable runnable= new IWorkspaceRunnable() {
@Override
public void run(IProgressMonitor monitor) throws CoreException {
- monitor.beginTask(FileBuffersMessages.ContainerCreator_task_creatingContainer, fContainerFullPath.segmentCount());
+ SubMonitor subMonitor = SubMonitor.convert(monitor, FileBuffersMessages.ContainerCreator_task_creatingContainer, fContainerFullPath.segmentCount());
if (fContainer != null)
return;
@@ -91,7 +91,7 @@ public class ContainerCreator {
if (resource != null) {
if (resource instanceof IContainer) {
fContainer= (IContainer) resource;
- monitor.worked(1);
+ subMonitor.worked(1);
} else {
// fContainerFullPath specifies a file as directory
throw new CoreException(new Status(IStatus.ERROR, FileBuffersPlugin.PLUGIN_ID, IStatus.OK, NLSUtility.format(FileBuffersMessages.ContainerCreator_destinationMustBeAContainer, resource.getFullPath()), null));
@@ -100,15 +100,11 @@ public class ContainerCreator {
else {
if (i == 0) {
IProject projectHandle= createProjectHandle(root, currentSegment);
- IProgressMonitor subMonitor= new SubProgressMonitor(monitor, 1);
- fContainer= createProject(projectHandle, subMonitor);
- subMonitor.done();
+ fContainer= createProject(projectHandle, subMonitor.newChild(1));
}
else {
IFolder folderHandle= createFolderHandle(fContainer, currentSegment);
- IProgressMonitor subMonitor= new SubProgressMonitor(monitor, 1);
- fContainer= createFolder(folderHandle, subMonitor);
- subMonitor.done();
+ fContainer= createFolder(folderHandle, subMonitor.newChild(1));
}
}
}
@@ -138,26 +134,16 @@ public class ContainerCreator {
}
private IProject createProject(IProject projectHandle, IProgressMonitor monitor) throws CoreException {
- monitor.beginTask("", 100);//$NON-NLS-1$
- try {
+ SubMonitor subMonitor= SubMonitor.convert(monitor, 2);
+ projectHandle.create(subMonitor.newChild(1));
- IProgressMonitor subMonitor= new SubProgressMonitor(monitor, 50);
- projectHandle.create(subMonitor);
- subMonitor.done();
-
- if (monitor.isCanceled())
- throw new OperationCanceledException();
-
- subMonitor= new SubProgressMonitor(monitor, 50);
- projectHandle.open(subMonitor);
- subMonitor.done();
+ if (monitor.isCanceled())
+ throw new OperationCanceledException();
- if (monitor.isCanceled())
- throw new OperationCanceledException();
+ projectHandle.open(subMonitor.newChild(1));
- } finally {
- monitor.done();
- }
+ if (monitor.isCanceled())
+ throw new OperationCanceledException();
return projectHandle;
}

Back to the top