jruaux 2003/01/10 09:51:53
Modified: Eclipse-Plugin/src/java/org/apache/cactus/eclipse/launcher
CactusLaunchShortcut.java
Log:
Added progress monitor capability
Revision Changes Path
1.20 +66 -12
jakarta-cactus/Eclipse-Plugin/src/java/org/apache/cactus/eclipse/launcher/CactusLaunchShortcut.java
Index: CactusLaunchShortcut.java
===================================================================
RCS file:
/home/cvs/jakarta-cactus/Eclipse-Plugin/src/java/org/apache/cactus/eclipse/launcher/CactusLaunchShortcut.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- CactusLaunchShortcut.java 8 Jan 2003 16:51:51 -0000 1.19
+++ CactusLaunchShortcut.java 10 Jan 2003 17:51:53 -0000 1.20
@@ -65,9 +65,11 @@
import org.apache.cactus.eclipse.ui.CactusPlugin;
import org.apache.cactus.eclipse.ui.CactusPreferences;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunchConfigurationType;
import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.internal.junit.launcher.JUnitLaunchShortcut;
import org.eclipse.jdt.internal.junit.runner.ITestRunListener;
@@ -75,6 +77,7 @@
import org.eclipse.jdt.internal.junit.util.TestSearchEngine;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
/**
* Launch shortcut used to start the Cactus launch configuration on the
@@ -165,8 +168,30 @@
}
if (type != null)
{
- prepareCactusTests(type);
JUnitPlugin.getDefault().addTestRunListener(this);
+ final IJavaProject theJavaProject = type.getJavaProject();
+ ProgressMonitorDialog dialog =
+ new ProgressMonitorDialog(getShell());
+ IRunnableWithProgress runnable = new IRunnableWithProgress()
+ {
+ public void run(IProgressMonitor thePM)
+ throws InterruptedException
+ {
+ prepareCactusTests(theJavaProject, thePM);
+ }
+ };
+ try
+ {
+ dialog.run(true, true, runnable);
+ }
+ catch (InvocationTargetException e)
+ {
+ // TODO: handle exception
+ }
+ catch (InterruptedException e)
+ {
+ // TODO: handle exception (cancel button ?)
+ }
super.launchType(theSearch, theMode);
}
}
@@ -179,24 +204,27 @@
/**
* creates the war file, deploys and launches the container.
- * @param theType the Java file
+ * @param theJavaProject the Java file
+ * @param thePM sdfsdf
*/
- private void prepareCactusTests(IType theType)
+ private void prepareCactusTests(
+ IJavaProject theJavaProject,
+ IProgressMonitor thePM)
{
-
provider = CactusPlugin.getContainerProvider();
try
{
WarBuilder newWar =
new WarBuilder(
- theType.getJavaProject(),
+ theJavaProject,
new File(CactusPreferences.getJarsDir()));
- war = newWar.createWar();
+ war = newWar.createWar(thePM);
provider.deploy(
CactusPreferences.getContextURLPath(),
war.toURL(),
- null);
- provider.start(null);
+ null,
+ thePM);
+ provider.start(null, thePM);
}
catch (CoreException e)
{
@@ -217,13 +245,15 @@
/**
* Stops the container and undeploys (cleans) it.
+ * @param thePM a progress monitor that reflects progress made while tearing
+ * down the container setup
*/
- private void teardownCactusTests()
+ private void teardownCactusTests(IProgressMonitor thePM)
{
try
{
- provider.stop(null);
- provider.undeploy(null, null);
+ provider.stop(null, thePM);
+ provider.undeploy(null, null, thePM);
war.delete();
}
catch (CoreException e)
@@ -241,13 +271,37 @@
{
}
+
/**
* Test run has ended so we tear down the container setup.
* @param theElapsedTime not used here
*/
public void testRunEnded(long theElapsedTime)
{
- teardownCactusTests();
+ ProgressMonitorDialog dialog =
+ new ProgressMonitorDialog(getShell());
+ IRunnableWithProgress runnable = new IRunnableWithProgress()
+ {
+ public void run(IProgressMonitor thePM)
+ throws InterruptedException
+ {
+ teardownCactusTests(thePM);
+ }
+ };
+ try
+ {
+ dialog.run(true, true, runnable);
+ }
+ catch (InvocationTargetException e)
+ {
+ e.printStackTrace();
+ // TODO: handle exception
+ }
+ catch (InterruptedException e)
+ {
+ e.printStackTrace();
+ // TODO: handle exception (cancel button ?)
+ }
}
/**
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>