diff options
Diffstat (limited to 'launch/org.eclipse.cdt.launch')
7 files changed, 231 insertions, 122 deletions
diff --git a/launch/org.eclipse.cdt.launch/ChangeLog b/launch/org.eclipse.cdt.launch/ChangeLog index b8fcc69524b..1dfc721d276 100644 --- a/launch/org.eclipse.cdt.launch/ChangeLog +++ b/launch/org.eclipse.cdt.launch/ChangeLog @@ -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 Added variables support to arguments, environment and working directory. diff --git a/launch/org.eclipse.cdt.launch/plugin.xml b/launch/org.eclipse.cdt.launch/plugin.xml index 3f27e525229..55ea4336c87 100644 --- a/launch/org.eclipse.cdt.launch/plugin.xml +++ b/launch/org.eclipse.cdt.launch/plugin.xml @@ -131,5 +131,19 @@ id="org.eclipse.cdt.launch.CPropertyTester"> </propertyTester> </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> diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/AbstractCLaunchDelegate.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/AbstractCLaunchDelegate.java index fa7270ec419..2616c1b2050 100644 --- a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/AbstractCLaunchDelegate.java +++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/AbstractCLaunchDelegate.java @@ -760,7 +760,7 @@ abstract public class AbstractCLaunchDelegate extends LaunchConfigurationDelegat * @throws CoreException */ protected Properties getEnvironmentAsProperty(ILaunchConfiguration config) throws CoreException { - String[] envp = getEnvironmentArray(config); + String[] envp = getEnvironment(config); Properties p = new Properties( ); for( int i = 0; i < envp.length; i++ ) { int idx = envp[i].indexOf('='); diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/CoreFileLaunchDelegate.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/CoreFileLaunchDelegate.java index c2f7cfc96d7..c1d91634053 100644 --- a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/CoreFileLaunchDelegate.java +++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/CoreFileLaunchDelegate.java @@ -1,11 +1,11 @@ -/******************************************************************************* - * Copyright (c) 2002 - 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 +/*************************************************************************************************** + * Copyright (c) 2002 - 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; 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.IPath; import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.QualifiedName; +import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.SubProgressMonitor; import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.ILaunch; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; +import org.eclipse.debug.core.IStatusHandler; 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 { @@ -100,34 +98,18 @@ public class CoreFileLaunchDelegate extends AbstractCLaunchDelegate { } protected IPath promptForCoreFilePath(final IProject project, final ICDebugConfiguration debugConfig) throws CoreException { - final Shell shell = LaunchUIPlugin.getShell(); - final String res[] = {null}; - if (shell == null) { - abort(LaunchMessages.getString("CoreFileLaunchDelegate.No_Shell_available_in_Launch"), null, //$NON-NLS-1$ - ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR); - } - Display display = shell.getDisplay(); - display.syncExec(new Runnable() { - - 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$ - initPath = project.getLocation().toString(); + IStatus fPromptStatus = new Status(IStatus.INFO, "org.eclipse.debug.ui", 200, "", null); //$NON-NLS-1$//$NON-NLS-2$ + IStatus processPrompt = new Status(IStatus.INFO, "org.eclipse.cdt.launch", 101, "", null); //$NON-NLS-1$//$NON-NLS-2$ + // consult a status handler + IStatusHandler prompter = DebugPlugin.getDefault().getStatusHandler(fPromptStatus); + if (prompter != null) { + try { + Object result = prompter.handleStatus(processPrompt, new Object[]{project, debugConfig}); + if (result instanceof IPath) { + return (IPath)result; } - dialog.setFilterExtensions(debugConfig.getCoreFileExtensions()); - dialog.setFilterPath(initPath); - res[0] = dialog.open(); + } catch (CoreException e) { } - }); - if (res[0] != null) { - return new Path(res[0]); } return null; } diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/LocalAttachLaunchDelegate.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/LocalAttachLaunchDelegate.java index 0ce94f78421..eb9b1b13a57 100644 --- a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/LocalAttachLaunchDelegate.java +++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/LocalAttachLaunchDelegate.java @@ -8,9 +8,6 @@ ******************************************************************************/ 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.model.ICProject; 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.model.ICDITarget; 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.LaunchUIPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; 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.debug.core.DebugPlugin; import org.eclipse.debug.core.ILaunch; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; import org.eclipse.debug.core.ILaunchManager; -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.Display; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.dialogs.TwoPaneElementSelector; +import org.eclipse.debug.core.IStatusHandler; public class LocalAttachLaunchDelegate extends AbstractCLaunchDelegate { @@ -114,78 +105,20 @@ public class LocalAttachLaunchDelegate extends AbstractCLaunchDelegate { } protected int promptForProcessID(ILaunchConfiguration config) throws CoreException { - final Shell shell = LaunchUIPlugin.getShell(); - final int pidResult[] = {-1}; - if (shell == null) { - abort(LaunchMessages.getString("LocalAttachLaunchDelegate.No_Shell_available_in_Launch"), null, //$NON-NLS-1$ - ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR); - } - Display display = shell.getDisplay(); - display.syncExec(new Runnable() { - - 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(); - } + IStatus fPromptStatus = new Status(IStatus.INFO, "org.eclipse.debug.ui", 200, "", null); //$NON-NLS-1$//$NON-NLS-2$ + IStatus processPrompt = new Status(IStatus.INFO, "org.eclipse.cdt.launch", 100, "", null); //$NON-NLS-1$//$NON-NLS-2$ + // consult a status handler + IStatusHandler prompter = DebugPlugin.getDefault().getStatusHandler(fPromptStatus); + if (prompter != null) { + try { + Object result = prompter.handleStatus(processPrompt, config); + if (result instanceof Integer) { + return ((Integer)result).intValue(); } + } catch (CoreException e) { } - }); - return pidResult[0]; + } + return -1; } /* diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/CoreFilePrompter.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/CoreFilePrompter.java new file mode 100644 index 00000000000..c8d92a3e79b --- /dev/null +++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/CoreFilePrompter.java @@ -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; + } + +}
\ No newline at end of file diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/ProcessPrompter.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/ProcessPrompter.java new file mode 100644 index 00000000000..4f147215df5 --- /dev/null +++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/ProcessPrompter.java @@ -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; + } + +}
\ No newline at end of file |