mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-04 14:55:41 +02:00
see change log
This commit is contained in:
parent
b39a005df0
commit
46d6b8f8c1
7 changed files with 231 additions and 122 deletions
|
@ -1,3 +1,17 @@
|
||||||
|
2004-11-1 David Inglis
|
||||||
|
Use status handlers to prompt for launch input (process id and core file).
|
||||||
|
|
||||||
|
* plugin.xml
|
||||||
|
* src/org/eclipse/cdt/launch/internal/CoreFileLaunchDelegate.java
|
||||||
|
* src/org/eclipse/cdt/launch/internal/LocalAttachLaunchDelegate.java
|
||||||
|
* src/org/eclipse/cdt/launch/internal/ui/CoreFilePrompter.java
|
||||||
|
* src/org/eclipse/cdt/launch/internal/ui/ProcessPrompter.java
|
||||||
|
|
||||||
|
2004-11-01 David Inglis
|
||||||
|
getEnvironmentAsProperty was not using new getEnviroment().
|
||||||
|
|
||||||
|
* src/org/eclipse/cdt/launch/AbstractCLaunchDelegate.java
|
||||||
|
|
||||||
2004-10-22 David Inglis
|
2004-10-22 David Inglis
|
||||||
Added variables support to arguments, environment and working directory.
|
Added variables support to arguments, environment and working directory.
|
||||||
|
|
||||||
|
|
|
@ -131,5 +131,19 @@
|
||||||
id="org.eclipse.cdt.launch.CPropertyTester">
|
id="org.eclipse.cdt.launch.CPropertyTester">
|
||||||
</propertyTester>
|
</propertyTester>
|
||||||
</extension>
|
</extension>
|
||||||
|
<extension
|
||||||
|
point="org.eclipse.debug.core.statusHandlers">
|
||||||
|
<statusHandler
|
||||||
|
code="100"
|
||||||
|
plugin="org.eclipse.cdt.launch"
|
||||||
|
class="org.eclipse.cdt.launch.internal.ui.ProcessPrompter"
|
||||||
|
id="org.eclipse.cdt.launch.statusHandler.processPrompter">
|
||||||
|
</statusHandler>
|
||||||
|
<statusHandler
|
||||||
|
code="101"
|
||||||
|
plugin="org.eclipse.cdt.launch"
|
||||||
|
class="org.eclipse.cdt.launch.internal.ui.CoreFilePrompter"
|
||||||
|
id="org.eclipse.cdt.launch.statusHandler.coreFilePrompter">
|
||||||
|
</statusHandler>
|
||||||
|
</extension>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
|
@ -760,7 +760,7 @@ abstract public class AbstractCLaunchDelegate extends LaunchConfigurationDelegat
|
||||||
* @throws CoreException
|
* @throws CoreException
|
||||||
*/
|
*/
|
||||||
protected Properties getEnvironmentAsProperty(ILaunchConfiguration config) throws CoreException {
|
protected Properties getEnvironmentAsProperty(ILaunchConfiguration config) throws CoreException {
|
||||||
String[] envp = getEnvironmentArray(config);
|
String[] envp = getEnvironment(config);
|
||||||
Properties p = new Properties( );
|
Properties p = new Properties( );
|
||||||
for( int i = 0; i < envp.length; i++ ) {
|
for( int i = 0; i < envp.length; i++ ) {
|
||||||
int idx = envp[i].indexOf('=');
|
int idx = envp[i].indexOf('=');
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
/*******************************************************************************
|
/***************************************************************************************************
|
||||||
* Copyright (c) 2002 - 2004 QNX Software Systems and others. All rights
|
* Copyright (c) 2002 - 2004 QNX Software Systems and others. All rights reserved. This program and
|
||||||
* reserved. This program and the accompanying materials are made available
|
* the accompanying materials are made available under the terms of the Common Public License v1.0
|
||||||
* under the terms of the Common Public License v1.0 which accompanies this
|
* which accompanies this distribution, and is available at
|
||||||
* distribution, and is available at http://www.eclipse.org/legal/cpl-v10.html
|
* http://www.eclipse.org/legal/cpl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors: QNX Software Systems - Initial API and implementation
|
* Contributors: QNX Software Systems - Initial API and implementation
|
||||||
******************************************************************************/
|
**************************************************************************************************/
|
||||||
package org.eclipse.cdt.launch.internal;
|
package org.eclipse.cdt.launch.internal;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.IBinaryParser.IBinaryExecutable;
|
import org.eclipse.cdt.core.IBinaryParser.IBinaryExecutable;
|
||||||
|
@ -23,18 +23,16 @@ import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
import org.eclipse.core.runtime.IStatus;
|
||||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||||
import org.eclipse.core.runtime.Path;
|
import org.eclipse.core.runtime.Status;
|
||||||
import org.eclipse.core.runtime.QualifiedName;
|
|
||||||
import org.eclipse.core.runtime.SubProgressMonitor;
|
import org.eclipse.core.runtime.SubProgressMonitor;
|
||||||
import org.eclipse.debug.core.DebugPlugin;
|
import org.eclipse.debug.core.DebugPlugin;
|
||||||
import org.eclipse.debug.core.ILaunch;
|
import org.eclipse.debug.core.ILaunch;
|
||||||
import org.eclipse.debug.core.ILaunchConfiguration;
|
import org.eclipse.debug.core.ILaunchConfiguration;
|
||||||
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
|
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
|
||||||
|
import org.eclipse.debug.core.IStatusHandler;
|
||||||
import org.eclipse.debug.core.model.IProcess;
|
import org.eclipse.debug.core.model.IProcess;
|
||||||
import org.eclipse.swt.widgets.Display;
|
|
||||||
import org.eclipse.swt.widgets.FileDialog;
|
|
||||||
import org.eclipse.swt.widgets.Shell;
|
|
||||||
|
|
||||||
public class CoreFileLaunchDelegate extends AbstractCLaunchDelegate {
|
public class CoreFileLaunchDelegate extends AbstractCLaunchDelegate {
|
||||||
|
|
||||||
|
@ -100,34 +98,18 @@ public class CoreFileLaunchDelegate extends AbstractCLaunchDelegate {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IPath promptForCoreFilePath(final IProject project, final ICDebugConfiguration debugConfig) throws CoreException {
|
protected IPath promptForCoreFilePath(final IProject project, final ICDebugConfiguration debugConfig) throws CoreException {
|
||||||
final Shell shell = LaunchUIPlugin.getShell();
|
IStatus fPromptStatus = new Status(IStatus.INFO, "org.eclipse.debug.ui", 200, "", null); //$NON-NLS-1$//$NON-NLS-2$
|
||||||
final String res[] = {null};
|
IStatus processPrompt = new Status(IStatus.INFO, "org.eclipse.cdt.launch", 101, "", null); //$NON-NLS-1$//$NON-NLS-2$
|
||||||
if (shell == null) {
|
// consult a status handler
|
||||||
abort(LaunchMessages.getString("CoreFileLaunchDelegate.No_Shell_available_in_Launch"), null, //$NON-NLS-1$
|
IStatusHandler prompter = DebugPlugin.getDefault().getStatusHandler(fPromptStatus);
|
||||||
ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR);
|
if (prompter != null) {
|
||||||
}
|
try {
|
||||||
Display display = shell.getDisplay();
|
Object result = prompter.handleStatus(processPrompt, new Object[]{project, debugConfig});
|
||||||
display.syncExec(new Runnable() {
|
if (result instanceof IPath) {
|
||||||
|
return (IPath)result;
|
||||||
public void run() {
|
|
||||||
FileDialog dialog = new FileDialog(shell);
|
|
||||||
dialog.setText(LaunchMessages.getString("CoreFileLaunchDelegate.Select_Corefile")); //$NON-NLS-1$
|
|
||||||
|
|
||||||
String initPath = null;
|
|
||||||
try {
|
|
||||||
initPath = project.getPersistentProperty(new QualifiedName(LaunchUIPlugin.getUniqueIdentifier(), "SavePath")); //$NON-NLS-1$
|
|
||||||
} catch (CoreException e) {
|
|
||||||
}
|
}
|
||||||
if (initPath == null || initPath.equals("")) { //$NON-NLS-1$
|
} catch (CoreException e) {
|
||||||
initPath = project.getLocation().toString();
|
|
||||||
}
|
|
||||||
dialog.setFilterExtensions(debugConfig.getCoreFileExtensions());
|
|
||||||
dialog.setFilterPath(initPath);
|
|
||||||
res[0] = dialog.open();
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
if (res[0] != null) {
|
|
||||||
return new Path(res[0]);
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,9 +8,6 @@
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package org.eclipse.cdt.launch.internal;
|
package org.eclipse.cdt.launch.internal;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
|
||||||
import org.eclipse.cdt.core.IProcessInfo;
|
|
||||||
import org.eclipse.cdt.core.IProcessList;
|
|
||||||
import org.eclipse.cdt.core.IBinaryParser.IBinaryExecutable;
|
import org.eclipse.cdt.core.IBinaryParser.IBinaryExecutable;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
import org.eclipse.cdt.debug.core.CDIDebugModel;
|
import org.eclipse.cdt.debug.core.CDIDebugModel;
|
||||||
|
@ -20,27 +17,21 @@ import org.eclipse.cdt.debug.core.cdi.CDIException;
|
||||||
import org.eclipse.cdt.debug.core.cdi.ICDISession;
|
import org.eclipse.cdt.debug.core.cdi.ICDISession;
|
||||||
import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
|
import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
|
||||||
import org.eclipse.cdt.launch.AbstractCLaunchDelegate;
|
import org.eclipse.cdt.launch.AbstractCLaunchDelegate;
|
||||||
import org.eclipse.cdt.launch.internal.ui.LaunchImages;
|
|
||||||
import org.eclipse.cdt.launch.internal.ui.LaunchMessages;
|
import org.eclipse.cdt.launch.internal.ui.LaunchMessages;
|
||||||
import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin;
|
import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
import org.eclipse.core.runtime.IStatus;
|
||||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||||
import org.eclipse.core.runtime.Path;
|
import org.eclipse.core.runtime.Status;
|
||||||
import org.eclipse.core.runtime.SubProgressMonitor;
|
import org.eclipse.core.runtime.SubProgressMonitor;
|
||||||
|
import org.eclipse.debug.core.DebugPlugin;
|
||||||
import org.eclipse.debug.core.ILaunch;
|
import org.eclipse.debug.core.ILaunch;
|
||||||
import org.eclipse.debug.core.ILaunchConfiguration;
|
import org.eclipse.debug.core.ILaunchConfiguration;
|
||||||
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
|
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
|
||||||
import org.eclipse.debug.core.ILaunchManager;
|
import org.eclipse.debug.core.ILaunchManager;
|
||||||
import org.eclipse.jface.dialogs.MessageDialog;
|
import org.eclipse.debug.core.IStatusHandler;
|
||||||
import org.eclipse.jface.viewers.ILabelProvider;
|
|
||||||
import org.eclipse.jface.viewers.LabelProvider;
|
|
||||||
import org.eclipse.jface.window.Window;
|
|
||||||
import org.eclipse.swt.graphics.Image;
|
|
||||||
import org.eclipse.swt.widgets.Display;
|
|
||||||
import org.eclipse.swt.widgets.Shell;
|
|
||||||
import org.eclipse.ui.dialogs.TwoPaneElementSelector;
|
|
||||||
|
|
||||||
public class LocalAttachLaunchDelegate extends AbstractCLaunchDelegate {
|
public class LocalAttachLaunchDelegate extends AbstractCLaunchDelegate {
|
||||||
|
|
||||||
|
@ -114,78 +105,20 @@ public class LocalAttachLaunchDelegate extends AbstractCLaunchDelegate {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int promptForProcessID(ILaunchConfiguration config) throws CoreException {
|
protected int promptForProcessID(ILaunchConfiguration config) throws CoreException {
|
||||||
final Shell shell = LaunchUIPlugin.getShell();
|
IStatus fPromptStatus = new Status(IStatus.INFO, "org.eclipse.debug.ui", 200, "", null); //$NON-NLS-1$//$NON-NLS-2$
|
||||||
final int pidResult[] = {-1};
|
IStatus processPrompt = new Status(IStatus.INFO, "org.eclipse.cdt.launch", 100, "", null); //$NON-NLS-1$//$NON-NLS-2$
|
||||||
if (shell == null) {
|
// consult a status handler
|
||||||
abort(LaunchMessages.getString("LocalAttachLaunchDelegate.No_Shell_available_in_Launch"), null, //$NON-NLS-1$
|
IStatusHandler prompter = DebugPlugin.getDefault().getStatusHandler(fPromptStatus);
|
||||||
ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR);
|
if (prompter != null) {
|
||||||
}
|
try {
|
||||||
Display display = shell.getDisplay();
|
Object result = prompter.handleStatus(processPrompt, config);
|
||||||
display.syncExec(new Runnable() {
|
if (result instanceof Integer) {
|
||||||
|
return ((Integer)result).intValue();
|
||||||
public void run() {
|
|
||||||
ILabelProvider provider = new LabelProvider() {
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
|
|
||||||
*/
|
|
||||||
public String getText(Object element) {
|
|
||||||
IProcessInfo info = (IProcessInfo)element;
|
|
||||||
IPath path = new Path(info.getName());
|
|
||||||
return path.lastSegment() + " - " + info.getPid(); //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object)
|
|
||||||
*/
|
|
||||||
public Image getImage(Object element) {
|
|
||||||
return LaunchImages.get(LaunchImages.IMG_OBJS_EXEC);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
ILabelProvider qprovider = new LabelProvider() {
|
|
||||||
|
|
||||||
public String getText(Object element) {
|
|
||||||
IProcessInfo info = (IProcessInfo)element;
|
|
||||||
return info.getName();
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object)
|
|
||||||
*/
|
|
||||||
public Image getImage(Object element) {
|
|
||||||
return LaunchImages.get(LaunchImages.IMG_OBJS_EXEC);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
TwoPaneElementSelector dialog = new TwoPaneElementSelector(shell, provider, qprovider);
|
|
||||||
dialog.setTitle(LaunchMessages.getString("LocalAttachLaunchDelegate.Select_Process")); //$NON-NLS-1$
|
|
||||||
dialog.setMessage(LaunchMessages.getString("LocalAttachLaunchDelegate.Select_Process_to_attach_debugger_to")); //$NON-NLS-1$
|
|
||||||
IProcessList plist = null;
|
|
||||||
try {
|
|
||||||
plist = CCorePlugin.getDefault().getProcessList();
|
|
||||||
} catch (CoreException e) {
|
|
||||||
LaunchUIPlugin.errorDialog(
|
|
||||||
LaunchMessages.getString("LocalAttachLaunchDelegate.CDT_Launch_Error"), e.getStatus()); //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
if (plist == null) {
|
|
||||||
MessageDialog.openError(
|
|
||||||
shell,
|
|
||||||
LaunchMessages.getString("LocalAttachLaunchDelegate.CDT_Launch_Error"), LaunchMessages.getString("LocalAttachLaunchDelegate.Platform_cannot_list_processes")); //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
dialog.setElements(plist.getProcessList());
|
|
||||||
if (dialog.open() == Window.OK) {
|
|
||||||
IProcessInfo info = (IProcessInfo)dialog.getFirstResult();
|
|
||||||
if (info != null) {
|
|
||||||
pidResult[0] = info.getPid();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
} catch (CoreException e) {
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
return pidResult[0];
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -0,0 +1,60 @@
|
||||||
|
/***************************************************************************************************
|
||||||
|
* Copyright (c) 2004 QNX Software Systems and others. All rights reserved. This program and the
|
||||||
|
* accompanying materials are made available under the terms of the Common Public License v1.0 which
|
||||||
|
* accompanies this distribution, and is available at http://www.eclipse.org/legal/cpl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors: QNX Software Systems - initial API and implementation
|
||||||
|
**************************************************************************************************/
|
||||||
|
package org.eclipse.cdt.launch.internal.ui;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
|
||||||
|
import org.eclipse.cdt.debug.core.ICDebugConfiguration;
|
||||||
|
import org.eclipse.core.resources.IProject;
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.core.runtime.IStatus;
|
||||||
|
import org.eclipse.core.runtime.Path;
|
||||||
|
import org.eclipse.core.runtime.QualifiedName;
|
||||||
|
import org.eclipse.core.runtime.Status;
|
||||||
|
import org.eclipse.debug.core.IStatusHandler;
|
||||||
|
import org.eclipse.swt.widgets.FileDialog;
|
||||||
|
import org.eclipse.swt.widgets.Shell;
|
||||||
|
|
||||||
|
public class CoreFilePrompter implements IStatusHandler {
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.eclipse.debug.core.IStatusHandler#handleStatus(org.eclipse.core.runtime.IStatus,
|
||||||
|
* java.lang.Object)
|
||||||
|
*/
|
||||||
|
public Object handleStatus(IStatus status, Object source) throws CoreException {
|
||||||
|
final Shell shell = LaunchUIPlugin.getShell();
|
||||||
|
if (shell == null) {
|
||||||
|
IStatus error = new Status(IStatus.ERROR, LaunchUIPlugin.getUniqueIdentifier(),
|
||||||
|
ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR,
|
||||||
|
LaunchMessages.getString("CoreFileLaunchDelegate.No_Shell_available_in_Launch"), null); //$NON-NLS-1$
|
||||||
|
throw new CoreException(error);
|
||||||
|
}
|
||||||
|
FileDialog dialog = new FileDialog(shell);
|
||||||
|
dialog.setText(LaunchMessages.getString("CoreFileLaunchDelegate.Select_Corefile")); //$NON-NLS-1$
|
||||||
|
Object[] args = (Object[])source;
|
||||||
|
IProject project = (IProject)args[0];
|
||||||
|
ICDebugConfiguration debugConfig = (ICDebugConfiguration)args[1];
|
||||||
|
String initPath = null;
|
||||||
|
try {
|
||||||
|
initPath = project.getPersistentProperty(new QualifiedName(LaunchUIPlugin.getUniqueIdentifier(), "SavePath")); //$NON-NLS-1$
|
||||||
|
} catch (CoreException e) {
|
||||||
|
}
|
||||||
|
if (initPath == null || initPath.equals("")) { //$NON-NLS-1$
|
||||||
|
initPath = project.getLocation().toString();
|
||||||
|
}
|
||||||
|
dialog.setFilterExtensions(debugConfig.getCoreFileExtensions());
|
||||||
|
dialog.setFilterPath(initPath);
|
||||||
|
String res = dialog.open();
|
||||||
|
if (res != null) {
|
||||||
|
return new Path(res);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,106 @@
|
||||||
|
/***************************************************************************************************
|
||||||
|
* Copyright (c) 2004 QNX Software Systems and others. All rights reserved. This program and the
|
||||||
|
* accompanying materials are made available under the terms of the Common Public License v1.0 which
|
||||||
|
* accompanies this distribution, and is available at http://www.eclipse.org/legal/cpl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors: QNX Software Systems - initial API and implementation
|
||||||
|
**************************************************************************************************/
|
||||||
|
package org.eclipse.cdt.launch.internal.ui;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
|
import org.eclipse.cdt.core.IProcessInfo;
|
||||||
|
import org.eclipse.cdt.core.IProcessList;
|
||||||
|
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
import org.eclipse.core.runtime.IStatus;
|
||||||
|
import org.eclipse.core.runtime.Path;
|
||||||
|
import org.eclipse.core.runtime.Status;
|
||||||
|
import org.eclipse.debug.core.IStatusHandler;
|
||||||
|
import org.eclipse.jface.dialogs.MessageDialog;
|
||||||
|
import org.eclipse.jface.viewers.ILabelProvider;
|
||||||
|
import org.eclipse.jface.viewers.LabelProvider;
|
||||||
|
import org.eclipse.jface.window.Window;
|
||||||
|
import org.eclipse.swt.graphics.Image;
|
||||||
|
import org.eclipse.swt.widgets.Shell;
|
||||||
|
import org.eclipse.ui.dialogs.TwoPaneElementSelector;
|
||||||
|
|
||||||
|
public class ProcessPrompter implements IStatusHandler {
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.eclipse.debug.core.IStatusHandler#handleStatus(org.eclipse.core.runtime.IStatus,
|
||||||
|
* java.lang.Object)
|
||||||
|
*/
|
||||||
|
public Object handleStatus(IStatus status, Object source) throws CoreException {
|
||||||
|
Shell shell = LaunchUIPlugin.getShell();
|
||||||
|
if (shell == null) {
|
||||||
|
IStatus error = new Status(IStatus.ERROR, LaunchUIPlugin.getUniqueIdentifier(),
|
||||||
|
ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR,
|
||||||
|
LaunchMessages.getString("CoreFileLaunchDelegate.No_Shell_available_in_Launch"), null); //$NON-NLS-1$
|
||||||
|
throw new CoreException(error);
|
||||||
|
}
|
||||||
|
|
||||||
|
ILabelProvider provider = new LabelProvider() {
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public String getText(Object element) {
|
||||||
|
IProcessInfo info = (IProcessInfo)element;
|
||||||
|
IPath path = new Path(info.getName());
|
||||||
|
return path.lastSegment() + " - " + info.getPid(); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public Image getImage(Object element) {
|
||||||
|
return LaunchImages.get(LaunchImages.IMG_OBJS_EXEC);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
ILabelProvider qprovider = new LabelProvider() {
|
||||||
|
|
||||||
|
public String getText(Object element) {
|
||||||
|
IProcessInfo info = (IProcessInfo)element;
|
||||||
|
return info.getName();
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public Image getImage(Object element) {
|
||||||
|
return LaunchImages.get(LaunchImages.IMG_OBJS_EXEC);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
TwoPaneElementSelector dialog = new TwoPaneElementSelector(shell, provider, qprovider);
|
||||||
|
dialog.setTitle(LaunchMessages.getString("LocalAttachLaunchDelegate.Select_Process")); //$NON-NLS-1$
|
||||||
|
dialog.setMessage(LaunchMessages.getString("LocalAttachLaunchDelegate.Select_Process_to_attach_debugger_to")); //$NON-NLS-1$
|
||||||
|
IProcessList plist = null;
|
||||||
|
try {
|
||||||
|
plist = CCorePlugin.getDefault().getProcessList();
|
||||||
|
} catch (CoreException e) {
|
||||||
|
LaunchUIPlugin.errorDialog(LaunchMessages.getString("LocalAttachLaunchDelegate.CDT_Launch_Error"), e.getStatus()); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
if (plist == null) {
|
||||||
|
MessageDialog.openError(
|
||||||
|
shell,
|
||||||
|
LaunchMessages.getString("LocalAttachLaunchDelegate.CDT_Launch_Error"), LaunchMessages.getString("LocalAttachLaunchDelegate.Platform_cannot_list_processes")); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
dialog.setElements(plist.getProcessList());
|
||||||
|
if (dialog.open() == Window.OK) {
|
||||||
|
IProcessInfo info = (IProcessInfo)dialog.getFirstResult();
|
||||||
|
if (info != null) {
|
||||||
|
return new Integer(info.getPid());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue