mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-21 21:52:10 +02:00
LaunchBar - bugs in handling config and project based descriptors
* added tracing * added method to get LCType without need for lc * delete LC is nasty in platform, notificaton is sent after it is deleted, have to store parametes somewhere else to be able to handle it properly * added toString to abstract classes * allow config based type to have null config * fixed loader for default provider extension (and added test for it) Change-Id: I223684414eb51e18fe7f54113b1ae2055ddab1ae Signed-off-by: Alena Laskavaia <elaskavaia.cdt@gmail.com> Reviewed-on: https://git.eclipse.org/r/31043 Tested-by: Hudson CI
This commit is contained in:
parent
5340082453
commit
9d6f5db024
12 changed files with 214 additions and 50 deletions
|
@ -43,6 +43,7 @@ import org.eclipse.core.internal.resources.Project;
|
|||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IConfigurationElement;
|
||||
import org.eclipse.core.runtime.IExtension;
|
||||
import org.eclipse.core.runtime.IExtensionPoint;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
|
@ -102,32 +103,38 @@ public class LaunchBarManagerTest extends TestCase {
|
|||
private ILaunchManager lman;
|
||||
private IProject aaa;
|
||||
private ArrayList<ILaunchMode> globalmodes = new ArrayList<>();
|
||||
IExtensionPoint point;
|
||||
IEclipsePreferences store = new EclipsePreferences();
|
||||
|
||||
public class FixedLaunchBarManager extends LaunchBarManager {
|
||||
public FixedLaunchBarManager() throws CoreException {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IExtensionPoint getExtensionPoint() {
|
||||
return point;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ILaunchManager getLaunchManager() {
|
||||
return lman;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IEclipsePreferences getPreferenceStore() {
|
||||
return store;
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
final IExtensionPoint point = mock(IExtensionPoint.class);
|
||||
point = mock(IExtensionPoint.class);
|
||||
doReturn(new IExtension[] {}).when(point).getExtensions();
|
||||
lman = mock(ILaunchManager.class);
|
||||
doReturn(new ILaunchConfiguration[] {}).when(lman).getLaunchConfigurations();
|
||||
doReturn(globalmodes.toArray(new ILaunchMode[globalmodes.size()])).when(lman).getLaunchModes();
|
||||
|
||||
final IEclipsePreferences store = new EclipsePreferences();
|
||||
manager = new LaunchBarManager() {
|
||||
@Override
|
||||
public IExtensionPoint getExtensionPoint() {
|
||||
return point;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ILaunchManager getLaunchManager() {
|
||||
return lman;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IEclipsePreferences getPreferenceStore() {
|
||||
return store;
|
||||
}
|
||||
};
|
||||
manager = new FixedLaunchBarManager();
|
||||
// mock
|
||||
// lc
|
||||
lctype = mockLCType("lctype1");
|
||||
|
@ -397,7 +404,7 @@ public class LaunchBarManagerTest extends TestCase {
|
|||
// user created a project
|
||||
manager.launchObjectAdded(aaa);
|
||||
assertEquals(1, manager.getLaunchDescriptors().length);
|
||||
assertEquals(aaa.getName(), manager.getLaunchDescriptors()[0].getName());
|
||||
assertTrue(manager.getLaunchDescriptors()[0].getName().startsWith(aaa.getName()));
|
||||
// user clicked on descriptor geer to edit lc, new lc is created
|
||||
manager.launchConfigurationAdded(lc);
|
||||
assertEquals(1, manager.getLaunchDescriptors().length);
|
||||
|
@ -408,13 +415,20 @@ public class LaunchBarManagerTest extends TestCase {
|
|||
manager.launchConfigurationAdded(lc2);
|
||||
assertEquals(2, manager.getLaunchDescriptors().length);
|
||||
// user deleted lc
|
||||
manager.launchConfigurationRemoved(lc2);
|
||||
userDeletesLC(lc2);
|
||||
assertEquals(1, manager.getLaunchDescriptors().length);
|
||||
// user deleted last lc, now we back to project default
|
||||
manager.launchConfigurationRemoved(lc);
|
||||
userDeletesLC(lc);
|
||||
assertEquals(1, manager.getLaunchDescriptors().length);
|
||||
}
|
||||
|
||||
protected void userDeletesLC(ILaunchConfiguration lc2) {
|
||||
String string = lc2.getName();
|
||||
reset(lc2);
|
||||
doReturn(string).when(lc2).getName();
|
||||
manager.launchConfigurationRemoved(lc2);
|
||||
}
|
||||
|
||||
protected void projectMappingSetup() {
|
||||
descType = new ProjectBasedLaunchDescriptorType("desc2", lctype.getIdentifier()) {
|
||||
protected IProject getProject(ILaunchConfiguration llc) {
|
||||
|
@ -750,4 +764,30 @@ public class LaunchBarManagerTest extends TestCase {
|
|||
manager.launchConfigurationRemoved(lc);
|
||||
verify(provider).launchConfigurationRemoved(lc);
|
||||
}
|
||||
|
||||
public void testExtensionConfigDefaultProvider() throws CoreException {
|
||||
IExtension extension = mock(IExtension.class);
|
||||
doReturn(new IExtension[] { extension }).when(point).getExtensions();
|
||||
IConfigurationElement element = mock(IConfigurationElement.class);
|
||||
IConfigurationElement targetElement = mock(IConfigurationElement.class);
|
||||
mockTargetElement(targetElement, targetType);
|
||||
doReturn("defaultConfigProvider").when(element).getName();
|
||||
doReturn(new IConfigurationElement[] { element, targetElement }).when(extension).getConfigurationElements();
|
||||
doReturn(targetType.getId()).when(element).getAttribute("targetType");
|
||||
doReturn(lctype.getIdentifier()).when(element).getAttribute("launchConfigurationType");
|
||||
manager = new FixedLaunchBarManager();
|
||||
targetType.targets.add(mytarget);
|
||||
manager.launchObjectAdded(lc);
|
||||
ILaunchDescriptor[] launchDescriptors = manager.getLaunchDescriptors();
|
||||
assertEquals(1, launchDescriptors.length);
|
||||
assertNotNull(launchDescriptors[0]);
|
||||
assertEquals(lc.getName(), launchDescriptors[0].getName());
|
||||
assertEquals(mytarget, manager.getActiveLaunchTarget());
|
||||
}
|
||||
|
||||
private void mockTargetElement(IConfigurationElement element, TargetType targetType2) throws CoreException {
|
||||
doReturn("targetType").when(element).getName();
|
||||
doReturn(targetType.getId()).when(element).getAttribute("id");
|
||||
doReturn(targetType).when(element).createExecutableExtension("class");
|
||||
}
|
||||
}
|
||||
|
|
2
launch/org.eclipse.cdt.launchbar.core/.options
Normal file
2
launch/org.eclipse.cdt.launchbar.core/.options
Normal file
|
@ -0,0 +1,2 @@
|
|||
org.eclipse.cdt.launchbar.core/debug=true
|
||||
org.eclipse.cdt.launchbar.core/debug/launchbar=true
|
|
@ -32,17 +32,17 @@ public abstract class AbstractLaunchConfigurationProvider implements ILaunchConf
|
|||
@Override
|
||||
public ILaunchConfiguration getLaunchConfiguration(ILaunchDescriptor descriptor) throws CoreException {
|
||||
if (descriptor instanceof ILaunchDescriptorConfigBased) {
|
||||
return ((ILaunchDescriptorConfigBased) descriptor).getConfig();
|
||||
return ((ILaunchDescriptorConfigBased) descriptor).getLaunchConfiguration();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILaunchConfigurationType getLaunchConfigurationType(ILaunchDescriptor descriptor) throws CoreException {
|
||||
ILaunchConfiguration config = getLaunchConfiguration(descriptor);
|
||||
if (config != null) {
|
||||
return config.getType();
|
||||
if (descriptor instanceof ILaunchDescriptorConfigBased) {
|
||||
return ((ILaunchDescriptorConfigBased) descriptor).getLaunchConfigurationType();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -10,12 +10,18 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.launchbar.core;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.eclipse.cdt.launchbar.core.internal.Activator;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.debug.core.DebugPlugin;
|
||||
import org.eclipse.debug.core.ILaunchConfiguration;
|
||||
import org.eclipse.debug.core.ILaunchConfigurationType;
|
||||
|
||||
public class ConfigBasedLaunchConfigurationProvider extends AbstractLaunchConfigurationProvider implements
|
||||
ILaunchConfigurationProvider {
|
||||
private String typeId;
|
||||
protected HashMap<ILaunchConfiguration, Object> configMap = new HashMap<>();
|
||||
protected String typeId;
|
||||
|
||||
public ConfigBasedLaunchConfigurationProvider(String launchConfigurationTypeId) {
|
||||
this.typeId = launchConfigurationTypeId;
|
||||
|
@ -23,8 +29,12 @@ public class ConfigBasedLaunchConfigurationProvider extends AbstractLaunchConfig
|
|||
|
||||
public boolean ownsConfiguration(ILaunchConfiguration element) {
|
||||
try {
|
||||
// cannot use getType method when config is deleted, event sent after, no getters work on it
|
||||
if (configMap.containsKey(element))
|
||||
return true;
|
||||
return element.getType().getIdentifier().equals(typeId);
|
||||
} catch (CoreException e) {
|
||||
Activator.log(e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -32,23 +42,40 @@ public class ConfigBasedLaunchConfigurationProvider extends AbstractLaunchConfig
|
|||
@Override
|
||||
public boolean launchConfigurationAdded(ILaunchConfiguration configuration) throws CoreException {
|
||||
if (ownsConfiguration(configuration)) {
|
||||
rememberConfiguration(configuration);
|
||||
manager.launchObjectAdded(configuration);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected void rememberConfiguration(ILaunchConfiguration configuration) {
|
||||
configMap.put(configuration, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean launchConfigurationRemoved(ILaunchConfiguration configuration) throws CoreException {
|
||||
if (ownsConfiguration(configuration)) {
|
||||
manager.launchObjectRemoved(configuration);
|
||||
forgetConfiguration(configuration);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected void forgetConfiguration(ILaunchConfiguration configuration) {
|
||||
configMap.remove(configuration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILaunchConfigurationType getLaunchConfigurationType(ILaunchDescriptor descriptor) throws CoreException {
|
||||
ILaunchConfigurationType type = super.getLaunchConfigurationType(descriptor);
|
||||
if (type!=null) return type;
|
||||
return DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationType(typeId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Provider for " + typeId;
|
||||
return "provider for " + typeId;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,19 +10,26 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.launchbar.core;
|
||||
|
||||
import org.eclipse.cdt.launchbar.core.internal.Activator;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.debug.core.ILaunchConfiguration;
|
||||
import org.eclipse.debug.core.ILaunchConfigurationType;
|
||||
|
||||
public class ConfigBasedLaunchDescriptor extends AbstractLaunchDescriptor implements ILaunchDescriptorConfigBased {
|
||||
private final ILaunchDescriptorType type;
|
||||
private final ILaunchConfiguration config;
|
||||
private ILaunchConfiguration config;
|
||||
|
||||
public ConfigBasedLaunchDescriptor(ILaunchDescriptorType type, ILaunchConfiguration config) {
|
||||
if (type == null)
|
||||
throw new NullPointerException();
|
||||
this.type = type;
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
if (config == null)
|
||||
return "?";
|
||||
return config.getName();
|
||||
}
|
||||
|
||||
|
@ -31,12 +38,29 @@ public class ConfigBasedLaunchDescriptor extends AbstractLaunchDescriptor implem
|
|||
return type;
|
||||
}
|
||||
|
||||
public ILaunchConfiguration getConfig() {
|
||||
public ILaunchConfiguration getLaunchConfiguration() {
|
||||
return config;
|
||||
}
|
||||
|
||||
public ILaunchConfigurationType getLaunchConfigurationType() {
|
||||
if (config != null)
|
||||
try {
|
||||
return config.getType();
|
||||
} catch (CoreException e) {
|
||||
Activator.log(e); // can happened when config is deleted XXX hide in this case
|
||||
}
|
||||
if (type instanceof ConfigBasedLaunchDescriptorType) {
|
||||
return ((ConfigBasedLaunchDescriptorType) type).getLaunchConfigurationType();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getId();
|
||||
return "LC/" + getName();
|
||||
}
|
||||
|
||||
public void setLaunchConfiguration(ILaunchConfiguration config) {
|
||||
this.config = config;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,9 @@
|
|||
package org.eclipse.cdt.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.ILaunchConfigurationType;
|
||||
|
||||
public class ConfigBasedLaunchDescriptorType extends AbstarctLaunchDescriptorType implements ILaunchDescriptorType {
|
||||
private String id;
|
||||
|
@ -51,4 +53,13 @@ public class ConfigBasedLaunchDescriptorType extends AbstarctLaunchDescriptorTyp
|
|||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public ILaunchConfigurationType getLaunchConfigurationType() {
|
||||
return DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationType(typeId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "type for " + typeId;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,13 +11,19 @@
|
|||
package org.eclipse.cdt.launchbar.core;
|
||||
|
||||
import org.eclipse.debug.core.ILaunchConfiguration;
|
||||
import org.eclipse.debug.core.ILaunchConfigurationType;
|
||||
|
||||
/**
|
||||
* Interface for descriptors which are based on launch configurations
|
||||
*/
|
||||
public interface ILaunchDescriptorConfigBased extends ILaunchDescriptor {
|
||||
/**
|
||||
* Return launch configuration on which it is based
|
||||
* Return launch configuration on which it is based (can be null)
|
||||
*/
|
||||
public ILaunchConfiguration getConfig();
|
||||
public ILaunchConfiguration getLaunchConfiguration();
|
||||
|
||||
/**
|
||||
* Return launch configuration type on which it is based (cannot be null)
|
||||
*/
|
||||
public ILaunchConfigurationType getLaunchConfigurationType();
|
||||
}
|
||||
|
|
|
@ -25,18 +25,25 @@ public abstract class ProjectBasedLaunchConfigurationProvider extends ConfigBase
|
|||
|
||||
@Override
|
||||
public boolean launchConfigurationAdded(ILaunchConfiguration configuration) throws CoreException {
|
||||
boolean res = super.launchConfigurationAdded(configuration);
|
||||
if (!super.launchConfigurationAdded(configuration)) return false;
|
||||
IProject project = getProject(configuration);
|
||||
getManager().launchObjectChanged(project);
|
||||
return res;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean launchConfigurationRemoved(ILaunchConfiguration configuration) throws CoreException {
|
||||
boolean res = super.launchConfigurationRemoved(configuration);
|
||||
IProject project = getProject(configuration);
|
||||
getManager().launchObjectChanged(project);
|
||||
return res;
|
||||
if (!ownsConfiguration(configuration))
|
||||
return false;
|
||||
IProject project = (IProject) configMap.get(configuration); // cannot use getters from configuration, it is deleted
|
||||
if (!super.launchConfigurationRemoved(configuration)) return false;
|
||||
if (project != null)
|
||||
getManager().launchObjectChanged(project);
|
||||
return true;
|
||||
}
|
||||
|
||||
protected void rememberConfiguration(ILaunchConfiguration configuration) {
|
||||
configMap.put(configuration, getProject(configuration));
|
||||
}
|
||||
|
||||
protected abstract IProject getProject(ILaunchConfiguration llc);
|
||||
|
|
|
@ -26,13 +26,20 @@ public class ProjectBasedLaunchDescriptor extends ConfigBasedLaunchDescriptor {
|
|||
}
|
||||
|
||||
public String getName() {
|
||||
if (getConfig() == null)
|
||||
if (getLaunchConfiguration() == null)
|
||||
return project.getName();
|
||||
else
|
||||
return getConfig().getName();
|
||||
return getLaunchConfiguration().getName();
|
||||
}
|
||||
|
||||
public IProject getProject() {
|
||||
return project;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if (getLaunchConfiguration() == null)
|
||||
return getName();
|
||||
return "LC/" + getName();
|
||||
}
|
||||
}
|
|
@ -13,6 +13,7 @@ package org.eclipse.cdt.launchbar.core.internal;
|
|||
import org.eclipse.cdt.launchbar.core.ILaunchBarManager;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.core.runtime.Plugin;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.osgi.framework.Bundle;
|
||||
|
@ -73,4 +74,11 @@ public class Activator extends Plugin {
|
|||
log(new Status(IStatus.ERROR, PLUGIN_ID, exception.getLocalizedMessage(), exception));
|
||||
}
|
||||
|
||||
private static final String DEBUG_ONE =
|
||||
PLUGIN_ID + "/debug/launchbar";
|
||||
|
||||
public static void trace(String str) {
|
||||
if (plugin == null || (plugin.isDebugging() && "true".equalsIgnoreCase(Platform.getDebugOption(DEBUG_ONE))))
|
||||
System.out.println("launchbar: " + str);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -124,10 +124,10 @@ public class LaunchBarManager extends PlatformObject implements ILaunchBarManage
|
|||
String targetType = element.getAttribute("targetType");
|
||||
String launchType = element.getAttribute("launchConfigurationType");
|
||||
String isDefault = element.getAttribute("isDefault");
|
||||
ILaunchConfigurationProvider configProvider = new ConfigBasedLaunchConfigurationProvider(launchType);
|
||||
addConfigProvider(descriptorType, targetType, Boolean.valueOf(isDefault), configProvider);
|
||||
ILaunchDescriptorType type = new ConfigBasedLaunchDescriptorType(descriptorType, launchType);
|
||||
addDescriptorType(type, 2);// TODO: fix priority
|
||||
ILaunchConfigurationProvider configProvider = new ConfigBasedLaunchConfigurationProvider(launchType);
|
||||
addConfigProvider(type.getId(), targetType, Boolean.valueOf(isDefault), configProvider);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Activator.log(e); // exceptions during extension loading, log and move on
|
||||
|
@ -177,6 +177,7 @@ public class LaunchBarManager extends PlatformObject implements ILaunchBarManage
|
|||
} catch (Exception e) {
|
||||
Activator.log(e);
|
||||
}
|
||||
Activator.trace("registered descriptor type " + type);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -189,6 +190,7 @@ public class LaunchBarManager extends PlatformObject implements ILaunchBarManage
|
|||
} catch (Exception e) {
|
||||
Activator.log(e);
|
||||
}
|
||||
Activator.trace("registered target " + targetType);
|
||||
}
|
||||
|
||||
protected ILaunchManager getLaunchManager() {
|
||||
|
@ -222,6 +224,7 @@ public class LaunchBarManager extends PlatformObject implements ILaunchBarManage
|
|||
} catch (Exception e) {
|
||||
Activator.log(e);
|
||||
}
|
||||
Activator.trace("registered provider " + descriptorType + "->" + targetType);
|
||||
}
|
||||
|
||||
public ILaunchDescriptorType getDescriptorType(String descriptorTypeId) {
|
||||
|
@ -237,7 +240,8 @@ public class LaunchBarManager extends PlatformObject implements ILaunchBarManage
|
|||
ILaunchDescriptor old = objectDescriptorMap.get(element);
|
||||
if (old != null) { // old mapping is removed
|
||||
objectDescriptorMap.remove(element);
|
||||
descriptors.remove(getId(old));
|
||||
if (!objectDescriptorMap.values().contains(old)) // if no one else is mapped to it
|
||||
descriptors.remove(getId(old));
|
||||
}
|
||||
ILaunchDescriptor desc = null;
|
||||
// re-do the mapping, change in object can change descriptor (for example project has new nature)
|
||||
|
@ -245,6 +249,7 @@ public class LaunchBarManager extends PlatformObject implements ILaunchBarManage
|
|||
try {
|
||||
if (descriptorType.ownsLaunchObject(element)) {
|
||||
desc = descriptorType.getDescriptor(element);
|
||||
Activator.trace("launch object remap found " + element + " -> " + descriptorType + " -> " + desc);
|
||||
objectDescriptorMap.put(element, desc); // set it even if desc is null to keep object is map
|
||||
if (desc != null) // null if we own the object but do not create descriptor
|
||||
descriptors.put(getId(desc), desc);
|
||||
|
@ -254,6 +259,7 @@ public class LaunchBarManager extends PlatformObject implements ILaunchBarManage
|
|||
Activator.log(e);
|
||||
}
|
||||
}
|
||||
Activator.trace("launch object remap " + element + "-> " + objectDescriptorMap.get(element));
|
||||
if (old != null && old.equals(activeLaunchDesc) && !old.equals(desc)) {
|
||||
// change of object caused changed of descriptor, which was active, reset since old is invalid now
|
||||
// setting it to null, will actually rollback to last used one which is still valid
|
||||
|
@ -262,11 +268,13 @@ public class LaunchBarManager extends PlatformObject implements ILaunchBarManage
|
|||
// new object causes re-set of active descriptor too
|
||||
setActiveLaunchDescriptor(desc);
|
||||
}
|
||||
|
||||
return desc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILaunchDescriptor launchObjectAdded(Object element) {
|
||||
Activator.trace("launch object added " + element);
|
||||
if (objectDescriptorMap.containsKey(element)) {
|
||||
// it was added already, perform change
|
||||
return launchObjectChanged(element);
|
||||
|
@ -276,6 +284,7 @@ public class LaunchBarManager extends PlatformObject implements ILaunchBarManage
|
|||
|
||||
@Override
|
||||
public ILaunchDescriptor launchObjectChanged(Object element) {
|
||||
Activator.trace("launch object changed " + element);
|
||||
// only applied to object that were added via launchObjectAdded
|
||||
if (!objectDescriptorMap.containsKey(element))
|
||||
return null;
|
||||
|
@ -290,14 +299,18 @@ public class LaunchBarManager extends PlatformObject implements ILaunchBarManage
|
|||
|
||||
@Override
|
||||
public void launchObjectRemoved(Object element) {
|
||||
Activator.trace("launch object removed " + element);
|
||||
ILaunchDescriptor desc = objectDescriptorMap.get(element);
|
||||
objectDescriptorMap.remove(element);
|
||||
if (desc != null) {
|
||||
descriptors.remove(getId(desc)); // can multiple elements maps to the same descriptor?
|
||||
if (desc.equals(activeLaunchDesc)) {
|
||||
// Roll back to the last one and make sure we don't come back
|
||||
ILaunchDescriptor nextDesc = getLastUsedDescriptor();
|
||||
setActiveLaunchDescriptor(nextDesc);
|
||||
if (!objectDescriptorMap.values().contains(desc)) {
|
||||
// if no one else is mapped to it
|
||||
descriptors.remove(getId(desc)); // can multiple elements maps to the same descriptor?
|
||||
if (desc.equals(activeLaunchDesc)) {
|
||||
// Roll back to the last one and make sure we don't come back
|
||||
ILaunchDescriptor nextDesc = getLastUsedDescriptor();
|
||||
setActiveLaunchDescriptor(nextDesc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -328,10 +341,12 @@ public class LaunchBarManager extends PlatformObject implements ILaunchBarManage
|
|||
|
||||
@Override
|
||||
public void setActiveLaunchDescriptor(ILaunchDescriptor configDesc) {
|
||||
Activator.trace("set active descriptor " + configDesc);
|
||||
if (activeLaunchDesc == configDesc) {
|
||||
// Sync since targets could be changed since last time (and modes theoretically too)
|
||||
syncActiveTarget();
|
||||
syncActiveMode();
|
||||
Activator.trace("resync for " + configDesc);
|
||||
return;
|
||||
}
|
||||
if (configDesc != null && !descriptors.containsValue(configDesc))
|
||||
|
@ -346,6 +361,7 @@ public class LaunchBarManager extends PlatformObject implements ILaunchBarManage
|
|||
}
|
||||
// store in persistent storage
|
||||
setPreference(getPreferenceStore(), PREF_ACTIVE_CONFIG_DESC, getId(activeLaunchDesc));
|
||||
Activator.trace("new active config is stored " + configDesc);
|
||||
|
||||
// Send notifications
|
||||
updateLaunchDescriptor(activeLaunchDesc);
|
||||
|
@ -582,7 +598,9 @@ public class LaunchBarManager extends PlatformObject implements ILaunchBarManage
|
|||
try {
|
||||
if (descriptor instanceof ILaunchDescriptorConfigBased) {
|
||||
// if descriptor is launch config based we don't need provider to determine the type
|
||||
return ((ILaunchDescriptorConfigBased) descriptor).getConfig().getType();
|
||||
ILaunchConfiguration config = ((ILaunchDescriptorConfigBased) descriptor).getLaunchConfiguration();
|
||||
if (config != null)
|
||||
return config.getType();
|
||||
}
|
||||
String descriptorTypeId = descriptor.getType().getId();
|
||||
Map<String, ILaunchConfigurationProvider> targetMap = configProviders.get(descriptorTypeId);
|
||||
|
@ -637,12 +655,14 @@ public class LaunchBarManager extends PlatformObject implements ILaunchBarManage
|
|||
|
||||
@Override
|
||||
public void launchConfigurationAdded(ILaunchConfiguration configuration) {
|
||||
Activator.trace("launch config added " + configuration);
|
||||
// TODO filter by launch configuration type to avoid loading plug-ins
|
||||
for (ILaunchDescriptorType descriptorType : descriptorTypes.keySet()) {
|
||||
Map<String, ILaunchConfigurationProvider> targetMap = configProviders.get(descriptorType.getId());
|
||||
for (ILaunchConfigurationProvider configProvider : targetMap.values()) {
|
||||
try {
|
||||
if (configProvider.launchConfigurationAdded(configuration)) {
|
||||
Activator.trace("launch config claimed by " + configProvider);
|
||||
return;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
@ -651,17 +671,20 @@ public class LaunchBarManager extends PlatformObject implements ILaunchBarManage
|
|||
}
|
||||
}
|
||||
// No one claimed it, send it through the descriptorTypes
|
||||
Activator.trace("launch config not claimed");
|
||||
launchObjectAdded(configuration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void launchConfigurationRemoved(ILaunchConfiguration configuration) {
|
||||
Activator.trace("launch config removed " + configuration);
|
||||
// TODO filter by launch configuration type
|
||||
for (ILaunchDescriptorType descriptorType : descriptorTypes.keySet()) {
|
||||
Map<String, ILaunchConfigurationProvider> targetMap = configProviders.get(descriptorType.getId());
|
||||
for (ILaunchConfigurationProvider configProvider : targetMap.values()) {
|
||||
try {
|
||||
if (configProvider.launchConfigurationRemoved(configuration)) {
|
||||
Activator.trace("launch config claimed by " + configProvider);
|
||||
return;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
@ -669,6 +692,7 @@ public class LaunchBarManager extends PlatformObject implements ILaunchBarManage
|
|||
}
|
||||
}
|
||||
}
|
||||
Activator.trace("launch config not claimed");
|
||||
launchObjectRemoved(configuration);
|
||||
}
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.eclipse.core.runtime.Status;
|
|||
import org.eclipse.core.runtime.jobs.Job;
|
||||
import org.eclipse.debug.core.ILaunchConfiguration;
|
||||
import org.eclipse.debug.core.ILaunchConfigurationType;
|
||||
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
|
||||
import org.eclipse.debug.core.ILaunchMode;
|
||||
import org.eclipse.debug.internal.ui.DebugUIPlugin;
|
||||
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchGroupExtension;
|
||||
|
@ -160,6 +161,13 @@ public class ConfigSelector extends CSelector {
|
|||
LaunchGroupExtension groupExt = DebugUIPlugin.getDefault().getLaunchConfigurationManager().getLaunchGroup(group.getIdentifier());
|
||||
if (groupExt != null) {
|
||||
ILaunchConfiguration config = getManager().getLaunchConfiguration(desc, target);
|
||||
if (config == null) {
|
||||
MessageDialog.openError(shell, "No launch configuration", "Cannot edit this configuration");
|
||||
return;
|
||||
}
|
||||
if (config.isWorkingCopy() && ((ILaunchConfigurationWorkingCopy) config).isDirty()) {
|
||||
config = ((ILaunchConfigurationWorkingCopy) config).doSave();
|
||||
}
|
||||
final LaunchConfigurationEditDialog dialog = new LaunchConfigurationEditDialog(shell, config, groupExt);
|
||||
dialog.setInitialStatus(Status.OK_STATUS);
|
||||
dialog.open();
|
||||
|
|
Loading…
Add table
Reference in a new issue