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

Bug 466489 - Limit launchbar-visible configs to public launch types; fix unit test

- Cleanup of bad catch block

Change-Id: If5c9adcc6970ffb480312e2453fcb153674cf79b
Signed-off-by: Rob Stryker <rob.stryker@jboss.com>
This commit is contained in:
Rob Stryker 2015-05-05 21:49:03 -04:00 committed by Elena Laskavaia
parent fd58fed7e4
commit 4e67214de3
3 changed files with 18 additions and 6 deletions

View file

@ -3,7 +3,9 @@ package org.eclipse.launchbar.core.internal;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.launchbar.core.ILaunchDescriptor;
import org.eclipse.launchbar.core.ILaunchDescriptorType;
@ -27,12 +29,20 @@ public class DefaultLaunchDescriptorType implements ILaunchDescriptorType {
public ILaunchDescriptor getDescriptor(Object element) {
if (element instanceof ILaunchConfiguration) {
ILaunchConfiguration config = (ILaunchConfiguration) element;
DefaultLaunchDescriptor descriptor = descriptors.get(config);
if (descriptor == null) {
descriptor = new DefaultLaunchDescriptor(this, config);
descriptors.put(config, descriptor);
}
return descriptor;
try {
if( config.getType() != null && config.getType().isPublic()
&& !(config.getAttribute(ILaunchManager.ATTR_PRIVATE, false))) {
DefaultLaunchDescriptor descriptor = descriptors.get(config);
if (descriptor == null) {
descriptor = new DefaultLaunchDescriptor(this, config);
descriptors.put(config, descriptor);
}
return descriptor;
}
} catch(CoreException ce) {
Activator.log(ce.getStatus());
}
}
return null;

View file

@ -192,6 +192,7 @@ public class LaunchBarManager2Test {
protected ILaunchConfigurationType mockLCType(String id) {
ILaunchConfigurationType lctype = mock(ILaunchConfigurationType.class);
doReturn(true).when(lctype).isPublic();
doReturn(id).when(lctype).getIdentifier();
doReturn(lctype).when(lman).getLaunchConfigurationType(id);
return lctype;

View file

@ -48,6 +48,7 @@ public class LaunchBarManagerTest {
// Mocking
ILaunchConfigurationType launchConfigType = mock(ILaunchConfigurationType.class);
ILaunchConfiguration launchConfig = mock(ILaunchConfiguration.class);
doReturn(true).when(launchConfigType).isPublic();
doReturn(launchConfigType).when(launchConfig).getType();
doReturn("dummy").when(launchConfigType).getIdentifier();
doReturn(true).when(launchConfigType).supportsMode("run");