diff --git a/launch/org.eclipse.cdt.launchbar.cdt.core/plugin.xml b/launch/org.eclipse.cdt.launchbar.cdt.core/plugin.xml
index ae90a5929e7..5535690d377 100644
--- a/launch/org.eclipse.cdt.launchbar.cdt.core/plugin.xml
+++ b/launch/org.eclipse.cdt.launchbar.cdt.core/plugin.xml
@@ -1,13 +1,5 @@
-
-
-
diff --git a/launch/org.eclipse.cdt.launchbar.cdt.core/src/org/eclipse/cdt/launchbar/cdt/core/internal/Activator.java b/launch/org.eclipse.cdt.launchbar.cdt.core/src/org/eclipse/cdt/launchbar/cdt/core/internal/Activator.java
index 1ef410fd26f..2ee76bf841d 100644
--- a/launch/org.eclipse.cdt.launchbar.cdt.core/src/org/eclipse/cdt/launchbar/cdt/core/internal/Activator.java
+++ b/launch/org.eclipse.cdt.launchbar.cdt.core/src/org/eclipse/cdt/launchbar/cdt/core/internal/Activator.java
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * 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.cdt.launchbar.cdt.core.internal;
import org.osgi.framework.BundleActivator;
@@ -5,6 +15,8 @@ import org.osgi.framework.BundleContext;
public class Activator implements BundleActivator {
+ public static final String ID = "org.eclipse.cdt.launchbar.cdt.core";
+
private static BundleContext context;
static BundleContext getContext() {
diff --git a/launch/org.eclipse.cdt.launchbar.cdt.core/src/org/eclipse/cdt/launchbar/cdt/core/internal/CDTLaunchConfigDescriptor.java b/launch/org.eclipse.cdt.launchbar.cdt.core/src/org/eclipse/cdt/launchbar/cdt/core/internal/CDTLaunchConfigDescriptor.java
deleted file mode 100644
index 8b3f571755c..00000000000
--- a/launch/org.eclipse.cdt.launchbar.cdt.core/src/org/eclipse/cdt/launchbar/cdt/core/internal/CDTLaunchConfigDescriptor.java
+++ /dev/null
@@ -1,128 +0,0 @@
-package org.eclipse.cdt.launchbar.cdt.core.internal;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
-import org.eclipse.cdt.launchbar.core.ILaunchBarManager;
-import org.eclipse.cdt.launchbar.core.ILaunchConfigurationDescriptor;
-import org.eclipse.cdt.launchbar.core.ILaunchTarget;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
-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.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.debug.core.ILaunchManager;
-import org.eclipse.debug.core.ILaunchMode;
-
-public class CDTLaunchConfigDescriptor implements ILaunchConfigurationDescriptor {
-
- private final ILaunchBarManager manager;
- private String projectName;
- private ILaunchConfiguration config;
- private ILaunchMode[] launchModes;
-
- public CDTLaunchConfigDescriptor(ILaunchBarManager manager, IProject project) {
- this.manager = manager;
- this.projectName = project.getName();
- }
-
- public CDTLaunchConfigDescriptor(ILaunchBarManager manager, ILaunchConfiguration config) {
- this.manager = manager;
- this.config = config;
- }
-
- @Override
- public String getName() {
- if (config != null)
- return config.getName();
- else
- return projectName;
- }
-
- private ILaunchManager getLaunchManager() {
- return DebugPlugin.getDefault().getLaunchManager();
- }
-
- private IProject getProject() {
- return ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
- }
-
- @Override
- public ILaunchConfiguration getLaunchConfiguration() throws CoreException {
- if (config == null) {
- ILaunchConfigurationType configType = config.getType();
- ILaunchConfigurationWorkingCopy wc = configType.newInstance(null, getLaunchManager().generateLaunchConfigurationName(projectName));
- wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, projectName);
- wc.setMappedResources(new IResource[] { getProject() });
- wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, (String) null);
-
- // TODO finish this off
-
- config = wc.doSave();
- }
- return config;
- }
-
- @Override
- public boolean matches(ILaunchConfiguration launchConfiguration) throws CoreException {
- if (config == launchConfiguration)
- return true;
-
- String pname = launchConfiguration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, "");
- return pname.equals(projectName);
- }
-
- @Override
- public ILaunchTarget[] getLaunchTargets() {
- return new ILaunchTarget[] { manager.getLocalLaunchTarget() };
- }
-
- @Override
- public ILaunchTarget getLaunchTarget(String id) {
- ILaunchTarget localTarget = manager.getLocalLaunchTarget();
- if (localTarget.getId().equals(id))
- return localTarget;
- return null;
- }
-
- @Override
- public void setActiveLaunchTarget(ILaunchTarget target) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public ILaunchMode[] getLaunchModes() throws CoreException {
- if (launchModes == null) {
- List mymodes = new ArrayList<>();
- ILaunchConfigurationType type = config.getType();
- ILaunchMode[] modes = DebugPlugin.getDefault().getLaunchManager().getLaunchModes();
- for (ILaunchMode mode : modes) {
- if (type.supportsMode(mode.getIdentifier())) {
- mymodes.add(mode);
- }
- }
- launchModes = mymodes.toArray(new ILaunchMode[mymodes.size()]);
- }
- return launchModes;
- }
-
- @Override
- public ILaunchMode getLaunchMode(String id) throws CoreException {
- for (ILaunchMode mode : getLaunchModes())
- if (mode.getIdentifier().equals(id))
- return mode;
- return null;
- }
-
- @Override
- public void setActiveLaunchMode(ILaunchMode mode) {
- // TODO Auto-generated method stub
-
- }
-
-}
diff --git a/launch/org.eclipse.cdt.launchbar.cdt.core/src/org/eclipse/cdt/launchbar/cdt/core/internal/CDTLaunchConfigProvider.java b/launch/org.eclipse.cdt.launchbar.cdt.core/src/org/eclipse/cdt/launchbar/cdt/core/internal/CDTLaunchConfigProvider.java
deleted file mode 100644
index 523615a1f0f..00000000000
--- a/launch/org.eclipse.cdt.launchbar.cdt.core/src/org/eclipse/cdt/launchbar/cdt/core/internal/CDTLaunchConfigProvider.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package org.eclipse.cdt.launchbar.cdt.core.internal;
-
-import org.eclipse.cdt.launchbar.core.ILaunchBarManager;
-import org.eclipse.cdt.launchbar.core.ILaunchConfigurationDescriptor;
-import org.eclipse.cdt.launchbar.core.ILaunchConfigurationsProvider;
-
-public class CDTLaunchConfigProvider implements ILaunchConfigurationsProvider {
-
- public CDTLaunchConfigProvider() {
- // TODO Auto-generated constructor stub
- }
-
- @Override
- public void init(ILaunchBarManager manager) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public ILaunchConfigurationDescriptor filterDescriptor(ILaunchBarManager manager, ILaunchConfigurationDescriptor descriptor) {
- return descriptor;
- }
-
-}
diff --git a/launch/org.eclipse.cdt.launchbar.core/plugin.xml b/launch/org.eclipse.cdt.launchbar.core/plugin.xml
index 4ccd1a4a5ba..fc378e9d598 100644
--- a/launch/org.eclipse.cdt.launchbar.core/plugin.xml
+++ b/launch/org.eclipse.cdt.launchbar.core/plugin.xml
@@ -1,6 +1,28 @@
-
+
+
+
+
+
+
+
+
+
+
+
diff --git a/launch/org.eclipse.cdt.launchbar.core/schema/launchBarContributions.exsd b/launch/org.eclipse.cdt.launchbar.core/schema/launchBarContributions.exsd
new file mode 100644
index 00000000000..78b8e1abdfe
--- /dev/null
+++ b/launch/org.eclipse.cdt.launchbar.core/schema/launchBarContributions.exsd
@@ -0,0 +1,205 @@
+
+
+
+
+
+
+
+
+ [Enter description of this extension point.]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Is this the default target type for this descriptor type.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ [Enter the first release in which this extension point appears.]
+
+
+
+
+
+
+
+
+ [Enter extension point usage example here.]
+
+
+
+
+
+
+
+
+ [Enter API information here.]
+
+
+
+
+
+
+
+
+ [Enter information about supplied implementation of this extension point.]
+
+
+
+
+
diff --git a/launch/org.eclipse.cdt.launchbar.core/schema/launchConfigProvider.exsd b/launch/org.eclipse.cdt.launchbar.core/schema/launchConfigProvider.exsd
deleted file mode 100644
index 6fba0084105..00000000000
--- a/launch/org.eclipse.cdt.launchbar.core/schema/launchConfigProvider.exsd
+++ /dev/null
@@ -1,109 +0,0 @@
-
-
-
-
-
-
-
-
- [Enter description of this extension point.]
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- [Enter the first release in which this extension point appears.]
-
-
-
-
-
-
-
-
- [Enter extension point usage example here.]
-
-
-
-
-
-
-
-
- [Enter API information here.]
-
-
-
-
-
-
-
-
- [Enter information about supplied implementation of this extension point.]
-
-
-
-
-
diff --git a/launch/org.eclipse.cdt.launchbar.core/src/org/eclipse/cdt/launchbar/core/ILaunchBarManager.java b/launch/org.eclipse.cdt.launchbar.core/src/org/eclipse/cdt/launchbar/core/ILaunchBarManager.java
index 157ef144c3d..da5faf23330 100644
--- a/launch/org.eclipse.cdt.launchbar.core/src/org/eclipse/cdt/launchbar/core/ILaunchBarManager.java
+++ b/launch/org.eclipse.cdt.launchbar.core/src/org/eclipse/cdt/launchbar/core/ILaunchBarManager.java
@@ -13,48 +13,53 @@ package org.eclipse.cdt.launchbar.core;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationType;
import org.eclipse.debug.core.ILaunchMode;
public interface ILaunchBarManager extends IAdaptable {
- ILaunchConfigurationDescriptor[] getLaunchConfigurationDescriptors();
+ ILaunchDescriptor[] getLaunchDescriptors() throws CoreException;
- ILaunchConfigurationDescriptor getActiveLaunchConfigurationDescriptor();
+ ILaunchDescriptor getActiveLaunchDescriptor() throws CoreException;
- void setActiveLaunchConfigurationDescriptor(ILaunchConfigurationDescriptor configDesc) throws CoreException;
-
- void addLaunchConfigurationDescriptor(ILaunchConfigurationDescriptor configDesc) throws CoreException;
-
- void removeLaunchConfigurationDescriptor(ILaunchConfigurationDescriptor configDesc);
-
- ILaunchConfigurationDescriptor getLaunchConfigurationDescriptor(ILaunchConfiguration configuration) throws CoreException;
+ void setActiveLaunchDescriptor(ILaunchDescriptor configDesc) throws CoreException;
- ILaunchMode getActiveLaunchMode();
+ ILaunchMode[] getLaunchModes() throws CoreException;
+
+ ILaunchMode getActiveLaunchMode() throws CoreException;
+
+ void setActiveLaunchMode(ILaunchMode mode) throws CoreException;
+
+ ILaunchTarget[] getLaunchTargets() throws CoreException;
- void setActiveLaunchMode(ILaunchMode mode);
-
- ILaunchTarget getActiveLaunchTarget();
-
- void setActiveLaunchTarget(ILaunchTarget target);
-
- void addLaunchTarget(ILaunchTarget target);
-
- void removeLaunchTarget(ILaunchTarget target);
-
- ILaunchTarget getLocalLaunchTarget();
+ ILaunchTarget getLaunchTarget(String id) throws CoreException;
+
+ ILaunchTarget getActiveLaunchTarget() throws CoreException;
+
+ void setActiveLaunchTarget(ILaunchTarget target) throws CoreException;
+
+ ILaunchConfigurationType getLaunchConfigurationType(ILaunchDescriptor descriptor, ILaunchTarget target) throws CoreException;
+
+ ILaunchConfiguration getLaunchConfiguration(ILaunchDescriptor descriptor, ILaunchTarget target) throws CoreException;
+
+ ILaunchDescriptor launchObjectAdded(Object element) throws CoreException;
+
+ void launchObjectRemoved(Object element) throws CoreException;
interface Listener {
void activeConfigurationDescriptorChanged();
void activeLaunchModeChanged();
-
+
void activeLaunchTargetChanged();
+ void launchDescriptorRemoved(ILaunchDescriptor descriptor);
+
}
void addListener(Listener listener);
-
+
void removeListener(Listener listener);
}
diff --git a/launch/org.eclipse.cdt.launchbar.core/src/org/eclipse/cdt/launchbar/core/ILaunchConfigurationDescriptor.java b/launch/org.eclipse.cdt.launchbar.core/src/org/eclipse/cdt/launchbar/core/ILaunchConfigurationDescriptor.java
deleted file mode 100644
index 3d8a2603d4f..00000000000
--- a/launch/org.eclipse.cdt.launchbar.core/src/org/eclipse/cdt/launchbar/core/ILaunchConfigurationDescriptor.java
+++ /dev/null
@@ -1,92 +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.cdt.launchbar.core;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.ILaunchMode;
-
-public interface ILaunchConfigurationDescriptor {
-
- /**
- * Name to show in the launch configuration selector.
- *
- * @return name of the launch configuration
- */
- String getName();
-
- /**
- * The corresponding launch configuration.
- * If this launch config hasn't been created yet, it will be
- *
- * @return the corresponding launch configuration
- * @throws CoreException
- */
- ILaunchConfiguration getLaunchConfiguration() throws CoreException;
-
- /**
- * Is this launch configuration managed by this descriptor.
- *
- * @param launchConfiguration
- * @return
- * @throws CoreException
- */
- boolean matches(ILaunchConfiguration launchConfiguration) throws CoreException;
-
- /**
- * Return the list of launch targets this configuration can launcht to.
- *
- * @return launch targets
- */
- ILaunchTarget[] getLaunchTargets();
-
- /**
- * Return the launch target with the given id.
- *
- * @param id id of target
- * @return launch target
- */
- ILaunchTarget getLaunchTarget(String id);
-
- /**
- * Set the active launch target. Allows the descriptor to prepare for
- * a launch on that target.
- *
- * @param target the new active launch target
- */
- void setActiveLaunchTarget(ILaunchTarget target);
-
- /**
- * Return the launch modes supported by this descriptor.
- *
- * @return launch modes
- * @throws CoreException
- */
- ILaunchMode[] getLaunchModes() throws CoreException;
-
- /**
- * Returns the launch mode with the given identifier.
- *
- * @param id
- * @return launch mode with id
- * @throws CoreException
- */
- ILaunchMode getLaunchMode(String id) throws CoreException;
-
- /**
- * Set the active launch mode. Allows the descriptor to prepare for a
- * launch in that mode.
- *
- * @param mode the new active launch mode
- */
- void setActiveLaunchMode(ILaunchMode mode);
-
-}
diff --git a/launch/org.eclipse.cdt.launchbar.core/src/org/eclipse/cdt/launchbar/core/ILaunchConfigurationProvider.java b/launch/org.eclipse.cdt.launchbar.core/src/org/eclipse/cdt/launchbar/core/ILaunchConfigurationProvider.java
new file mode 100644
index 00000000000..a028221c710
--- /dev/null
+++ b/launch/org.eclipse.cdt.launchbar.core/src/org/eclipse/cdt/launchbar/core/ILaunchConfigurationProvider.java
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * 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.cdt.launchbar.core;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationType;
+
+public interface ILaunchConfigurationProvider {
+
+ /**
+ * Do any initialization.
+ *
+ * @param manager
+ * @throws CoreException
+ */
+ void init(ILaunchBarManager manager) throws CoreException;
+
+ /**
+ * 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.
+ *
+ * @param configuration
+ * @return
+ * @throws CoreException
+ */
+ boolean ownsLaunchConfiguration(ILaunchConfiguration configuration) throws CoreException;
+
+ /**
+ * Returns the launch configuration type used to launch the descriptor on this target type.
+ *
+ * @param descriptor
+ * @param target
+ * @return launch configuration type
+ * @throws CoreException
+ */
+ ILaunchConfigurationType getLaunchConfigurationType(ILaunchDescriptor descriptor) throws CoreException;
+
+ /**
+ * Create a launch configuration for the descriptor to launch on the target.
+ *
+ * @param descriptor
+ * @param target
+ * @return launch configuration
+ * @throws CoreException
+ */
+ ILaunchConfiguration getLaunchConfiguration(ILaunchDescriptor descriptor) throws CoreException;
+
+ /**
+ * A launch configuration has been removed.
+ *
+ * @param configuration
+ * @throws CoreException
+ */
+ void launchConfigurationRemoved(ILaunchConfiguration configuration) throws CoreException;
+
+}
diff --git a/launch/org.eclipse.cdt.launchbar.core/src/org/eclipse/cdt/launchbar/core/ILaunchDescriptor.java b/launch/org.eclipse.cdt.launchbar.core/src/org/eclipse/cdt/launchbar/core/ILaunchDescriptor.java
new file mode 100644
index 00000000000..9fde3bdac57
--- /dev/null
+++ b/launch/org.eclipse.cdt.launchbar.core/src/org/eclipse/cdt/launchbar/core/ILaunchDescriptor.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * 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.cdt.launchbar.core;
+
+
+/**
+ * Represents a thing that can be launched.
+ */
+public interface ILaunchDescriptor {
+
+ /**
+ * Name to show in the launch descriptor selector.
+ *
+ * @return name of the launch descriptor
+ */
+ String getName();
+
+ /**
+ * The type of launch descriptor.
+ *
+ * @return provider
+ */
+ ILaunchDescriptorType getType();
+
+}
diff --git a/launch/org.eclipse.cdt.launchbar.core/src/org/eclipse/cdt/launchbar/core/ILaunchDescriptorType.java b/launch/org.eclipse.cdt.launchbar.core/src/org/eclipse/cdt/launchbar/core/ILaunchDescriptorType.java
new file mode 100644
index 00000000000..11b3fc5feeb
--- /dev/null
+++ b/launch/org.eclipse.cdt.launchbar.core/src/org/eclipse/cdt/launchbar/core/ILaunchDescriptorType.java
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * 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.cdt.launchbar.core;
+
+import org.eclipse.core.runtime.CoreException;
+
+/**
+ * Provides the list of launch configurations
+ *
+ */
+public interface ILaunchDescriptorType {
+
+ /**
+ * The id for the provider.
+ *
+ * @return provider id
+ */
+ String getId();
+
+ /**
+ * Called after existing launch configs have been added. The provider
+ * can now add any more that they'd like to have.
+ */
+ void init(ILaunchBarManager manager);
+
+ /**
+ * Does this type own this launch element.
+ *
+ * @param element
+ * @return owns element
+ * @throws CoreException
+ */
+ boolean ownsLaunchObject(Object element) throws CoreException;
+
+ /**
+ * Return a descriptor for the given element. The element can be a launch
+ * configuration, a project, or anything else that gets fed to the
+ * launch bar manager.
+ *
+ * May return null to essentially eat the element so no other types
+ * create a descriptor for it.
+ *
+ * @param descriptor candidate descriptor
+ * @return the best descriptor
+ * @throws CoreException
+ */
+ ILaunchDescriptor getDescriptor(Object element) throws CoreException;
+
+ /**
+ * Return a handle to the launch bar manager.
+ *
+ * @return launchbar manager
+ */
+ ILaunchBarManager getManager();
+
+}
diff --git a/launch/org.eclipse.cdt.launchbar.core/src/org/eclipse/cdt/launchbar/core/ILaunchObjectProvider.java b/launch/org.eclipse.cdt.launchbar.core/src/org/eclipse/cdt/launchbar/core/ILaunchObjectProvider.java
new file mode 100644
index 00000000000..82520fb027f
--- /dev/null
+++ b/launch/org.eclipse.cdt.launchbar.core/src/org/eclipse/cdt/launchbar/core/ILaunchObjectProvider.java
@@ -0,0 +1,21 @@
+package org.eclipse.cdt.launchbar.core;
+
+/**
+ * An extension that serves up objects to feed launch descriptors.
+ *
+ */
+public interface ILaunchObjectProvider {
+
+ /**
+ * Add initial launch descriptors and set up listeners.
+ *
+ * @param launchbar manager
+ */
+ void init(ILaunchBarManager manager);
+
+ /**
+ * Shutting down, remove any listeners.
+ */
+ void dispose();
+
+}
diff --git a/launch/org.eclipse.cdt.launchbar.core/src/org/eclipse/cdt/launchbar/core/ILaunchTarget.java b/launch/org.eclipse.cdt.launchbar.core/src/org/eclipse/cdt/launchbar/core/ILaunchTarget.java
index c45dd0499f9..d6899a084d6 100644
--- a/launch/org.eclipse.cdt.launchbar.core/src/org/eclipse/cdt/launchbar/core/ILaunchTarget.java
+++ b/launch/org.eclipse.cdt.launchbar.core/src/org/eclipse/cdt/launchbar/core/ILaunchTarget.java
@@ -26,4 +26,17 @@ public interface ILaunchTarget {
* @return name
*/
String getName();
+
+ /**
+ * Returns the type for this target.
+ *
+ * @return target type
+ */
+ ILaunchTargetType getType();
+
+ /**
+ * This target has been made active.
+ */
+ void setActive();
+
}
diff --git a/launch/org.eclipse.cdt.launchbar.core/src/org/eclipse/cdt/launchbar/core/ILaunchConfigurationsProvider.java b/launch/org.eclipse.cdt.launchbar.core/src/org/eclipse/cdt/launchbar/core/ILaunchTargetType.java
similarity index 52%
rename from launch/org.eclipse.cdt.launchbar.core/src/org/eclipse/cdt/launchbar/core/ILaunchConfigurationsProvider.java
rename to launch/org.eclipse.cdt.launchbar.core/src/org/eclipse/cdt/launchbar/core/ILaunchTargetType.java
index 116d5828a76..f292a929faf 100644
--- a/launch/org.eclipse.cdt.launchbar.core/src/org/eclipse/cdt/launchbar/core/ILaunchConfigurationsProvider.java
+++ b/launch/org.eclipse.cdt.launchbar.core/src/org/eclipse/cdt/launchbar/core/ILaunchTargetType.java
@@ -10,25 +10,35 @@
*******************************************************************************/
package org.eclipse.cdt.launchbar.core;
-/**
- * Provides the list of launch configurations
- *
- */
-public interface ILaunchConfigurationsProvider {
+public interface ILaunchTargetType {
/**
- * Called after existing launch configs have been added. The provider
- * can now add any more that they'd like to have.
+ * Called by the launchbar manager to initialize and pass a hendle to itself.
+ *
+ * @param manager
*/
void init(ILaunchBarManager manager);
/**
- * If the provider has a better descriptor than the suggested one, return a better one.
- * Otherwise, return the one that was passed in.
+ * The id of the target type.
*
- * @param descriptor candidate descriptor
- * @return the best descriptor
+ * @return target type id
*/
- ILaunchConfigurationDescriptor filterDescriptor(ILaunchBarManager manager, ILaunchConfigurationDescriptor descriptor);
+ String getId();
+
+ /**
+ * Return the list of targets for this type.
+ *
+ * @return targets
+ */
+ ILaunchTarget[] getTargets();
+
+ /**
+ * Return the target with the specified id.
+ *
+ * @param id
+ * @return target
+ */
+ ILaunchTarget getTarget(String id);
}
diff --git a/launch/org.eclipse.cdt.launchbar.core/src/org/eclipse/cdt/launchbar/core/internal/DefaultLaunchConfigurationDescriptor.java b/launch/org.eclipse.cdt.launchbar.core/src/org/eclipse/cdt/launchbar/core/internal/DefaultLaunchConfigurationDescriptor.java
deleted file mode 100644
index 3a4bc13107b..00000000000
--- a/launch/org.eclipse.cdt.launchbar.core/src/org/eclipse/cdt/launchbar/core/internal/DefaultLaunchConfigurationDescriptor.java
+++ /dev/null
@@ -1,96 +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.cdt.launchbar.core.internal;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.cdt.launchbar.core.ILaunchBarManager;
-import org.eclipse.cdt.launchbar.core.ILaunchConfigurationDescriptor;
-import org.eclipse.cdt.launchbar.core.ILaunchTarget;
-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.debug.core.ILaunchMode;
-
-public class DefaultLaunchConfigurationDescriptor implements ILaunchConfigurationDescriptor {
-
- private final ILaunchBarManager manager;
- private ILaunchConfiguration config;
- private ILaunchMode[] launchModes;
-
- public DefaultLaunchConfigurationDescriptor(ILaunchBarManager manager, ILaunchConfiguration config) {
- this.manager = manager;
- this.config = config;
- }
-
- @Override
- public String getName() {
- return config.getName();
- }
-
- @Override
- public ILaunchConfiguration getLaunchConfiguration() throws CoreException {
- return config;
- }
-
- @Override
- public boolean matches(ILaunchConfiguration launchConfiguration) {
- return config.equals(launchConfiguration);
- }
-
- @Override
- public ILaunchTarget getLaunchTarget(String id) {
- return LocalTarget.ID.equals(id) ? manager.getLocalLaunchTarget() : null;
- }
-
- @Override
- public ILaunchTarget[] getLaunchTargets() {
- return new ILaunchTarget[] { manager.getLocalLaunchTarget() };
- }
-
- @Override
- public void setActiveLaunchTarget(ILaunchTarget target) {
- // nothing to do
- }
-
- @Override
- public ILaunchMode[] getLaunchModes() throws CoreException {
- if (launchModes == null) {
- List mymodes = new ArrayList<>();
- ILaunchConfigurationType type = config.getType();
- ILaunchMode[] modes = DebugPlugin.getDefault().getLaunchManager().getLaunchModes();
- for (ILaunchMode mode : modes) {
- if (type.supportsMode(mode.getIdentifier())) {
- mymodes.add(mode);
- }
- }
- launchModes = mymodes.toArray(new ILaunchMode[mymodes.size()]);
- }
- return launchModes;
- }
-
- @Override
- public ILaunchMode getLaunchMode(String id) throws CoreException {
- for (ILaunchMode mode : getLaunchModes()) {
- if (mode.getIdentifier().equals(id))
- return mode;
- }
- return null;
- }
-
- @Override
- public void setActiveLaunchMode(ILaunchMode mode) {
- // nothing to do
- }
-
-}
diff --git a/launch/org.eclipse.cdt.launchbar.core/src/org/eclipse/cdt/launchbar/core/internal/DefaultLaunchConfigurationProvider.java b/launch/org.eclipse.cdt.launchbar.core/src/org/eclipse/cdt/launchbar/core/internal/DefaultLaunchConfigurationProvider.java
new file mode 100644
index 00000000000..83bbce1cec3
--- /dev/null
+++ b/launch/org.eclipse.cdt.launchbar.core/src/org/eclipse/cdt/launchbar/core/internal/DefaultLaunchConfigurationProvider.java
@@ -0,0 +1,44 @@
+package org.eclipse.cdt.launchbar.core.internal;
+
+import org.eclipse.cdt.launchbar.core.ILaunchBarManager;
+import org.eclipse.cdt.launchbar.core.ILaunchConfigurationProvider;
+import org.eclipse.cdt.launchbar.core.ILaunchDescriptor;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationType;
+
+public class DefaultLaunchConfigurationProvider implements ILaunchConfigurationProvider {
+
+ @Override
+ public void init(ILaunchBarManager manager) throws CoreException {
+ // nothing to do
+ }
+
+ @Override
+ public boolean ownsLaunchConfiguration(ILaunchConfiguration configuration) throws CoreException {
+ // We may own it but return false to let it percolate through to the descriptor type.
+ return false;
+ }
+
+ @Override
+ public ILaunchConfiguration getLaunchConfiguration(ILaunchDescriptor descriptor) throws CoreException {
+ if (descriptor instanceof DefaultLaunchDescriptor) {
+ return ((DefaultLaunchDescriptor) descriptor).getConfig();
+ }
+ return null;
+ }
+
+ @Override
+ public ILaunchConfigurationType getLaunchConfigurationType(ILaunchDescriptor descriptor) throws CoreException {
+ if (descriptor instanceof DefaultLaunchDescriptor) {
+ return ((DefaultLaunchDescriptor) descriptor).getConfig().getType();
+ }
+ return null;
+ }
+
+ @Override
+ public void launchConfigurationRemoved(ILaunchConfiguration configation) throws CoreException {
+ // The descriptor will handle the remove.
+ }
+
+}
diff --git a/launch/org.eclipse.cdt.launchbar.core/src/org/eclipse/cdt/launchbar/core/internal/DefaultLaunchDescriptor.java b/launch/org.eclipse.cdt.launchbar.core/src/org/eclipse/cdt/launchbar/core/internal/DefaultLaunchDescriptor.java
new file mode 100644
index 00000000000..ebd779f3380
--- /dev/null
+++ b/launch/org.eclipse.cdt.launchbar.core/src/org/eclipse/cdt/launchbar/core/internal/DefaultLaunchDescriptor.java
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * 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.cdt.launchbar.core.internal;
+
+import org.eclipse.cdt.launchbar.core.ILaunchDescriptor;
+import org.eclipse.cdt.launchbar.core.ILaunchDescriptorType;
+import org.eclipse.debug.core.ILaunchConfiguration;
+
+public class DefaultLaunchDescriptor implements ILaunchDescriptor {
+
+ private final DefaultLaunchDescriptorType type;
+ private final ILaunchConfiguration config;
+
+ public DefaultLaunchDescriptor(DefaultLaunchDescriptorType type, ILaunchConfiguration config) {
+ this.type = type;
+ this.config = config;
+ }
+
+ @Override
+ public String getName() {
+ return config.getName();
+ }
+
+ @Override
+ public ILaunchDescriptorType getType() {
+ return type;
+ }
+
+ public ILaunchConfiguration getConfig() {
+ return config;
+ }
+
+}
diff --git a/launch/org.eclipse.cdt.launchbar.core/src/org/eclipse/cdt/launchbar/core/internal/DefaultLaunchDescriptorType.java b/launch/org.eclipse.cdt.launchbar.core/src/org/eclipse/cdt/launchbar/core/internal/DefaultLaunchDescriptorType.java
new file mode 100644
index 00000000000..f9c76bb891d
--- /dev/null
+++ b/launch/org.eclipse.cdt.launchbar.core/src/org/eclipse/cdt/launchbar/core/internal/DefaultLaunchDescriptorType.java
@@ -0,0 +1,39 @@
+package org.eclipse.cdt.launchbar.core.internal;
+
+import org.eclipse.cdt.launchbar.core.ILaunchBarManager;
+import org.eclipse.cdt.launchbar.core.ILaunchDescriptor;
+import org.eclipse.cdt.launchbar.core.ILaunchDescriptorType;
+import org.eclipse.debug.core.ILaunchConfiguration;
+
+public class DefaultLaunchDescriptorType implements ILaunchDescriptorType {
+
+ public static final String ID = "org.eclipse.cdt.launchbar.core.descriptor.default";
+
+ private ILaunchBarManager manager;
+
+ @Override
+ public String getId() {
+ return ID;
+ }
+
+ @Override
+ public void init(ILaunchBarManager manager) {
+ this.manager = manager;
+ }
+
+ @Override
+ public boolean ownsLaunchObject(Object element) {
+ return element instanceof ILaunchConfiguration;
+ }
+
+ @Override
+ public ILaunchDescriptor getDescriptor(Object element) {
+ return new DefaultLaunchDescriptor(this, (ILaunchConfiguration) element);
+ }
+
+ @Override
+ public ILaunchBarManager getManager() {
+ return manager;
+ }
+
+}
diff --git a/launch/org.eclipse.cdt.launchbar.core/src/org/eclipse/cdt/launchbar/core/internal/LaunchBarManager.java b/launch/org.eclipse.cdt.launchbar.core/src/org/eclipse/cdt/launchbar/core/internal/LaunchBarManager.java
index 3a7c19348df..adc6a14c65c 100644
--- a/launch/org.eclipse.cdt.launchbar.core/src/org/eclipse/cdt/launchbar/core/internal/LaunchBarManager.java
+++ b/launch/org.eclipse.cdt.launchbar.core/src/org/eclipse/cdt/launchbar/core/internal/LaunchBarManager.java
@@ -20,9 +20,12 @@ import java.util.List;
import java.util.Map;
import org.eclipse.cdt.launchbar.core.ILaunchBarManager;
-import org.eclipse.cdt.launchbar.core.ILaunchConfigurationDescriptor;
-import org.eclipse.cdt.launchbar.core.ILaunchConfigurationsProvider;
+import org.eclipse.cdt.launchbar.core.ILaunchConfigurationProvider;
+import org.eclipse.cdt.launchbar.core.ILaunchDescriptor;
+import org.eclipse.cdt.launchbar.core.ILaunchDescriptorType;
+import org.eclipse.cdt.launchbar.core.ILaunchObjectProvider;
import org.eclipse.cdt.launchbar.core.ILaunchTarget;
+import org.eclipse.cdt.launchbar.core.ILaunchTargetType;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtension;
@@ -34,6 +37,7 @@ import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationListener;
+import org.eclipse.debug.core.ILaunchConfigurationType;
import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.debug.core.ILaunchMode;
import org.osgi.service.prefs.BackingStoreException;
@@ -42,142 +46,183 @@ import org.osgi.service.prefs.Preferences;
public class LaunchBarManager extends PlatformObject implements ILaunchBarManager, ILaunchConfigurationListener {
private List listeners = new LinkedList<>();
- private List providers = new ArrayList<>();
- private Map configDescs = new HashMap<>();
- private ILaunchConfigurationDescriptor lastConfigDesc;
-
- private ILaunchConfigurationDescriptor activeConfigDesc;
+ private Map targetTypes = new HashMap<>();
+ private List descriptorTypes = new ArrayList<>();
+ private Map descriptors = new HashMap<>();
+ private List objectProviders = new ArrayList<>();
+ // Map descriptor type to target type to provider
+ private Map> configProviders = new HashMap<>();
+ // Map descriptor type to target type
+ private Map defaultTargetTypes = new HashMap<>();
+ private Map