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:
parent
0b73b5bf15
commit
2edb4b19bb
1 changed files with 15 additions and 1 deletions
|
@ -12,6 +12,8 @@
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.ui.util;
|
package org.eclipse.cdt.internal.ui.util;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
import org.eclipse.core.resources.IMarker;
|
import org.eclipse.core.resources.IMarker;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
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.action.IAction;
|
||||||
import org.eclipse.jface.viewers.ISelection;
|
import org.eclipse.jface.viewers.ISelection;
|
||||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
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.Event;
|
||||||
|
import org.eclipse.swt.widgets.MessageBox;
|
||||||
import org.eclipse.ui.IEditorPart;
|
import org.eclipse.ui.IEditorPart;
|
||||||
import org.eclipse.ui.IObjectActionDelegate;
|
import org.eclipse.ui.IObjectActionDelegate;
|
||||||
import org.eclipse.ui.IWorkbenchPart;
|
import org.eclipse.ui.IWorkbenchPart;
|
||||||
|
@ -54,7 +59,16 @@ public class OpenExternalProblemAction extends ActionDelegate implements IObject
|
||||||
if (attributeObject instanceof String) {
|
if (attributeObject instanceof String) {
|
||||||
String externalLocation = (String) attributeObject;
|
String externalLocation = (String) attributeObject;
|
||||||
IPath externalPath = new Path(externalLocation);
|
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));
|
IEditorPart editor = EditorUtility.openInEditor(externalPath, getCProject(marker));
|
||||||
if (editor != null) {
|
if (editor != null) {
|
||||||
IDE.gotoMarker(editor, marker);
|
IDE.gotoMarker(editor, marker);
|
||||||
|
|
Loading…
Add table
Reference in a new issue