|
Eclipse Platform 2.1 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.eclipse.ui.part.WorkbenchPart | +--org.eclipse.ui.part.EditorPart
Abstract base implementation of all workbench editors.
This class should be subclassed by clients wishing to define new editors.
The name of the subclass should be given as the "class"
attribute in a editor
extension contributed to the workbench's
view extension point (named "org.eclipse.ui.editors"
).
For example, the plug-in's XML markup might contain:
<extension point="org.eclipse.ui.editors"> <editor id="com.example.myplugin.ed" name="My Editor" icon="./images/cedit.gif" extensions="foo" class="com.example.myplugin.MyFooEditor" contributorClass="com.example.myplugin.MyFooEditorContributor" /> </extension>where
com.example.myplugin.MyEditor
is the name of the
EditorPart
subclass.
Subclasses must implement the following methods:
IEditorPart.init
- to initialize editor when assigned its siteIWorkbenchPart.createPartControl
- to create the editor's controls IWorkbenchPart.setFocus
- to accept focusIEditorPart.isDirty
- to decide whether a significant change has
occurredIEditorPart.doSave
- to save contents of editorIEditorPart.doSaveAs
- to save contents of editorIEditorPart.isSaveAsAllowed
- to control Save AsIEditorPart.gotoMarker
- to make selections based on markersSubclasses may extend or reimplement the following methods as required:
IExecutableExtension.setInitializationData
- extend to provide additional
initialization when editor extension is instantiatedIWorkbenchPart.dispose
- extend to provide additional cleanupIAdaptable.getAdapter
- reimplement to make the editor
adaptable
Fields inherited from interface org.eclipse.ui.IEditorPart |
PROP_DIRTY, PROP_INPUT |
Fields inherited from interface org.eclipse.ui.IWorkbenchPart |
PROP_TITLE |
Constructor Summary | |
protected |
EditorPart()
Creates a new workbench editor. |
Method Summary | |
abstract void |
doSave(IProgressMonitor monitor)
Saves the contents of this part. |
abstract void |
doSaveAs()
Saves the contents of this part to another object. |
IEditorInput |
getEditorInput()
Returns the input for this editor. |
IEditorSite |
getEditorSite()
Returns the site for this editor. |
String |
getTitleToolTip()
Returns the title tool tip text of this workbench part. |
abstract void |
gotoMarker(IMarker marker)
Sets the cursor and selection state for this editor to the passage defined by the given marker. |
abstract void |
init(IEditorSite site,
IEditorInput input)
Initializes this editor with the given editor site and input. |
abstract boolean |
isDirty()
Returns whether the contents of this part have changed since the last save operation. |
abstract boolean |
isSaveAsAllowed()
Returns whether the "Save As" operation is supported by this part. |
boolean |
isSaveOnCloseNeeded()
Returns whether the contents of this part should be saved when the part is closed. |
protected void |
setInput(IEditorInput input)
Sets the input to this editor. |
Methods inherited from class org.eclipse.ui.part.WorkbenchPart |
addPropertyListener, createPartControl, dispose, firePropertyChange, getAdapter, getConfigurationElement, getDefaultImage, getSite, getTitle, getTitleImage, removePropertyListener, setFocus, setInitializationData, setSite, setTitle, setTitleImage, setTitleToolTip |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.eclipse.ui.IWorkbenchPart |
addPropertyListener, createPartControl, dispose, getSite, getTitle, getTitleImage, removePropertyListener, setFocus |
Methods inherited from interface org.eclipse.core.runtime.IAdaptable |
getAdapter |
Constructor Detail |
protected EditorPart()
Method Detail |
public abstract void doSave(IProgressMonitor monitor)
ISaveablePart
If the save is successful, the part should fire a property changed event
reflecting the new dirty state (PROP_DIRTY
property).
If the save is cancelled through user action, or for any other reason, the
part should invoke setCancelled
on the IProgressMonitor
to inform the caller.
This method is long-running; progress and cancellation are provided by the given progress monitor.
doSave
in interface ISaveablePart
org.eclipse.ui.ISaveablePart
monitor
- the progress monitorpublic abstract void doSaveAs()
ISaveablePart
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
IProgressMonitor
should be used to indicate progress.
If the save is successful, the part fires a property changed event
reflecting the new dirty state (PROP_DIRTY
property).
doSaveAs
in interface ISaveablePart
public IEditorInput getEditorInput()
IEditorPart
PROP_INPUT
.getEditorInput
in interface IEditorPart
org.eclipse.ui.IEditorPart
public IEditorSite getEditorSite()
IEditorPart
(IEditorSite) getSite()
.getEditorSite
in interface IEditorPart
org.eclipse.ui.IEditorPart
public String getTitleToolTip()
IWorkbenchPart
PROP_TITLE
.
The tool tip text is used to populate the title bar of this part's visual container.
getTitleToolTip
in interface IWorkbenchPart
getTitleToolTip
in class WorkbenchPart
org.eclipse.ui.IWorkbenchPart
public abstract void gotoMarker(IMarker marker)
IEditorPart
gotoMarker
in interface IEditorPart
org.eclipse.ui.IEditorPart
marker
- the markerpublic abstract void init(IEditorSite site, IEditorInput input) throws PartInitException
IEditorPart
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
init
in interface IEditorPart
org.eclipse.ui.IEditorPart
site
- the editor siteinput
- the editor inputPartInitException
- if this editor was not initialized successfullypublic abstract boolean isDirty()
ISaveablePart
PROP_DIRTY
.
isDirty
in interface ISaveablePart
org.eclipse.ui.ISaveablePart
true
if the contents have been modified and need
saving, and false
if they have not changed since the last
savepublic abstract boolean isSaveAsAllowed()
ISaveablePart
isSaveAsAllowed
in interface ISaveablePart
org.eclipse.ui.ISaveablePart
true
if "Save As" is supported, and false
if not supportedpublic boolean isSaveOnCloseNeeded()
ISaveablePart
isSaveOnCloseNeeded
in interface ISaveablePart
org.eclipse.ui.ISaveablePart
true
if the contents of the part should be saved on
close, and false
if the contents are expendableprotected void setInput(IEditorInput input)
input
- the editor input
|
Eclipse Platform 2.1 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |