1 11 package org.eclipse.jdt.internal.ui; 12 13 14 import org.eclipse.core.runtime.IAdapterFactory; 15 16 import org.eclipse.core.resources.IFile; 17 import org.eclipse.core.resources.IResource; 18 19 import org.eclipse.ui.part.FileEditorInput; 20 21 import org.eclipse.jdt.core.IJavaElement; 22 import org.eclipse.jdt.core.JavaCore; 23 24 public class ResourceAdapterFactory implements IAdapterFactory { 25 26 private static Class [] PROPERTIES= new Class [] { 27 IJavaElement.class 28 }; 29 30 public Class [] getAdapterList() { 31 return PROPERTIES; 32 } 33 34 public Object getAdapter(Object element, Class key) { 35 if (IJavaElement.class.equals(key)) { 36 37 if (element instanceof IFile) { 39 IJavaElement je= JavaPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(new FileEditorInput((IFile)element)); 40 if (je != null) 41 return je; 42 } 43 44 return JavaCore.create((IResource)element); 45 } 46 return null; 47 } 48 } 49 | Popular Tags |