mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-11 11:05:24 +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 {
|
private void syncActiveMode() throws CoreException {
|
||||||
if (activeLaunchDesc == null || activeLaunchTarget == null) {
|
if (activeLaunchDesc == null) {
|
||||||
setActiveLaunchMode(null);
|
setActiveLaunchMode(null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -574,9 +574,6 @@ public class LaunchBarManager implements ILaunchBarManager, ILaunchTargetListene
|
||||||
}
|
}
|
||||||
|
|
||||||
public ILaunchMode[] getLaunchModes() throws CoreException {
|
public ILaunchMode[] getLaunchModes() throws CoreException {
|
||||||
if (activeLaunchTarget == null) {
|
|
||||||
return new ILaunchMode[0];
|
|
||||||
}
|
|
||||||
ILaunchConfigurationType configType = getLaunchConfigurationType(activeLaunchDesc, activeLaunchTarget);
|
ILaunchConfigurationType configType = getLaunchConfigurationType(activeLaunchDesc, activeLaunchTarget);
|
||||||
if (configType == null)
|
if (configType == null)
|
||||||
return new ILaunchMode[0];
|
return new ILaunchMode[0];
|
||||||
|
@ -689,6 +686,8 @@ public class LaunchBarManager implements ILaunchBarManager, ILaunchTargetListene
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setActiveLaunchTarget(ILaunchTarget target) throws CoreException {
|
public void setActiveLaunchTarget(ILaunchTarget target) throws CoreException {
|
||||||
|
if (target == null)
|
||||||
|
target = ILaunchTarget.NULL_TARGET;
|
||||||
if (activeLaunchTarget == target) {
|
if (activeLaunchTarget == target) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -699,7 +698,7 @@ public class LaunchBarManager implements ILaunchBarManager, ILaunchTargetListene
|
||||||
}
|
}
|
||||||
|
|
||||||
private void storeLaunchTarget(ILaunchDescriptor desc, ILaunchTarget target) {
|
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
|
// no point storing null, if stored id is invalid it won't be used
|
||||||
// anyway
|
// anyway
|
||||||
return;
|
return;
|
||||||
|
@ -722,7 +721,7 @@ public class LaunchBarManager implements ILaunchBarManager, ILaunchTargetListene
|
||||||
|
|
||||||
private ILaunchTarget getDefaultLaunchTarget(ILaunchDescriptor descriptor) {
|
private ILaunchTarget getDefaultLaunchTarget(ILaunchDescriptor descriptor) {
|
||||||
List<ILaunchTarget> targets = getLaunchTargets(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 {
|
public ILaunchConfiguration getActiveLaunchConfiguration() throws CoreException {
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
package org.eclipse.launchbar.core.target;
|
package org.eclipse.launchbar.core.target;
|
||||||
|
|
||||||
import org.eclipse.core.runtime.IAdaptable;
|
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
|
* A launch target is a thing that a launch will run on. Launch targets are
|
||||||
|
@ -17,6 +18,7 @@ import org.eclipse.core.runtime.IAdaptable;
|
||||||
* @noimplement not to be implemented by clients
|
* @noimplement not to be implemented by clients
|
||||||
*/
|
*/
|
||||||
public interface ILaunchTarget extends IAdaptable {
|
public interface ILaunchTarget extends IAdaptable {
|
||||||
|
public static final ILaunchTarget NULL_TARGET = new LaunchTarget("null", "---");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name of the target.
|
* The name of the target.
|
||||||
|
|
|
@ -49,7 +49,7 @@ public class TargetSelector extends CSelector implements ILaunchTargetListener {
|
||||||
private final ILaunchTargetUIManager targetUIManager = Activator.getService(ILaunchTargetUIManager.class);
|
private final ILaunchTargetUIManager targetUIManager = Activator.getService(ILaunchTargetUIManager.class);
|
||||||
private final ILaunchTargetManager targetManager = Activator.getService(ILaunchTargetManager.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) {
|
public TargetSelector(Composite parent, int style) {
|
||||||
super(parent, style);
|
super(parent, style);
|
||||||
|
@ -89,6 +89,9 @@ public class TargetSelector extends CSelector implements ILaunchTargetListener {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Image getImage(Object element) {
|
public Image getImage(Object element) {
|
||||||
|
if (element == ILaunchTarget.NULL_TARGET) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
if (element instanceof ILaunchTarget) {
|
if (element instanceof ILaunchTarget) {
|
||||||
// TODO apply a status overlay
|
// TODO apply a status overlay
|
||||||
ILaunchTarget target = (ILaunchTarget) element;
|
ILaunchTarget target = (ILaunchTarget) element;
|
||||||
|
|
Loading…
Add table
Reference in a new issue