1 11 package org.eclipse.pde.internal.ui.editor; 12 13 14 import java.io.File ; 15 16 import org.eclipse.core.resources.IStorage; 17 import org.eclipse.jface.resource.ImageDescriptor; 18 import org.eclipse.ui.IEditorRegistry; 19 import org.eclipse.ui.IPersistableElement; 20 import org.eclipse.ui.IStorageEditorInput; 21 import org.eclipse.ui.PlatformUI; 22 23 24 27 public class JarEntryEditorInput implements IStorageEditorInput { 28 29 private IStorage fJarEntryFile; 30 31 public JarEntryEditorInput(IStorage jarEntryFile) { 32 fJarEntryFile= jarEntryFile; 33 } 34 35 37 public boolean equals(Object obj) { 38 if (this == obj) 39 return true; 40 if (!(obj instanceof JarEntryEditorInput)) 41 return false; 42 JarEntryEditorInput other= (JarEntryEditorInput) obj; 43 return fJarEntryFile.equals(other.fJarEntryFile); 44 } 45 46 49 public IPersistableElement getPersistable() { 50 return null; 51 } 52 53 56 public String getName() { 57 return fJarEntryFile.getName(); 58 } 59 60 63 public String getFullPath() { 64 return fJarEntryFile.getFullPath().toString(); 65 } 66 67 70 public String getContentType() { 71 return fJarEntryFile.getFullPath().getFileExtension(); 72 } 73 74 77 public String getToolTipText() { 78 File file = (File ) fJarEntryFile.getAdapter(File .class); 79 if (file != null) 80 return file.getAbsolutePath(); 81 return fJarEntryFile.getFullPath().toString(); 82 } 83 84 87 public ImageDescriptor getImageDescriptor() { 88 IEditorRegistry registry= PlatformUI.getWorkbench().getEditorRegistry(); 89 return registry.getImageDescriptor(fJarEntryFile.getFullPath().getFileExtension()); 90 } 91 92 95 public boolean exists() { 96 return true; 98 } 99 100 103 public Object getAdapter(Class adapter) { 104 if (adapter.equals(File .class)) 105 return fJarEntryFile.getAdapter(File .class); 106 return null; 107 } 108 109 112 public IStorage getStorage() { 113 return fJarEntryFile; 114 } 115 } 116 117 118 | Popular Tags |