Class EditorPart
- All Implemented Interfaces:
- IAdaptable,- IExecutableExtension,- IEditorPart,- ISaveablePart,- IWorkbenchPart,- IWorkbenchPart2,- IWorkbenchPart3,- IWorkbenchPartOrientation
- Direct Known Subclasses:
- AbstractMultiEditor,- AbstractTextEditor,- CommonSourceNotFoundEditor,- CompareEditor,- ErrorEditorPart,- FormPage,- MultiPageEditorPart
 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 site
- IWorkbenchPart.createPartControl- to create the editor's controls
- IWorkbenchPart.setFocus- to accept focus
- IEditorPart.isDirty- to decide whether a significant change has occurred
- IEditorPart.doSave- to save contents of editor
- IEditorPart.doSaveAs- to save contents of editor
- IEditorPart.isSaveAsAllowed- to control Save As
Subclasses may extend or reimplement the following methods as required:
- IExecutableExtension.setInitializationData- extend to provide additional initialization when editor extension is instantiated
- IWorkbenchPart.dispose- extend to provide additional cleanup
- IAdaptable.getAdapter- reimplement to make the editor adaptable
- 
Field SummaryFields inherited from interface org.eclipse.ui.IEditorPartPROP_DIRTY, PROP_INPUTFields inherited from interface org.eclipse.ui.IWorkbenchPartPROP_TITLE
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionprotected final voidcheckSite(IWorkbenchPartSite site) Checks that the given site is valid for this type of part.abstract voiddoSave(IProgressMonitor monitor) Saves the contents of this part.abstract voiddoSaveAs()Saves the contents of this part to another object.Returns the input for this editor.Returns the site for this editor.Returns the title tool tip text of this workbench part.abstract voidinit(IEditorSite site, IEditorInput input) Initializes this editor with the given editor site and input.abstract booleanisDirty()Returns whether the contents of this part have changed since the last save operation.abstract booleanReturns whether the "Save As" operation is supported by this part.booleanReturns whether the contents of this part should be saved when the part is closed.protected voidsetContentDescription(String description) Sets the content description for this part.voidsetInitializationData(IConfigurationElement cfig, String propertyName, Object data) This method is called by the implementation of the methodIConfigurationElement.createExecutableExtensionon a newly constructed extension, passing it its relevant configuration information.protected voidsetInput(IEditorInput input) Sets the input to this editor.protected voidsetInputWithNotify(IEditorInput input) Sets the input to this editor and fires a PROP_INPUT property change if the input has changed.protected voidsetPartName(String partName) Sets the name of this part.Methods inherited from class org.eclipse.ui.part.WorkbenchPartaddPartPropertyListener, addPropertyListener, createPartControl, dispose, firePartPropertyChanged, firePropertyChange, getAdapter, getConfigurationElement, getContentDescription, getDefaultImage, getOrientation, getPartName, getPartProperties, getPartProperty, getSite, getTitle, getTitleImage, removePartPropertyListener, removePropertyListener, setFocus, setPartProperty, setSite, setTitle, setTitleImage, setTitleToolTip, showBusyMethods inherited from class org.eclipse.core.commands.common.EventManageraddListenerObject, clearListeners, getListeners, isListenerAttached, removeListenerObjectMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.eclipse.core.runtime.IAdaptablegetAdapterMethods inherited from interface org.eclipse.ui.IWorkbenchPartaddPropertyListener, createPartControl, dispose, getSite, getTitle, getTitleImage, removePropertyListener, setFocus
- 
Constructor Details- 
EditorPartprotected EditorPart()Creates a new workbench editor.
 
- 
- 
Method Details- 
doSaveDescription copied from interface:ISaveablePartSaves the contents of this part.If the save is successful, the part should fire a property changed event reflecting the new dirty state ( PROP_DIRTYproperty).If the save is cancelled through user action, or for any other reason, the part should invoke setCancelledon theIProgressMonitorto inform the caller.This method is long-running; progress and cancellation are provided by the given progress monitor. - Specified by:
- doSavein interface- ISaveablePart
- Parameters:
- monitor- the progress monitor
 
