use of org.eclipse.debug.core.ILaunch in project bndtools by bndtools.
the class NativeBndLaunchDelegate method isAlreadyRunning.
/**
* Check if we already have a configuration running
*/
public boolean isAlreadyRunning(ILaunchConfiguration configuration) throws CoreException {
// Check for existing launches of same resource
BndPreferences prefs = new BndPreferences();
if (prefs.getWarnExistingLaunches()) {
IResource launchResource = LaunchUtils.getTargetResource(configuration);
if (launchResource == null)
return false;
int processCount = 0;
for (ILaunch l : DebugPlugin.getDefault().getLaunchManager().getLaunches()) {
// ... is it the same launch resource?
ILaunchConfiguration launchConfig = l.getLaunchConfiguration();
if (launchConfig == null) {
continue;
}
if (launchResource.equals(LaunchUtils.getTargetResource(launchConfig))) {
// Iterate existing processes
for (IProcess process : l.getProcesses()) {
if (!process.isTerminated())
processCount++;
}
}
}
// Warn if existing processes running
if (processCount > 0) {
Status status = new Status(IStatus.WARNING, Plugin.PLUGIN_ID, 0, "One or more OSGi Frameworks have already been launched for this configuration. Additional framework instances may interfere with each other due to the shared storage directory.", null);
IStatusHandler prompter = DebugPlugin.getDefault().getStatusHandler(status);
if (prompter != null) {
boolean okay = (Boolean) prompter.handleStatus(status, launchResource);
return !okay;
}
}
}
return false;
}
use of org.eclipse.debug.core.ILaunch in project bndtools by bndtools.
the class AbstractOSGiLaunchDelegate method finalLaunchCheck.
@Override
public boolean finalLaunchCheck(ILaunchConfiguration configuration, String mode, IProgressMonitor monitor) throws CoreException {
// Check for existing launches of same resource
BndPreferences prefs = new BndPreferences();
if (prefs.getWarnExistingLaunches()) {
IResource launchResource = LaunchUtils.getTargetResource(configuration);
if (launchResource == null)
throw new CoreException(new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, "Bnd launch target was not specified or does not exist.", null));
int processCount = 0;
for (ILaunch l : DebugPlugin.getDefault().getLaunchManager().getLaunches()) {
// ... is it the same launch resource?
ILaunchConfiguration launchConfig = l.getLaunchConfiguration();
if (launchConfig == null) {
continue;
}
if (launchResource.equals(LaunchUtils.getTargetResource(launchConfig))) {
// Iterate existing processes
for (IProcess process : l.getProcesses()) {
if (!process.isTerminated())
processCount++;
}
}
}
// Warn if existing processes running
if (processCount > 0) {
Status status = new Status(IStatus.WARNING, Plugin.PLUGIN_ID, 0, "One or more OSGi Frameworks have already been launched for this configuration. Additional framework instances may interfere with each other due to the shared storage directory.", null);
IStatusHandler prompter = DebugPlugin.getDefault().getStatusHandler(status);
if (prompter != null) {
boolean okay = (Boolean) prompter.handleStatus(status, launchResource);
if (!okay)
return okay;
}
}
}
IStatus launchStatus = getLauncherStatus();
IStatusHandler prompter = DebugPlugin.getDefault().getStatusHandler(launchStatus);
if (prompter != null)
return (Boolean) prompter.handleStatus(launchStatus, run);
return true;
}
Aggregations