|
Eclipse Platform 2.0 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--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.
AbstractMultiPageEditorActionBarContributor
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. |
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. |
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. |
Methods inherited from class org.eclipse.ui.part.EditorPart |
doSave, doSaveAs, getEditorInput, getEditorSite, getTitleToolTip, gotoMarker, isSaveAsAllowed, isSaveOnCloseNeeded, setInput |
Methods inherited from class org.eclipse.ui.part.WorkbenchPart |
addPropertyListener, firePropertyChange, getAdapter, getConfigurationElement, getDefaultImage, getSite, getTitle, getTitleImage, removePropertyListener, 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, getSite, getTitle, getTitleImage, removePropertyListener |
Methods inherited from interface org.eclipse.core.runtime.IAdaptable |
getAdapter |
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, org.eclipse.swt.widgets.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
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 controlprotected 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 editor siteinput
- the editor input
PartInitException
- if this editor was not initialized successfullypublic 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 IEditorPart
isDirty
in class EditorPart
true
if the contents have been modified and need
saving, and false
if they have not changed since the last
saveprotected 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(org.eclipse.swt.widgets.Control)
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 label
|
Eclipse Platform 2.0 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |