From 8d4ea57654a6454b43686678db0363ce74a29fab Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Thu, 3 Mar 2016 21:05:35 -0500 Subject: [PATCH] Bug 488950 - Remove "New..." button from 'Connect' dialogue Change-Id: Ia60e7a9e1e6d211bbe4c137f3ff5f7368ab68e83 --- .../META-INF/MANIFEST.MF | 2 +- dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/pom.xml | 2 +- .../ui/commands/GdbConnectCommand.java | 53 +++---------------- .../ui/launching/LaunchUIMessages.properties | 2 - .../ui/launching/ProcessPrompter.java | 39 ++------------ .../ui/launching/ProcessPrompterDialog.java | 43 +-------------- 6 files changed, 15 insertions(+), 126 deletions(-) diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/META-INF/MANIFEST.MF b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/META-INF/MANIFEST.MF index ef774dac70a..c60bc3436ba 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/META-INF/MANIFEST.MF +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/META-INF/MANIFEST.MF @@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-Vendor: %providerName 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-Localization: plugin Require-Bundle: org.eclipse.ui, diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/pom.xml b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/pom.xml index 7e862b812f6..bca5ab17ab6 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/pom.xml +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/pom.xml @@ -11,7 +11,7 @@ ../../pom.xml - 2.5.0-SNAPSHOT + 2.6.0-SNAPSHOT org.eclipse.cdt.dsf.gdb.ui eclipse-plugin diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/GdbConnectCommand.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/GdbConnectCommand.java index 7e893792d34..3a8c349dd5b 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/GdbConnectCommand.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/GdbConnectCommand.java @@ -22,7 +22,6 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.Executor; import java.util.concurrent.RejectedExecutionException; -import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; import org.eclipse.cdt.debug.core.model.IConnectHandler; import org.eclipse.cdt.dsf.concurrent.CountingRequestMonitor; 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.command.ICommandControlService; 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.internal.ui.GdbUIPlugin; 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.NewExecutableInfo; 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.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.IGDBProcesses; 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.mi.service.IMIProcessDMContext; import org.eclipse.cdt.dsf.service.DsfServicesTracker; import org.eclipse.cdt.dsf.service.DsfSession; 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 IProcessExtendedInfo[] fProcessList = null; DataRequestMonitor fRequestMonitor; - boolean fNewProcessSupported; - boolean fRemote; private List fDebuggedProcesses; - public PromptForPidJob(String name, boolean newProcessSupported, boolean remote, IProcessExtendedInfo[] procs, List debuggedProcesses, DataRequestMonitor rm) { + public PromptForPidJob(String name, IProcessExtendedInfo[] procs, List debuggedProcesses, DataRequestMonitor rm) { super(name); - fNewProcessSupported = newProcessSupported; - fRemote = remote; fProcessList = procs; fRequestMonitor = rm; fDebuggedProcesses = debuggedProcesses; @@ -172,11 +165,11 @@ public class GdbConnectCommand extends RefreshableDebugCommand implements IConne null); try { - PrompterInfo info = new PrompterInfo(fNewProcessSupported, fRemote, fProcessList, fDebuggedProcesses); + PrompterInfo info = new PrompterInfo(fProcessList, fDebuggedProcesses); Object result = new ProcessPrompter().handleStatus(null, info); if (result == null) { fRequestMonitor.cancel(); - } else if (result instanceof IProcessExtendedInfo[] || result instanceof NewExecutableInfo) { + } else if (result instanceof IProcessExtendedInfo[]) { fRequestMonitor.setData(result); } else if (result instanceof Integer) { // 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) { final ICommandControlDMContext controlCtx = commandControl.getContext(); - final boolean remote = backend.getSessionType() == SessionType.REMOTE; - // First check if the "New..." button should be enabled. - procService.isDebugNewProcessSupported(controlCtx, new DataRequestMonitor(fExecutor, rm) { - @Override - protected void handleCompleted() { - final boolean newProcessSupported = isSuccess() && getData(); - - // Now get the list of all processes + // Now get the list of all processes procService.getRunningProcesses( controlCtx, new DataRequestMonitor(fExecutor, rm) { @@ -419,11 +405,9 @@ public class GdbConnectCommand extends RefreshableDebugCommand implements IConne protected void handleSuccess() { List 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( LaunchUIMessages.getString("ProcessPrompter.PromptJob"), //$NON-NLS-1$ - newProcessSupported, - remote, procInfoList.toArray(new IProcessExtendedInfo[procInfoList.size()]), dbgPids, new DataRequestMonitor(fExecutor, rm) { @@ -435,10 +419,7 @@ public class GdbConnectCommand extends RefreshableDebugCommand implements IConne @Override protected void handleSuccess() { Object data = getData(); - if (data instanceof NewExecutableInfo) { - // User wants to start a new process - startNewProcess(controlCtx, (NewExecutableInfo)data, rm); - } else if (data instanceof IProcessExtendedInfo[]) { + if (data instanceof IProcessExtendedInfo[]) { attachToProcesses(controlCtx, (IProcessExtendedInfo[])data, rm); } else { 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 { 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 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(fExecutor, rm)); - } - catch(CoreException e) { - rm.setStatus(e.getStatus()); - rm.done(); - } - } - private void attachToProcesses(final ICommandControlDMContext controlDmc, IProcessExtendedInfo[] processes, final RequestMonitor rm) { // For a local attach, GDB can figure out the binary automatically, diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/LaunchUIMessages.properties b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/LaunchUIMessages.properties index 03cf0d35349..44ee360e020 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/LaunchUIMessages.properties +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/LaunchUIMessages.properties @@ -236,6 +236,4 @@ ProcessPrompter.Core=core ProcessPrompter.Cores=cores ProcessPrompter.PromptJob=Prompt for Process ProcessPrompter.ErrProcessConected=Process {0} already connected - -ProcessPrompterDialog.New=New... ProcessPrompterDialog.TitlePrefix=Choose binary for process: diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/ProcessPrompter.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/ProcessPrompter.java index f95da0bd985..bff8df09dd3 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/ProcessPrompter.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/ProcessPrompter.java @@ -38,25 +38,15 @@ import com.ibm.icu.text.MessageFormat; public class ProcessPrompter implements IStatusHandler { public static class PrompterInfo { - public boolean supportsNewProcess; - public boolean remote; public IProcessExtendedInfo[] processList; public List debuggedProcesses; - public PrompterInfo(boolean supportsNew, boolean remote, IProcessExtendedInfo[] list, List debuggedProcs) { - supportsNewProcess = supportsNew; - this.remote = remote; + public PrompterInfo(IProcessExtendedInfo[] list, List debuggedProcs) { 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 public Object handleStatus(IStatus status, Object info) throws CoreException { Shell shell = GdbUIPlugin.getShell(); @@ -92,11 +82,6 @@ public class ProcessPrompter implements IStatusHandler { } } else { ILabelProvider provider = new LabelProvider() { - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object) - */ @Override public String getText(Object element) { IProcessExtendedInfo info = (IProcessExtendedInfo)element; @@ -150,11 +135,7 @@ public class ProcessPrompter implements IStatusHandler { return text.toString(); } - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object) - */ + @Override public Image getImage(Object element) { return LaunchImages.get(LaunchImages.IMG_OBJS_EXEC); @@ -166,11 +147,7 @@ public class ProcessPrompter implements IStatusHandler { IProcessExtendedInfo info = (IProcessExtendedInfo)element; return info.getName(); } - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object) - */ + @Override public Image getImage(Object element) { 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 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.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); 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(); if (results != null) { IProcessExtendedInfo[] processes = new IProcessExtendedInfo[results.length]; diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/ProcessPrompterDialog.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/ProcessPrompterDialog.java index 545ac26f857..433b4e4fdd0 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/ProcessPrompterDialog.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/ProcessPrompterDialog.java @@ -18,7 +18,6 @@ import org.eclipse.core.runtime.Status; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.viewers.ILabelProvider; import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Event; 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 * is the list of all selections of the top pane (shown in the bottom * 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 { - private static final int NEW_BUTTON_ID = 9876; - private NewExecutableInfo fExecInfo; - private boolean fSupportsNewProcess; - private boolean fRemote; public ProcessPrompterDialog(Shell parent, ILabelProvider elementRenderer, - ILabelProvider qualifierRenderer, boolean supportsNewProcess, boolean remote) { + ILabelProvider 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. *