1 11 package org.eclipse.ui.internal.editors.text; 12 13 import java.net.URI ; 14 15 import org.eclipse.core.filesystem.URIUtil; 16 17 import org.eclipse.core.runtime.IAdapterFactory; 18 import org.eclipse.core.runtime.IPath; 19 20 import org.eclipse.ui.editors.text.ILocationProvider; 21 import org.eclipse.ui.editors.text.ILocationProviderExtension; 22 23 import org.eclipse.ui.IURIEditorInput; 24 25 26 31 public class IURIEditorInputAdapterFactory implements IAdapterFactory { 32 33 private static class LocationProvider implements ILocationProvider, ILocationProviderExtension { 34 37 public IPath getPath(Object element) { 38 URI uri= getURI(element); 39 if (uri != null) 40 return URIUtil.toPath(uri); 41 return null; 42 } 43 44 47 public URI getURI(Object element) { 48 if (element instanceof IURIEditorInput) { 49 IURIEditorInput input= (IURIEditorInput)element; 50 return input.getURI(); 51 } 52 return null; 53 } 54 } 55 56 57 58 private static final Class [] ADAPTER_LIST= new Class [] { ILocationProvider.class }; 59 60 61 private ILocationProvider fLocationProvider= new LocationProvider(); 62 63 66 public Object getAdapter(Object adaptableObject, Class adapterType) { 67 if (ILocationProvider.class.equals(adapterType)) { 68 if (adaptableObject instanceof IURIEditorInput) 69 return fLocationProvider; 70 } 71 return null; 72 } 73 74 77 public Class [] getAdapterList() { 78 return ADAPTER_LIST; 79 } 80 } 81 | Popular Tags |