summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpelder2007-04-26 11:27:52 (EDT)
committer pelder2007-04-26 11:27:52 (EDT)
commit3cde29a1eb688a6f3e7d04ac2e70f59afe2b0870 (patch)
tree76b526fa4fe4600029895bfd8c2c6e42a8b8c198
parent0f91b6c2fa4c7245c2185569d3c4a825d98190cd (diff)
downloadorg.eclipse.jet-3cde29a1eb688a6f3e7d04ac2e70f59afe2b0870.zip
org.eclipse.jet-3cde29a1eb688a6f3e7d04ac2e70f59afe2b0870.tar.gz
org.eclipse.jet-3cde29a1eb688a6f3e7d04ac2e70f59afe2b0870.tar.bz2
[183457] Use IWorkspace.build and IProject.build instead of joining the auto-build job when a build is required.
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/internal/runtime/ProjectJETBundleProvider.java40
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/taglib/java/JavaActionsUtil.java18
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/taglib/workspace/ActionsUtil.java29
3 files changed, 40 insertions, 47 deletions
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/runtime/ProjectJETBundleProvider.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/runtime/ProjectJETBundleProvider.java
index a06f78c..d494d79 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/runtime/ProjectJETBundleProvider.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/runtime/ProjectJETBundleProvider.java
@@ -33,6 +33,8 @@ import org.eclipse.core.resources.IResourceChangeEvent;
import org.eclipse.core.resources.IResourceChangeListener;
import org.eclipse.core.resources.IResourceDelta;
import org.eclipse.core.resources.IResourceDeltaVisitor;
+import org.eclipse.core.resources.IWorkspaceRunnable;
+import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -279,7 +281,7 @@ public class ProjectJETBundleProvider implements IResourceChangeListener, IJETBu
ProjectJETBundleDescriptor descriptor = (ProjectJETBundleDescriptor)getDescriptor(id);
if (descriptor != null)
{
- if (ensureProjectIsBuilt(monitor))
+ if (ensureProjectIsBuilt(descriptor.getProjectName(), monitor))
{
bundle = InternalJET2Platform.getDefault().getJETBundleInstaller().installBundle(descriptor.getBaseURL());
}
@@ -297,34 +299,20 @@ public class ProjectJETBundleProvider implements IResourceChangeListener, IJETBu
}
}
- /**
- * @param monitor
- */
- private boolean ensureProjectIsBuilt(IProgressMonitor monitor)
- {
- boolean built = true;
- // wait for in-progress auto-build to complete
- IJobManager jobManager = Platform.getJobManager();
- Job[] build = jobManager.find(ResourcesPlugin.FAMILY_AUTO_BUILD);
- if (build.length == 1)
+ private boolean ensureProjectIsBuilt(String name, IProgressMonitor monitor) {
+ try
{
- monitor.beginTask(JET2Messages.ProjectTemplateBundleDescriptor_WaitingForBuild, 1);
- try
- {
- build[0].join();
- }
- catch (InterruptedException e)
- {
- built = false;
- }
- finally
- {
- monitor.done();
- }
+ final IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(name);
+ project.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, monitor);
+ return true;
+ }
+ catch (CoreException e)
+ {
+ e.printStackTrace();
+ return false;
}
- return built;
}
-
+
public void unload(Bundle bundle) throws BundleException
{
if(bundle != null)
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/taglib/java/JavaActionsUtil.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/taglib/java/JavaActionsUtil.java
index 6c76b99..22eb69f 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/taglib/java/JavaActionsUtil.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/taglib/java/JavaActionsUtil.java
@@ -22,7 +22,9 @@ import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.emf.codegen.util.ImportManager;
@@ -73,6 +75,19 @@ public class JavaActionsUtil
return (IFolder)getContainerForPackage(sourceFolder, packageName);
}
+ private static void buildProject(String projectName)
+ {
+ final IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+ try
+ {
+ project.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, new NullProgressMonitor());
+ }
+ catch (CoreException e)
+ {
+ //e.printStackTrace();
+ }
+ }
+
/**
* Return the {@link IFolder} corresponding to the given Java package name.
* @param sourceFolder the source folder containing the package
@@ -98,7 +113,8 @@ public class JavaActionsUtil
if (jElementForFolder == null)
{
// checkpoint the workspace (inform the builders) of our changes to date...
- ActionsUtil.checkpointWorkspace(true, new NullProgressMonitor());
+ ActionsUtil.checkpointWorkspace(false, new NullProgressMonitor());
+ buildProject(sourceFolder.segment(0));
// and try again...
jElementForFolder = JavaCore.create(ResourcesPlugin.getWorkspace().getRoot().findMember(sourceFolder));
}
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/taglib/workspace/ActionsUtil.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/taglib/workspace/ActionsUtil.java
index 6c97483..65b8234 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/taglib/workspace/ActionsUtil.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/taglib/workspace/ActionsUtil.java
@@ -33,16 +33,14 @@ import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.core.runtime.content.IContentDescription;
-import org.eclipse.core.runtime.jobs.IJobManager;
-import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jet.IWriterListener;
import org.eclipse.jet.JET2Writer;
import org.eclipse.jet.internal.l10n.JET2Messages;
@@ -589,24 +587,15 @@ public final class ActionsUtil
private static void waitForBuildToComplete(IProgressMonitor monitor)
{
- // wait for in-progress auto-build to complete
- IJobManager jobManager = Platform.getJobManager();
- Job[] build = jobManager.find(ResourcesPlugin.FAMILY_AUTO_BUILD);
- if (build.length == 1)
+ monitor.beginTask(JET2Messages.ProjectTemplateBundleDescriptor_WaitingForBuild, 1);
+ try {
+ ResourcesPlugin.getWorkspace().build(IncrementalProjectBuilder.INCREMENTAL_BUILD, monitor);
+ }
+ catch (CoreException e)
{
- monitor.beginTask(JET2Messages.ProjectTemplateBundleDescriptor_WaitingForBuild, 1);
- try
- {
- build[0].join();
- }
- catch (InterruptedException e)
- {
- // nothing to do, continue...
- }
- finally
- {
- monitor.done();
- }
+ // XXX should consider doing something here. The build failed...
+ } finally {
+ monitor.done();
}
}