package org.eparapher.rcp.editors; import org.eclipse.core.runtime.IPath; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.ui.IPathEditorInput; import org.eclipse.ui.IPersistableElement; import org.eparapher.rcp.tools.GUIIcons; public class FileEditorInput implements IPathEditorInput { private IPath fPath; /** * Creates an editor input based of the given file resource. * * @param path the file */ public FileEditorInput(IPath path) { if (path == null) { throw new IllegalArgumentException(); } this.fPath = path; } /* * @see java.lang.Object#hashCode() */ public int hashCode() { return fPath.hashCode(); } /* * @see java.lang.Object#equals(java.lang.Object) */ public boolean equals(Object obj) { if (this == obj) return true; if (!(obj instanceof FileEditorInput)) return false; FileEditorInput other = (FileEditorInput) obj; return fPath.equals(other.fPath); } /* * @see org.eclipse.ui.IEditorInput#exists() */ public boolean exists() { return fPath.toFile().exists(); } /* * @see org.eclipse.ui.IEditorInput#getImageDescriptor() */ public ImageDescriptor getImageDescriptor() { return ImageDescriptor.createFromImage(GUIIcons.FILE_ICON_TXT); } /* * @see org.eclipse.ui.IEditorInput#getName() */ public String getName() { return fPath.toString(); } /* * @see org.eclipse.ui.IEditorInput#getToolTipText() */ public String getToolTipText() { return fPath.makeRelative().toOSString(); } /* * @see org.eclipse.ui.IPathEditorInput#getPath() */ public IPath getPath() { return fPath; } public IPersistableElement getPersistable() { return null; } public Object getAdapter(Class adapter) { return null; } }