# HG changeset patch # User Milos Kleint # Date 1224155757 -7200 # Node ID 5633764b55e4b1157fc22ff7f53c65bc9731695a # Parent cfeebb6e5701bfdf747d4fccb16cb93e50930301 #110465 use the new api to plug into the rerun build/stop build actions diff -r cfeebb6e5701 -r 5633764b55e4 maven/nbproject/project.xml --- a/maven/nbproject/project.xml Thu Oct 16 13:12:03 2008 +0200 +++ b/maven/nbproject/project.xml Thu Oct 16 13:15:57 2008 +0200 @@ -40,7 +40,6 @@ Version 2 license, then the option applies only if the new code is made subject to such option by the copyright holder. --> - org.netbeans.modules.apisupport.project @@ -204,7 +203,7 @@ 1 - 1.31 + 1.32 diff -r cfeebb6e5701 -r 5633764b55e4 maven/src/org/netbeans/modules/maven/execute/AbstractMavenExecutor.java --- a/maven/src/org/netbeans/modules/maven/execute/AbstractMavenExecutor.java Thu Oct 16 13:12:03 2008 +0200 +++ b/maven/src/org/netbeans/modules/maven/execute/AbstractMavenExecutor.java Thu Oct 16 13:15:57 2008 +0200 @@ -57,6 +57,7 @@ import org.netbeans.modules.maven.api.execute.RunUtils; import org.netbeans.modules.maven.execute.ui.RunGoalsPanel; import org.netbeans.modules.maven.spi.lifecycle.MavenBuildPlanSupport; +import org.netbeans.spi.project.ui.support.BuildExecutionSupport; import org.openide.DialogDescriptor; import org.openide.DialogDisplayer; import org.openide.execution.ExecutorTask; @@ -84,7 +85,8 @@ private List listeners = new ArrayList(); protected ExecutorTask task; private static final Set forbidden = new HashSet(); - + protected MavenItem item; + protected final Object SEMAPHORE = new Object(); static { forbidden.add("netbeans.logger.console"); //NOI18N @@ -123,7 +125,11 @@ public final void setTask(ExecutorTask task) { - this.task = task; + synchronized (SEMAPHORE) { + this.task = task; + this.item = new MavenItem(); + SEMAPHORE.notifyAll(); + } } public final void addInitialMessage(String line, OutputListener listener) { @@ -334,4 +340,25 @@ } } } + + private class MavenItem implements BuildExecutionSupport.Item { + + public String getDisplayName() { + return config.getTaskDisplayName(); + } + + public void repeatExecution() { + RunUtils.executeMaven(config); + } + + public boolean isRunning() { + return !task.isFinished(); + } + + public void stopRunning() { + AbstractMavenExecutor.this.cancel(); + } + + } + } diff -r cfeebb6e5701 -r 5633764b55e4 maven/src/org/netbeans/modules/maven/execute/MavenCommandLineExecutor.java --- a/maven/src/org/netbeans/modules/maven/execute/MavenCommandLineExecutor.java Thu Oct 16 13:12:03 2008 +0200 +++ b/maven/src/org/netbeans/modules/maven/execute/MavenCommandLineExecutor.java Thu Oct 16 13:15:57 2008 +0200 @@ -57,6 +57,7 @@ import org.netbeans.modules.maven.api.execute.ExecutionContext; import org.netbeans.modules.maven.api.execute.ExecutionResultChecker; import org.netbeans.modules.maven.api.execute.LateBoundPrerequisitesChecker; +import org.netbeans.spi.project.ui.support.BuildExecutionSupport; import org.openide.filesystems.FileObject; import org.openide.filesystems.FileUtil; import org.openide.util.Lookup; @@ -88,6 +89,16 @@ * not to be called directrly.. use execute(); */ public void run() { + synchronized (SEMAPHORE) { + if (task == null) { + try { + SEMAPHORE.wait(); + } catch (InterruptedException ex) { + LOGGER.log(Level.FINE, "interrupted", ex); + } + } + } + final RunConfig clonedConfig = new BeanRunConfig(this.config); int executionresult = -10; InputOutput ioput = getInputOutput(); @@ -107,6 +118,8 @@ handle.start(); processInitialMessage(); try { + BuildExecutionSupport.registerRunningItem(item); + out = new CommandLineOutputHandler(ioput, clonedConfig.getProject(), handle, clonedConfig); File workingDir = clonedConfig.getExecutionDirectory(); @@ -172,6 +185,8 @@ } throw death; } finally { + BuildExecutionSupport.registerFinishedItem(item); + try { //defend against badly written extensions.. out.buildFinished(); if (clonedConfig.getProject() != null) { diff -r cfeebb6e5701 -r 5633764b55e4 maven/src/org/netbeans/modules/maven/execute/MavenJavaExecutor.java --- a/maven/src/org/netbeans/modules/maven/execute/MavenJavaExecutor.java Thu Oct 16 13:12:03 2008 +0200 +++ b/maven/src/org/netbeans/modules/maven/execute/MavenJavaExecutor.java Thu Oct 16 13:15:57 2008 +0200 @@ -58,8 +58,6 @@ import org.apache.maven.execution.DefaultMavenExecutionRequest; import org.apache.maven.execution.MavenExecutionRequest; import org.apache.maven.execution.MavenExecutionResult; -import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugin.MojoFailureException; import org.netbeans.api.options.OptionsDisplayer; import org.netbeans.api.progress.ProgressHandle; import org.netbeans.api.progress.ProgressHandleFactory; @@ -75,6 +73,7 @@ import org.netbeans.modules.maven.api.execute.ExecutionContext; import org.netbeans.modules.maven.api.execute.ExecutionResultChecker; import org.netbeans.modules.maven.api.execute.LateBoundPrerequisitesChecker; +import org.netbeans.spi.project.ui.support.BuildExecutionSupport; import org.openide.awt.StatusDisplayer; import org.openide.filesystems.FileObject; import org.openide.filesystems.FileUtil; @@ -111,6 +110,7 @@ handle.addContributor(backupContrib); } + @Override protected boolean isEmbedded() { return true; } @@ -121,6 +121,16 @@ * not to be called directrly.. use execute(); */ public void run() { + synchronized (SEMAPHORE) { + if (task == null) { + try { + SEMAPHORE.wait(); + } catch (InterruptedException ex) { + LOGGER.log(Level.FINE, "interrupted", ex); + } + } + } + finishing = false; RunConfig clonedConfig = new BeanRunConfig(this.config); // check the prerequisites @@ -162,6 +172,8 @@ MavenExecutionRequest req = new DefaultMavenExecutionRequest(); int executionResult = -10; try { + BuildExecutionSupport.registerRunningItem(item); + MavenEmbedder embedder; ProgressTransferListener.setAggregateHandle(handle); out = new JavaOutputHandler(ioput, clonedConfig.getProject(), handle, clonedConfig); @@ -256,6 +268,8 @@ } finally { finishing = true; //#103460 ProgressHandle ph = ProgressHandleFactory.createSystemHandle( "Additional maven build processing"); + BuildExecutionSupport.registerFinishedItem(item); + ph.start(); try { //defend against badly written extensions.. out.buildFinished();