Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormspector2007-06-10 12:26:44 -0400
committermspector2007-06-10 12:26:44 -0400
commit2eeaacbe33ddb4e8ff5c741c7706e221712061c3 (patch)
tree515cd70fa53ad90e3f925fad1f19a54a0a122bdc
parent8f54ead904e2e8b6ed2a7ca80a5fa730b5e59e9a (diff)
downloadorg.eclipse.pdt-2eeaacbe33ddb4e8ff5c741c7706e221712061c3.tar.gz
org.eclipse.pdt-2eeaacbe33ddb4e8ff5c741c7706e221712061c3.tar.xz
org.eclipse.pdt-2eeaacbe33ddb4e8ff5c741c7706e221712061c3.zip
- Revert to usage of FileStoreEditorInput
- Proper usage of external files in debugger
-rw-r--r--plugins/org.eclipse.php.ui/plugin.xml1
-rw-r--r--plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/ExternalFileHyperlink.java8
-rw-r--r--plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/PHPEditorMatchingStrategy.java37
-rw-r--r--plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/PHPStructuredEditor.java47
-rw-r--r--plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/util/EditorUtility.java28
-rw-r--r--plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/util/PHPOpenExternalFileAction.java8
6 files changed, 47 insertions, 82 deletions
diff --git a/plugins/org.eclipse.php.ui/plugin.xml b/plugins/org.eclipse.php.ui/plugin.xml
index 1f99e2ff5..98978d1b9 100644
--- a/plugins/org.eclipse.php.ui/plugin.xml
+++ b/plugins/org.eclipse.php.ui/plugin.xml
@@ -176,7 +176,6 @@
default="true"
icon="icons/full/obj16/phpfile.gif"
id="org.eclipse.php.editor"
- matchingStrategy="org.eclipse.php.internal.ui.editor.PHPEditorMatchingStrategy"
name="PHP Editor"
symbolicFontName="org.eclipse.wst.sse.ui.textfont">
<contentTypeBinding contentTypeId="org.eclipse.php.core.phpsource" />
diff --git a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/ExternalFileHyperlink.java b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/ExternalFileHyperlink.java
index d565b5240..82e0bfda3 100644
--- a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/ExternalFileHyperlink.java
+++ b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/ExternalFileHyperlink.java
@@ -12,13 +12,13 @@ package org.eclipse.php.internal.ui.editor;
import java.io.File;
+import org.eclipse.core.internal.filesystem.local.LocalFile;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.hyperlink.IHyperlink;
-import org.eclipse.php.internal.core.containers.LocalFileStorage;
-import org.eclipse.php.internal.ui.containers.LocalFileStorageEditorInput;
import org.eclipse.php.internal.ui.util.EditorUtility;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.ide.FileStoreEditorInput;
/**
* Hyperlink for external files.
@@ -51,8 +51,8 @@ class ExternalFileHyperlink implements IHyperlink {
public void open() {
if (fHyperlinkFile != null) {
- LocalFileStorage fileStorage = new LocalFileStorage(fHyperlinkFile);
- IEditorInput input = new LocalFileStorageEditorInput(fileStorage);
+ LocalFile fileStore = new LocalFile(fHyperlinkFile);
+ IEditorInput input = new FileStoreEditorInput(fileStore);
try {
EditorUtility.openInEditor(input);
} catch (PartInitException e) {
diff --git a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/PHPEditorMatchingStrategy.java b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/PHPEditorMatchingStrategy.java
deleted file mode 100644
index 8e6811e79..000000000
--- a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/PHPEditorMatchingStrategy.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package org.eclipse.php.internal.ui.editor;
-
-import java.io.File;
-
-import org.eclipse.php.internal.core.containers.LocalFileStorage;
-import org.eclipse.php.internal.ui.Logger;
-import org.eclipse.php.internal.ui.containers.LocalFileStorageEditorInput;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorMatchingStrategy;
-import org.eclipse.ui.IEditorReference;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.ide.FileStoreEditorInput;
-import org.eclipse.ui.internal.util.Util;
-
-/**
- * This class provides strategy of matching PHP editor inputs.
- * First check whether the editor input is {@link FileStoreEditorInput}, which can be
- * received from Eclipse platform; if it is - convert it to {@link LocalFileStorageEditorInput}
- * - WST-compatible editor input.
- *
- * @author Michael
- */
-public class PHPEditorMatchingStrategy implements IEditorMatchingStrategy {
-
- public boolean matches(IEditorReference editorRef, IEditorInput input) {
- if (input instanceof FileStoreEditorInput) {
- input = new LocalFileStorageEditorInput(new LocalFileStorage(new File(((FileStoreEditorInput) input).getURI())));
- }
- try {
- IEditorInput editorInput = editorRef.getEditorInput();
- return Util.equals(editorInput, input);
- } catch (PartInitException e) {
- Logger.logException(e);
- }
- return false;
- }
-}
diff --git a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/PHPStructuredEditor.java b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/PHPStructuredEditor.java
index 2fd93fa29..3d50e1638 100644
--- a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/PHPStructuredEditor.java
+++ b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/PHPStructuredEditor.java
@@ -10,11 +10,11 @@
*******************************************************************************/
package org.eclipse.php.internal.ui.editor;
-import java.io.File;
import java.text.BreakIterator;
import java.text.CharacterIterator;
import java.util.*;
+import org.eclipse.core.filesystem.URIUtil;
import org.eclipse.core.resources.*;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
@@ -53,8 +53,6 @@ import org.eclipse.php.internal.core.resources.ExternalFilesRegistry;
import org.eclipse.php.internal.ui.PHPUIMessages;
import org.eclipse.php.internal.ui.PHPUiPlugin;
import org.eclipse.php.internal.ui.actions.*;
-import org.eclipse.php.internal.ui.containers.LocalFileStorageEditorInput;
-import org.eclipse.php.internal.ui.containers.StorageEditorInput;
import org.eclipse.php.internal.ui.editor.hover.SourceViewerInformationControl;
import org.eclipse.php.internal.ui.outline.PHPContentOutlineConfiguration;
import org.eclipse.php.internal.ui.outline.PHPContentOutlineConfiguration.DoubleClickListener;
@@ -72,7 +70,7 @@ import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.*;
import org.eclipse.ui.actions.ActionContext;
import org.eclipse.ui.actions.ActionGroup;
-import org.eclipse.ui.ide.FileStoreEditorInput;
+import org.eclipse.ui.editors.text.TextFileDocumentProvider;
import org.eclipse.ui.texteditor.*;
import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
@@ -416,6 +414,14 @@ public class PHPStructuredEditor extends StructuredTextEditor {
super.init(site, input);
PhpVersionChangedHandler.getInstance().addPhpVersionChangedListener(phpVersionListener);
}
+
+ protected void setDocumentProvider(IEditorInput input) {
+ if (input instanceof IURIEditorInput) {
+ setDocumentProvider(new TextFileDocumentProvider());
+ } else {
+ super.setDocumentProvider(input);
+ }
+ }
public void dispose() {
PhpVersionChangedHandler.getInstance().removePhpVersionChangedListener(phpVersionListener);
@@ -1286,15 +1292,16 @@ public class PHPStructuredEditor extends StructuredTextEditor {
IResource resource = null;
IPath externalPath = null;
- // Replace input received from Eclipse platform with WST-compatible:
- if (input instanceof FileStoreEditorInput) {
- input = new LocalFileStorageEditorInput(new LocalFileStorage(new File(((FileStoreEditorInput)input).getURI())));
- }
-
if (input instanceof IFileEditorInput) {
+ // This is the existing workspace file
final IFileEditorInput fileInput = (IFileEditorInput) input;
resource = fileInput.getFile();
- } else if (input instanceof IStorageEditorInput) {
+ }
+ else if (input instanceof IStorageEditorInput) {
+ // This kind of editor input usually means non-workspace file, like
+ // PHP file which comes from include path, remote file which comes from
+ // Web server while debugging, file from ZIP archive, etc...
+
final IStorageEditorInput editorInput = (IStorageEditorInput) input;
final IStorage storage = editorInput.getStorage();
@@ -1302,25 +1309,21 @@ public class PHPStructuredEditor extends StructuredTextEditor {
resource = ((ZipEntryStorage) storage).getProject();
} else if (storage instanceof LocalFileStorage && ((LocalFileStorage) storage).getProject() != null) {
resource = ((LocalFileStorage) storage).getProject();
- }
- // Suppose that it's a external storage (or remote).
- // If something goes wrong in some case - add another "if" above.
- else {
+ } else {
+ // This is, probably, a remote storage:
externalPath = storage.getFullPath();
resource = ExternalFileDecorator.createFile(externalPath.toString());
-
- if (!(input instanceof StorageEditorInput)) {
- input = new StorageEditorInput(storage) {
- public boolean exists() {
- return false;
- }
- };
- }
}
+ } else if (input instanceof IURIEditorInput) {
+ // External file editor input. It's usually used when opening PHP file
+ // via "File -> Open File" menu option, or using D&D:
+ externalPath = URIUtil.toPath(((IURIEditorInput)input).getURI());
+ resource = ExternalFileDecorator.createFile(externalPath.toString());
}
if (resource instanceof IFile) {
if (PHPModelUtil.isPhpFile((IFile) resource)) {
+ // Add file decorator entry to the list of external files:
if (externalPath != null && (resource instanceof ExternalFileDecorator)) {
ExternalFilesRegistry.getInstance().addFileEntry(externalPath.toString(), (ExternalFileDecorator) resource);
}
diff --git a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/util/EditorUtility.java b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/util/EditorUtility.java
index 5e0810add..e0739a712 100644
--- a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/util/EditorUtility.java
+++ b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/util/EditorUtility.java
@@ -18,6 +18,7 @@ import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import java.util.zip.ZipInputStream;
+import org.eclipse.core.internal.filesystem.local.LocalFile;
import org.eclipse.core.internal.resources.ICoreConstants;
import org.eclipse.core.resources.*;
import org.eclipse.core.runtime.*;
@@ -31,9 +32,7 @@ import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.php.internal.core.containers.LocalFileStorage;
import org.eclipse.php.internal.core.containers.ZipEntryStorage;
import org.eclipse.php.internal.core.phpModel.PHPModelUtil;
-import org.eclipse.php.internal.core.phpModel.parser.PHPIncludePathModel;
-import org.eclipse.php.internal.core.phpModel.parser.PHPProjectModel;
-import org.eclipse.php.internal.core.phpModel.parser.PHPWorkspaceModelManager;
+import org.eclipse.php.internal.core.phpModel.parser.*;
import org.eclipse.php.internal.core.phpModel.phpElementData.PHPCodeData;
import org.eclipse.php.internal.core.phpModel.phpElementData.PHPFileData;
import org.eclipse.php.internal.core.phpModel.phpElementData.UserData;
@@ -49,6 +48,7 @@ import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.TreeItem;
import org.eclipse.ui.*;
import org.eclipse.ui.actions.WorkspaceModifyOperation;
+import org.eclipse.ui.ide.FileStoreEditorInput;
import org.eclipse.ui.ide.IDE;
import org.eclipse.ui.ide.IGotoMarker;
import org.eclipse.ui.part.FileEditorInput;
@@ -207,16 +207,16 @@ public class EditorUtility {
}
public static IEditorInput getEditorInput(final Object input) {
- IProject project = null;
if (input instanceof TreeItem) {
- project = getProject((TreeItem) input);
+ IProject project = getProject((TreeItem) input);
final String incDir = getIncludeDirectory((TreeItem) input);
return getEditorInput((PHPCodeData) ((TreeItem) input).getData(), project, incDir);
}
- if (input instanceof PHPCodeData)
+ if (input instanceof PHPCodeData) {
return getEditorInput((PHPCodeData) input, null, null);
-
+ }
+
if (input instanceof IFile)
return new FileEditorInput((IFile) input);
@@ -234,14 +234,15 @@ public class EditorUtility {
if (source instanceof File) {
File externalSource = (File) source;
Path path = new Path(externalSource.getPath());
-
- final LocalFileStorage fileStorage = new LocalFileStorage((File) source);
- // If this file isn't external, it's probably from the include path:
- if (!ExternalFilesRegistry.getInstance().isEntryExist(path.toString())) {
- fileStorage.setProject(project);
- fileStorage.setIncBaseDirName(incDir);
+ // If this is external file:
+ if (ExternalFilesRegistry.getInstance().isEntryExist(path.toString())) {
+ return new FileStoreEditorInput(new LocalFile(externalSource));
}
+
+ LocalFileStorage fileStorage = new LocalFileStorage((File) source);
+ fileStorage.setProject(project);
+ fileStorage.setIncBaseDirName(incDir);
return new LocalFileStorageEditorInput(fileStorage);
}
if (source instanceof ZipFile)
@@ -266,6 +267,7 @@ public class EditorUtility {
if (input == null)
return null;
+
PHPIncludePathModel includePathModel = (PHPIncludePathModel) input.getData();
if (includePathModel.getType() == PHPIncludePathModel.TYPE_VARIABLE) {
IPath includePath = IncludePathVariableManager.instance().getIncludePathVariable(includePathModel.getID());
diff --git a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/util/PHPOpenExternalFileAction.java b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/util/PHPOpenExternalFileAction.java
index 5704ae1d2..cee7310d1 100644
--- a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/util/PHPOpenExternalFileAction.java
+++ b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/util/PHPOpenExternalFileAction.java
@@ -1,6 +1,5 @@
package org.eclipse.php.internal.ui.util;
-import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
@@ -23,12 +22,11 @@ import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.window.Window;
-import org.eclipse.php.internal.core.containers.LocalFileStorage;
import org.eclipse.php.internal.ui.Logger;
-import org.eclipse.php.internal.ui.containers.LocalFileStorageEditorInput;
import org.eclipse.ui.*;
import org.eclipse.ui.dialogs.ElementListSelectionDialog;
import org.eclipse.ui.editors.text.EditorsUI;
+import org.eclipse.ui.ide.FileStoreEditorInput;
import org.eclipse.ui.internal.editors.text.EditorsPlugin;
import org.eclipse.ui.part.FileEditorInput;
@@ -182,8 +180,8 @@ public class PHPOpenExternalFileAction extends Action implements IWorkbenchWindo
IFile workspaceFile= getWorkspaceFile(fileStore);
if (workspaceFile != null)
return new FileEditorInput(workspaceFile);
- LocalFileStorage fileStorage = new LocalFileStorage(new File(fileStore.toURI()));
- return new LocalFileStorageEditorInput(fileStorage);
+
+ return new FileStoreEditorInput(fileStore);
}
private IFile getWorkspaceFile(IFileStore fileStore) {

Back to the top