1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

bug 323402: Open external location in Problems View throws exception when file is not there

This commit is contained in:
Andrew Gvozdev 2010-08-23 16:25:21 +00:00
parent 0b73b5bf15
commit 2edb4b19bb

View file

@ -12,6 +12,8 @@
package org.eclipse.cdt.internal.ui.util;
import java.io.File;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
@ -20,7 +22,10 @@ import org.eclipse.core.runtime.Path;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IObjectActionDelegate;
import org.eclipse.ui.IWorkbenchPart;
@ -55,6 +60,15 @@ public class OpenExternalProblemAction extends ActionDelegate implements IObject
String externalLocation = (String) attributeObject;
IPath externalPath = new Path(externalLocation);
File file = externalPath.toFile() ;
if (!file.canRead()) {
MessageBox errorMsg = new MessageBox(CUIPlugin.getActiveWorkbenchShell(), SWT.ICON_ERROR | SWT.OK);
errorMsg.setText(Messages.OpenExternalProblemAction_ErrorOpeningFile);
errorMsg.setMessage(NLS.bind(Messages.OpenExternalProblemAction_CannotReadExternalLocation, externalPath));
errorMsg.open();
return;
}
IEditorPart editor = EditorUtility.openInEditor(externalPath, getCProject(marker));
if (editor != null) {
IDE.gotoMarker(editor, marker);