1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-07 00:05:53 +02:00

Bug 488950 - Remove "New..." button from 'Connect' dialogue

Change-Id: Ia60e7a9e1e6d211bbe4c137f3ff5f7368ab68e83
This commit is contained in:
Marc Khouzam 2016-03-03 21:05:35 -05:00 committed by Gerrit Code Review @ Eclipse.org
parent 11c94f2755
commit 8d4ea57654
6 changed files with 15 additions and 126 deletions

View file

@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2
Bundle-Name: %pluginName Bundle-Name: %pluginName
Bundle-Vendor: %providerName Bundle-Vendor: %providerName
Bundle-SymbolicName: org.eclipse.cdt.dsf.gdb.ui;singleton:=true Bundle-SymbolicName: org.eclipse.cdt.dsf.gdb.ui;singleton:=true
Bundle-Version: 2.5.0.qualifier Bundle-Version: 2.6.0.qualifier
Bundle-Activator: org.eclipse.cdt.dsf.gdb.internal.ui.GdbUIPlugin Bundle-Activator: org.eclipse.cdt.dsf.gdb.internal.ui.GdbUIPlugin
Bundle-Localization: plugin Bundle-Localization: plugin
Require-Bundle: org.eclipse.ui, Require-Bundle: org.eclipse.ui,

View file

@ -11,7 +11,7 @@
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>
<version>2.5.0-SNAPSHOT</version> <version>2.6.0-SNAPSHOT</version>
<artifactId>org.eclipse.cdt.dsf.gdb.ui</artifactId> <artifactId>org.eclipse.cdt.dsf.gdb.ui</artifactId>
<packaging>eclipse-plugin</packaging> <packaging>eclipse-plugin</packaging>
</project> </project>

View file

