1 8 package com.mountainminds.eclemma.internal.ui.wizards; 9 10 import java.io.File ; 11 12 import org.eclipse.core.runtime.IPath; 13 import org.eclipse.core.runtime.Path; 14 import org.eclipse.core.runtime.PlatformObject; 15 import org.eclipse.jface.resource.ImageDescriptor; 16 import org.eclipse.ui.IPathEditorInput; 17 import org.eclipse.ui.IPersistableElement; 18 import org.eclipse.ui.editors.text.ILocationProvider; 19 20 26 public class ExternalFileEditorInput extends PlatformObject implements 27 IPathEditorInput, ILocationProvider { 28 29 private File file; 30 31 public ExternalFileEditorInput(File file) { 32 this.file = file; 33 } 34 35 public boolean equals(Object o) { 36 if (o instanceof IPathEditorInput) { 37 IPathEditorInput input = (IPathEditorInput) o; 38 return getPath().equals(input.getPath()); 39 } 40 return false; 41 } 42 43 public int hashCode() { 44 return file.hashCode(); 45 } 46 47 49 public boolean exists() { 50 return file.exists(); 51 } 52 53 public ImageDescriptor getImageDescriptor() { 54 return null; 55 } 56 57 public String getName() { 58 return file.getName(); 59 } 60 61 public IPersistableElement getPersistable() { 62 return null; 63 } 64 65 public String getToolTipText() { 66 return file.getAbsolutePath(); 67 } 68 69 71 public IPath getPath() { 72 return Path.fromOSString(file.getAbsolutePath()); 73 } 74 75 77 public IPath getPath(Object element) { 78 if (element instanceof ExternalFileEditorInput) { 79 return ((ExternalFileEditorInput) element).getPath(); 80 } else { 81 return null; 82 } 83 } 84 85 } 86 | Popular Tags |