1 11 12 package org.eclipse.ui.internal.editors.text; 13 14 import org.eclipse.core.resources.IFile; 15 import org.eclipse.core.runtime.IAdapterFactory; 16 import org.eclipse.core.runtime.IPath; 17 18 import org.eclipse.ui.IFileEditorInput; 19 import org.eclipse.ui.editors.text.ILocationProvider; 20 21 24 public class FileEditorInputAdapterFactory implements IAdapterFactory { 25 26 private static class LocationProvider implements ILocationProvider { 27 30 public IPath getPath(Object element) { 31 if (element instanceof IFileEditorInput) { 32 IFileEditorInput input= (IFileEditorInput) element; 33 return input.getFile().getFullPath(); 34 } 35 return null; 36 } 37 } 38 39 40 private static final Class [] ADAPTER_LIST= new Class [] { ILocationProvider.class }; 41 42 43 private ILocationProvider fLocationProvider= new LocationProvider(); 44 45 48 public Object getAdapter(Object adaptableObject, Class adapterType) { 49 if (ILocationProvider.class.equals(adapterType)) { 50 if (adaptableObject instanceof IFile) 51 return fLocationProvider; 52 } 53 return null; 54 } 55 56 59 public Class [] getAdapterList() { 60 return ADAPTER_LIST; 61 } 62 } 63 | Popular Tags |