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