use of org.eclipse.debug.core.IStatusHandler 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;
}
Aggregations