@ -22,7 +22,6 @@ import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executor; import java.util.concurrent.Executor;
import java.util.concurrent.RejectedExecutionException; import java.util.concurrent.RejectedExecutionException;
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
import org.eclipse.cdt.debug.core.model.IConnectHandler; import org.eclipse.cdt.debug.core.model.IConnectHandler;
import org.eclipse.cdt.dsf.concurrent.CountingRequestMonitor; import org.eclipse.cdt.dsf.concurrent.CountingRequestMonitor;
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor; import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
@ -41,12 +40,10 @@ import org.eclipse.cdt.dsf.debug.service.IProcesses.IProcessDMContext;
import org.eclipse.cdt.dsf.debug.service.IProcesses.IThreadDMData; import org.eclipse.cdt.dsf.debug.service.IProcesses.IThreadDMData;
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService; import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService;
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlDMContext; import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlDMContext;
import org.eclipse.cdt.dsf.gdb.IGDBLaunchConfigurationConstants;
import org.eclipse.cdt.dsf.gdb.actions.IConnect; import org.eclipse.cdt.dsf.gdb.actions.IConnect;
import org.eclipse.cdt.dsf.gdb.internal.ui.GdbUIPlugin; import org.eclipse.cdt.dsf.gdb.internal.ui.GdbUIPlugin;
import org.eclipse.cdt.dsf.gdb.internal.ui.actions.ProcessInfo; import org.eclipse.cdt.dsf.gdb.internal.ui.actions.ProcessInfo;
import org.eclipse.cdt.dsf.gdb.internal.ui.launching.LaunchUIMessages; import org.eclipse.cdt.dsf.gdb.internal.ui.launching.LaunchUIMessages;
import org.eclipse.cdt.dsf.gdb.internal.ui.launching.NewExecutableInfo;
import org.eclipse.cdt.dsf.gdb.internal.ui.launching.ProcessPrompter; import org.eclipse.cdt.dsf.gdb.internal.ui.launching.ProcessPrompter;
import org.eclipse.cdt.dsf.gdb.internal.ui.launching.ProcessPrompter.PrompterInfo; import org.eclipse.cdt.dsf.gdb.internal.ui.launching.ProcessPrompter.PrompterInfo;
import org.eclipse.cdt.dsf.gdb.launching.GdbLaunch; import org.eclipse.cdt.dsf.gdb.launching.GdbLaunch;
@ -55,8 +52,8 @@ import org.eclipse.cdt.dsf.gdb.launching.LaunchMessages;
import org.eclipse.cdt.dsf.gdb.service.IGDBBackend; import org.eclipse.cdt.dsf.gdb.service.IGDBBackend;
import org.eclipse.cdt.dsf.gdb.service.IGDBProcesses; import org.eclipse.cdt.dsf.gdb.service.IGDBProcesses;
import org.eclipse.cdt.dsf.gdb.service.IGDBProcesses.IGdbThreadDMData; import org.eclipse.cdt.dsf.gdb.service.IGDBProcesses.IGdbThreadDMData;
import org.eclipse.cdt.dsf.mi.service.IMIProcessDMContext;
import org.eclipse.cdt.dsf.gdb.service.SessionType; import org.eclipse.cdt.dsf.gdb.service.SessionType;
import org.eclipse.cdt.dsf.mi.service.IMIProcessDMContext;
import org.eclipse.cdt.dsf.service.DsfServicesTracker; import org.eclipse.cdt.dsf.service.DsfServicesTracker;
import org.eclipse.cdt.dsf.service.DsfSession; import org.eclipse.cdt.dsf.service.DsfSession;
import org.eclipse.cdt.dsf.ui.viewmodel.datamodel.IDMVMContext; import org.eclipse.cdt.dsf.ui.viewmodel.datamodel.IDMVMContext;
@ -152,14 +149,10 @@ public class GdbConnectCommand extends RefreshableDebugCommand implements IConne
// The list of processes used in the case of an ATTACH session // The list of processes used in the case of an ATTACH session
IProcessExtendedInfo[] fProcessList = null; IProcessExtendedInfo[] fProcessList = null;
DataRequestMonitor<Object> fRequestMonitor; DataRequestMonitor<Object> fRequestMonitor;
boolean fNewProcessSupported;
boolean fRemote;
private List<String> fDebuggedProcesses; private List<String> fDebuggedProcesses;
public PromptForPidJob(String name, boolean newProcessSupported, boolean remote, IProcessExtendedInfo[] procs, List<String> debuggedProcesses, DataRequestMonitor<Object> rm) { public PromptForPidJob(String name, IProcessExtendedInfo[] procs, List<String> debuggedProcesses, DataRequestMonitor<Object> rm) {
super(name); super(name);
fNewProcessSupported = newProcessSupported;
fRemote = remote;
fProcessList = procs; fProcessList = procs;
fRequestMonitor = rm; fRequestMonitor = rm;
fDebuggedProcesses = debuggedProcesses; fDebuggedProcesses = debuggedProcesses;
@ -172,11 +165,11 @@ public class GdbConnectCommand extends RefreshableDebugCommand implements IConne
null); null);
try { try {
PrompterInfo info = new PrompterInfo(fNewProcessSupported, fRemote, fProcessList, fDebuggedProcesses); PrompterInfo info = new PrompterInfo(fProcessList, fDebuggedProcesses);
Object result = new ProcessPrompter().handleStatus(null, info); Object result = new ProcessPrompter().handleStatus(null, info);
if (result == null) { if (result == null) {
fRequestMonitor.cancel(); fRequestMonitor.cancel();
} else if (result instanceof IProcessExtendedInfo[] || result instanceof NewExecutableInfo) { } else if (result instanceof IProcessExtendedInfo[]) {
fRequestMonitor.setData(result); fRequestMonitor.setData(result);
} else if (result instanceof Integer) { } else if (result instanceof Integer) {
// This is the case where the user typed in a pid number directly // This is the case where the user typed in a pid number directly
@ -393,15 +386,8 @@ public class GdbConnectCommand extends RefreshableDebugCommand implements IConne
if (procService != null && commandControl != null && backend != null) { if (procService != null && commandControl != null && backend != null) {
final ICommandControlDMContext controlCtx = commandControl.getContext(); final ICommandControlDMContext controlCtx = commandControl.getContext();
final boolean remote = backend.getSessionType() == SessionType.REMOTE;
// First check if the "New..." button should be enabled. // Now get the list of all processes
procService.isDebugNewProcessSupported(controlCtx, new DataRequestMonitor<Boolean>(fExecutor, rm) {
@Override
protected void handleCompleted() {
final boolean newProcessSupported = isSuccess() && getData();
// Now get the list of all processes
procService.getRunningProcesses( procService.getRunningProcesses(
controlCtx, controlCtx,
new DataRequestMonitor<IProcessDMContext[]>(fExecutor, rm) { new DataRequestMonitor<IProcessDMContext[]>(fExecutor, rm) {
@ -419,11 +405,9 @@ public class GdbConnectCommand extends RefreshableDebugCommand implements IConne
protected void handleSuccess() { protected void handleSuccess() {
List<String> dbgPids = getData(); List<String> dbgPids = getData();
// Prompt the user to choose one or more processes, or to start a new one // Prompt the user to choose one or more processes
new PromptForPidJob( new PromptForPidJob(
LaunchUIMessages.getString("ProcessPrompter.PromptJob"), //$NON-NLS-1$ LaunchUIMessages.getString("ProcessPrompter.PromptJob"), //$NON-NLS-1$
newProcessSupported,
remote,
procInfoList.toArray(new IProcessExtendedInfo[procInfoList.size()]), procInfoList.toArray(new IProcessExtendedInfo[procInfoList.size()]),
dbgPids, dbgPids,
new DataRequestMonitor<Object>(fExecutor, rm) { new DataRequestMonitor<Object>(fExecutor, rm) {
@ -435,10 +419,7 @@ public class GdbConnectCommand extends RefreshableDebugCommand implements IConne
@Override @Override
protected void handleSuccess() { protected void handleSuccess() {
Object data = getData(); Object data = getData();
if (data instanceof NewExecutableInfo) { if (data instanceof IProcessExtendedInfo[]) {
// User wants to start a new process
startNewProcess(controlCtx, (NewExecutableInfo)data, rm);
} else if (data instanceof IProcessExtendedInfo[]) {
attachToProcesses(controlCtx, (IProcessExtendedInfo[])data, rm); attachToProcesses(controlCtx, (IProcessExtendedInfo[])data, rm);
} else { } else {
rm.done(new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, IDsfStatusConstants.INTERNAL_ERROR, "Invalid return type for process prompter", null)); //$NON-NLS-1$ rm.done(new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, IDsfStatusConstants.INTERNAL_ERROR, "Invalid return type for process prompter", null)); //$NON-NLS-1$
@ -515,8 +496,6 @@ public class GdbConnectCommand extends RefreshableDebugCommand implements IConne
} }
} }
}); });
}
});
} else { } else {
rm.done(); rm.done();
} }
@ -524,24 +503,6 @@ public class GdbConnectCommand extends RefreshableDebugCommand implements IConne
}); });
} }
private void startNewProcess(ICommandControlDMContext controlDmc, NewExecutableInfo info, RequestMonitor rm) {
IGDBProcesses procService = fTracker.getService(IGDBProcesses.class);
try {
Map<String, Object> attributes = fLaunch.getLaunchConfiguration().getAttributes();
attributes.put(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_REMOTE_BINARY, info.getTargetPath());
attributes.put(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, info.getArguments());
procService.debugNewProcess(
controlDmc,
info.getHostPath(),
attributes,
new DataRequestMonitor<IDMContext>(fExecutor, rm));
}
catch(CoreException e) {
rm.setStatus(e.getStatus());
rm.done();
}
}
private void attachToProcesses(final ICommandControlDMContext controlDmc, IProcessExtendedInfo[] processes, final RequestMonitor rm) { private void attachToProcesses(final ICommandControlDMContext controlDmc, IProcessExtendedInfo[] processes, final RequestMonitor rm) {
// For a local attach, GDB can figure out the binary automatically, // For a local attach, GDB can figure out the binary automatically,

View file

@ -236,6 +236,4 @@ ProcessPrompter.Core=core
ProcessPrompter.Cores=cores ProcessPrompter.Cores=cores
ProcessPrompter.PromptJob=Prompt for Process ProcessPrompter.PromptJob=Prompt for Process
ProcessPrompter.ErrProcessConected=Process {0} already connected ProcessPrompter.ErrProcessConected=Process {0} already connected
ProcessPrompterDialog.New=New...
ProcessPrompterDialog.TitlePrefix=Choose binary for process: ProcessPrompterDialog.TitlePrefix=Choose binary for process:

View file

@ -38,25 +38,15 @@ import com.ibm.icu.text.MessageFormat;
public class ProcessPrompter implements IStatusHandler { public class ProcessPrompter implements IStatusHandler {
public static class PrompterInfo { public static class PrompterInfo {
public boolean supportsNewProcess;
public boolean remote;
public IProcessExtendedInfo[] processList; public IProcessExtendedInfo[] processList;
public List<String> debuggedProcesses; public List<String> debuggedProcesses;
public PrompterInfo(boolean supportsNew, boolean remote, IProcessExtendedInfo[] list, List<String> debuggedProcs) { public PrompterInfo(IProcessExtendedInfo[] list, List<String> debuggedProcs) {
supportsNewProcess = supportsNew;
this.remote = remote;
processList = list; processList = list;
this.debuggedProcesses = debuggedProcs; debuggedProcesses = debuggedProcs;
} }
} }
/*
* (non-Javadoc)
*
* @see org.eclipse.debug.core.IStatusHandler#handleStatus(org.eclipse.core.runtime.IStatus,
* java.lang.Object)
*/
@Override @Override
public Object handleStatus(IStatus status, Object info) throws CoreException { public Object handleStatus(IStatus status, Object info) throws CoreException {
Shell shell = GdbUIPlugin.getShell(); Shell shell = GdbUIPlugin.getShell();
@ -92,11 +82,6 @@ public class ProcessPrompter implements IStatusHandler {
} }
} else { } else {
ILabelProvider provider = new LabelProvider() { ILabelProvider provider = new LabelProvider() {
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
*/
@Override @Override
public String getText(Object element) { public String getText(Object element) {
IProcessExtendedInfo info = (IProcessExtendedInfo)element; IProcessExtendedInfo info = (IProcessExtendedInfo)element;
@ -150,11 +135,7 @@ public class ProcessPrompter implements IStatusHandler {
return text.toString(); return text.toString();
} }
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object)
*/
@Override @Override
public Image getImage(Object element) { public Image getImage(Object element) {
return LaunchImages.get(LaunchImages.IMG_OBJS_EXEC); return LaunchImages.get(LaunchImages.IMG_OBJS_EXEC);
@ -166,11 +147,7 @@ public class ProcessPrompter implements IStatusHandler {
IProcessExtendedInfo info = (IProcessExtendedInfo)element; IProcessExtendedInfo info = (IProcessExtendedInfo)element;
return info.getName(); return info.getName();
} }
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object)
*/
@Override @Override
public Image getImage(Object element) { public Image getImage(Object element) {
return LaunchImages.get(LaunchImages.IMG_OBJS_EXEC); return LaunchImages.get(LaunchImages.IMG_OBJS_EXEC);
@ -179,7 +156,7 @@ public class ProcessPrompter implements IStatusHandler {
// Display the list of processes and have the user choose // Display the list of processes and have the user choose
ProcessPrompterDialog dialog = ProcessPrompterDialog dialog =
new ProcessPrompterDialog(shell, provider, qprovider, prompterInfo.supportsNewProcess, prompterInfo.remote); new ProcessPrompterDialog(shell, provider, qprovider);
dialog.setTitle(LaunchUIMessages.getString("LocalAttachLaunchDelegate.Select_Process")); //$NON-NLS-1$ dialog.setTitle(LaunchUIMessages.getString("LocalAttachLaunchDelegate.Select_Process")); //$NON-NLS-1$
dialog.setMessage(LaunchUIMessages.getString("LocalAttachLaunchDelegate.Select_Process_to_attach_debugger_to")); //$NON-NLS-1$ dialog.setMessage(LaunchUIMessages.getString("LocalAttachLaunchDelegate.Select_Process_to_attach_debugger_to")); //$NON-NLS-1$
@ -202,12 +179,6 @@ public class ProcessPrompter implements IStatusHandler {
}); });
dialog.setElements(plist); dialog.setElements(plist);
if (dialog.open() == Window.OK) { if (dialog.open() == Window.OK) {
// First check if the user pressed the New button
NewExecutableInfo execInfo = dialog.getExecutableInfo();
if (execInfo != null) {
return execInfo;
}
Object[] results = dialog.getResult(); Object[] results = dialog.getResult();
if (results != null) { if (results != null) {
IProcessExtendedInfo[] processes = new IProcessExtendedInfo[results.length]; IProcessExtendedInfo[] processes = new IProcessExtendedInfo[results.length];

View file

@ -18,7 +18,6 @@ import org.eclipse.core.runtime.Status;
import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.viewers.ILabelProvider; import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Listener;
@ -34,48 +33,12 @@ import org.eclipse.ui.dialogs.TwoPaneElementSelector;
* No selection is allowed in the bottom pane. The result returned * No selection is allowed in the bottom pane. The result returned
* is the list of all selections of the top pane (shown in the bottom * is the list of all selections of the top pane (shown in the bottom
* pane). * pane).
*
* The dialog also has a "New..." button that allows to start a new
* process. If the method getBinaryPath() returns a non-null string,
* it implies that a new process should be created and the return
* string indicates the location of the binary.
*
* Note that getBinaryPath() should be checked before calling getResult()
* as it takes precedence over it.
*
*/ */
public class ProcessPrompterDialog extends TwoPaneElementSelector { public class ProcessPrompterDialog extends TwoPaneElementSelector {
private static final int NEW_BUTTON_ID = 9876;
private NewExecutableInfo fExecInfo;
private boolean fSupportsNewProcess;
private boolean fRemote;
public ProcessPrompterDialog(Shell parent, ILabelProvider elementRenderer, public ProcessPrompterDialog(Shell parent, ILabelProvider elementRenderer,
ILabelProvider qualifierRenderer, boolean supportsNewProcess, boolean remote) { ILabelProvider qualifierRenderer) {
super(parent, elementRenderer, qualifierRenderer); super(parent, elementRenderer, qualifierRenderer);
fSupportsNewProcess = supportsNewProcess;
fRemote = remote;
}
@Override
protected void createButtonsForButtonBar(Composite parent) {
Button newButton = createButton(
parent, NEW_BUTTON_ID, LaunchUIMessages.getString("ProcessPrompterDialog.New"), false); //$NON-NLS-1$
newButton.setEnabled(fSupportsNewProcess);
super.createButtonsForButtonBar(parent);
}
@Override
protected void buttonPressed(int buttonId) {
if (buttonId == NEW_BUTTON_ID) {
NewExecutableDialog dialog = new NewExecutableDialog(getShell(), (fRemote) ? NewExecutableDialog.REMOTE : 0);
if (dialog.open() == IDialogConstants.OK_ID) {
fExecInfo = dialog.getExecutableInfo();
setReturnCode(OK);
close();
}
}
super.buttonPressed(buttonId);
} }
/* /*
@ -131,10 +94,6 @@ public class ProcessPrompterDialog extends TwoPaneElementSelector {
} }
} }
public NewExecutableInfo getExecutableInfo() {
return fExecInfo;
}
/** /**
* Validate only upper selected elements. Lower list is always disabled. * Validate only upper selected elements. Lower list is always disabled.
* *