1
/*******************************************************************************
2
* Copyright (c) 2004, 2006 QNX Software Systems and others.
3
* All rights reserved. This program and the accompanying materials
4
* are made available under the terms of the Eclipse Public License v1.0
5
* which accompanies this distribution, and is available at
6
* http://www.eclipse.org/legal/epl-v10.html
9
* QNX Software Systems - initial API and implementation
10
* Monta Vista - Joanne Woo - Bug 87556
11
*******************************************************************************/
12
package org.eclipse.cdt.launch.internal.ui;
16
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
17
import org.eclipse.cdt.debug.core.ICDebugConfiguration;
18
import org.eclipse.core.resources.IProject;
19
import org.eclipse.core.runtime.CoreException;
20
import org.eclipse.core.runtime.IStatus;
21
import org.eclipse.core.runtime.Path;
22
import org.eclipse.core.runtime.QualifiedName;
23
import org.eclipse.core.runtime.Status;
24
import org.eclipse.debug.core.IStatusHandler;
25
import org.eclipse.swt.widgets.FileDialog;
26
import org.eclipse.swt.widgets.Shell;
27
import org.eclipse.jface.dialogs.ErrorDialog;
29
public class CoreFilePrompter implements IStatusHandler {
34
* @see org.eclipse.debug.core.IStatusHandler#handleStatus(org.eclipse.core.runtime.IStatus,
37
public Object handleStatus(IStatus status, Object source) throws CoreException {
38
final Shell shell = LaunchUIPlugin.getShell();
40
IStatus error = new Status(IStatus.ERROR, LaunchUIPlugin.getUniqueIdentifier(),
41
ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR,
42
LaunchMessages.CoreFileLaunchDelegate_No_Shell_available_in_Launch, null);
43
throw new CoreException(error);
45
FileDialog dialog = new FileDialog(shell);
46
dialog.setText(LaunchMessages.CoreFileLaunchDelegate_Select_Corefile);
47
Object[] args = (Object[])source;
48
IProject project = (IProject)args[0];
49
ICDebugConfiguration debugConfig = (ICDebugConfiguration)args[1];
50
String initPath = null;
52
initPath = project.getPersistentProperty(new QualifiedName(LaunchUIPlugin.getUniqueIdentifier(), "SavePath")); //$NON-NLS-1$
53
} catch (CoreException e) {
55
if (initPath == null || initPath.equals("")) { //$NON-NLS-1$
56
initPath = project.getLocation().toString();
58
dialog.setFilterExtensions(debugConfig.getCoreFileExtensions());
59
dialog.setFilterPath(initPath);
60
String res = dialog.open();
62
File file = new File(res);
63
if (!file.exists() || !file.canRead()) {
64
ErrorDialog.openError(shell, LaunchMessages.CoreFileLaunchDelegate_postmortem_debugging_failed,
65
LaunchMessages.CoreFileLaunchDelegate_Corefile_not_accessible,
66
new Status(IStatus.ERROR, LaunchUIPlugin.getUniqueIdentifier(),
67
ICDTLaunchConfigurationConstants.ERR_NO_COREFILE,
68
LaunchMessages.CoreFileLaunchDelegate_Corefile_not_readable, null));