Eclipse Platform
2.0

org.eclipse.ui
Interface IEditorPart

All Superinterfaces:
IAdaptable, IWorkbenchPart
All Known Subinterfaces:
IReusableEditor, ITextEditor
All Known Implementing Classes:
AbstractTextEditor, EditorPart

public interface IEditorPart
extends IWorkbenchPart

An editor is a visual component within a workbench page. It is typically used to edit or browse a document or input object. The input is identified using an IEditorInput. Modifications made in an editor part follow an open-save-close lifecycle model (in contrast to a view part, where modifications are saved to the workbench immediately).

An editor is document or input-centric. Each editor has an input, and only one editor can exist for each editor input within a page. This policy has been designed to simplify part management.

An editor should be used in place of a view whenever more than one instance of a document type can exist.

This interface may be implemented directly. For convenience, a base implementation is defined in EditorPart.

An editor part is added to the workbench in two stages:

  1. An editor extension is contributed to the workbench registry. This extension defines the extension id, extension class, and the file extensions which are supported by the editor.
  2. An editor part based upon the extension is created and added to the workbench when the user opens a file with one of the supported file extensions (or some other suitable form of editor input).

All editor parts implement the IAdaptable interface; extensions are managed by the platform's adapter manager.

See Also:
IPerspective#openEditor, EditorPart

Field Summary
static int PROP_DIRTY
          The property id for isDirty.
static int PROP_INPUT
          The property id for getEditorInput.
 
Fields inherited from interface org.eclipse.ui.IWorkbenchPart
PROP_TITLE
 
Method Summary
 void doSave(IProgressMonitor monitor)
          Saves the contents of this editor.
 void doSaveAs()
          Saves the contents of this editor to another object.
 IEditorInput getEditorInput()
          Returns the input for this editor.
 IEditorSite getEditorSite()
          Returns the site for this editor.
 void gotoMarker(IMarker marker)
          Sets the cursor and selection state for this editor to the passage defined by the given marker.
 void init(IEditorSite site, IEditorInput input)
          Initializes this editor with the given editor site and input.
 boolean isDirty()
          Returns whether the contents of this editor have changed since the last save operation.
 boolean isSaveAsAllowed()
          Returns whether the "save as" operation is supported by this editor.
 boolean isSaveOnCloseNeeded()
          Returns whether the contents of this editor should be saved when the editor is closed.
 
Methods inherited from interface org.eclipse.ui.IWorkbenchPart
addPropertyListener, createPartControl, dispose, getSite, getTitle, getTitleImage, getTitleToolTip, removePropertyListener, setFocus
 
Methods inherited from interface org.eclipse.core.runtime.IAdaptable
getAdapter
 

Field Detail

PROP_DIRTY

public static final int PROP_DIRTY
The property id for isDirty.

See Also:
Constant Field Values

PROP_INPUT

public static final int PROP_INPUT
The property id for getEditorInput.

See Also:
Constant Field Values
Method Detail

doSave

public void doSave(IProgressMonitor monitor)
Saves the contents of this editor.

If the save is successful, the editor should fire a property changed event reflecting the new dirty state (PROP_SAVE_NEEDED property).

If the save is cancelled through user action, or for any other reason, the editor should invoke setCancelled on the monitor to inform the caller.

This method is long-running; progress and cancellation are provided by the given progress monitor.

Parameters:
monitor - the progress monitor

doSaveAs

public void doSaveAs()
Saves the contents of this editor to another object.

Implementors are expected to open a "save as" dialog where the user will be able to select a new name for the contents. After the selection is made, the contents should be saved to that new name. During this operation a ProgressMonitorDialog should be used to indicate progress.

If the save is successful, the editor fires a property changed event reflecting the new dirty state (PROP_SAVE_NEEDED property).


getEditorInput

public IEditorInput getEditorInput()
Returns the input for this editor. If this value changes the part must fire a property listener event with PROP_INPUT.

Returns:
the editor input

getEditorSite

public IEditorSite getEditorSite()
Returns the site for this editor. The method is equivalent to (IEditorSite) getSite().

Returns:
the editor site

gotoMarker

public void gotoMarker(IMarker marker)
Sets the cursor and selection state for this editor to the passage defined by the given marker.

Parameters:
marker - the marker

init

public void init(IEditorSite site,
                 IEditorInput input)
          throws PartInitException
Initializes this editor with the given editor site and input.

This method is automatically called shortly after part construction; it marks the start of the part's lifecycle. The IWorkbenchPart.dispose method will be called automically at the end of the lifecycle. Clients must not call this method.

Implementors of this method must examine the editor input object type to determine if it is understood. If not, the implementor must throw a PartInitException

Parameters:
site - the editor site
input - the editor input
Throws:
PartInitException - if this editor was not initialized successfully

isDirty

public boolean isDirty()
Returns whether the contents of this editor have changed since the last save operation. If this value changes the part must fire a property listener event with PROP_DIRTY.

Returns:
true if the contents have been modified and need saving, and false if they have not changed since the last save

isSaveAsAllowed

public boolean isSaveAsAllowed()
Returns whether the "save as" operation is supported by this editor.

Returns:
true if "save as" is supported, and false if "save as" is not supported

isSaveOnCloseNeeded

public boolean isSaveOnCloseNeeded()
Returns whether the contents of this editor should be saved when the editor is closed.

Returns:
true if the contents of the editor should be saved on close, and false if the contents are expendable

Eclipse Platform
2.0

Copyright (c) IBM Corp. and others 2000, 2002. All Rights Reserved.