Class FileEditorInput

java.lang.Object
org.eclipse.core.runtime.PlatformObject
org.eclipse.ui.part.FileEditorInput
All Implemented Interfaces:
IAdaptable, IEditorInput, IFileEditorInput, IPathEditorInput, IPersistable, IPersistableElement, IStorageEditorInput, IURIEditorInput
Direct Known Subclasses:
FileInPlaceEditorInput

public class FileEditorInput extends PlatformObject implements IFileEditorInput, IPathEditorInput, IURIEditorInput, IPersistableElement
Adapter for making a file resource a suitable input for an editor.

This class may be instantiated; it is not intended to be subclassed.

Restriction:
This class is not intended to be subclassed by clients.
  • Constructor Details

    • FileEditorInput

      public FileEditorInput(IFile file)
      Creates an editor input based of the given file resource.
      Parameters:
      file - the file resource
  • Method Details

    • isLocalFile

      public static boolean isLocalFile(IFile file)
      Return whether or not file is local. Only IFiles with a local value should call IPathEditorInput.getPath()
      Parameters:
      file - the file to check; not null
      Returns:
      boolean true if the file has a local implementation.
      Since:
      3.4
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • exists

      public boolean exists()
      Description copied from interface: IEditorInput
      Returns whether the editor input exists.

      This method is primarily used to determine if an editor input should appear in the "File Most Recently Used" menu. An editor input will appear in the list until the return value of exists becomes false or it drops off the bottom of the list.

      Specified by:
      exists in interface IEditorInput
      Returns:
      true if the editor input exists; false otherwise
    • getFactoryId

      public String getFactoryId()
      Description copied from interface: IPersistableElement
      Returns the id of the element factory which should be used to re-create this object.

      Factory ids are declared in extensions to the standard extension point "org.eclipse.ui.elementFactories".

      Specified by:
      getFactoryId in interface IPersistableElement
      Returns:
      the element factory id
      See Also:
    • getFile

      public IFile getFile()
      Description copied from interface: IFileEditorInput
      Returns the file resource underlying this editor input.

      The IFile returned can be a handle to a resource that does not exist in the workspace. As such, an editor should provide appropriate feedback to the user instead of simply failing during input validation. For example, a text editor could open in read-only mode with a message in the text area to inform the user that the file does not exist.

      Specified by:
      getFile in interface IFileEditorInput
      Returns:
      the underlying file
    • getImageDescriptor

      public ImageDescriptor getImageDescriptor()
      Description copied from interface: IEditorInput
      Returns the image descriptor for this input.

      Note: although a null return value has never been permitted from this method, there are many known buggy implementations that return null. Clients that need the image for an editor are advised to use IWorkbenchPart.getImage() instead of IEditorInput.getImageDescriptor(), or to recover from a null return value in a manner that records the ID of the problematic editor input. Implementors that have been returning null from this method should pick some other default return value (such as ImageDescriptor.getMissingImageDescriptor()).

      Specified by:
      getImageDescriptor in interface IEditorInput
      Returns:
      the image descriptor for this input; may be null if there is no image.
    • getName

      public String getName()
      Description copied from interface: IEditorInput
      Returns the name of this editor input for display purposes.

      For instance, when the input is from a file, the return value would ordinarily be just the file name.

      Specified by:
      getName in interface IEditorInput
      Returns:
      the name string; never null;
    • getPersistable

      public IPersistableElement getPersistable()
      Description copied from interface: IEditorInput
      Returns an object that can be used to save the state of this editor input.
      Specified by:
      getPersistable in interface IEditorInput
      Returns:
      the persistable element, or null if this editor input cannot be persisted
    • getStorage

      public IStorage getStorage()
      Description copied from interface: IStorageEditorInput
      Returns the underlying IStorage object.
      Specified by:
      getStorage in interface IStorageEditorInput
      Returns:
      an IStorage object.
    • getToolTipText

      public String getToolTipText()
      Description copied from interface: IEditorInput
      Returns the tool tip text for this editor input. This text is used to differentiate between two input with the same name. For instance, MyClass.java in folder X and MyClass.java in folder Y. The format of the text varies between input types.
      Specified by:
      getToolTipText in interface IEditorInput
      Returns:
      the tool tip text; never null.
    • saveState

      public void saveState(IMemento memento)
      Description copied from interface: IPersistable
      Saves the state of the object in the given memento.
      Specified by:
      saveState in interface IPersistable
      Parameters:
      memento - the storage area for object's state
    • getURI

      public URI getURI()
      Description copied from interface: IURIEditorInput
      Returns the URI of the file underlying this editor input.
      Specified by:
      getURI in interface IURIEditorInput
      Returns:
      URI
    • getPath

      public IPath getPath()
      Description copied from interface: IPathEditorInput
      Returns the local file system path of the file underlying this editor input.
      Specified by:
      getPath in interface IPathEditorInput
      Returns:
      a local file system path
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getAdapter

      public <T> T getAdapter(Class<T> adapterType)
      Description copied from class: PlatformObject
      Returns an object which is an instance of the given class associated with this object. Returns null if no such object can be found.

      This implementation of the method declared by IAdaptable passes the request along to the platform's adapter manager; roughly Platform.getAdapterManager().getAdapter(this, adapter). Subclasses may override this method (however, if they do so, they should invoke the method on their superclass to ensure that the Platform's adapter manager is consulted).

      Specified by:
      getAdapter in interface IAdaptable
      Overrides:
      getAdapter in class PlatformObject
      Type Parameters:
      T - the class type
      Parameters:
      adapterType - the class to adapt to
      Returns:
      the adapted object or null
      See Also: