Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Vogel2016-09-09 09:12:57 +0000
committerStefan Xenos2016-09-20 12:57:34 +0000
commit553d5cdf11633ddb611e861062fc7561a0f361d2 (patch)
treeedf7ce156c20ab5035c8ae104363ade4da0cc9b2 /org.eclipse.core.filebuffers
parent6540c4c82552458c680d5c01672d0c573db2efd7 (diff)
downloadeclipse.platform.text-553d5cdf11633ddb611e861062fc7561a0f361d2.tar.gz
eclipse.platform.text-553d5cdf11633ddb611e861062fc7561a0f361d2.tar.xz
eclipse.platform.text-553d5cdf11633ddb611e861062fc7561a0f361d2.zip
Bug 479523 - Replace usage of SubProgressMonitor with SubMonitor in
eclipse.platform.text Also using split for automatic cancelation checking Change-Id: I0d78f0071a0b1d25683bd4404b489dd4334c6b5a 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, 8 insertions, 30 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..8045b48be 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.step(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.split(1));
}
else {
IFolder folderHandle= createFolderHandle(fContainer, currentSegment);
- IProgressMonitor subMonitor= new SubProgressMonitor(monitor, 1);
- fContainer= createFolder(folderHandle, subMonitor);
- subMonitor.done();
+ fContainer= createFolder(folderHandle, subMonitor.split(1));
}
}
}
@@ -138,27 +134,9 @@ public class ContainerCreator {
}
private IProject createProject(IProject projectHandle, IProgressMonitor monitor) throws CoreException {
- monitor.beginTask("", 100);//$NON-NLS-1$
- try {
-
- 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();
-
- } finally {
- monitor.done();
- }
-
+ SubMonitor subMonitor= SubMonitor.convert(monitor, 2);
+ projectHandle.create(subMonitor.split(1));
+ projectHandle.open(subMonitor.split(1));
return projectHandle;
}

Back to the top