improved code formatter
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / builder / ExternalEditorInput.java
1 package net.sourceforge.phpeclipse.builder;
2
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;
9
10 /**
11  * An EditorInput for an external file.
12  */
13 public class ExternalEditorInput implements IStorageEditorInput {
14
15          IStorage externalFile;
16
17          /**
18                 * Two ExternalEditorInputs are equal if their IStorage's are equal.
19                 * @see java.lang.Object#equals(java.lang.Object)
20                 */
21          public boolean equals(Object obj) {
22                         if (this == obj)
23                                  return true;
24                         if (!(obj instanceof ExternalEditorInput))
25                                  return false;
26                         ExternalEditorInput other = (ExternalEditorInput) obj;
27                         return externalFile.equals(other.externalFile);
28          }
29
30          /*
31                 * @see IEditorInput#exists()
32                 */
33          public boolean exists() {
34                         // External file can not be deleted
35                         return true;
36          }
37
38          /*
39                 * @see IAdaptable#getAdapter(Class)
40                 */
41          public Object getAdapter(Class adapter) {
42                         return null;
43          }
44
45          /*
46                 * @see IEditorInput#getContentType()
47                 */
48          public String getContentType() {
49                         return externalFile.getFullPath().getFileExtension();
50          }
51
52          /*
53                 * @see IEditorInput#getFullPath()
54                 */
55          public String getFullPath() {
56                         return externalFile.getFullPath().toString();
57          }
58
59          /*
60                 * @see IEditorInput#getImageDescriptor()
61                 */
62          public ImageDescriptor getImageDescriptor() {
63                         IEditorRegistry registry = PlatformUI.getWorkbench().getEditorRegistry();
64                         return registry.getImageDescriptor(externalFile.getFullPath().getFileExtension());
65          }
66
67          /*
68                 * @see IEditorInput#getName()
69                 */
70          public String getName() {
71                         return externalFile.getName();
72          }
73
74          /*
75                 * @see IEditorInput#getPersistable()
76                 */
77          public IPersistableElement getPersistable() {
78                         return null;
79          }
80
81          /*
82                 * see IStorageEditorInput#getStorage()
83                 */
84          public IStorage getStorage() {
85                         return externalFile;
86          }
87
88          /*
89                 * @see IEditorInput#getToolTipText()
90                 */
91          public String getToolTipText() {
92                         return externalFile.getFullPath().toString();
93          }
94
95          public ExternalEditorInput(IStorage exFile) {
96                         externalFile = exFile;
97          }
98 }