Fixed problem opening other sources
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / resourcesview / ResourceAdapterFactory.java
1 package net.sourceforge.phpeclipse.resourcesview;
2
3 import net.sourceforge.phpeclipse.PHPCore;
4
5 import org.eclipse.core.resources.IFile;
6 import org.eclipse.core.resources.IProject;
7 import org.eclipse.core.runtime.IAdapterFactory;
8
9 public class ResourceAdapterFactory implements IAdapterFactory {
10
11         protected static Class[] ADAPTERS_I_CREATE = new Class[] { PHPElement.class, PHPFile.class, PHPProject.class };
12
13         public ResourceAdapterFactory() {
14                 super();
15         }
16
17         public Object getAdapter(Object adaptableObject, Class adapterType) {
18                 if (PHPFile.class.equals(adapterType))
19                         return PHPCore.create((IFile) adaptableObject);
20
21                 if (PHPProject.class.equals(adapterType))
22                         return PHPCore.create((IProject) adaptableObject);
23
24                 if (PHPElement.class.equals(adapterType)) {
25                         if (adaptableObject instanceof IFile)
26                                 return PHPCore.create((IFile) adaptableObject);
27
28                         if (adaptableObject instanceof IProject)
29                                 return PHPCore.create((IProject) adaptableObject);
30                 }
31
32                 return null;
33         }
34
35         public Class[] getAdapterList() {
36                 return ADAPTERS_I_CREATE;
37         }
38
39 }