Search in sources :

Example 6 with ILaunch

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;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) BndPreferences(bndtools.preferences.BndPreferences) IStatusHandler(org.eclipse.debug.core.IStatusHandler) ILaunch(org.eclipse.debug.core.ILaunch) IProcess(org.eclipse.debug.core.model.IProcess) IResource(org.eclipse.core.resources.IResource)

Example 7 with ILaunch

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;
}
Also used : MultiStatus(org.eclipse.core.runtime.MultiStatus) IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) IStatus(org.eclipse.core.runtime.IStatus) BndPreferences(bndtools.preferences.BndPreferences) CoreException(org.eclipse.core.runtime.CoreException) IStatusHandler(org.eclipse.debug.core.IStatusHandler) ILaunch(org.eclipse.debug.core.ILaunch) IProcess(org.eclipse.debug.core.model.IProcess) IResource(org.eclipse.core.resources.IResource)

Aggregations

ILaunch (org.eclipse.debug.core.ILaunch)7 ILaunchManager (org.eclipse.debug.core.ILaunchManager)3 IProcess (org.eclipse.debug.core.model.IProcess)3 IProcess2 (org.talend.core.model.process.IProcess2)3 BndPreferences (bndtools.preferences.BndPreferences)2 IResource (org.eclipse.core.resources.IResource)2 IStatus (org.eclipse.core.runtime.IStatus)2 Status (org.eclipse.core.runtime.Status)2 ILaunchConfiguration (org.eclipse.debug.core.ILaunchConfiguration)2 IStatusHandler (org.eclipse.debug.core.IStatusHandler)2 ProjectLauncher (aQute.bnd.build.ProjectLauncher)1 CoreException (org.eclipse.core.runtime.CoreException)1 MultiStatus (org.eclipse.core.runtime.MultiStatus)1 DebugEvent (org.eclipse.debug.core.DebugEvent)1 IDebugEventSetListener (org.eclipse.debug.core.IDebugEventSetListener)1 IDebugTarget (org.eclipse.debug.core.model.IDebugTarget)1 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)1 Point (org.eclipse.swt.graphics.Point)1 SaveJobBeforeRunAction (org.talend.designer.runprocess.ui.actions.SaveJobBeforeRunAction)1