1 package net.sourceforge.phpeclipse.builder;
3 import org.eclipse.core.resources.IStorage;
4 import org.eclipse.jface.resource.ImageDescriptor;
5 import org.eclipse.ui.IEditorRegistry;
6 import org.eclipse.ui.IPersistableElement;
7 import org.eclipse.ui.IStorageEditorInput;
8 import org.eclipse.ui.PlatformUI;
11 * An EditorInput for an external file.
13 public class ExternalEditorInput implements IStorageEditorInput {
15 IStorage externalFile;
18 * Two ExternalEditorInputs are equal if their IStorage's are equal.
19 * @see java.lang.Object#equals(java.lang.Object)
21 public boolean equals(Object obj) {
24 if (!(obj instanceof ExternalEditorInput))
26 ExternalEditorInput other = (ExternalEditorInput) obj;
27 return externalFile.equals(other.externalFile);
31 * @see IEditorInput#exists()
33 public boolean exists() {
34 // External file can not be deleted
39 * @see IAdaptable#getAdapter(Class)
41 public Object getAdapter(Class adapter) {
46 * @see IEditorInput#getContentType()
48 public String getContentType() {
49 return externalFile.getFullPath().getFileExtension();
53 * @see IEditorInput#getFullPath()
55 public String getFullPath() {
56 return externalFile.getFullPath().toString();
60 * @see IEditorInput#getImageDescriptor()
62 public ImageDescriptor getImageDescriptor() {
63 IEditorRegistry registry = PlatformUI.getWorkbench().getEditorRegistry();
64 return registry.getImageDescriptor(externalFile.getFullPath().getFileExtension());
68 * @see IEditorInput#getName()
70 public String getName() {
71 return externalFile.getName();
75 * @see IEditorInput#getPersistable()
77 public IPersistableElement getPersistable() {
82 * see IStorageEditorInput#getStorage()
84 public IStorage getStorage() {
89 * @see IEditorInput#getToolTipText()
91 public String getToolTipText() {
92 return externalFile.getFullPath().toString();
95 public ExternalEditorInput(IStorage exFile) {
96 externalFile = exFile;