mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-09 09:15:38 +02:00
Bug 437392 - Added the Launch Targets View.
This view lists all launch targets that could appear in the Target selector. It allows us to add context menus to them to perform operations, such as opening a terminal view to the target. It will also gives us a cleaner UI to add and remove targets Change-Id: I538a204ce6f25fd017573c50585ac45cdeeaf554 Reviewed-on: https://git.eclipse.org/r/31856 Tested-by: Hudson CI Reviewed-by: Jonathan Williams <jonwilliams@qnx.com> Reviewed-by: Doug Schaefer <dschaefer@qnx.com>
This commit is contained in:
parent
ec2fe61a04
commit
3a81f65932
7 changed files with 204 additions and 18 deletions
|
@ -21,7 +21,10 @@
|
|||
<visibleWhen checkEnabled="false">
|
||||
<iterate ifEmpty="false">
|
||||
<adapt type="org.eclipse.core.resources.IResource">
|
||||
<test property="org.eclipse.core.resources.projectNature" value="org.eclipse.cdt.core.cnature"/>
|
||||
<test
|
||||
forcePluginActivation="true"
|
||||
property="org.eclipse.core.resources.projectNature"
|
||||
value="org.eclipse.cdt.core.cnature"/>
|
||||
</adapt>
|
||||
</iterate>
|
||||
</visibleWhen>
|
||||
|
|
|
@ -25,7 +25,7 @@ public interface ILaunchBarManager extends IAdaptable {
|
|||
ILaunchDescriptor getActiveLaunchDescriptor() throws CoreException;
|
||||
|
||||
void setActiveLaunchDescriptor(ILaunchDescriptor configDesc) throws CoreException;
|
||||
|
||||
|
||||
void updateLaunchDescriptor(ILaunchDescriptor configDesc) throws CoreException;
|
||||
|
||||
ILaunchMode[] getLaunchModes() throws CoreException;
|
||||
|
@ -35,15 +35,19 @@ public interface ILaunchBarManager extends IAdaptable {
|
|||
void setActiveLaunchMode(ILaunchMode mode) throws CoreException;
|
||||
|
||||
ILaunchTarget[] getLaunchTargets() throws CoreException;
|
||||
|
||||
|
||||
ILaunchTarget getLaunchTarget(String id) throws CoreException;
|
||||
|
||||
ILaunchTarget getActiveLaunchTarget() throws CoreException;
|
||||
|
||||
void setActiveLaunchTarget(ILaunchTarget target) throws CoreException;
|
||||
|
||||
|
||||
void updateLaunchTarget(ILaunchTarget target) throws CoreException;
|
||||
|
||||
void launchTargetAdded(ILaunchTarget target) throws CoreException;
|
||||
|
||||
void launchTargetRemoved(ILaunchTarget target) throws CoreException;
|
||||
|
||||
ILaunchConfigurationType getLaunchConfigurationType(ILaunchDescriptor descriptor, ILaunchTarget target) throws CoreException;
|
||||
|
||||
ILaunchConfiguration getLaunchConfiguration(ILaunchDescriptor descriptor, ILaunchTarget target) throws CoreException;
|
||||
|
@ -66,6 +70,8 @@ public interface ILaunchBarManager extends IAdaptable {
|
|||
|
||||
void launchDescriptorRemoved(ILaunchDescriptor descriptor);
|
||||
|
||||
void launchTargetsChanged();
|
||||
|
||||
}
|
||||
|
||||
void addListener(Listener listener);
|
||||
|
|
|
@ -441,8 +441,8 @@ public class LaunchBarManager extends PlatformObject implements ILaunchBarManage
|
|||
return;
|
||||
}
|
||||
// default target for descriptor
|
||||
setActiveLaunchTarget(getDeafultLaunchTarget(activeLaunchDesc));
|
||||
}
|
||||
setActiveLaunchTarget(getDefaultLaunchTarget(activeLaunchDesc));
|
||||
}
|
||||
|
||||
protected void syncActiveMode() {
|
||||
if (activeLaunchDesc == null) {
|
||||
|
@ -590,10 +590,6 @@ public class LaunchBarManager extends PlatformObject implements ILaunchBarManage
|
|||
|
||||
@Override
|
||||
public void setActiveLaunchTarget(ILaunchTarget target) {
|
||||
if (target == null) {
|
||||
// try and select another target XXX this should not be an API
|
||||
target = getDeafultLaunchTarget(activeLaunchDesc);
|
||||
}
|
||||
if (activeLaunchTarget == target)
|
||||
return;
|
||||
activeLaunchTarget = target;
|
||||
|
@ -621,7 +617,35 @@ public class LaunchBarManager extends PlatformObject implements ILaunchBarManage
|
|||
}
|
||||
}
|
||||
|
||||
protected ILaunchTarget getDeafultLaunchTarget(ILaunchDescriptor descriptor) {
|
||||
@Override
|
||||
public void launchTargetAdded(ILaunchTarget target) throws CoreException {
|
||||
for (Listener listener : listeners) {
|
||||
try {
|
||||
listener.launchTargetsChanged();
|
||||
} catch (Exception e) {
|
||||
Activator.log(e);
|
||||
}
|
||||
}
|
||||
if (activeLaunchTarget == null && supportsTargetType(activeLaunchDesc, target.getType())) {
|
||||
setActiveLaunchTarget(target);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void launchTargetRemoved(ILaunchTarget target) throws CoreException {
|
||||
for (Listener listener : listeners) {
|
||||
try {
|
||||
listener.launchTargetsChanged();
|
||||
} catch (Exception e) {
|
||||
Activator.log(e);
|
||||
}
|
||||
}
|
||||
if (activeLaunchTarget == target) {
|
||||
setActiveLaunchTarget(getDefaultLaunchTarget(activeLaunchDesc));
|
||||
}
|
||||
}
|
||||
|
||||
protected ILaunchTarget getDefaultLaunchTarget(ILaunchDescriptor descriptor) {
|
||||
ILaunchTarget[] targets = getLaunchTargets(descriptor);
|
||||
if (targets.length > 0) {
|
||||
return targets[0];
|
||||
|
@ -641,6 +665,10 @@ public class LaunchBarManager extends PlatformObject implements ILaunchBarManage
|
|||
return null;
|
||||
}
|
||||
|
||||
public ILaunchTargetType[] getAllLaunchTargetTypes() {
|
||||
return targetTypes.values().toArray(new ILaunchTargetType[targetTypes.values().size()]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILaunchConfigurationType getLaunchConfigurationType(ILaunchDescriptor descriptor, ILaunchTarget target) {
|
||||
if (descriptor == null)
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
launchToolBar.label = LaunchBar
|
||||
targetsView.name = Launch Targets
|
||||
|
|
|
@ -71,5 +71,28 @@
|
|||
name="Local Target">
|
||||
</targetUI>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.ui.views">
|
||||
<view
|
||||
category="org.eclipse.cdt.ui.views"
|
||||
class="org.eclipse.cdt.launchbar.ui.internal.targetsView.LaunchTargetsViewPart"
|
||||
id="org.eclipse.cdt.launchbar.ui.targetsView"
|
||||
name="%targetsView.name"
|
||||
restorable="true">
|
||||
</view>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.ui.perspectiveExtensions">
|
||||
<perspectiveExtension
|
||||
targetID="org.eclipse.cdt.ui.CPerspective">
|
||||
<view
|
||||
id="org.eclipse.cdt.launchbar.ui.targetsView"
|
||||
minimized="false"
|
||||
ratio="0.75"
|
||||
relationship="bottom"
|
||||
relative="org.eclipse.ui.navigator.ProjectExplorer">
|
||||
</view>
|
||||
</perspectiveExtension>
|
||||
</extension>
|
||||
|
||||
</plugin>
|
||||
|
|
|
@ -39,11 +39,11 @@ public class LaunchBarControl implements ILaunchBarManager.Listener {
|
|||
|
||||
@Inject
|
||||
private ILaunchBarManager manager;
|
||||
|
||||
|
||||
private ConfigSelector configSelector;
|
||||
private ModeSelector modeSelector;
|
||||
private TargetSelector targetSelector;
|
||||
|
||||
|
||||
@PostConstruct
|
||||
public void createControl(Composite parent) {
|
||||
manager.addListener(this);
|
||||
|
@ -64,7 +64,7 @@ public class LaunchBarControl implements ILaunchBarManager.Listener {
|
|||
createButton(container, Activator.IMG_BUTTON_BUILD, Messages.LaunchBarControl_Build, Activator.CMD_BUILD);
|
||||
createButton(container, Activator.IMG_BUTTON_LAUNCH, Messages.LaunchBarControl_Launch, Activator.CMD_LAUNCH);
|
||||
createButton(container, Activator.IMG_BUTTON_STOP, Messages.LaunchBarControl_Stop, Activator.CMD_STOP);
|
||||
|
||||
|
||||
modeSelector = new ModeSelector(container, SWT.NONE);
|
||||
modeSelector.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
|
||||
modeSelector.setInput(manager);
|
||||
|
@ -76,7 +76,7 @@ public class LaunchBarControl implements ILaunchBarManager.Listener {
|
|||
Label label = new Label(container, SWT.NONE);
|
||||
label.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
|
||||
label.setText("on" + ":");
|
||||
|
||||
|
||||
targetSelector = new TargetSelector(container, SWT.NONE);
|
||||
targetSelector.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
|
||||
targetSelector.setInput(manager);
|
||||
|
@ -84,10 +84,10 @@ public class LaunchBarControl implements ILaunchBarManager.Listener {
|
|||
try {
|
||||
ILaunchDescriptor configDesc = manager.getActiveLaunchDescriptor();
|
||||
configSelector.setSelection(configDesc == null ? null : configDesc);
|
||||
|
||||
|
||||
ILaunchMode mode = manager.getActiveLaunchMode();
|
||||
modeSelector.setSelection(mode == null ? null : mode);
|
||||
|
||||
|
||||
ILaunchTarget target = manager.getActiveLaunchTarget();
|
||||
targetSelector.setSelection(target == null ? null : target);
|
||||
} catch (CoreException e) {
|
||||
|
@ -172,7 +172,13 @@ public class LaunchBarControl implements ILaunchBarManager.Listener {
|
|||
@Override
|
||||
public void launchDescriptorRemoved(ILaunchDescriptor descriptor) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void launchTargetsChanged() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,119 @@
|
|||
package org.eclipse.cdt.launchbar.ui.internal.targetsView;
|
||||
|
||||
import org.eclipse.cdt.launchbar.core.ILaunchBarManager;
|
||||
import org.eclipse.cdt.launchbar.core.ILaunchDescriptor;
|
||||
import org.eclipse.cdt.launchbar.core.ILaunchTarget;
|
||||
import org.eclipse.cdt.launchbar.core.ILaunchTargetType;
|
||||
import org.eclipse.cdt.launchbar.core.internal.LaunchBarManager;
|
||||
import org.eclipse.cdt.launchbar.ui.internal.Activator;
|
||||
import org.eclipse.jface.action.MenuManager;
|
||||
import org.eclipse.jface.viewers.ITreeContentProvider;
|
||||
import org.eclipse.jface.viewers.LabelProvider;
|
||||
import org.eclipse.jface.viewers.TreeViewer;
|
||||
import org.eclipse.jface.viewers.Viewer;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Menu;
|
||||
import org.eclipse.ui.part.ViewPart;
|
||||
|
||||
public class LaunchTargetsViewPart extends ViewPart {
|
||||
|
||||
private TreeViewer treeViewer;
|
||||
|
||||
public LaunchTargetsViewPart() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createPartControl(Composite parent) {
|
||||
treeViewer = new TreeViewer(parent, SWT.NONE);
|
||||
treeViewer.setContentProvider(new ITreeContentProvider() {
|
||||
|
||||
@Override
|
||||
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasChildren(Object element) {
|
||||
if (element instanceof LaunchBarManager)
|
||||
return true;
|
||||
else if (element instanceof ILaunchTargetType)
|
||||
return true;
|
||||
else if (element instanceof ILaunchTarget)
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getParent(Object element) {
|
||||
if (element instanceof ILaunchTarget)
|
||||
return ((ILaunchTarget) element).getType();
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] getElements(Object inputElement) {
|
||||
return ((LaunchBarManager) inputElement).getAllLaunchTargetTypes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] getChildren(Object parentElement) {
|
||||
if (parentElement instanceof ILaunchTargetType)
|
||||
return ((ILaunchTargetType) parentElement).getTargets();
|
||||
return new Object[0];
|
||||
}
|
||||
});
|
||||
|
||||
treeViewer.setLabelProvider(new LabelProvider() {
|
||||
@Override
|
||||
public String getText(Object element) {
|
||||
if (element instanceof ILaunchTargetType)
|
||||
return element.getClass().getSimpleName();
|
||||
else if (element instanceof ILaunchTarget)
|
||||
return ((ILaunchTarget) element).getName();
|
||||
return super.getText(element);
|
||||
}
|
||||
});
|
||||
|
||||
final ILaunchBarManager launchBarManager = Activator.getService(ILaunchBarManager.class);
|
||||
treeViewer.setInput(launchBarManager);
|
||||
launchBarManager.addListener(new ILaunchBarManager.Listener() {
|
||||
@Override
|
||||
public void launchTargetsChanged() {
|
||||
treeViewer.getControl().getDisplay().asyncExec(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
treeViewer.setInput(launchBarManager);
|
||||
}
|
||||
});
|
||||
}
|
||||
@Override
|
||||
public void launchDescriptorRemoved(ILaunchDescriptor descriptor) {
|
||||
}
|
||||
@Override
|
||||
public void activeLaunchTargetChanged() {
|
||||
}
|
||||
@Override
|
||||
public void activeLaunchModeChanged() {
|
||||
}
|
||||
@Override
|
||||
public void activeConfigurationDescriptorChanged() {
|
||||
}
|
||||
});
|
||||
|
||||
MenuManager menuManager = new MenuManager();
|
||||
Menu menu = menuManager.createContextMenu(treeViewer.getControl());
|
||||
treeViewer.getControl().setMenu(menu);
|
||||
getSite().registerContextMenu(menuManager, treeViewer);
|
||||
getSite().setSelectionProvider(treeViewer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFocus() {
|
||||
treeViewer.getControl().setFocus();
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue