mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-05 16:15:25 +02:00
[launchbar] Support launching without a target
- we should not make assumption about the target and let delegate deal with it. For example if no targets are created and you run for the first time, delegate can offer to create a target - also if launch bar participants don't care about targets at all we should be able to still show modes, etc - so I removed filters on null target and let participant deal with it (note null target is not the same as Local). To avoid NPEs null target is actually an object ILaunchTarget.NULL_TARGET Change-Id: Ie2a4d3430284adbb137a4565d9976a0ba554d41f
This commit is contained in:
parent
503a393e4e
commit
d5c63d386c
3 changed files with 14 additions and 10 deletions
|
@ -490,7 +490,7 @@ public class LaunchBarManager implements ILaunchBarManager, ILaunchTargetListene
|
|||
}
|
||||
|
||||
private void syncActiveMode() throws CoreException {
|
||||
if (activeLaunchDesc == null || activeLaunchTarget == null) {
|
||||
if (activeLaunchDesc == null) {
|
||||
setActiveLaunchMode(null);
|
||||
return;
|
||||
}
|
||||
|
@ -574,9 +574,6 @@ public class LaunchBarManager implements ILaunchBarManager, ILaunchTargetListene
|
|||
}
|
||||
|
||||
public ILaunchMode[] getLaunchModes() throws CoreException {
|
||||
if (activeLaunchTarget == null) {
|
||||
return new ILaunchMode[0];
|
||||
}
|
||||
ILaunchConfigurationType configType = getLaunchConfigurationType(activeLaunchDesc, activeLaunchTarget);
|
||||
if (configType == null)
|
||||
return new ILaunchMode[0];
|
||||
|
@ -689,6 +686,8 @@ public class LaunchBarManager implements ILaunchBarManager, ILaunchTargetListene
|
|||
}
|
||||
|
||||
public void setActiveLaunchTarget(ILaunchTarget target) throws CoreException {
|
||||
if (target == null)
|
||||
target = ILaunchTarget.NULL_TARGET;
|
||||
if (activeLaunchTarget == target) {
|
||||
return;
|
||||
}
|
||||
|
@ -699,7 +698,7 @@ public class LaunchBarManager implements ILaunchBarManager, ILaunchTargetListene
|
|||
}
|
||||
|
||||
private void storeLaunchTarget(ILaunchDescriptor desc, ILaunchTarget target) {
|
||||
if (target == null) {
|
||||
if (target == null || target == ILaunchTarget.NULL_TARGET) {
|
||||
// no point storing null, if stored id is invalid it won't be used
|
||||
// anyway
|
||||
return;
|
||||
|
@ -722,7 +721,7 @@ public class LaunchBarManager implements ILaunchBarManager, ILaunchTargetListene
|
|||
|
||||
private ILaunchTarget getDefaultLaunchTarget(ILaunchDescriptor descriptor) {
|
||||
List<ILaunchTarget> targets = getLaunchTargets(descriptor);
|
||||
return targets.isEmpty() ? null : targets.get(0);
|
||||
return targets.isEmpty() ? ILaunchTarget.NULL_TARGET : targets.get(0);
|
||||
}
|
||||
|
||||
public ILaunchConfiguration getActiveLaunchConfiguration() throws CoreException {
|
||||
|
|
|
@ -8,26 +8,28 @@
|
|||
package org.eclipse.launchbar.core.target;
|
||||
|
||||
import org.eclipse.core.runtime.IAdaptable;
|
||||
import org.eclipse.launchbar.core.internal.target.LaunchTarget;
|
||||
|
||||
/**
|
||||
* A launch target is a thing that a launch will run on. Launch targets are
|
||||
* simple objects with the intention that the launch delegates and launches will
|
||||
* adapt this object to an object that will assist in performing the launch.
|
||||
*
|
||||
*
|
||||
* @noimplement not to be implemented by clients
|
||||
*/
|
||||
public interface ILaunchTarget extends IAdaptable {
|
||||
public static final ILaunchTarget NULL_TARGET = new LaunchTarget("null", "---");
|
||||
|
||||
/**
|
||||
* The name of the target.
|
||||
*
|
||||
*
|
||||
* @return name of the target
|
||||
*/
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* The type of the target.
|
||||
*
|
||||
*
|
||||
* @return type of the target
|
||||
*/
|
||||
String getTypeId();
|
||||
|
|
|
@ -49,7 +49,7 @@ public class TargetSelector extends CSelector implements ILaunchTargetListener {
|
|||
private final ILaunchTargetUIManager targetUIManager = Activator.getService(ILaunchTargetUIManager.class);
|
||||
private final ILaunchTargetManager targetManager = Activator.getService(ILaunchTargetManager.class);
|
||||
|
||||
private static final String[] noTargets = new String[] { "---" }; //$NON-NLS-1$
|
||||
private static final ILaunchTarget[] noTargets = new ILaunchTarget[] { ILaunchTarget.NULL_TARGET };
|
||||
|
||||
public TargetSelector(Composite parent, int style) {
|
||||
super(parent, style);
|
||||
|
@ -89,6 +89,9 @@ public class TargetSelector extends CSelector implements ILaunchTargetListener {
|
|||
|
||||
@Override
|
||||
public Image getImage(Object element) {
|
||||
if (element == ILaunchTarget.NULL_TARGET) {
|
||||
return null;
|
||||
}
|
||||
if (element instanceof ILaunchTarget) {
|
||||
// TODO apply a status overlay
|
||||
ILaunchTarget target = (ILaunchTarget) element;
|
||||
|
|
Loading…
Add table
Reference in a new issue