~ubuntu-branches/debian/sid/eclipse-cdt/sid

« back to all changes in this revision

Viewing changes to launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/CoreFilePrompter.java

  • Committer: Package Import Robot
  • Author(s): Jakub Adam
  • Date: 2011-10-06 21:15:04 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20111006211504-8dutmljjih0zikfv
Tags: 8.0.1-1
* New upstream release.
* Split the JNI packages into a separate architecture dependent
  package and made eclipse-cdt architecture independent.
* Install JNI libraries into multiarch aware location
* Bumped Standards-Version to 3.9.2.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
7
 *
 
8
 * Contributors:
 
9
 *     QNX Software Systems - initial API and implementation
 
10
 *              Monta Vista - Joanne Woo - Bug 87556
 
11
 *******************************************************************************/
 
12
package org.eclipse.cdt.launch.internal.ui;
 
13
 
 
14
import java.io.File;
 
15
 
 
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;
 
28
 
 
29
public class CoreFilePrompter implements IStatusHandler {
 
30
 
 
31
        /*
 
32
         * (non-Javadoc)
 
33
         * 
 
34
         * @see org.eclipse.debug.core.IStatusHandler#handleStatus(org.eclipse.core.runtime.IStatus,
 
35
         *      java.lang.Object)
 
36
         */
 
37
        public Object handleStatus(IStatus status, Object source) throws CoreException {
 
38
                final Shell shell = LaunchUIPlugin.getShell();
 
39
                if (shell == null) {
 
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);
 
44
                }
 
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;
 
51
                try {
 
52
                        initPath = project.getPersistentProperty(new QualifiedName(LaunchUIPlugin.getUniqueIdentifier(), "SavePath")); //$NON-NLS-1$
 
53
                } catch (CoreException e) {
 
54
                }
 
55
                if (initPath == null || initPath.equals("")) { //$NON-NLS-1$
 
56
                        initPath = project.getLocation().toString();
 
57
                }
 
58
                dialog.setFilterExtensions(debugConfig.getCoreFileExtensions());
 
59
                dialog.setFilterPath(initPath);
 
60
                String res = dialog.open();
 
61
                if (res != null) {
 
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)); 
 
69
                        }
 
70
                        return new Path(res);
 
71
                }
 
72
                return null;
 
73
        }
 
74
 
 
75
}