public abstract class MultiPageEditorPart extends EditorPart
Subclasses must implement the following methods:
createPages - to create the required pages by calling one
of the addPage methodsIEditorPart.doSave - to save contents of editorIEditorPart.doSaveAs - to save contents of editorIEditorPart.isSaveAsAllowed - to enable Save AsIEditorPart.gotoMarker - to scroll to a marker
Multi-page editors have a single action bar contributor, which manages
contributions for all the pages. The contributor must be a subclass of
AbstractMultiPageEditorActionBarContributor. Note that since
any nested editors are created directly in code by callers of
addPage(IEditorPart,IEditorInput), nested editors do not have
their own contributors.
MultiPageEditorActionBarContributorPROP_DIRTY, PROP_INPUTPROP_TITLE| Modifier | Constructor and Description |
|---|---|
protected |
MultiPageEditorPart()
Creates an empty multi-page editor with no pages.
|
| Modifier and Type | Method and Description |
|---|---|
int |
addPage(Control control)
Creates and adds a new page containing the given control to this
multi-page editor.
|
int |
addPage(IEditorPart editor,
IEditorInput input)
Creates and adds a new page containing the given editor to this
multi-page editor.
|
void |
addPage(int index,
Control control)
Creates and adds a new page containing the given control to this
multi-page editor.
|
void |
addPage(int index,
IEditorPart editor,
IEditorInput input)
Creates and adds a new page containing the given editor to this
multi-page editor.
|
protected Composite |
createPageContainer(Composite parent)
Creates the parent control for the container returned by
getContainer(). |
protected abstract void |
createPages()
Creates the pages of this multi-page editor.
|
void |
createPartControl(Composite parent)
The
MultiPageEditor implementation of this
IWorkbenchPart method creates the control for the
multi-page editor by calling createContainer, then
createPages. |
protected IEditorSite |
createSite(IEditorPart editor)
Creates the site for the given nested editor.
|
void |
dispose()
The
MultiPageEditorPart implementation of this
IWorkbenchPart method disposes all nested editors. |
protected IEditorPart |
getActiveEditor()
Returns the active nested editor if there is one.
|
protected int |
getActivePage()
Returns the index of the currently active page, or -1 if there is no
active page.
|
Object |
getAdapter(Class adapter)
If there is an adapter registered against the subclass of
MultiPageEditorPart return that.
|
protected Composite |
getContainer()
Returns the composite control containing this multi-page editor's pages.
|
protected Control |
getControl(int pageIndex)
Returns the control for the given page index, or
null if
no control has been set for the page. |
protected IEditorPart |
getEditor(int pageIndex)
Returns the editor for the given page index.
|
protected int |
getPageCount()
Returns the number of pages in this multi-page editor.
|
protected Image |
getPageImage(int pageIndex)
Returns the image for the page with the given index, or
null
if no image has been set for the page. |
protected String |
getPageText(int pageIndex)
Returns the text label for the page with the given index.
|
protected void |
handlePropertyChange(int propertyId)
Handles a property change notification from a nested editor.
|
void |
init(IEditorSite site,
IEditorInput input)
The
MultiPageEditorPart implementation of this
IEditorPart method sets its site to the given site, its
input to the given input, and the site's selection provider to a
MultiPageSelectionProvider. |
boolean |
isDirty()
The
MultiPageEditorPart implementation of this
IEditorPart method returns whether the contents of any of
this multi-page editor's nested editors have changed since the last save. |
protected void |
pageChange(int newPageIndex)
Notifies this multi-page editor that the page with the given id has been
activated.
|
void |
removePage(int pageIndex)
Removes the page with the given index from this multi-page editor.
|
protected void |
setActivePage(int pageIndex)
Sets the currently active page.
|
protected void |
setControl(int pageIndex,
Control control)
Sets the control for the given page index.
|
void |
setFocus()
The
MultiPageEditor implementation of this
IWorkbenchPart method sets focus on the active nested
editor, if there is one. |
protected void |
setPageImage(int pageIndex,
Image image)
Sets the image for the page with the given index, or
null
to clear the image for the page. |
protected void |
setPageText(int pageIndex,
String text)
Sets the text label for the page with the given index.
|
checkSite, doSave, doSaveAs, getEditorInput, getEditorSite, getTitleToolTip, isSaveAsAllowed, isSaveOnCloseNeeded, setContentDescription, setInitializationData, setInput, setInputWithNotify, setPartNameaddPropertyListener, firePropertyChange, getConfigurationElement, getContentDescription, getDefaultImage, getOrientation, getPartName, getSite, getTitle, getTitleImage, removePropertyListener, setSite, setTitle, setTitleImage, setTitleToolTip, showBusyaddListenerObject, clearListeners, getListeners, isListenerAttached, removeListenerObjectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddPropertyListener, getSite, getTitle, getTitleImage, removePropertyListenerprotected MultiPageEditorPart()
public int addPage(Control control)
null, allowing it
to be created and set later using setControl.control - the control, or nullsetControl(int, Control)public void addPage(int index,
Control control)
null, allowing it to be created and set later using
setControl.index - the index at which to add the page (0-based)control - the control, or nullsetControl(int, Control)public int addPage(IEditorPart editor, IEditorInput input) throws PartInitException
editor - the nested editorinput - the input for the nested editorPartInitException - if a new page could not be createdthe handler for
property change events from the nested editorpublic void addPage(int index,
IEditorPart editor,
IEditorInput input)
throws PartInitException
index - the index at which to add the page (0-based)editor - the nested editorinput - the input for the nested editorPartInitException - if a new page could not be createdthe handler for
property change events from the nested editorprotected abstract void createPages()
Subclasses must implement this method.
public final void createPartControl(Composite parent)
MultiPageEditor implementation of this
IWorkbenchPart method creates the control for the
multi-page editor by calling createContainer, then
createPages. Subclasses should implement
createPages rather than overriding this method.createPartControl in interface IWorkbenchPartcreatePartControl in class WorkbenchPartparent - The parent in which the editor should be created; must not be
null.protected Composite createPageContainer(Composite parent)
getContainer().
Subclasses may extend and must call super implementation first.
parent - the parent for all of the editors contents.null.protected IEditorSite createSite(IEditorPart editor)
MultiPageEditorPart implementation of this method creates
an instance of MultiPageEditorSite. Subclasses may
reimplement to create more specialized sites.editor - the nested editorpublic void dispose()
MultiPageEditorPart implementation of this
IWorkbenchPart method disposes all nested editors.
Subclasses may extend.dispose in interface IWorkbenchPartdispose in class WorkbenchPartprotected IEditorPart getActiveEditor()
Subclasses should not override this method
null if noneprotected int getActivePage()
Subclasses should not override this method
protected Composite getContainer()
addPage(Control),
the passed control should be a child of this container.
Warning: Clients should not assume that the container is any particular subclass of Composite. The actual class used may change in order to improve the look and feel of multi-page editors. Any code making assumptions on the particular subclass would thus be broken.
Subclasses should not override this method
null if
createPartControl has not been called yetprotected Control getControl(int pageIndex)
null if
no control has been set for the page. The page index must be valid.
Subclasses should not override this method
pageIndex - the index of the pagenull if
none has been setprotected IEditorPart getEditor(int pageIndex)
pageIndex - the index of the pagenull if the
specified page was not created with
addPage(IEditorPart,IEditorInput)protected int getPageCount()
protected Image getPageImage(int pageIndex)
null
if no image has been set for the page. The page index must be valid.pageIndex - the index of the pagenull if noneprotected String getPageText(int pageIndex)
pageIndex - the index of the pageprotected void handlePropertyChange(int propertyId)
firePropertyChange with the same
property id. For example, if the dirty state of a nested editor changes
(property id IEditorPart.PROP_DIRTY), this method handles
it by firing a property change event for
IEditorPart.PROP_DIRTY to property listeners on this
multi-page editor.
Subclasses may extend or reimplement this method.
propertyId - the id of the property that changedpublic void init(IEditorSite site, IEditorInput input) throws PartInitException
MultiPageEditorPart implementation of this
IEditorPart method sets its site to the given site, its
input to the given input, and the site's selection provider to a
MultiPageSelectionProvider. Subclasses may extend this
method.init in interface IEditorPartinit in class EditorPartsite - The site for which this part is being created; must not be
null.input - The input on which this editor should be created; must not be
null.PartInitException - If the initialization of the part fails -- currently never.public boolean isDirty()
MultiPageEditorPart implementation of this
IEditorPart method returns whether the contents of any of
this multi-page editor's nested editors have changed since the last save.
Pages created with addPage(Control) are ignored.
Subclasses may extend or reimplement this method.
isDirty in interface ISaveablePartisDirty in class EditorParttrue if any of the nested editors are dirty;
false otherwise.protected void pageChange(int newPageIndex)
The MultiPageEditorPart implementation of this method sets
focus to the new page, and notifies the action bar contributor (if there
is one). This checks whether the action bar contributor is an instance of
MultiPageEditorActionBarContributor, and, if so, calls
setActivePage with the active nested editor. This also
fires a selection change event if required.
Subclasses may extend this method.
newPageIndex - the index of the activated pagepublic void removePage(int pageIndex)
pageIndex - the index of the pageaddPage(Control),
addPage(IEditorPart, IEditorInput)protected void setActivePage(int pageIndex)
pageIndex - the index of the page to be activated; the index must be validprotected void setControl(int pageIndex,
Control control)
pageIndex - the index of the pagecontrol - the control for the specified page, or null to
clear the controlpublic void setFocus()
MultiPageEditor implementation of this
IWorkbenchPart method sets focus on the active nested
editor, if there is one.
Subclasses may extend or reimplement.
setFocus in interface IWorkbenchPartsetFocus in class WorkbenchPartprotected void setPageImage(int pageIndex,
Image image)
null
to clear the image for the page. The page index must be valid.pageIndex - the index of the pageimage - the image, or nullprotected void setPageText(int pageIndex,
String text)
pageIndex - the index of the pagetext - the text labelpublic Object getAdapter(Class adapter)
getAdapter in interface IAdaptablegetAdapter in class WorkbenchPartadapter - the adapter class to look upnull if this object does not
have an adapter for the given classWorkbenchPart.getAdapter(java.lang.Class)Guidelines for using Eclipse APIs. Copyright (c) IBM Corp. and others 2000, 2006. All rights reserved.