- 
doSaveAspublic abstract void doSaveAs()Description copied from interface:ISaveablePartSaves the contents of this part 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 IProgressMonitorshould be used to indicate progress.If the save is successful, the part fires a property changed event reflecting the new dirty state ( PROP_DIRTYproperty).- Specified by:
- doSaveAsin interface- ISaveablePart
 
- 
getEditorInputDescription copied from interface:IEditorPartReturns the input for this editor. If this value changes the part must fire a property listener event withPROP_INPUT.- Specified by:
- getEditorInputin interface- IEditorPart
- Returns:
- the editor input
 
- 
getEditorSiteDescription copied from interface:IEditorPartReturns the site for this editor. This method is equivalent to(IEditorSite) getSite().The site can be nullwhile the editor is being initialized. After the initialization is complete, this value must be non-nullfor the remainder of the editor's life cycle.- Specified by:
- getEditorSitein interface- IEditorPart
- Returns:
- the editor site; this value may be nullif the editor has not yet been initialized
 
- 
getTitleToolTipDescription copied from interface:IWorkbenchPartReturns the title tool tip text of this workbench part. An empty string result indicates no tool tip. If this value changes the part must fire a property listener event withPROP_TITLE.The tool tip text is used to populate the title bar of this part's visual container. - Specified by:
- getTitleToolTipin interface- IWorkbenchPart
- Overrides:
- getTitleToolTipin class- WorkbenchPart
- Returns:
- the workbench part title tool tip (not null)
 
- 
initDescription copied from interface:IEditorPartInitializes this editor with the given editor site and input.This method is automatically called shortly after the part is instantiated. It marks the start of the part's lifecycle. The IWorkbenchPart.disposemethod 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- Specified by:
- initin interface- IEditorPart
- Parameters:
- site- the editor site
- input- the editor input
- Throws:
- PartInitException- if this editor was not initialized successfully
 
- 
isDirtypublic abstract boolean isDirty()Description copied from interface:ISaveablePartReturns whether the contents of this part have changed since the last save operation. If this value changes the part must fire a property listener event withPROP_DIRTY.Note: this method is called often on a part open or part activation switch, for example by actions to determine their enabled status. - Specified by:
- isDirtyin interface- ISaveablePart
- Returns:
- trueif the contents have been modified and need saving, and- falseif they have not changed since the last save
 
- 
isSaveAsAllowedpublic abstract boolean isSaveAsAllowed()Description copied from interface:ISaveablePartReturns whether the "Save As" operation is supported by this part.- Specified by:
- isSaveAsAllowedin interface- ISaveablePart
- Returns:
- trueif "Save As" is supported, and- falseif not supported
 
- 
isSaveOnCloseNeededpublic boolean isSaveOnCloseNeeded()Description copied from interface:ISaveablePartReturns whether the contents of this part should be saved when the part is closed.- Specified by:
- isSaveOnCloseNeededin interface- ISaveablePart
- Returns:
- trueif the contents of the part should be saved on close, and- falseif the contents are expendable
 
- 
setInputSets the input to this editor. This method simply updates the internal member variable.Unlike most of the other set methods on this class, this method does not fire a property change. Clients that call this method from a subclass must ensure that they fire an IWorkbenchPartConstants.PROP_INPUT property change after calling this method but before leaving whatever public method they are in. Clients that expose this method as public API must fire the property change within their implementation of setInput. Note that firing a property change may cause listeners to immediately reach back and call methods on this editor. Care should be taken not to fire the property change until the editor has fully updated its internal state to reflect the new input. - Parameters:
- input- the editor input
- See Also:
 
- 
setInputWithNotifySets the input to this editor and fires a PROP_INPUT property change if the input has changed. This is the convenience method implementation.Note that firing a property change may cause other objects to reach back and invoke methods on the editor. Care should be taken not to call this method until the editor has fully updated its internal state to reflect the new input. - Parameters:
- input- the editor input
- Since:
- 3.2
 
- 
setContentDescriptionDescription copied from class:WorkbenchPartSets the content description for this part. The content description is typically a short string describing the current contents of the part. Setting this to the empty string will cause a default content description to be used. Clients should call this method instead of overriding getContentDescription(). For views, the content description is shown (by default) in a line near the top of the view. For editors, the content description is shown beside the part name when showing a list of editors. If the editor is open on a file, this typically contains the path to the input file, without the filename or trailing slash.This may overwrite a value that was previously set in setTitle - Overrides:
- setContentDescriptionin class- WorkbenchPart
- Parameters:
- description- the content description
 
- 
setPartNameDescription copied from class:WorkbenchPartSets the name of this part. The name will be shown in the tab area for the part. Clients should call this method instead of overriding getPartName. Setting this to the empty string will cause a default part name to be used.setPartName and setContentDescription are intended to replace setTitle. This may change a value that was previously set using setTitle. - Overrides:
- setPartNamein class- WorkbenchPart
- Parameters:
- partName- the part name, as it should be displayed in tabs.
 
- 
setInitializationDataDescription copied from class:WorkbenchPartThis method is called by the implementation of the methodIConfigurationElement.createExecutableExtensionon a newly constructed extension, passing it its relevant configuration information. Most executable extensions only make use of the first two call arguments.Regular executable extensions specify their Java implementation class name as an attribute of the configuration element for the extension. For example <action run="com.example.BaseAction"/>In the above example, this method would be called with a reference to the <action>element (first argument), and"run"as the name of the attribute that defined this executable extension (second argument).The last parameter is for the specific use of extension adapters and is typically not used by regular executable extensions. There are two supported ways of associating additional adapter-specific data with the configuration in a way that is transparent to the extension point implementor: (1) by specifying adapter data as part of the implementation class attribute value. The Java class name can be followed by a ":" separator, followed by any adapter data in string form. For example, if the extension point specifies an attribute "run"to contain the name of the extension implementation, an adapter can be configured as<action run="com.example.ExternalAdapter:./cmds/util.exe -opt 3"/>(2) by converting the attribute used to specify the executable extension to a child element of the original configuration element, and specifying the adapter data in the form of xml markup. Using this form, the example above would become <action> <run class="com.xyz.ExternalAdapter"> <parameter name="exec" value="./cmds/util.exe"/> <parameter name="opt" value="3"/> </run> </action>Form (2) will typically only be used for extension points that anticipate the majority of extensions configured into it will in fact be in the form of adapters. In either case, the specified adapter class is instantiated using its 0-argument public constructor. The adapter data is passed as the last argument of this method. The data argument is defined as Object. It can have the following values: - null, if no adapter data was supplied
- in case (1), the initialization data string is passed as a
 String
- in case (2), the initialization data is passed as a
 Hashtablecontaining the actual parameter names and values (bothStrings)
 WorkbenchPartimplementation of thisIExecutableExtensionrecords the configuration element in and internal state variable (accessible viagetConfigElement). It also loads the title image, if one is specified in the configuration element. Subclasses may extend. Should not be called by clients. It is called by the core plugin when creating this executable extension.- Specified by:
- setInitializationDatain interface- IExecutableExtension
- Overrides:
- setInitializationDatain class- WorkbenchPart
- Parameters:
- cfig- the configuration element used to trigger this execution. It can be queried by the executable extension for specific configuration properties
- propertyName- the name of an attribute of the configuration element used on the- createExecutableExtension(String)call. This argument can be used in the cases where a single configuration element is used to define multiple executable extensions.
- data- adapter data in the form of a- String, a- Hashtable, or- null.
- See Also:
 
- 
checkSiteChecks that the given site is valid for this type of part. The site for an editor must be anIEditorSite.- Overrides:
- checkSitein class- WorkbenchPart
- Parameters:
- site- the site to check
- Since:
- 3.1
 
 
-