mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-30 21:55:31 +02:00
Update LaunchBar APIs to deal with multiple target types per desc.
Also fixed up the case in new workspaces. Change-Id: Ibbabc549034614c8095510c630da73f7eec171e3 Reviewed-on: https://git.eclipse.org/r/29427 Reviewed-by: Doug Schaefer <dschaefer@qnx.com> Tested-by: Doug Schaefer <dschaefer@qnx.com>
This commit is contained in:
parent
b87b828496
commit
67939973fb
13 changed files with 235 additions and 146 deletions
|
@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2
|
|||
Bundle-Name: LaunchBar for CDT Core
|
||||
Bundle-SymbolicName: org.eclipse.cdt.launchbar.cdt.core;singleton:=true
|
||||
Bundle-Version: 1.0.0.qualifier
|
||||
Bundle-Activator: org.eclipse.cdt.launchbar.cdt.core.Activator
|
||||
Bundle-Activator: org.eclipse.cdt.launchbar.cdt.core.internal.Activator
|
||||
Bundle-Vendor: Eclipse CDT
|
||||
Require-Bundle: org.eclipse.core.runtime,
|
||||
org.eclipse.cdt.launchbar.core,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package org.eclipse.cdt.launchbar.cdt.core;
|
||||
package org.eclipse.cdt.launchbar.cdt.core.internal;
|
||||
|
||||
import org.osgi.framework.BundleActivator;
|
||||
import org.osgi.framework.BundleContext;
|
|
@ -1,7 +1,12 @@
|
|||
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.DefaultLaunchConfigurationDescriptor;
|
||||
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;
|
||||
|
@ -11,18 +16,23 @@ 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 extends DefaultLaunchConfigurationDescriptor {
|
||||
public class CDTLaunchConfigDescriptor implements ILaunchConfigurationDescriptor {
|
||||
|
||||
private final ILaunchBarManager manager;
|
||||
private String projectName;
|
||||
private ILaunchConfiguration config;
|
||||
private ILaunchMode[] launchModes;
|
||||
|
||||
public CDTLaunchConfigDescriptor(IProject project) {
|
||||
super(null);
|
||||
projectName = project.getName();
|
||||
public CDTLaunchConfigDescriptor(ILaunchBarManager manager, IProject project) {
|
||||
this.manager = manager;
|
||||
this.projectName = project.getName();
|
||||
}
|
||||
|
||||
public CDTLaunchConfigDescriptor(ILaunchConfiguration config) {
|
||||
super(config);
|
||||
public CDTLaunchConfigDescriptor(ILaunchBarManager manager, ILaunchConfiguration config) {
|
||||
this.manager = manager;
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -41,15 +51,10 @@ public class CDTLaunchConfigDescriptor extends DefaultLaunchConfigurationDescrip
|
|||
return ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILaunchConfigurationType getLaunchConfigurationType() throws CoreException {
|
||||
return getLaunchManager().getLaunchConfigurationType(ICDTLaunchConfigurationConstants.ID_LAUNCH_C_APP);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILaunchConfiguration getLaunchConfiguration() throws CoreException {
|
||||
if (config == null) {
|
||||
ILaunchConfigurationType configType = getLaunchConfigurationType();
|
||||
ILaunchConfigurationType configType = config.getType();
|
||||
ILaunchConfigurationWorkingCopy wc = configType.newInstance(null, getLaunchManager().generateLaunchConfigurationName(projectName));
|
||||
wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, projectName);
|
||||
wc.setMappedResources(new IResource[] { getProject() });
|
||||
|
@ -63,9 +68,61 @@ public class CDTLaunchConfigDescriptor extends DefaultLaunchConfigurationDescrip
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(ILaunchConfiguration launchConfiguration) {
|
||||
// TODO matches if it's the same project
|
||||
return false;
|
||||
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<ILaunchMode> 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
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ public class CDTLaunchConfigProvider implements ILaunchConfigurationsProvider {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ILaunchConfigurationDescriptor filterDescriptor(ILaunchConfigurationDescriptor descriptor) {
|
||||
public ILaunchConfigurationDescriptor filterDescriptor(ILaunchBarManager manager, ILaunchConfigurationDescriptor descriptor) {
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
|
|
|
@ -9,4 +9,5 @@ Require-Bundle: org.eclipse.core.runtime,
|
|||
org.eclipse.debug.core;bundle-version="3.9.0"
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Export-Package: org.eclipse.cdt.launchbar.core
|
||||
Export-Package: org.eclipse.cdt.launchbar.core,
|
||||
org.eclipse.cdt.launchbar.core.internal;x-friends:="org.eclipse.cdt.launchbar.ui"
|
||||
|
|
|
@ -27,16 +27,12 @@ public interface ILaunchBarManager extends IAdaptable {
|
|||
|
||||
void removeLaunchConfigurationDescriptor(ILaunchConfigurationDescriptor configDesc);
|
||||
|
||||
ILaunchConfigurationDescriptor getLaunchConfigurationDescriptor(ILaunchConfiguration configuration);
|
||||
ILaunchConfigurationDescriptor getLaunchConfigurationDescriptor(ILaunchConfiguration configuration) throws CoreException;
|
||||
|
||||
ILaunchMode[] getLaunchModes() throws CoreException;
|
||||
|
||||
ILaunchMode getActiveLaunchMode();
|
||||
|
||||
void setActiveLaunchMode(ILaunchMode mode);
|
||||
|
||||
ILaunchTarget[] getLaunchTargets();
|
||||
|
||||
ILaunchTarget getActiveLaunchTarget();
|
||||
|
||||
void setActiveLaunchTarget(ILaunchTarget target);
|
||||
|
@ -44,6 +40,8 @@ public interface ILaunchBarManager extends IAdaptable {
|
|||
void addLaunchTarget(ILaunchTarget target);
|
||||
|
||||
void removeLaunchTarget(ILaunchTarget target);
|
||||
|
||||
ILaunchTarget getLocalLaunchTarget();
|
||||
|
||||
interface Listener {
|
||||
|
||||
|
|
|
@ -12,7 +12,6 @@ package org.eclipse.cdt.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.ILaunchMode;
|
||||
|
||||
public interface ILaunchConfigurationDescriptor {
|
||||
|
@ -24,13 +23,6 @@ public interface ILaunchConfigurationDescriptor {
|
|||
*/
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* The type of launch configuration supported by this descriptor.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
ILaunchConfigurationType getLaunchConfigurationType() throws CoreException;
|
||||
|
||||
/**
|
||||
* The corresponding launch configuration.
|
||||
* If this launch config hasn't been created yet, it will be
|
||||
|
@ -45,8 +37,9 @@ public interface ILaunchConfigurationDescriptor {
|
|||
*
|
||||
* @param launchConfiguration
|
||||
* @return
|
||||
* @throws CoreException
|
||||
*/
|
||||
boolean matches(ILaunchConfiguration launchConfiguration);
|
||||
boolean matches(ILaunchConfiguration launchConfiguration) throws CoreException;
|
||||
|
||||
/**
|
||||
* Return the list of launch targets this configuration can launcht to.
|
||||
|
@ -63,14 +56,6 @@ public interface ILaunchConfigurationDescriptor {
|
|||
*/
|
||||
ILaunchTarget getLaunchTarget(String id);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* Set the active launch target. Allows the descriptor to prepare for
|
||||
* a launch on that target.
|
||||
|
@ -79,4 +64,29 @@ public interface ILaunchConfigurationDescriptor {
|
|||
*/
|
||||
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);
|
||||
|
||||
}
|
||||
|
|
|
@ -29,6 +29,6 @@ public interface ILaunchConfigurationsProvider {
|
|||
* @param descriptor candidate descriptor
|
||||
* @return the best descriptor
|
||||
*/
|
||||
ILaunchConfigurationDescriptor filterDescriptor(ILaunchConfigurationDescriptor descriptor);
|
||||
ILaunchConfigurationDescriptor filterDescriptor(ILaunchBarManager manager, ILaunchConfigurationDescriptor descriptor);
|
||||
|
||||
}
|
||||
|
|
|
@ -8,20 +8,28 @@
|
|||
* Contributors:
|
||||
* Doug Schaefer
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.launchbar.core;
|
||||
package org.eclipse.cdt.launchbar.core.internal;
|
||||
|
||||
import org.eclipse.cdt.launchbar.core.internal.LaunchBarManager;
|
||||
import org.eclipse.cdt.launchbar.core.internal.LocalTarget;
|
||||
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 {
|
||||
|
||||
protected ILaunchConfiguration config;
|
||||
private final ILaunchBarManager manager;
|
||||
private ILaunchConfiguration config;
|
||||
private ILaunchMode[] launchModes;
|
||||
|
||||
public DefaultLaunchConfigurationDescriptor(ILaunchConfiguration config) {
|
||||
public DefaultLaunchConfigurationDescriptor(ILaunchBarManager manager, ILaunchConfiguration config) {
|
||||
this.manager = manager;
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
|
@ -35,11 +43,6 @@ public class DefaultLaunchConfigurationDescriptor implements ILaunchConfiguratio
|
|||
return config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILaunchConfigurationType getLaunchConfigurationType() throws CoreException{
|
||||
return config.getType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(ILaunchConfiguration launchConfiguration) {
|
||||
return config.equals(launchConfiguration);
|
||||
|
@ -47,12 +50,12 @@ public class DefaultLaunchConfigurationDescriptor implements ILaunchConfiguratio
|
|||
|
||||
@Override
|
||||
public ILaunchTarget getLaunchTarget(String id) {
|
||||
return LocalTarget.ID.equals(id) ? LaunchBarManager.getLocalLaunchTarget() : null;
|
||||
return LocalTarget.ID.equals(id) ? manager.getLocalLaunchTarget() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILaunchTarget[] getLaunchTargets() {
|
||||
return new ILaunchTarget[] { LaunchBarManager.getLocalLaunchTarget() };
|
||||
return new ILaunchTarget[] { manager.getLocalLaunchTarget() };
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -60,6 +63,31 @@ public class DefaultLaunchConfigurationDescriptor implements ILaunchConfiguratio
|
|||
// nothing to do
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILaunchMode[] getLaunchModes() throws CoreException {
|
||||
if (launchModes == null) {
|
||||
List<ILaunchMode> 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
|
|
@ -19,7 +19,6 @@ import java.util.LinkedList;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.cdt.launchbar.core.DefaultLaunchConfigurationDescriptor;
|
||||
import org.eclipse.cdt.launchbar.core.ILaunchBarManager;
|
||||
import org.eclipse.cdt.launchbar.core.ILaunchConfigurationDescriptor;
|
||||
import org.eclipse.cdt.launchbar.core.ILaunchConfigurationsProvider;
|
||||
|
@ -35,7 +34,6 @@ 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;
|
||||
|
@ -47,7 +45,6 @@ public class LaunchBarManager extends PlatformObject implements ILaunchBarManage
|
|||
private List<ProviderExtensionDescriptor> providers = new ArrayList<>();
|
||||
private Map<String, ILaunchConfigurationDescriptor> configDescs = new HashMap<>();
|
||||
private ILaunchConfigurationDescriptor lastConfigDesc;
|
||||
private ILaunchMode[] launchModes = new ILaunchMode[0];
|
||||
|
||||
private ILaunchConfigurationDescriptor activeConfigDesc;
|
||||
private ILaunchMode activeLaunchMode;
|
||||
|
@ -115,11 +112,11 @@ public class LaunchBarManager extends PlatformObject implements ILaunchBarManage
|
|||
|
||||
ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
|
||||
for (ILaunchConfiguration configuration : launchManager.getLaunchConfigurations()) {
|
||||
ILaunchConfigurationDescriptor configDesc = new DefaultLaunchConfigurationDescriptor(configuration);
|
||||
ILaunchConfigurationDescriptor configDesc = new DefaultLaunchConfigurationDescriptor(this, configuration);
|
||||
|
||||
|
||||
for (ProviderExtensionDescriptor provider : providers) {
|
||||
configDesc = provider.getProvider().filterDescriptor(configDesc);
|
||||
configDesc = provider.getProvider().filterDescriptor(this, configDesc);
|
||||
}
|
||||
configDescs.put(configDesc.getName(), configDesc);
|
||||
}
|
||||
|
@ -147,9 +144,9 @@ public class LaunchBarManager extends PlatformObject implements ILaunchBarManage
|
|||
|
||||
@Override
|
||||
public void launchConfigurationAdded(ILaunchConfiguration configuration) {
|
||||
ILaunchConfigurationDescriptor configDesc = new DefaultLaunchConfigurationDescriptor(configuration);
|
||||
ILaunchConfigurationDescriptor configDesc = new DefaultLaunchConfigurationDescriptor(this, configuration);
|
||||
for (ProviderExtensionDescriptor provider : providers) {
|
||||
configDesc = provider.getProvider().filterDescriptor(configDesc);
|
||||
configDesc = provider.getProvider().filterDescriptor(this, configDesc);
|
||||
}
|
||||
try {
|
||||
addLaunchConfigurationDescriptor(configDesc);
|
||||
|
@ -166,9 +163,13 @@ public class LaunchBarManager extends PlatformObject implements ILaunchBarManage
|
|||
|
||||
@Override
|
||||
public void launchConfigurationRemoved(ILaunchConfiguration configuration) {
|
||||
ILaunchConfigurationDescriptor configDesc = getLaunchConfigurationDescriptor(configuration);
|
||||
if (configDesc != null)
|
||||
removeLaunchConfigurationDescriptor(configDesc);
|
||||
try {
|
||||
ILaunchConfigurationDescriptor configDesc = getLaunchConfigurationDescriptor(configuration);
|
||||
if (configDesc != null)
|
||||
removeLaunchConfigurationDescriptor(configDesc);
|
||||
} catch (CoreException e) {
|
||||
Activator.log(e.getStatus());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -189,7 +190,7 @@ public class LaunchBarManager extends PlatformObject implements ILaunchBarManage
|
|||
}
|
||||
|
||||
@Override
|
||||
public ILaunchConfigurationDescriptor getLaunchConfigurationDescriptor(ILaunchConfiguration configuration) {
|
||||
public ILaunchConfigurationDescriptor getLaunchConfigurationDescriptor(ILaunchConfiguration configuration) throws CoreException {
|
||||
// Check by name
|
||||
ILaunchConfigurationDescriptor configDesc = configDescs.get(configuration.getName());
|
||||
if (configDesc.matches(configuration))
|
||||
|
@ -231,20 +232,6 @@ public class LaunchBarManager extends PlatformObject implements ILaunchBarManage
|
|||
return;
|
||||
}
|
||||
|
||||
// Get the launch modes
|
||||
List<ILaunchMode> mymodes = new ArrayList<>();
|
||||
ILaunchConfigurationType type = activeConfigDesc.getLaunchConfigurationType();
|
||||
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()]);
|
||||
|
||||
// Get the launch targets
|
||||
// TODO
|
||||
|
||||
// Send notifications
|
||||
for (Listener listener : listeners) {
|
||||
listener.activeConfigurationDescriptorChanged();
|
||||
|
@ -252,6 +239,7 @@ public class LaunchBarManager extends PlatformObject implements ILaunchBarManage
|
|||
|
||||
// Set active mode
|
||||
String activeModeName = store.node(activeConfigDesc.getName()).get(PREF_ACTIVE_LAUNCH_MODE, null);
|
||||
ILaunchMode[] launchModes = activeConfigDesc.getLaunchModes();
|
||||
boolean foundMode = false;
|
||||
if (activeModeName != null) {
|
||||
for (ILaunchMode mode : launchModes) {
|
||||
|
@ -264,9 +252,9 @@ public class LaunchBarManager extends PlatformObject implements ILaunchBarManage
|
|||
}
|
||||
if (!foundMode) {
|
||||
if (launchModes.length > 0) {
|
||||
ILaunchMode mode = getLaunchMode("debug");
|
||||
ILaunchMode mode = activeConfigDesc.getLaunchMode("debug");
|
||||
if (mode == null) {
|
||||
mode = getLaunchMode("run");
|
||||
mode = activeConfigDesc.getLaunchMode("run");
|
||||
}
|
||||
if (mode == null) {
|
||||
mode = launchModes[0];
|
||||
|
@ -321,18 +309,6 @@ public class LaunchBarManager extends PlatformObject implements ILaunchBarManage
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILaunchMode[] getLaunchModes() throws CoreException {
|
||||
return launchModes;
|
||||
}
|
||||
|
||||
public ILaunchMode getLaunchMode(String id) {
|
||||
for (ILaunchMode mode : launchModes)
|
||||
if (id.equals(mode.getIdentifier()))
|
||||
return mode;
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILaunchMode getActiveLaunchMode() {
|
||||
return activeLaunchMode;
|
||||
|
@ -344,6 +320,9 @@ public class LaunchBarManager extends PlatformObject implements ILaunchBarManage
|
|||
return;
|
||||
activeLaunchMode = mode;
|
||||
|
||||
if (activeConfigDesc == null)
|
||||
return;
|
||||
|
||||
Preferences store = InstanceScope.INSTANCE.getNode(Activator.PLUGIN_ID).node(activeConfigDesc.getName());
|
||||
if (mode != null) {
|
||||
store.put(PREF_ACTIVE_LAUNCH_MODE, mode.getIdentifier());
|
||||
|
@ -362,14 +341,6 @@ public class LaunchBarManager extends PlatformObject implements ILaunchBarManage
|
|||
listener.activeLaunchModeChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILaunchTarget[] getLaunchTargets() {
|
||||
if (activeConfigDesc != null)
|
||||
return activeConfigDesc.getLaunchTargets();
|
||||
else
|
||||
return new ILaunchTarget[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILaunchTarget getActiveLaunchTarget() {
|
||||
return activeLaunchTarget;
|
||||
|
@ -380,6 +351,10 @@ public class LaunchBarManager extends PlatformObject implements ILaunchBarManage
|
|||
if (activeLaunchTarget == target) return;
|
||||
|
||||
activeLaunchTarget = target;
|
||||
|
||||
if (activeConfigDesc == null)
|
||||
return;
|
||||
|
||||
Preferences store = InstanceScope.INSTANCE.getNode(Activator.PLUGIN_ID).node(activeConfigDesc.getName());
|
||||
if (target != null) {
|
||||
store.put(PREF_ACTIVE_LAUNCH_TARGET, target.getId());
|
||||
|
@ -398,7 +373,7 @@ public class LaunchBarManager extends PlatformObject implements ILaunchBarManage
|
|||
listener.activeLaunchTargetChanged();
|
||||
}
|
||||
|
||||
public static LocalTarget getLocalLaunchTarget() {
|
||||
public LocalTarget getLocalLaunchTarget() {
|
||||
return localLaunchTarget;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ import java.util.Map;
|
|||
|
||||
import org.eclipse.cdt.launchbar.core.ILaunchBarManager;
|
||||
import org.eclipse.cdt.launchbar.core.ILaunchConfigurationDescriptor;
|
||||
import org.eclipse.cdt.launchbar.core.internal.DefaultLaunchConfigurationDescriptor;
|
||||
import org.eclipse.cdt.launchbar.ui.internal.Activator;
|
||||
import org.eclipse.cdt.launchbar.ui.internal.LaunchBarUIManager;
|
||||
import org.eclipse.cdt.launchbar.ui.internal.dialogs.LaunchConfigurationEditDialog;
|
||||
|
@ -61,6 +62,8 @@ public class ConfigSelector extends CSelector {
|
|||
|
||||
private LaunchBarUIManager uiManager;
|
||||
|
||||
private static final String[] noConfigs = new String[] { "No Launch Configurations" };
|
||||
|
||||
public ConfigSelector(Composite parent, int style) {
|
||||
super(parent, style);
|
||||
|
||||
|
@ -76,11 +79,9 @@ public class ConfigSelector extends CSelector {
|
|||
@Override
|
||||
public Object[] getElements(Object inputElement) {
|
||||
ILaunchConfigurationDescriptor[] descs = getManager().getLaunchConfigurationDescriptors();
|
||||
if (descs.length == 0) {
|
||||
return new String[] { "No Launch Configurations" };
|
||||
} else {
|
||||
if (descs.length > 0)
|
||||
return descs;
|
||||
}
|
||||
return noConfigs;
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -103,19 +104,21 @@ public class ConfigSelector extends CSelector {
|
|||
}
|
||||
|
||||
// Default
|
||||
try {
|
||||
ILaunchConfigurationType type = configDesc.getLaunchConfigurationType();
|
||||
ImageDescriptor imageDescriptor = DebugUITools.getDefaultImageDescriptor(type);
|
||||
if (imageDescriptor != null) {
|
||||
Image image = images.get(imageDescriptor);
|
||||
if (image == null) {
|
||||
image = imageDescriptor.createImage();
|
||||
images.put(imageDescriptor, image);
|
||||
if (element instanceof DefaultLaunchConfigurationDescriptor) {
|
||||
try {
|
||||
ILaunchConfigurationType type = configDesc.getLaunchConfiguration().getType();
|
||||
ImageDescriptor imageDescriptor = DebugUITools.getDefaultImageDescriptor(type);
|
||||
if (imageDescriptor != null) {
|
||||
Image image = images.get(imageDescriptor);
|
||||
if (image == null) {
|
||||
image = imageDescriptor.createImage();
|
||||
images.put(imageDescriptor, image);
|
||||
}
|
||||
return image;
|
||||
}
|
||||
return image;
|
||||
} catch (CoreException e) {
|
||||
Activator.log(e);
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
Activator.log(e);
|
||||
}
|
||||
}
|
||||
// Default
|
||||
|
@ -275,4 +278,11 @@ public class ConfigSelector extends CSelector {
|
|||
uiManager = (LaunchBarUIManager) ((ILaunchBarManager) input).getAdapter(LaunchBarUIManager.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSelection(Object element) {
|
||||
if (element == null)
|
||||
element = noConfigs[0];
|
||||
super.setSelection(element);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -32,6 +32,8 @@ import org.eclipse.swt.widgets.Composite;
|
|||
@SuppressWarnings("restriction")
|
||||
public class ModeSelector extends CSelector {
|
||||
|
||||
private static final String[] noModes = new String[] { "---" };
|
||||
|
||||
public ModeSelector(Composite parent, int style) {
|
||||
super(parent, style);
|
||||
|
||||
|
@ -47,11 +49,13 @@ public class ModeSelector extends CSelector {
|
|||
@Override
|
||||
public Object[] getElements(Object inputElement) {
|
||||
try {
|
||||
return getManager().getLaunchModes();
|
||||
ILaunchMode[] modes = getManager().getActiveLaunchConfigurationDescriptor().getLaunchModes();
|
||||
if (modes.length > 0)
|
||||
return modes;
|
||||
} catch (CoreException e) {
|
||||
Activator.log(e);
|
||||
return new Object[0];
|
||||
}
|
||||
return noModes;
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -69,20 +73,15 @@ public class ModeSelector extends CSelector {
|
|||
ILaunchConfigurationDescriptor config = getManager().getActiveLaunchConfigurationDescriptor();
|
||||
if (config != null && element instanceof ILaunchMode) {
|
||||
ILaunchMode mode = (ILaunchMode) element;
|
||||
try {
|
||||
ILaunchGroup group = DebugUIPlugin.getDefault().getLaunchConfigurationManager()
|
||||
.getLaunchGroup(config.getLaunchConfigurationType(), mode.getIdentifier());
|
||||
if (group != null) {
|
||||
ImageDescriptor imageDesc = group.getImageDescriptor();
|
||||
Image image = images.get(imageDesc);
|
||||
if (image == null) {
|
||||
image = imageDesc.createImage();
|
||||
images.put(imageDesc, image);
|
||||
}
|
||||
return image;
|
||||
ILaunchGroup group = DebugUIPlugin.getDefault().getLaunchConfigurationManager().getDefaultLaunchGroup(mode.getIdentifier());
|
||||
if (group != null) {
|
||||
ImageDescriptor imageDesc = group.getImageDescriptor();
|
||||
Image image = images.get(imageDesc);
|
||||
if (image == null) {
|
||||
image = imageDesc.createImage();
|
||||
images.put(imageDesc, image);
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
Activator.log(e);
|
||||
return image;
|
||||
}
|
||||
}
|
||||
return super.getImage(element);
|
||||
|
@ -92,14 +91,9 @@ public class ModeSelector extends CSelector {
|
|||
ILaunchConfigurationDescriptor config = getManager().getActiveLaunchConfigurationDescriptor();
|
||||
if (config != null && element instanceof ILaunchMode) {
|
||||
ILaunchMode mode = (ILaunchMode) element;
|
||||
try {
|
||||
ILaunchGroup group = DebugUIPlugin.getDefault().getLaunchConfigurationManager()
|
||||
.getLaunchGroup(config.getLaunchConfigurationType(), mode.getIdentifier());
|
||||
if (group != null) {
|
||||
return group.getLabel().replace("&", "");
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
Activator.log(e);
|
||||
ILaunchGroup group = DebugUIPlugin.getDefault().getLaunchConfigurationManager().getDefaultLaunchGroup(mode.getIdentifier());
|
||||
if (group != null) {
|
||||
return group.getLabel().replace("&", "");
|
||||
}
|
||||
}
|
||||
return super.getText(element);
|
||||
|
@ -153,4 +147,11 @@ public class ModeSelector extends CSelector {
|
|||
return (ILaunchBarManager) getInput();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSelection(Object element) {
|
||||
if (element == null)
|
||||
element = noModes[0];
|
||||
super.setSelection(element);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,10 +19,8 @@ import org.eclipse.cdt.launchbar.ui.ILaunchBarUIConstants;
|
|||
import org.eclipse.cdt.launchbar.ui.internal.Activator;
|
||||
import org.eclipse.cdt.launchbar.ui.internal.LaunchBarUIManager;
|
||||
import org.eclipse.jface.viewers.ILabelProvider;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.jface.viewers.IStructuredContentProvider;
|
||||
import org.eclipse.jface.viewers.LabelProvider;
|
||||
import org.eclipse.jface.viewers.StructuredSelection;
|
||||
import org.eclipse.jface.viewers.Viewer;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.MouseAdapter;
|
||||
|
@ -44,7 +42,8 @@ public class TargetSelector extends CSelector {
|
|||
|
||||
private final LaunchBarUIManager uiManager;
|
||||
|
||||
private static final ISelection nullSelection = new StructuredSelection("---");
|
||||
private static final String[] noTargets = new String[] { "---" };
|
||||
|
||||
|
||||
public TargetSelector(Composite parent, int style) {
|
||||
super(parent, style);
|
||||
|
@ -64,7 +63,10 @@ public class TargetSelector extends CSelector {
|
|||
|
||||
@Override
|
||||
public Object[] getElements(Object inputElement) {
|
||||
return getManager().getLaunchTargets();
|
||||
ILaunchTarget[] targets = getManager().getActiveLaunchConfigurationDescriptor().getLaunchTargets();
|
||||
if (targets.length > 0)
|
||||
return targets;
|
||||
return noTargets;
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -89,7 +91,7 @@ public class TargetSelector extends CSelector {
|
|||
if (labelProvider != null) {
|
||||
return labelProvider.getText(element);
|
||||
}
|
||||
return target.getId();
|
||||
return target.getName();
|
||||
}
|
||||
return super.getText(element);
|
||||
}
|
||||
|
@ -227,4 +229,11 @@ public class TargetSelector extends CSelector {
|
|||
return (ILaunchBarManager) getInput();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSelection(Object element) {
|
||||
if (element == null)
|
||||
element = noTargets[0];
|
||||
super.setSelection(element);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue