1 11 12 package org.eclipse.jdt.internal.ui.javaeditor; 13 14 15 import org.eclipse.jface.resource.ImageDescriptor; 16 17 import org.eclipse.ui.IMemento; 18 import org.eclipse.ui.IPersistableElement; 19 20 import org.eclipse.jdt.core.IClassFile; 21 import org.eclipse.jdt.core.JavaModelException; 22 23 import org.eclipse.jdt.internal.ui.JavaPluginImages; 24 25 26 29 public class InternalClassFileEditorInput implements IClassFileEditorInput, IPersistableElement { 30 31 private IClassFile fClassFile; 32 33 public InternalClassFileEditorInput(IClassFile classFile) { 34 fClassFile= classFile; 35 } 36 37 40 public boolean equals(Object obj) { 41 if (this == obj) 42 return true; 43 if (!(obj instanceof InternalClassFileEditorInput)) 44 return false; 45 InternalClassFileEditorInput other= (InternalClassFileEditorInput) obj; 46 return fClassFile.equals(other.fClassFile); 47 } 48 49 52 public int hashCode() { 53 return fClassFile.hashCode(); 54 } 55 56 59 public IClassFile getClassFile() { 60 return fClassFile; 61 } 62 63 66 public IPersistableElement getPersistable() { 67 return this; 68 } 69 70 73 public String getName() { 74 return fClassFile.getElementName(); 75 } 76 77 80 public String getToolTipText() { 81 return fClassFile.getType().getFullyQualifiedName(); 82 } 83 84 87 public ImageDescriptor getImageDescriptor() { 88 try { 89 if (fClassFile.isClass()) 90 return JavaPluginImages.DESC_OBJS_CFILECLASS; 91 return JavaPluginImages.DESC_OBJS_CFILEINT; 92 } catch (JavaModelException e) { 93 } 95 return JavaPluginImages.DESC_OBJS_CFILE; 96 } 97 98 101 public boolean exists() { 102 return fClassFile.exists(); 103 } 104 105 108 public Object getAdapter(Class adapter) { 109 if (adapter == IClassFile.class) 110 return fClassFile; 111 return fClassFile.getAdapter(adapter); 112 } 113 114 117 public void saveState(IMemento memento) { 118 ClassFileEditorInputFactory.saveState(memento, this); 119 } 120 121 124 public String getFactoryId() { 125 return ClassFileEditorInputFactory.ID; 126 } 127 } 128 129 130 | Popular Tags |