diff --git a/bundles/org.eclipse.launchbar.core/schema/launchBarContributions.exsd b/bundles/org.eclipse.launchbar.core/schema/launchBarContributions.exsd index 91f7c5152aa..6fa1fe86532 100644 --- a/bundles/org.eclipse.launchbar.core/schema/launchBarContributions.exsd +++ b/bundles/org.eclipse.launchbar.core/schema/launchBarContributions.exsd @@ -131,6 +131,13 @@ provider with priority 5. Priority 0 is reserved for default provider. + + + + Does the descriptor managed by this config provider support the null target. + + + diff --git a/bundles/org.eclipse.launchbar.core/src/org/eclipse/launchbar/core/ILaunchBarManager.java b/bundles/org.eclipse.launchbar.core/src/org/eclipse/launchbar/core/ILaunchBarManager.java index b80b6ef1734..72d415653bc 100644 --- a/bundles/org.eclipse.launchbar.core/src/org/eclipse/launchbar/core/ILaunchBarManager.java +++ b/bundles/org.eclipse.launchbar.core/src/org/eclipse/launchbar/core/ILaunchBarManager.java @@ -25,20 +25,20 @@ import org.eclipse.launchbar.core.target.ILaunchTarget; public interface ILaunchBarManager extends ILaunchConfigurationListener { /** - * A launch object has been added. Create a matching launch descriptor if available. + * A launch object has been added. Create a matching launch descriptor if + * available. * - * @param element - * launch object + * @param element launch object * @return the launch descriptor that got created, null of none was * @throws CoreException */ ILaunchDescriptor launchObjectAdded(Object launchObject) throws CoreException; /** - * A launch object has been removed. Remove the associated launch descriptor if there is one. + * A launch object has been removed. Remove the associated launch descriptor if + * there is one. * - * @param element - * launch object + * @param element launch object * @throws CoreException */ void launchObjectRemoved(Object launchObject) throws CoreException; @@ -66,37 +66,118 @@ public interface ILaunchBarManager extends ILaunchConfigurationListener { void removeListener(ILaunchBarListener listener); /** - * Return the type id for the given launch descriptor type. This is defined in the extension - * point that defines the type. + * Return the type id for the given launch descriptor type. This is defined in + * the extension point that defines the type. * - * @param descType - * descriptor type + * @param descType descriptor type * @return the type id for the descriptor type */ String getDescriptorTypeId(ILaunchDescriptorType descType) throws CoreException; + /** + * Returns the active launch descriptor. + * + * @return active launch descriptor + * @throws CoreException + */ ILaunchDescriptor getActiveLaunchDescriptor() throws CoreException; - + + /** + * Returns the active launch mode. + * + * @return active launch mode + * @throws CoreException + */ ILaunchMode getActiveLaunchMode() throws CoreException; + /** + * Returns the active launch target. + * + * @return active launch target + * @throws CoreException + */ ILaunchTarget getActiveLaunchTarget() throws CoreException; - + + /** + * Returns the active launch configuration as derived from the active descriptor + * and target. + * + * @return active launch configuration + * @throws CoreException + */ ILaunchConfiguration getActiveLaunchConfiguration() throws CoreException; + /** + * Returns the launch configuration derived from the given launch descriptor and + * target. + * + * @param desc launch descriptor + * @param target launch target + * @return launch configuration + * @throws CoreException + */ ILaunchConfiguration getLaunchConfiguration(ILaunchDescriptor desc, ILaunchTarget target) throws CoreException; - - ILaunchConfigurationType getLaunchConfigurationType(ILaunchDescriptor desc, ILaunchTarget target) throws CoreException; - + + /** + * Returns the launch configuration type used for configurations that are + * derived from the given launch descriptor and launch target without creating a + * launch configuration. + * + * @param desc launch descriptor + * @param target launch target + * @return launch configuration type + * @throws CoreException + */ + ILaunchConfigurationType getLaunchConfigurationType(ILaunchDescriptor desc, ILaunchTarget target) + throws CoreException; + + /** + * Returns all know launch descriptors. + * + * @return launch descriptors + * @throws CoreException + */ ILaunchDescriptor[] getLaunchDescriptors() throws CoreException; - + + /** + * Set the active launch descriptor. + * + * @param desc launch descriptor + * @throws CoreException + */ void setActiveLaunchDescriptor(ILaunchDescriptor desc) throws CoreException; + /** + * Return all launch modes for the active launch descriptor and active launch target. + * + * @return launch modes + * @throws CoreException + */ ILaunchMode[] getLaunchModes() throws CoreException; - + + /** + * Set the active launch mode. + * + * @param mode launch mode + * @throws CoreException + */ void setActiveLaunchMode(ILaunchMode mode) throws CoreException; + /** + * Return all launch targets supported by the given launch descriptor. + * + * @param desc launch descriptor + * @return launch targets + * @throws CoreException + */ ILaunchTarget[] getLaunchTargets(ILaunchDescriptor desc) throws CoreException; - + + /** + * Set the active launch target. + * + * @param target launch target + * @throws CoreException + */ void setActiveLaunchTarget(ILaunchTarget target) throws CoreException; - + } diff --git a/bundles/org.eclipse.launchbar.core/src/org/eclipse/launchbar/core/internal/LaunchBarManager.java b/bundles/org.eclipse.launchbar.core/src/org/eclipse/launchbar/core/internal/LaunchBarManager.java index e7957ecf35f..f496b4e0ef0 100644 --- a/bundles/org.eclipse.launchbar.core/src/org/eclipse/launchbar/core/internal/LaunchBarManager.java +++ b/bundles/org.eclipse.launchbar.core/src/org/eclipse/launchbar/core/internal/LaunchBarManager.java @@ -37,6 +37,7 @@ import org.eclipse.debug.core.ILaunchConfigurationType; import org.eclipse.debug.core.ILaunchListener; import org.eclipse.debug.core.ILaunchManager; import org.eclipse.debug.core.ILaunchMode; +import org.eclipse.launchbar.core.DefaultLaunchDescriptor; import org.eclipse.launchbar.core.ILaunchBarListener; import org.eclipse.launchbar.core.ILaunchBarManager; import org.eclipse.launchbar.core.ILaunchConfigurationProvider; @@ -310,6 +311,14 @@ public class LaunchBarManager implements ILaunchBarManager, ILaunchTargetListene throws CoreException { if (descriptor == null) return null; + + if (descriptor instanceof DefaultLaunchDescriptor) { + // With the default descriptor, we already have the config, just return the type + // Doesn't matter what the target is, that's dealt with at launch time + ILaunchConfiguration config = descriptor.getAdapter(ILaunchConfiguration.class); + return config.getType(); + } + for (LaunchConfigProviderInfo providerInfo : configProviders.get(getDescriptorTypeId(descriptor.getType()))) { if (providerInfo.enabled(descriptor) && providerInfo.enabled(target)) { ILaunchConfigurationProvider provider = providerInfo.getProvider(); @@ -321,6 +330,8 @@ public class LaunchBarManager implements ILaunchBarManager, ILaunchTargetListene } } } + + // not found return null; } @@ -708,6 +719,9 @@ public class LaunchBarManager implements ILaunchBarManager, ILaunchTargetListene targets.add(target); } } + if (supportsNullTarget(descriptor)) { + targets.add(ILaunchTarget.NULL_TARGET); + } return targets.toArray(new ILaunchTarget[targets.size()]); } @@ -727,6 +741,16 @@ public class LaunchBarManager implements ILaunchBarManager, ILaunchTargetListene return false; } + boolean supportsNullTarget(ILaunchDescriptor descriptor) { + String descriptorTypeId = getDescriptorTypeId(descriptor.getType()); + for (LaunchConfigProviderInfo providerInfo : configProviders.get(descriptorTypeId)) { + if (providerInfo.enabled(descriptor) && providerInfo.supportsNullTarget()) { + return true; + } + } + return false; + } + @Override public ILaunchTarget getActiveLaunchTarget() { return activeLaunchTarget; @@ -761,9 +785,8 @@ public class LaunchBarManager implements ILaunchBarManager, ILaunchTargetListene } private void storeLaunchTarget(ILaunchDescriptor desc, ILaunchTarget target) { - if (target == null || target == ILaunchTarget.NULL_TARGET) { - // no point storing null, if stored id is invalid it won't be used - // anyway + if (target == null) { + // Don't store if it's null. Not sure we're null any more anyway. return; } // per desc store, desc can be null means it store globally @@ -807,6 +830,11 @@ public class LaunchBarManager implements ILaunchBarManager, ILaunchTargetListene if (descriptor == null) { return null; } + + if (descriptor instanceof DefaultLaunchDescriptor) { + return descriptor.getAdapter(ILaunchConfiguration.class); + } + String descTypeId = getDescriptorTypeId(descriptor.getType()); for (LaunchConfigProviderInfo providerInfo : configProviders.get(descTypeId)) { try { diff --git a/bundles/org.eclipse.launchbar.core/src/org/eclipse/launchbar/core/internal/LaunchConfigProviderInfo.java b/bundles/org.eclipse.launchbar.core/src/org/eclipse/launchbar/core/internal/LaunchConfigProviderInfo.java index 73c686f2f10..9ee32ead2de 100644 --- a/bundles/org.eclipse.launchbar.core/src/org/eclipse/launchbar/core/internal/LaunchConfigProviderInfo.java +++ b/bundles/org.eclipse.launchbar.core/src/org/eclipse/launchbar/core/internal/LaunchConfigProviderInfo.java @@ -22,6 +22,7 @@ import org.eclipse.launchbar.core.ILaunchConfigurationProvider; public class LaunchConfigProviderInfo { private final String descriptorTypeId; private final int priority; + private final boolean supportsNullTarget; private IConfigurationElement element; private ILaunchConfigurationProvider provider; private Expression expression; @@ -38,6 +39,13 @@ public class LaunchConfigProviderInfo { } priority = priorityNum; + String nullTargetString = element.getAttribute("supportsNullTarget"); //$NON-NLS-1$ + if (nullTargetString != null) { + supportsNullTarget = Boolean.parseBoolean(nullTargetString); + } else { + supportsNullTarget = false; + } + this.element = element; IConfigurationElement[] enabledExpressions = element.getChildren("enablement");//$NON-NLS-1$ @@ -70,6 +78,10 @@ public class LaunchConfigProviderInfo { return priority; } + public boolean supportsNullTarget() { + return supportsNullTarget; + } + public ILaunchConfigurationProvider getProvider() { if (provider == null) { try {