diff --git a/bundles/org.eclipse.launchbar.core/META-INF/MANIFEST.MF b/bundles/org.eclipse.launchbar.core/META-INF/MANIFEST.MF
index b84817037d6..f28215054bf 100644
--- a/bundles/org.eclipse.launchbar.core/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.launchbar.core/META-INF/MANIFEST.MF
@@ -12,4 +12,5 @@ Require-Bundle: org.eclipse.core.runtime,
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Bundle-ActivationPolicy: lazy
Export-Package: org.eclipse.launchbar.core,
- org.eclipse.launchbar.core.internal;x-friends:="org.eclipse.launchbar.core.tests,org.eclipse.launchbar.ui"
+ org.eclipse.launchbar.core.internal;x-friends:="org.eclipse.launchbar.core.tests,org.eclipse.launchbar.ui",
+ org.eclipse.launchbar.core.launch
diff --git a/bundles/org.eclipse.launchbar.core/plugin.xml b/bundles/org.eclipse.launchbar.core/plugin.xml
index 28ce28378c3..37f566a2016 100644
--- a/bundles/org.eclipse.launchbar.core/plugin.xml
+++ b/bundles/org.eclipse.launchbar.core/plugin.xml
@@ -4,14 +4,20 @@
-
-
+
+
+
+
diff --git a/bundles/org.eclipse.launchbar.core/schema/launchBarContributions.exsd b/bundles/org.eclipse.launchbar.core/schema/launchBarContributions.exsd
index 7edd8c1feb8..aa466cf7c57 100644
--- a/bundles/org.eclipse.launchbar.core/schema/launchBarContributions.exsd
+++ b/bundles/org.eclipse.launchbar.core/schema/launchBarContributions.exsd
@@ -19,11 +19,8 @@
-
-
-
@@ -86,48 +83,7 @@
-
-
-
- A target is the machine you launch on. Typical examples include the local machine we are running on, or remote embedded or server targets.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- The osname property for the connection, i.e. the operating system name, e.g. win32, linux. If not specified, matches all.
-
-
-
-
-
-
- The osarch property for the connection, i.e. the CPU architecture such as x86, armv7. If not specified, matches all.
-
-
-
-
-
-
-
+
Descriptor types and target types map to a launch configuration type. Configurations of that type knows how to launch for the desciptor on targets of that type.
@@ -144,51 +100,11 @@
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Is this the default target type for this descriptor type.
-
-
-
-
-
-
-
-
-
- The config provider knows how to create launch configurations from descriptors. It tracks which configs it has created so that they don't show up as descriptors on their own.
-
-
-
-
-
-
-
-
-
-
-
@@ -204,43 +120,6 @@
-
-
-
- The default config provider is brought in when no other config providers claim a given launch configuration. This entry associates a target type with the launch configuration so that it can be launched on targets of that type.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Is this the default target type for this descriptor type.
-
-
-
-
-
-
diff --git a/bundles/org.eclipse.launchbar.core/src/org/eclipse/launchbar/core/AbstractLaunchConfigProvider.java b/bundles/org.eclipse.launchbar.core/src/org/eclipse/launchbar/core/AbstractLaunchConfigProvider.java
new file mode 100644
index 00000000000..5166e31301e
--- /dev/null
+++ b/bundles/org.eclipse.launchbar.core/src/org/eclipse/launchbar/core/AbstractLaunchConfigProvider.java
@@ -0,0 +1,43 @@
+package org.eclipse.launchbar.core;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.launchbar.core.internal.Activator;
+import org.eclipse.remote.core.IRemoteConnection;
+
+/**
+ * Common launch config provider. Manages creating launch configurations and ensuring
+ * duplicates are managed properly.
+ */
+public abstract class AbstractLaunchConfigProvider implements ILaunchConfigurationProvider {
+
+ private static final String ORIGINAL_NAME = Activator.PLUGIN_ID + ".originalName"; //$NON-NLS-1$
+
+ protected ILaunchConfiguration createLaunchConfiguration(ILaunchDescriptor descriptor, IRemoteConnection target) throws CoreException {
+ ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
+ String name = launchManager.generateLaunchConfigurationName(descriptor.getName());
+ ILaunchConfigurationWorkingCopy workingCopy = getLaunchConfigurationType(descriptor, target).newInstance(null, name);
+
+ populateLaunchConfiguration(descriptor, workingCopy);
+
+ return workingCopy.doSave();
+ }
+
+ protected void populateLaunchConfiguration(ILaunchDescriptor descriptor, ILaunchConfigurationWorkingCopy workingCopy)
+ throws CoreException {
+ // Leave our breadcrumb
+ workingCopy.setAttribute(ORIGINAL_NAME, workingCopy.getName());
+ }
+
+ @Override
+ public boolean ownsLaunchConfiguration(ILaunchConfiguration configuration) throws CoreException {
+ // We created it if it has the same name we created it with.
+ // This covers the case when the config was duplicated.
+ // We can own only one, the original one.
+ return configuration.getAttribute(ORIGINAL_NAME, "").equals(configuration.getName()); //$NON-NLS-1$
+ }
+
+}
diff --git a/bundles/org.eclipse.launchbar.core/src/org/eclipse/launchbar/core/DefaultLaunchConfigProvider.java b/bundles/org.eclipse.launchbar.core/src/org/eclipse/launchbar/core/DefaultLaunchConfigProvider.java
new file mode 100644
index 00000000000..3d647286428
--- /dev/null
+++ b/bundles/org.eclipse.launchbar.core/src/org/eclipse/launchbar/core/DefaultLaunchConfigProvider.java
@@ -0,0 +1,59 @@
+package org.eclipse.launchbar.core;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationType;
+import org.eclipse.remote.core.IRemoteConnection;
+
+/**
+ * The launch config provider for the default descriptor which is the launch config itself.
+ *
+ * Override this class and register an extension if you want to support targets other than the local connection.
+ */
+public class DefaultLaunchConfigProvider implements ILaunchConfigurationProvider {
+
+ @Override
+ public boolean supports(ILaunchDescriptor descriptor, IRemoteConnection target) throws CoreException {
+ // Only supports Local connection
+ return target.getConnectionType().getId().equals("org.eclipse.remote.LocalServices"); //$NON-NLS-1$
+ }
+
+ @Override
+ public ILaunchConfigurationType getLaunchConfigurationType(ILaunchDescriptor descriptor, IRemoteConnection target)
+ throws CoreException {
+ return descriptor.getAdapter(ILaunchConfiguration.class).getType();
+ }
+
+ @Override
+ public ILaunchConfiguration getLaunchConfiguration(ILaunchDescriptor descriptor, IRemoteConnection target)
+ throws CoreException {
+ return descriptor.getAdapter(ILaunchConfiguration.class);
+ }
+
+ @Override
+ public boolean ownsLaunchConfiguration(ILaunchConfiguration configuration) throws CoreException {
+ // If I get here, I own it
+ return true;
+ }
+
+ @Override
+ public Object launchConfigurationAdded(ILaunchConfiguration configuration) throws CoreException {
+ return configuration;
+ }
+
+ @Override
+ public boolean launchConfigurationRemoved(ILaunchConfiguration configuration) throws CoreException {
+ return true;
+ }
+
+ @Override
+ public void launchDescriptorRemoved(ILaunchDescriptor descriptor) throws CoreException {
+ // nothing to do
+ }
+
+ @Override
+ public void launchTargetRemoved(IRemoteConnection target) throws CoreException {
+ // nothing to do
+ }
+
+}
diff --git a/bundles/org.eclipse.launchbar.core/src/org/eclipse/launchbar/core/ILaunchConfigurationProvider.java b/bundles/org.eclipse.launchbar.core/src/org/eclipse/launchbar/core/ILaunchConfigurationProvider.java
index b2be74cb823..84c883942b8 100644
--- a/bundles/org.eclipse.launchbar.core/src/org/eclipse/launchbar/core/ILaunchConfigurationProvider.java
+++ b/bundles/org.eclipse.launchbar.core/src/org/eclipse/launchbar/core/ILaunchConfigurationProvider.java
@@ -1,44 +1,89 @@
/*******************************************************************************
- * Copyright (c) 2014 QNX Software Systems and others.
+ * Copyright (c) 2014, 2015 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Doug Schaefer
+ * QNX Software Systems - initial
*******************************************************************************/
package org.eclipse.launchbar.core;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationType;
-import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.remote.core.IRemoteConnection;
/**
* The provider of launch configurations of a given type for a given descriptor type
* and a given target type.
*
- * It is recommended to extend {@link LaunchConfigurationProvider}
- * instead of implementing this directly.
+ * It is recommended to extend {@link AbstractLaunchConfigProvider} or one of it's
+ * subclasses instead of implementing this directly.
*/
public interface ILaunchConfigurationProvider {
/**
- * Does this provider own this launch configuration. If so, make sure the launch descriptor
- * is properly constructed by sending in a launch object to the launch manager.
- * And return that object.
+ * Does this config provider provide launch configurations for the combination
+ * of descriptor and target.
+ *
+ * Note: this is called when filtering targets for a descriptor. Processing
+ * should be minimal.
+ *
+ * @param descriptor
+ * @param target
+ * @return
+ */
+ boolean supports(ILaunchDescriptor descriptor, IRemoteConnection target) throws CoreException;
+
+ /**
+ * Return the launch configuation type for the descriptor and target.
+ *
+ * @param descriptor
+ * @param target launch configuration type or null if not supported
+ * @return
+ * @throws CoreException
+ */
+ ILaunchConfigurationType getLaunchConfigurationType(ILaunchDescriptor descriptor,
+ IRemoteConnection target) throws CoreException;
+
+ /**
+ * Create a launch configuration for the descriptor to launch on the target.
+ *
+ * @param descriptor the descriptor to create the config for
+ * @param target the target to launch the config on
+ * @return launch configuration
+ * @throws CoreException
+ */
+ ILaunchConfiguration getLaunchConfiguration(ILaunchDescriptor descriptor, IRemoteConnection target)
+ throws CoreException;
+
+ /**
+ * Does this provider own the launch configuration.
+ *
+ * @param configuration launch configuration
+ * @return true if this provider owns the launch configuration
+ * @throws CoreException
+ */
+ boolean ownsLaunchConfiguration(ILaunchConfiguration configuration) throws CoreException;
+
+ /**
+ * A launch configuration has been added.
+ * Return the launch object associated with this configuration and the launch bar manager
+ * will ensure the descriptor is created for it.
*
* @param configuration
- * @return launch object that relates to this config or null it does not own it.
+ * @return whether this provider owns this launch configuration
* @throws CoreException
*/
Object launchConfigurationAdded(ILaunchConfiguration configuration) throws CoreException;
/**
* A launch configuration has been removed.
- * It it fired after launch configuration has been removed from file system, so accessing its attributes won't work.
* This notification can be used to purge internal cache for example.
+ * This method is called after launch configuration has been removed from file system,
+ * so accessing its attributes won't work.
* If provider cannot determine if it owns it it should return false.
*
* @param configuration
@@ -48,21 +93,21 @@ public interface ILaunchConfigurationProvider {
boolean launchConfigurationRemoved(ILaunchConfiguration configuration) throws CoreException;
/**
- * Returns the launch configuration type for configurations created by this provider.
- *
- * @return launch configuration type
- * @throws CoreException
- */
- ILaunchConfigurationType getLaunchConfigurationType() throws CoreException;
-
- /**
- * Create a launch configuration for the descriptor to launch on the target.
+ * A launch descriptor has been removed. Remove any launch configurations that were
+ * created for it.
*
* @param descriptor
- * @param target
- * @return launch configuration
- * @throws CoreException
+ * @throws CoreException
*/
- ILaunchConfiguration createLaunchConfiguration(ILaunchManager launchManager, ILaunchDescriptor descriptor) throws CoreException;
+ void launchDescriptorRemoved(ILaunchDescriptor descriptor) throws CoreException;
+
+ /**
+ * A launch target has been removed. Remove any launch configurations that were created
+ * for it.
+ *
+ * @param target
+ * @throws CoreException
+ */
+ void launchTargetRemoved(IRemoteConnection target) throws CoreException;
}
diff --git a/bundles/org.eclipse.launchbar.core/src/org/eclipse/launchbar/core/LaunchConfigurationProvider.java b/bundles/org.eclipse.launchbar.core/src/org/eclipse/launchbar/core/LaunchConfigurationProvider.java
deleted file mode 100644
index 2d423398597..00000000000
--- a/bundles/org.eclipse.launchbar.core/src/org/eclipse/launchbar/core/LaunchConfigurationProvider.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2014 QNX Software Systems and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Doug Schaefer
- *******************************************************************************/
-package org.eclipse.launchbar.core;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.debug.core.ILaunchManager;
-import org.eclipse.launchbar.core.internal.Activator;
-
-/**
- * A root class for launch configuration providers. Provides the ability to detect launch
- * configurations that it has created.
- */
-public abstract class LaunchConfigurationProvider implements ILaunchConfigurationProvider {
-
- // Used to make sure this is the config we've created
- protected static final String ORIGINAL_NAME = Activator.PLUGIN_ID + ".originalName"; //$NON-NLS-1$
-
- @Override
- public ILaunchConfiguration createLaunchConfiguration(ILaunchManager launchManager, ILaunchDescriptor descriptor) throws CoreException {
- String name = launchManager.generateLaunchConfigurationName(getConfigurationName(descriptor));
- ILaunchConfigurationWorkingCopy wc = getLaunchConfigurationType().newInstance(null, name);
- wc.setAttribute(ORIGINAL_NAME, name);
- populateConfiguration(wc, descriptor);
- return wc.doSave();
- }
-
- /**
- * Potential name for new configurations. Names are still put through the launch manager
- * to ensure they are unique.
- *
- * @param descriptor the launch descriptor triggering the configuration creation
- * @return candidate configuration name
- */
- protected String getConfigurationName(ILaunchDescriptor descriptor) {
- // by default, use the descriptor name
- return descriptor.getName();
- }
-
- /**
- * Populate the new configuration with attributes and resources.
- *
- * @param workingCopy working copy for the new configuration
- * @param descriptor the launch descriptor that triggered the new configuration
- * @throws CoreException
- */
- protected void populateConfiguration(ILaunchConfigurationWorkingCopy workingCopy, ILaunchDescriptor descriptor) throws CoreException {
- // by default, nothing to add
- }
-
- /**
- * Determines if we created this launch configuration. Generally used by the launch configuration
- * add handler to determine if the incoming launch configuration is ours.
- *
- * @param configuration
- * @return do we own this launch configuration
- * @throws CoreException
- */
- protected boolean ownsConfiguration(ILaunchConfiguration configuration) throws CoreException {
- // must be the same config type
- if (!configuration.getType().equals(getLaunchConfigurationType()))
- return false;
-
- // we created it if it has the same name we created it with
- return configuration.getAttribute(ORIGINAL_NAME, "").equals(configuration.getName()); //$NON-NLS-1$
- }
-
-}
diff --git a/bundles/org.eclipse.launchbar.core/src/org/eclipse/launchbar/core/PerTypeLaunchConfigProvider.java b/bundles/org.eclipse.launchbar.core/src/org/eclipse/launchbar/core/PerTypeLaunchConfigProvider.java
new file mode 100644
index 00000000000..c766166e0fe
--- /dev/null
+++ b/bundles/org.eclipse.launchbar.core/src/org/eclipse/launchbar/core/PerTypeLaunchConfigProvider.java
@@ -0,0 +1,115 @@
+/*******************************************************************************
+ * Copyright (c) 2015 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * QNX Software Systems - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.launchbar.core;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationType;
+import org.eclipse.remote.core.IRemoteConnection;
+
+/**
+ * Common launch configuration provider for cases where it provides for a single
+ * connection type and a single launch configuration type.
+ */
+public abstract class PerTypeLaunchConfigProvider extends AbstractLaunchConfigProvider {
+
+ // Map from launch object to launch configuration
+ private Map