no change
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / builder / ExternalEditorInput.java
1 /*
2  * Created on 06.09.2003
3  *
4  * To change the template for this generated file go to
5  * Window>Preferences>Java>Code Generation>Code and Comments
6  */
7 package net.sourceforge.phpeclipse.builder;
8
9 import org.eclipse.core.resources.IStorage;
10 import org.eclipse.jface.resource.ImageDescriptor;
11 import org.eclipse.ui.IEditorRegistry;
12 import org.eclipse.ui.IPersistableElement;
13 import org.eclipse.ui.IStorageEditorInput;
14 import org.eclipse.ui.PlatformUI;
15
16 /**
17  * An EditorInput for an external file.
18  */
19 public class ExternalEditorInput implements IStorageEditorInput {
20
21          IStorage externalFile;
22
23          /**
24                 * Two ExternalEditorInputs are equal if their IStorage's are equal.
25                 * @see java.lang.Object#equals(java.lang.Object)
26                 */
27          public boolean equals(Object obj) {
28                         if (this == obj)
29                                  return true;
30                         if (!(obj instanceof ExternalEditorInput))
31                                  return false;
32                         ExternalEditorInput other = (ExternalEditorInput) obj;
33                         return externalFile.equals(other.externalFile);
34          }
35
36          /*
37                 * @see IEditorInput#exists()
38                 */
39          public boolean exists() {
40                         // External file can not be deleted
41                         return true;
42          }
43
44          /*
45                 * @see IAdaptable#getAdapter(Class)
46                 */
47          public Object getAdapter(Class adapter) {
48                         return null;
49          }
50
51          /*
52                 * @see IEditorInput#getContentType()
53                 */
54          public String getContentType() {
55                         return externalFile.getFullPath().getFileExtension();
56          }
57
58          /*
59                 * @see IEditorInput#getFullPath()
60                 */
61          public String getFullPath() {
62                         return externalFile.getFullPath().toString();
63          }
64
65          /*
66                 * @see IEditorInput#getImageDescriptor()
67                 */
68          public ImageDescriptor getImageDescriptor() {
69                         IEditorRegistry registry = PlatformUI.getWorkbench().getEditorRegistry();
70                         return registry.getImageDescriptor(externalFile.getFullPath().getFileExtension());
71          }
72
73          /*
74                 * @see IEditorInput#getName()
75                 */
76          public String getName() {
77                         return externalFile.getName();
78          }
79
80          /*
81                 * @see IEditorInput#getPersistable()
82                 */
83          public IPersistableElement getPersistable() {
84                         return null;
85          }
86
87          /*
88                 * see IStorageEditorInput#getStorage()
89                 */
90          public IStorage getStorage() {
91                         return externalFile;
92          }
93
94          /*
95                 * @see IEditorInput#getToolTipText()
96                 */
97          public String getToolTipText() {
98                         return externalFile.getFullPath().toString();
99          }
100
101          public ExternalEditorInput(IStorage exFile) {
102                         externalFile = exFile;
103          }
104 }