1 11 12 package org.eclipse.jdt.internal.ui.javaeditor; 13 14 15 import org.eclipse.core.runtime.IPath; 16 17 import org.eclipse.core.resources.IStorage; 18 19 import org.eclipse.jface.resource.ImageDescriptor; 20 21 import org.eclipse.ui.IEditorRegistry; 22 import org.eclipse.ui.IPersistableElement; 23 import org.eclipse.ui.IStorageEditorInput; 24 import org.eclipse.ui.PlatformUI; 25 26 import org.eclipse.jdt.core.IJarEntryResource; 27 import org.eclipse.jdt.core.IPackageFragmentRoot; 28 29 30 33 public class JarEntryEditorInput implements IStorageEditorInput { 34 35 private IStorage fJarEntryFile; 36 37 public JarEntryEditorInput(IStorage jarEntryFile) { 38 fJarEntryFile= jarEntryFile; 39 } 40 41 43 public boolean equals(Object obj) { 44 if (this == obj) 45 return true; 46 if (!(obj instanceof JarEntryEditorInput)) 47 return false; 48 JarEntryEditorInput other= (JarEntryEditorInput) obj; 49 return fJarEntryFile.equals(other.fJarEntryFile); 50 } 51 52 55 public IPersistableElement getPersistable() { 56 return null; 57 } 58 59 62 public String getName() { 63 return fJarEntryFile.getName(); 64 } 65 66 69 public String getContentType() { 70 return fJarEntryFile.getFullPath().getFileExtension(); 71 } 72 73 76 public String getToolTipText() { 77 if (fJarEntryFile instanceof IJarEntryResource) { 78 IJarEntryResource jarEntry= (IJarEntryResource)fJarEntryFile; 79 IPackageFragmentRoot root= jarEntry.getPackageFragmentRoot(); 80 IPath fullPath= root.getPath().append(fJarEntryFile.getFullPath()); 81 if (root.isExternal()) 82 return fullPath.toOSString(); 83 return fullPath.toString(); 84 85 } 86 87 IPath fullPath= fJarEntryFile.getFullPath(); 88 if (fullPath == null) 89 return null; 90 return fullPath.toString(); 91 } 92 93 96 public ImageDescriptor getImageDescriptor() { 97 IEditorRegistry registry= PlatformUI.getWorkbench().getEditorRegistry(); 98 return registry.getImageDescriptor(getContentType()); 99 } 100 101 104 public boolean exists() { 105 return true; 107 } 108 109 112 public Object getAdapter(Class adapter) { 113 return null; 114 } 115 116 119 public IStorage getStorage() { 120 return fJarEntryFile; 121 } 122 } 123 124 125 | Popular Tags |