}
/**
- * Determine the path of an include name string
+ * Creata the file for the given absolute file path
+ *
+ * @param absoluteFilePath
+ * @param project
+ * @return the file for the given absolute file path or <code>null</code> if no existing file can be found
+ */
+ public static IFile createFile(IPath absoluteFilePath, IProject project) {
+ if (absoluteFilePath == null || project == null) {
+ return null;
+ }
+ String projectPath = project.getLocation().toString();
+ String filePath = absoluteFilePath.toString().substring(projectPath.length() + 1);
+ return project.getFile(filePath);
+ }
+
+ /**
+ * Determine the path of an include name string
*
* @param includeNameString
* @param resource
* @param project
+ * @return the path for the given include filename or <code>null</code> if no existing file can be found
*/
public static IPath determineFilePath(String includeNameString, IResource resource, IProject project) {
IPath documentRootPath = ProjectPrefUtil.getDocumentRoot(project);
**********************************************************************************************************************************/
package net.sourceforge.phpeclipse.actions;
-import java.io.File;
import java.util.Collections;
import java.util.List;
import java.util.Set;
+import net.sourceforge.phpdt.internal.ui.util.PHPFileUtil;
import net.sourceforge.phpeclipse.PHPeclipsePlugin;
import net.sourceforge.phpeclipse.builder.IdentifierIndexManager;
import net.sourceforge.phpeclipse.builder.PHPIdentifierLocation;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.internal.resources.File;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
private void openIncludeFile(String filename) {
if (filename != null && !filename.equals("")) {
try {
- IFile file = getIncludeFile(fProject, (IFileEditorInput) fEditor.getEditorInput(), filename);
- if (file != null && file.exists()) {
- PHPeclipsePlugin.getDefault().openFileInTextEditor(file.getLocation().toString());
- return;
+ IFile currentFile = ((IFileEditorInput) fEditor.getEditorInput()).getFile();
+ IPath path = PHPFileUtil.determineFilePath(filename, currentFile, fProject);
+ if (path != null) {
+// String projectPath = fProject.getLocation().toString();
+// String filePath = path.toString().substring(projectPath.length()+1);
+// IFile file = fProject.getFile(filePath);
+ IFile file = PHPFileUtil.createFile(path, fProject);
+ // IFile file = getIncludeFile(fProject, (IFileEditorInput) fEditor.getEditorInput(), filename);
+ if (file != null && file.exists()) {
+ PHPeclipsePlugin.getDefault().openFileInTextEditor(file.getLocation().toString());
+ return;
+ }
}
} catch (Exception e) {
// ignore
List list = indexManager.getFileList(filename);
if (list != null && list.size() > 0) {
//String workspaceLocation = PHPeclipsePlugin.getWorkspace().getRoot().getLocation().toString();
- String workspaceLocation = fProject.getLocation().toString() + File.separatorChar;
+ String workspaceLocation = fProject.getLocation().toString() + java.io.File.separatorChar;
ListSelectionDialog listSelectionDialog = new ListSelectionDialog(PHPeclipsePlugin.getDefault().getWorkbench()
.getActiveWorkbenchWindow().getShell(), list, new ListContentProvider(), new LabelProvider(),
// String workspaceLocation = PHPeclipsePlugin.getWorkspace().getRoot()
// .getLocation().toString();
- String workspaceLocation = fProject.getLocation().toString() + File.separatorChar;
+ String workspaceLocation = fProject.getLocation().toString() + java.io.File.separatorChar;
// TODO show all entries of the list in a dialog box
// at the moment always the first entry will be opened
if (locationsList.size() > 1) {
return editorInput.getFile().getParent();
}
- private IFile getIncludeFile(IProject project, IFileEditorInput editorInput, String relativeFilename) {
- IContainer container = getWorkingLocation(editorInput);
- String fullPath = project.getLocation().toString();
- IFile file = null;
- if (relativeFilename.startsWith("../")) {
- Path path = new Path(relativeFilename);
- file = container.getFile(path);
- return file;
- }
- int index = relativeFilename.lastIndexOf('/');
-
- if (index >= 0) {
- Path path = new Path(relativeFilename);
- file = project.getFile(path);
- if (file.exists()) {
- return file;
- }
- }
-
- Path path = new Path(relativeFilename);
- file = container.getFile(path);
-
- return file;
- }
+ // private IFile getIncludeFile(IProject project, IFileEditorInput editorInput, String relativeFilename) {
+ // IContainer container = getWorkingLocation(editorInput);
+ // String fullPath = project.getLocation().toString();
+ // IFile file = null;
+ // if (relativeFilename.startsWith("../")) {
+ // Path path = new Path(relativeFilename);
+ // file = container.getFile(path);
+ // return file;
+ // }
+ // int index = relativeFilename.lastIndexOf('/');
+ //
+ // if (index >= 0) {
+ // Path path = new Path(relativeFilename);
+ // file = project.getFile(path);
+ // if (file.exists()) {
+ // return file;
+ // }
+ // }
+ //
+ // Path path = new Path(relativeFilename);
+ // file = container.getFile(path);
+ //
+ // return file;
+ // }
}
\ No newline at end of file