From e7a030473706729d279486f3c74aaa324b027c20 Mon Sep 17 00:00:00 2001 From: D Tim Cummings Date: Fri, 29 Mar 2019 09:09:31 +1000 Subject: [PATCH 1/2] Fix compile errors since updates to workspace mechanic in April 2014. --- .../mechanic/ImportProjectTaskScanner.java | 17 +++++++++++------ .../wolips/mechanic/ImportProjectsTask.java | 1 - 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/wolips/core/plugins/org.objectstyle.wolips.mechanic/src/org/objectstyle/wolips/mechanic/ImportProjectTaskScanner.java b/wolips/core/plugins/org.objectstyle.wolips.mechanic/src/org/objectstyle/wolips/mechanic/ImportProjectTaskScanner.java index ce2174f9db..948751425d 100644 --- a/wolips/core/plugins/org.objectstyle.wolips.mechanic/src/org/objectstyle/wolips/mechanic/ImportProjectTaskScanner.java +++ b/wolips/core/plugins/org.objectstyle.wolips.mechanic/src/org/objectstyle/wolips/mechanic/ImportProjectTaskScanner.java @@ -3,7 +3,6 @@ import java.io.BufferedReader; import java.io.File; import java.io.FileReader; -import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.logging.Level; @@ -14,12 +13,13 @@ import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; -import com.google.eclipse.mechanic.DirectoryIteratingTaskScanner; import com.google.eclipse.mechanic.IResourceTaskProvider; import com.google.eclipse.mechanic.IResourceTaskReference; +import com.google.eclipse.mechanic.ListCollector; +import com.google.eclipse.mechanic.ResourceTaskScanner; import com.google.eclipse.mechanic.TaskCollector; -public class ImportProjectTaskScanner extends DirectoryIteratingTaskScanner { +public class ImportProjectTaskScanner extends ResourceTaskScanner { private static final Logger log = Logger.getLogger(ImportProjectsTask.class.getName()); public ImportProjectTaskScanner() { @@ -29,8 +29,13 @@ public ImportProjectTaskScanner() { public void scan(IResourceTaskProvider source, TaskCollector collector) { Pattern variablePattern = Pattern.compile("^#\\s*@(\\S+)\\s+(.*)"); - for (Iterator iterator = source.getTaskReferences(".proj").iterator(); iterator.hasNext();) { - IResourceTaskReference ref = iterator.next(); + // based on example scanner at https://github.com/alfsch/workspacemechanic/ + // source folder: parent/bundles/com.google.eclipse.mechanic/src/ + // source: com/google/eclipse/mechanic/internal/PreferenceFileTaskScanner.java + + ListCollector taskCollector = ListCollector.create(); + source.collectTaskReferences(".proj", taskCollector); + for (IResourceTaskReference ref : taskCollector.get()) { File projectFile = ref.asFile(); try { BufferedReader br = new BufferedReader(new FileReader(projectFile)); @@ -68,7 +73,7 @@ else if (line.startsWith("#")) { } } - collector.add(new ImportProjectsTask(id, title, description, importPaths, reconcile)); + collector.collect(new ImportProjectsTask(id, title, description, importPaths, reconcile)); } finally { br.close(); diff --git a/wolips/core/plugins/org.objectstyle.wolips.mechanic/src/org/objectstyle/wolips/mechanic/ImportProjectsTask.java b/wolips/core/plugins/org.objectstyle.wolips.mechanic/src/org/objectstyle/wolips/mechanic/ImportProjectsTask.java index a4f977c53a..22b95ccae5 100644 --- a/wolips/core/plugins/org.objectstyle.wolips.mechanic/src/org/objectstyle/wolips/mechanic/ImportProjectsTask.java +++ b/wolips/core/plugins/org.objectstyle.wolips.mechanic/src/org/objectstyle/wolips/mechanic/ImportProjectsTask.java @@ -41,7 +41,6 @@ public ImportProjectsTask(String id, String title, String description, List Date: Fri, 29 Mar 2019 10:49:22 +1000 Subject: [PATCH 2/2] Replace deprecated SubProcessMonitor with SubMonitor --- .../objectstyle/wolips/mechanic/ImportProjectsTask.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/wolips/core/plugins/org.objectstyle.wolips.mechanic/src/org/objectstyle/wolips/mechanic/ImportProjectsTask.java b/wolips/core/plugins/org.objectstyle.wolips.mechanic/src/org/objectstyle/wolips/mechanic/ImportProjectsTask.java index 22b95ccae5..992bb8f0a7 100644 --- a/wolips/core/plugins/org.objectstyle.wolips.mechanic/src/org/objectstyle/wolips/mechanic/ImportProjectsTask.java +++ b/wolips/core/plugins/org.objectstyle.wolips.mechanic/src/org/objectstyle/wolips/mechanic/ImportProjectsTask.java @@ -18,7 +18,7 @@ import org.eclipse.core.runtime.IStatus; 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 com.google.eclipse.mechanic.CompositeTask; @@ -128,9 +128,9 @@ public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException { for (IProjectDescription projectDescription : projectDescriptions) { try { IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectDescription.getName()); - monitor.beginTask("Importing " + project.getName() + " ...", 100); - project.create(projectDescription, new SubProgressMonitor(monitor, 30)); - project.open(IResource.BACKGROUND_REFRESH, new SubProgressMonitor(monitor, 70)); + SubMonitor subMonitor = SubMonitor.convert(monitor, "Importing " + project.getName() + " ...", 100); + project.create(projectDescription, subMonitor.split(30)); + project.open(IResource.BACKGROUND_REFRESH, subMonitor.split(70)); } catch (Throwable t) { System.out.println("ImportProjectsTask.run: " + t.getMessage());