use of org.eclipse.debug.core.IDebugEventSetListener in project azure-tools-for-java by Microsoft.
the class MavenExecuteAction method launch.
public void launch(IContainer basecon, Callable<?> callback) throws CoreException {
if (basecon == null) {
return;
}
ILaunchConfiguration launchConfiguration = createLaunchConfiguration(basecon);
if (launchConfiguration == null) {
return;
}
ILaunch launch = launchConfiguration.launch(MVN_LAUNCH_MODE, new NullProgressMonitor(), true, true);
DebugPlugin.getDefault().addDebugEventListener(new IDebugEventSetListener() {
@Override
public void handleDebugEvents(DebugEvent[] events) {
for (int i = 0; i < events.length; i++) {
DebugEvent event = events[i];
if (event.getSource() instanceof IProcess && event.getKind() == DebugEvent.TERMINATE) {
IProcess process = (IProcess) event.getSource();
if (launch == process.getLaunch()) {
DebugPlugin.getDefault().removeDebugEventListener(this);
try {
if (process.getExitValue() == 0) {
callback.call();
}
} catch (Exception e) {
e.printStackTrace();
}
return;
}
}
}
}
});
}
use of org.eclipse.debug.core.IDebugEventSetListener in project bndtools by bndtools.
the class AbstractOSGiLaunchDelegate method launch.
@Override
public void launch(ILaunchConfiguration configuration, String mode, final ILaunch launch, IProgressMonitor monitor) throws CoreException {
// Register listener to clean up temp files on exit of launched JVM
final ProjectLauncher launcher = getProjectLauncher();
IDebugEventSetListener listener = new IDebugEventSetListener() {
@Override
public void handleDebugEvents(DebugEvent[] events) {
for (DebugEvent event : events) {
if (event.getKind() == DebugEvent.TERMINATE) {
Object source = event.getSource();
if (source instanceof IProcess) {
ILaunch processLaunch = ((IProcess) source).getLaunch();
if (processLaunch == launch) {
// Not interested in any further events =>
// unregister this listener
DebugPlugin.getDefault().removeDebugEventListener(this);
// *may* cause LinkageErrors.
try {
launcher.cleanup();
} catch (Throwable t) {
logger.logError("Error cleaning launcher temporary files", t);
}
LaunchUtils.endRun((Run) launcher.getProject());
}
}
}
}
}
};
DebugPlugin.getDefault().addDebugEventListener(listener);
// Now actually launch
super.launch(configuration, mode, launch, monitor);
}
use of org.eclipse.debug.core.IDebugEventSetListener in project webtools.servertools by eclipse.
the class PreviewServerBehaviour method addProcessListener.
protected void addProcessListener(final IProcess newProcess) {
if (processListener != null || newProcess == null)
return;
processListener = new IDebugEventSetListener() {
public void handleDebugEvents(DebugEvent[] events) {
if (events != null) {
for (DebugEvent event : events) {
if (newProcess != null && newProcess.equals(event.getSource()) && event.getKind() == DebugEvent.TERMINATE) {
stop(true);
}
}
}
}
};
DebugPlugin.getDefault().addDebugEventListener(processListener);
}
use of org.eclipse.debug.core.IDebugEventSetListener in project liferay-ide by liferay.
the class PortalServerBehavior method addProcessListener.
public void addProcessListener(final IProcess newProcess) {
if (processListener != null || newProcess == null) {
return;
}
processListener = new IDebugEventSetListener() {
@Override
public void handleDebugEvents(DebugEvent[] events) {
if (events != null) {
for (DebugEvent event : events) {
if (newProcess != null && newProcess.equals(event.getSource()) && event.getKind() == DebugEvent.TERMINATE) {
cleanup();
}
}
}
}
};
DebugPlugin.getDefault().addDebugEventListener(processListener);
}
use of org.eclipse.debug.core.IDebugEventSetListener in project jbosstools-openshift by jbosstools.
the class AbstractCDKShutdownController method shutdownViaLaunch.
private void shutdownViaLaunch() throws CoreException {
String args = getShutdownArgs();
String cmd = getCommandLocation();
CDKServer cdk = (CDKServer) getServer().loadAdapter(CDKServer.class, new NullProgressMonitor());
ILaunchConfiguration lc = getServer().getLaunchConfiguration(true, new NullProgressMonitor());
ILaunchConfigurationWorkingCopy lc2 = new CDKLaunchUtility().createExternalToolsLaunch(getServer(), args, new Path(cmd).lastSegment(), lc, cmd, cdk.skipUnregistration());
IProcess p = null;
ILaunch launch = null;
try {
launch = lc2.launch("run", new NullProgressMonitor());
IProcess[] all = launch.getProcesses();
if (all.length > 0)
p = all[0];
} catch (CoreException ce) {
CDKCoreActivator.pluginLog().logError(ce);
getBehavior().setServerStarted();
throw new CoreException(new Status(IStatus.ERROR, CDKCoreActivator.PLUGIN_ID, ce.getMessage(), ce));
}
if (p == null) {
getBehavior().setServerStopped();
throw new CoreException(new Status(IStatus.ERROR, CDKCoreActivator.PLUGIN_ID, "Call to shutdown command has failed."));
}
final IProcess myProcess = p;
IDebugEventSetListener listener = (new IDebugEventSetListener() {
public void handleDebugEvents(DebugEvent[] events) {
if (events != null) {
int size = events.length;
for (int i = 0; i < size; i++) {
if (myProcess != null && myProcess.equals(events[i].getSource()) && events[i].getKind() == DebugEvent.TERMINATE) {
processTerminated(getServer(), null);
DebugPlugin.getDefault().removeDebugEventListener(this);
}
}
}
}
});
DebugPlugin.getDefault().addDebugEventListener(listener);
}
Aggregations