1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-03 07:05:24 +02:00

launchbar: active remote connection is not persisted in the remote

services

- if you select target for given launch config and restart IDE
it is not persistent, because it queries remote services and
it has not been set. Moving setting of target in the correct place
Note: if launch config is not created yet it would not be create
and mapping would not be set but it would be persisted by launch bar
itself
- also added protection against null listener

Change-Id: I41f8651ba2251ca9f841450fc1f511643bfde681
This commit is contained in:
Alena Laskavaia 2015-04-27 10:35:54 -04:00
parent 013c6fa1fe
commit f2b778e3c7
2 changed files with 27 additions and 12 deletions

View file

@ -831,6 +831,15 @@ public class LaunchBarManager implements ILaunchBarManager, ILaunchConfiguration
}
// per desc store, desc can be null means it store globally
setPreference(getPerDescriptorStore(desc), PREF_ACTIVE_LAUNCH_TARGET, toString(getTargetId(target)));
// Also we have to store this in remote connection service
try {
ILaunchConfiguration config = getLaunchConfiguration(desc, target, false);
if (config != null) {
remoteLaunchConfigService.setActiveConnection(config, target);
}
} catch (CoreException e) {
Activator.log(e);
}
}
private void fireActiveLaunchTargetChanged() {
@ -854,18 +863,16 @@ public class LaunchBarManager implements ILaunchBarManager, ILaunchConfiguration
}
public ILaunchConfiguration getActiveLaunchConfiguration() throws CoreException {
ILaunchConfiguration activeConfig = getLaunchConfiguration(activeLaunchDesc, activeLaunchTarget);
if (activeConfig != null) {
// Save the config -> target mapping
// TODO: seems to be weird place for setting this
remoteLaunchConfigService.setActiveConnection(activeConfig, activeLaunchTarget);
}
return activeConfig;
return getLaunchConfiguration(activeLaunchDesc, activeLaunchTarget);
}
// Don't call this to get the active launch config. Use getActiveLaunchConfiguration(). It ensures that config -> target
// mapping is saved.
public ILaunchConfiguration getLaunchConfiguration(ILaunchDescriptor descriptor, IRemoteConnection target) throws CoreException {
return getLaunchConfiguration(descriptor, target, true);
}
private ILaunchConfiguration getLaunchConfiguration(ILaunchDescriptor descriptor, IRemoteConnection target,
boolean create) throws CoreException {
if (descriptor == null) {
return null;
}
@ -884,11 +891,14 @@ public class LaunchBarManager implements ILaunchBarManager, ILaunchConfiguration
configMap = new HashMap<>();
configs.put(descriptor, configMap);
}
if (create == false)
return null;
// Not found, create, store and return it
ILaunchConfiguration config = configProvider.createLaunchConfiguration(getLaunchManager(), descriptor);
if (config != null) {
configMap.put(configProvider, config);
// since new LC is created we need to associate it with remote target
storeLaunchTarget(descriptor, target);
return config;
}
}
@ -897,10 +907,14 @@ public class LaunchBarManager implements ILaunchBarManager, ILaunchConfiguration
}
public void addListener(Listener listener) {
if (listener == null)
return;
listeners.add(listener);
}
public void removeListener(Listener listener) {
if (listener == null)
return;
listeners.remove(listener);
}

View file

@ -185,6 +185,7 @@ public class LaunchBarManager2Test {
ILaunchConfiguration lc = mock(ILaunchConfiguration.class);
doReturn(string).when(lc).getName();
doReturn(lctype2).when(lc).getType();
doReturn("").when(lc).getAttribute(eq(ORIGINAL_NAME), eq(""));
return lc;
}
@ -580,7 +581,7 @@ public class LaunchBarManager2Test {
return "pbtype";
}
}
String ORIGINAL_NAME = org.eclipse.launchbar.core.internal.Activator.PLUGIN_ID + ".originalName";
protected void projectMappingSetup() throws CoreException {
descriptorType = new ProjectBasedLaunchDescriptorType();
descriptorTypeId = ((ProjectBasedLaunchDescriptorType) descriptorType).getId();
@ -599,7 +600,7 @@ public class LaunchBarManager2Test {
mockConfigTypeElement(localTargetTypeId, descriptorTypeId, launchConfigType.getIdentifier());
//lc = provider.createLaunchConfiguration(lman, descType.getDescriptor(aaa));
mockLCProject(launchConfig, aaa);
String ORIGINAL_NAME = org.eclipse.launchbar.core.internal.Activator.PLUGIN_ID + ".originalName";
mockLCAttribute(launchConfig, ORIGINAL_NAME, aaa.getName());
mockProviderElement(provider);
assertEquals(0, manager.getLaunchDescriptors().length);