diff options
author | Darin Wright | 2004-11-12 15:28:45 +0000 |
---|---|---|
committer | Darin Wright | 2004-11-12 15:28:45 +0000 |
commit | 5eb38352398563fc82a46e288ec355f52c9f07c0 (patch) | |
tree | bf5c0ab644df634c5149b8c1ca92592794d121b6 | |
parent | da7d5634be836fef6d88792468e0e3f18324f384 (diff) | |
download | eclipse.platform.debug-5eb38352398563fc82a46e288ec355f52c9f07c0.tar.gz eclipse.platform.debug-5eb38352398563fc82a46e288ec355f52c9f07c0.tar.xz eclipse.platform.debug-5eb38352398563fc82a46e288ec355f52c9f07c0.zip |
Bug 67439 - Support for hidden launches so they don't show in launch view.
6 files changed, 135 insertions, 12 deletions
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/core/ILaunchConfiguration.java b/org.eclipse.debug.core/core/org/eclipse/debug/core/ILaunchConfiguration.java index 1c5470af6..c66b224af 100644 --- a/org.eclipse.debug.core/core/org/eclipse/debug/core/ILaunchConfiguration.java +++ b/org.eclipse.debug.core/core/org/eclipse/debug/core/ILaunchConfiguration.java @@ -120,6 +120,8 @@ public interface ILaunchConfiguration extends IAdaptable { * delegate does not implement <code>ILaunchConfigurationDelegate2</code> * an incremental workspace build will be performed before the launch * by the debug platform. + * </p> + * <p> * The resulting launch object is registered with the launch manager * before passing it to this configuration's delegate launch method, for * contributions (debug targets and processes). @@ -148,6 +150,53 @@ public interface ILaunchConfiguration extends IAdaptable { public ILaunch launch(String mode, IProgressMonitor monitor, boolean build) throws CoreException; /** + * Launches this configuration in the specified mode by delegating to + * this configuration's launch configuration delegate, and returns the + * resulting launch. + * <p> + * If this configuration's launch delegate implements + * <code>ILaunchConfigurationDelegate2</code>, the launch delegate will + * be consulted to provide a launch object for the launch, + * perform pre-launch checks, and build before the launch. + * If <code>build</code> is <code>true</code> and the associated launch + * delegate does not implement <code>ILaunchConfigurationDelegate2</code> + * an incremental workspace build will be performed before the launch + * by the debug platform. + * </p> + * <p> + * When <code>register</code> is <code>true</code>, the resulting launch object + * is registered with the launch manager before passing it to this configuration's delegate + * launch method, for contributions (debug targets and processes). When + * <code>register</code> is <code>false</code>, the launch is not registered with + * the launch manager. Clients that launch configurations without registering + * a launch should register appropiate debug event filters to intercept events + * from unregistered launches. + * </p> + * <p> + * If the delegate contributes a source locator to the launch, that + * source locator is used. Otherwise an appropriate source locator is + * contributed to the launch based on the values of + * <code>ATTR_SOURCE_LOCATOR_ID</code> and + * <code>ATTR_SOURCE_LOCATOR_MEMENTO</code>. If the launch is cancelled (via + * the given progress monitor), the launch is removed from the launch + * manager. The launch is returned whether cancelled or not. Invoking this + * method causes the underlying launch configuration delegate to be + * instantiated (if not already). + * </p> + * @param mode the mode in which to launch, one of the mode constants + * defined by <code>ILaunchManager</code> - <code>RUN_MODE</code> or <code>DEBUG_MODE</code>. + * @param monitor progress monitor, or <code>null</code>. Since 3.0, this + * parameter is ignored. A cancellable progress monitor is provided by the Job + * framework. + * @param build whether the workspace should be built before the launch + * @param register whether to register the resulting launch with the launch manager + * @return resulting launch + * @throws CoreException if an exception occurrs during the launch sequence + * @since 3.1 + */ + public ILaunch launch(String mode, IProgressMonitor monitor, boolean build, boolean register) throws CoreException; + + /** * Returns whether this launch configuration supports the * specified mode. This is a handle-only method. * diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/core/ILaunchManager.java b/org.eclipse.debug.core/core/org/eclipse/debug/core/ILaunchManager.java index feb52866d..cc399f081 100644 --- a/org.eclipse.debug.core/core/org/eclipse/debug/core/ILaunchManager.java +++ b/org.eclipse.debug.core/core/org/eclipse/debug/core/ILaunchManager.java @@ -407,6 +407,15 @@ public interface ILaunchManager { */ public ISourceContainerType getSourceContainerType(String id); + /** + * Returns whether the given launch is currently registered. + * + * @param launch a launch + * @return whether the launch is currently registered + * @since 3.1 + */ + public boolean isRegistered(ILaunch launch); + } diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfiguration.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfiguration.java index f69c019ac..508f68ab0 100644 --- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfiguration.java +++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfiguration.java @@ -510,6 +510,14 @@ public class LaunchConfiguration extends PlatformObject implements ILaunchConfig * @see org.eclipse.debug.core.ILaunchConfiguration#launch(java.lang.String, org.eclipse.core.runtime.IProgressMonitor, boolean) */ public ILaunch launch(String mode, IProgressMonitor monitor, boolean build) throws CoreException { + return launch(mode, monitor, build, true); + } + + + /* (non-Javadoc) + * @see org.eclipse.debug.core.ILaunchConfiguration#launch(java.lang.String, org.eclipse.core.runtime.IProgressMonitor, boolean, boolean) + */ + public ILaunch launch(String mode, IProgressMonitor monitor, boolean build, boolean register) throws CoreException { // bug 28245 - force the delegate to load in case it is interested in launch notifications ILaunchConfigurationDelegate delegate= getDelegate(mode); ILaunchConfigurationDelegate2 delegate2 = null; @@ -563,7 +571,9 @@ public class LaunchConfiguration extends PlatformObject implements ILaunchConfig } } - getLaunchManager().addLaunch(launch); + if (register) { + getLaunchManager().addLaunch(launch); + } try { initializeSourceLocator(launch); delegate.launch(this, mode, launch, subMonitor); @@ -578,7 +588,6 @@ public class LaunchConfiguration extends PlatformObject implements ILaunchConfig getLaunchManager().removeLaunch(launch); } return launch; - - } + } } diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchManager.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchManager.java index b55c7ceb7..7fdece8d0 100644 --- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchManager.java +++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchManager.java @@ -28,10 +28,12 @@ import java.util.Collection; import java.util.Comparator; import java.util.Enumeration; import java.util.HashMap; +import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Properties; +import java.util.Set; import java.util.Vector; import javax.xml.parsers.DocumentBuilder; @@ -99,6 +101,9 @@ import org.xml.sax.SAXException; * * @see ILaunchManager */ +/** + * LaunchManager + */ public class LaunchManager extends PlatformObject implements ILaunchManager, IResourceChangeListener { /** @@ -160,6 +165,11 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe * Collection of launches */ private Vector fLaunches= new Vector(10); + + /** + * Set of launches for efficient 'isRegistered()' check + */ + private Set fLaunchSet = new HashSet(10); /** * Collection of listeners @@ -364,10 +374,11 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe * @param launch the launch to remove * @return whether the launch was removed */ - protected boolean internalRemoveLaunch(ILaunch launch) { + protected synchronized boolean internalRemoveLaunch(ILaunch launch) { if (launch == null) { return false; } + fLaunchSet.remove(launch); return fLaunches.remove(launch); } @@ -387,14 +398,11 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe getLaunchesNotifier().notify(launches, update); } - /** - * Returns whether the given launch is currently registered. - * - * @param launch a launch - * @return whether the given launch is currently registered + /* (non-Javadoc) + * @see org.eclipse.debug.core.ILaunchManager#isRegistered(org.eclipse.debug.core.ILaunch) */ - protected boolean isRegistered(ILaunch launch) { - return fLaunches.contains(launch); + public synchronized boolean isRegistered(ILaunch launch) { + return fLaunchSet.contains(launch); } /** @@ -453,11 +461,12 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe * @param launch launch to register * @return whether the launch was added */ - protected boolean internalAddLaunch(ILaunch launch) { + protected synchronized boolean internalAddLaunch(ILaunch launch) { if (fLaunches.contains(launch)) { return false; } fLaunches.add(launch); + fLaunchSet.add(launch); return true; } @@ -1809,4 +1818,6 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe initializeLaunchModes(); return (ILaunchMode) fLaunchModes.get(mode); } + + }
\ No newline at end of file diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/AbstractDebugEventHandler.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/AbstractDebugEventHandler.java index e0e686d42..769f3dbcf 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/AbstractDebugEventHandler.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/AbstractDebugEventHandler.java @@ -52,6 +52,11 @@ public abstract class AbstractDebugEventHandler implements IDebugEventSetListene private EventProcessingJob fUpdateJob = new EventProcessingJob(); /** + * Empty event set constant + */ + protected static final DebugEvent[] EMPTY_EVENT_SET = new DebugEvent[0]; + + /** * Job to dispatch debug event sets */ private class EventProcessingJob extends UIJob { @@ -122,6 +127,11 @@ public abstract class AbstractDebugEventHandler implements IDebugEventSetListene if (!isAvailable()) { return; } + // filter events + events = filterEvents(events); + if (events.length == 0) { + return; + } // add the event set to the queue and schedule update synchronized (fEventSetQueue) { fEventSetQueue.add(events); @@ -130,6 +140,16 @@ public abstract class AbstractDebugEventHandler implements IDebugEventSetListene } /** + * Filters the given events before processing. + * + * @param events event set received for processing + * @return events to be processed + */ + protected DebugEvent[] filterEvents(DebugEvent[] events) { + return events; + } + + /** * Updates this view for the given debug events. Unlike * doHandleDebugEvents(DebugEvent[]) which is only called if the view is * visible, this method is always called. This allows the view to perform diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/LaunchViewEventHandler.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/LaunchViewEventHandler.java index fa76ded84..1b0e6af5f 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/LaunchViewEventHandler.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/LaunchViewEventHandler.java @@ -22,7 +22,9 @@ import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.ILaunch; import org.eclipse.debug.core.ILaunchManager; import org.eclipse.debug.core.ILaunchesListener2; +import org.eclipse.debug.core.model.IDebugElement; import org.eclipse.debug.core.model.IDebugTarget; +import org.eclipse.debug.core.model.IProcess; import org.eclipse.debug.core.model.IStackFrame; import org.eclipse.debug.core.model.IThread; import org.eclipse.debug.internal.ui.DebugUIPlugin; @@ -56,6 +58,29 @@ public class LaunchViewEventHandler extends AbstractDebugEventHandler implements } + /* (non-Javadoc) + * @see org.eclipse.debug.internal.ui.views.AbstractDebugEventHandler#filterEvents(org.eclipse.debug.core.DebugEvent[]) + */ + protected DebugEvent[] filterEvents(DebugEvent[] events) { + for (int i = 0; i < events.length; i++) { + DebugEvent event = events[i]; + Object source = event.getSource(); + ILaunch launch = null; + if (source instanceof IDebugElement) { + launch = ((IDebugElement)source).getLaunch(); + } else if (source instanceof IProcess) { + launch = ((IProcess)source).getLaunch(); + } + // we only need to consider the first event, as all events in an event set come + // from the same program + if (DebugPlugin.getDefault().getLaunchManager().isRegistered(launch)) { + return events; + } + return EMPTY_EVENT_SET; + } + return events; + } + /** * @see AbstractDebugEventHandler#doHandleDebugEvents(DebugEvent[]) */ |