1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-18 21:55:45 +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.HashMap;
import java.util.Map; import java.util.Map;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.launchbar.core.ILaunchDescriptor; import org.eclipse.launchbar.core.ILaunchDescriptor;
import org.eclipse.launchbar.core.ILaunchDescriptorType; import org.eclipse.launchbar.core.ILaunchDescriptorType;
@ -27,6 +29,10 @@ public class DefaultLaunchDescriptorType implements ILaunchDescriptorType {
public ILaunchDescriptor getDescriptor(Object element) { public ILaunchDescriptor getDescriptor(Object element) {
if (element instanceof ILaunchConfiguration) { if (element instanceof ILaunchConfiguration) {
ILaunchConfiguration config = (ILaunchConfiguration) element; ILaunchConfiguration config = (ILaunchConfiguration) element;
try {
if( config.getType() != null && config.getType().isPublic()
&& !(config.getAttribute(ILaunchManager.ATTR_PRIVATE, false))) {
DefaultLaunchDescriptor descriptor = descriptors.get(config); DefaultLaunchDescriptor descriptor = descriptors.get(config);
if (descriptor == null) { if (descriptor == null) {
descriptor = new DefaultLaunchDescriptor(this, config); descriptor = new DefaultLaunchDescriptor(this, config);
@ -34,6 +40,10 @@ public class DefaultLaunchDescriptorType implements ILaunchDescriptorType {
} }
return descriptor; return descriptor;
} }
} catch(CoreException ce) {
Activator.log(ce.getStatus());
}
}
return null; return null;
} }

View file

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

View file

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