Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Leherbauer2008-04-02 10:37:56 +0000
committerAnton Leherbauer2008-04-02 10:37:56 +0000
commit7fde922525f0ae8058cf605f31befcd759f3574b (patch)
tree058d5f91e395d662b6d044e12c20620cb9a9283b /build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/editor
parentcfae4dbc59a2f2c0bee8857ecdaa59ad0590f32b (diff)
downloadorg.eclipse.cdt-7fde922525f0ae8058cf605f31befcd759f3574b.tar.gz
org.eclipse.cdt-7fde922525f0ae8058cf605f31befcd759f3574b.tar.xz
org.eclipse.cdt-7fde922525f0ae8058cf605f31befcd759f3574b.zip
Fix for 194578: NPE when attempting to edit a (new type) Makefile on a remote system
Patch by David Inglis
Diffstat (limited to 'build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/editor')
-rw-r--r--build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/editor/MakefileDocumentProvider.java4
-rw-r--r--build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/editor/OpenDeclarationAction.java55
-rw-r--r--build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/editor/OpenIncludeAction.java64
3 files changed, 37 insertions, 86 deletions
diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/editor/MakefileDocumentProvider.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/editor/MakefileDocumentProvider.java
index 1e7a68c0cfe..0d71f170d50 100644
--- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/editor/MakefileDocumentProvider.java
+++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/editor/MakefileDocumentProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2007 QNX Software Systems and others.
+ * Copyright (c) 2000, 2008 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -61,7 +61,7 @@ public class MakefileDocumentProvider extends TextFileDocumentProvider implement
/**
*/
- private IMakefile createMakefile(IFile file) {
+ private IMakefile createMakefile(IFile file) throws CoreException {
if (file.exists()) {
return MakeCorePlugin.getDefault().createMakefile(file);
}
diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/editor/OpenDeclarationAction.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/editor/OpenDeclarationAction.java
index 55a28384a5f..f9f78409ed3 100644
--- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/editor/OpenDeclarationAction.java
+++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/editor/OpenDeclarationAction.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -10,25 +10,14 @@
*******************************************************************************/
package org.eclipse.cdt.make.internal.ui.editor;
-import org.eclipse.cdt.core.resources.FileStorage;
-import org.eclipse.cdt.internal.ui.util.ExternalEditorInput;
import org.eclipse.cdt.make.core.makefile.IDirective;
import org.eclipse.cdt.make.core.makefile.IMakefile;
import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
import org.eclipse.cdt.make.internal.ui.text.WordPartDetector;
import org.eclipse.cdt.make.ui.IWorkingCopyManager;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IStorage;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.ITextSelection;
import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IStorageEditorInput;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.ide.IDE;
import org.eclipse.ui.texteditor.IDocumentProvider;
import org.eclipse.ui.texteditor.ITextEditor;
import org.eclipse.ui.texteditor.TextEditorAction;
@@ -77,51 +66,11 @@ public class OpenDeclarationAction extends TextEditorAction {
directives = makefile.getTargetRules(name);
}
if (directives != null && directives.length > 0) {
- openInEditor(directives[0]);
+ OpenIncludeAction.openInEditor(directives[0]);
}
} catch (Exception x) {
//
}
}
}
-
- private static IEditorPart openInEditor(IDirective directive) throws PartInitException {
- String filename = directive.getFileName();
- IPath path = new Path(filename);
- IFile file = MakeUIPlugin.getWorkspace().getRoot().getFileForLocation(path);
- if (file != null) {
- IWorkbenchPage p = MakeUIPlugin.getActivePage();
- if (p != null) {
- IEditorPart editorPart = IDE.openEditor(p, file, true);
- if (editorPart instanceof MakefileEditor) {
- ((MakefileEditor)editorPart).setSelection(directive, true);
- }
- return editorPart;
- }
- } else {
- // External file
- IStorage storage = new FileStorage(path);
- IStorageEditorInput input = new ExternalEditorInput(storage);
- IWorkbenchPage p = MakeUIPlugin.getActivePage();
- if (p != null) {
- String editorID = "org.eclipse.cdt.make.editor"; //$NON-NLS-1$
- IEditorPart editorPart = IDE.openEditor(p, input, editorID, true);
- if (editorPart instanceof MakefileEditor) {
- ((MakefileEditor)editorPart).setSelection(directive, true);
- }
- return editorPart;
- }
-
- }
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jdt.ui.actions.SelectionDispatchAction#selectionChanged(org.eclipse.jface.text.ITextSelection)
- */
- //public void selectionChanged(ITextSelection selection) {
- //setEnabled(fEditor != null);
- //}
}
diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/editor/OpenIncludeAction.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/editor/OpenIncludeAction.java
index 01569150c60..fa236c47e99 100644
--- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/editor/OpenIncludeAction.java
+++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/editor/OpenIncludeAction.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2002, 2006 QNX Software Systems and others.
+ * Copyright (c) 2002, 2008 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -11,26 +11,26 @@
package org.eclipse.cdt.make.internal.ui.editor;
+import java.net.URI;
import java.util.ArrayList;
import java.util.List;
-import org.eclipse.cdt.core.resources.FileStorage;
-import org.eclipse.cdt.internal.ui.util.ExternalEditorInput;
import org.eclipse.cdt.make.core.makefile.IDirective;
import org.eclipse.cdt.make.core.makefile.gnu.IInclude;
import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
+import org.eclipse.core.filesystem.EFS;
+import org.eclipse.core.filesystem.IFileStore;
import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IStorage;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IStorageEditorInput;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.ide.FileStoreEditorInput;
import org.eclipse.ui.ide.IDE;
/**
@@ -70,33 +70,35 @@ public class OpenIncludeAction extends Action {
}
}
- private static IEditorPart openInEditor(IDirective directive) throws PartInitException {
- String filename = directive.getFileName();
- IPath path = new Path(filename);
- IFile file = MakeUIPlugin.getWorkspace().getRoot().getFileForLocation(path);
- if (file != null) {
- IWorkbenchPage p = MakeUIPlugin.getActivePage();
- if (p != null) {
- IEditorPart editorPart = IDE.openEditor(p, file, true);
- if (editorPart instanceof MakefileEditor) {
- ((MakefileEditor)editorPart).setSelection(directive, true);
+ public static IEditorPart openInEditor(IDirective directive) throws PartInitException {
+ try {
+ URI uri = directive.getMakefile().getFileURI();
+ IFileStore store = EFS.getStore(uri);
+
+ IFile[] file = MakeUIPlugin.getWorkspace().getRoot().findFilesForLocationURI(uri);
+ if (file.length > 0 && file[0] != null) {
+ IWorkbenchPage p = MakeUIPlugin.getActivePage();
+ if (p != null) {
+ IEditorPart editorPart = IDE.openEditor(p, file[0], true);
+ if (editorPart instanceof MakefileEditor) {
+ ((MakefileEditor) editorPart).setSelection(directive, true);
+ }
+ return editorPart;
}
- return editorPart;
- }
- } else {
- // External file
- IStorage storage = new FileStorage(path);
- IStorageEditorInput input = new ExternalEditorInput(storage);
- IWorkbenchPage p = MakeUIPlugin.getActivePage();
- if (p != null) {
- String editorID = "org.eclipse.cdt.make.editor"; //$NON-NLS-1$
- IEditorPart editorPart = IDE.openEditor(p, input, editorID, true);
- if (editorPart instanceof MakefileEditor) {
- ((MakefileEditor)editorPart).setSelection(directive, true);
+ } else {
+ // External file
+ IEditorInput input = new FileStoreEditorInput(store);
+ IWorkbenchPage p = MakeUIPlugin.getActivePage();
+ if (p != null) {
+ String editorID = "org.eclipse.cdt.make.editor"; //$NON-NLS-1$
+ IEditorPart editorPart = IDE.openEditor(p, input, editorID, true);
+ if (editorPart instanceof MakefileEditor) {
+ ((MakefileEditor) editorPart).setSelection(directive, true);
+ }
+ return editorPart;
}
- return editorPart;
}
-
+ } catch (CoreException e) {
}
return null;
}

Back to the top