1 11 package org.eclipse.ui.internal.ide; 12 13 import org.eclipse.core.filesystem.EFS; 14 import org.eclipse.core.filesystem.IFileStore; 15 import org.eclipse.core.filesystem.URIUtil; 16 17 import org.eclipse.core.runtime.CoreException; 18 import org.eclipse.core.runtime.IAdapterFactory; 19 import org.eclipse.core.runtime.IPath; 20 21 import org.eclipse.ui.IPathEditorInput; 22 import org.eclipse.ui.IURIEditorInput; 23 import org.eclipse.ui.ide.FileStoreEditorInput; 24 25 26 31 public class IURIEditorInputAdapterFactory implements IAdapterFactory { 32 33 private static class PathEditorInputAdapter extends FileStoreEditorInput implements IPathEditorInput { 34 35 40 public PathEditorInputAdapter(IFileStore fileStore) { 41 super(fileStore); 42 } 43 44 47 public IPath getPath() { 48 return URIUtil.toPath(getURI()); 49 } 50 } 51 52 53 54 private static final Class [] ADAPTER_LIST= new Class [] { IPathEditorInput.class }; 55 56 57 58 61 public Object getAdapter(Object adaptableObject, Class adapterType) { 62 if (IPathEditorInput.class.equals(adapterType)) { 63 if (adaptableObject instanceof IURIEditorInput) { 64 IFileStore fileStore; 65 try { 66 fileStore= EFS.getStore(((IURIEditorInput) adaptableObject).getURI()); 67 if (fileStore.getFileSystem() == EFS.getLocalFileSystem()) { 68 return new PathEditorInputAdapter(fileStore); 69 } 70 } catch (CoreException e) { 71 return null; 72 } 73 } 74 } 75 return null; 76 } 77 78 79 82 public Class [] getAdapterList() { 83 return ADAPTER_LIST; 84 } 85 } 86 | Popular Tags |