|
Eclipse Platform Release 3.3 |
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.core.commands.common.EventManager
org.eclipse.ui.part.WorkbenchPart
org.eclipse.ui.part.EditorPart
org.eclipse.ui.part.MultiPageEditorPart
A multi-page editor is an editor with multiple pages, each of which may contain an editor or an arbitrary SWT control.
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.
MultiPageEditorActionBarContributor
Field Summary |
---|
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 |
MultiPageEditorPart()
Creates an empty multi-page editor with no pages. |
Method Summary | |
---|---|
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.
|
IEditorPart[] |
findEditors(IEditorInput input)
Find the editors contained in this multi-page editor whose editor input match the provided input. |
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. |
void |
setActiveEditor(IEditorPart editorPart)
Set the active page of this multi-page editor to the page that contains the given editor part. |
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. |
Methods inherited from class org.eclipse.ui.part.EditorPart |
---|
checkSite, doSave, doSaveAs, getEditorInput, getEditorSite, getTitleToolTip, isSaveAsAllowed, isSaveOnCloseNeeded, setContentDescription, setInitializationData, setInput, setInputWithNotify, setPartName |
Methods inherited from class org.eclipse.ui.part.WorkbenchPart |
---|
addPartPropertyListener, addPropertyListener, firePartPropertyChanged, firePropertyChange, getConfigurationElement, getContentDescription, getDefaultImage, getOrientation, getPartName, getPartProperties, getPartProperty, getSite, getTitle, getTitleImage, removePartPropertyListener, removePropertyListener, setPartProperty, setSite, setTitle, setTitleImage, setTitleToolTip, showBusy |
Methods inherited from class org.eclipse.core.commands.common.EventManager |
---|
addListenerObject, clearListeners, getListeners, isListenerAttached, removeListenerObject |
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, getSite, getTitle, getTitleImage, removePropertyListener |
Constructor Detail |
protected MultiPageEditorPart()
Method Detail |
public int addPage(Control control)
null
, allowing it
to be created and set later using setControl
.
control
- the control, or null
setControl(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 null
setControl(int, Control)
public int addPage(IEditorPart editor, IEditorInput input) throws PartInitException
editor
- the nested editorinput
- the input for the nested editor
PartInitException
- if a new page could not be createdthe handler for
property change events from the nested editor
public 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 editor
PartInitException
- if a new page could not be createdthe handler for
property change events from the nested editor
protected 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 IWorkbenchPart
createPartControl
in class WorkbenchPart
parent
- 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 editor
public void dispose()
MultiPageEditorPart
implementation of this
IWorkbenchPart
method disposes all nested editors.
Subclasses may extend.
dispose
in interface IWorkbenchPart
dispose
in class WorkbenchPart
protected 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 page
null
if
none has been setprotected IEditorPart getEditor(int pageIndex)
pageIndex
- the index of the page
null
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 page
null
if noneprotected String getPageText(int pageIndex)
pageIndex
- the index of the page
protected 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 IEditorPart
init
in class EditorPart
site
- 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 ISaveablePart
isDirty
in class EditorPart
true
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 IWorkbenchPart
setFocus
in class WorkbenchPart
protected 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 null
protected void setPageText(int pageIndex, String text)
pageIndex
- the index of the pagetext
- the text labelpublic Object getAdapter(Class adapter)
getAdapter
in interface IAdaptable
getAdapter
in class WorkbenchPart
WorkbenchPart.getAdapter(java.lang.Class)
public final IEditorPart[] findEditors(IEditorInput input)
input
- the editor input
public final void setActiveEditor(IEditorPart editorPart)
editorPart
- the editor part
|
Eclipse Platform Release 3.3 |
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Guidelines for using Eclipse APIs.
Copyright (c) IBM Corp. and others 2000, 2007. All rights reserved.