public abstract class FormEditor extends MultiPageEditorPart
Pages are added 'lazily' i.e. adding a page reserves a tab for it but does not cause the page control to be created. Page control is created when an attempt is made to select the page in question. This allows editors with several tabs and complex pages to open quickly.
Subclasses should extend this class and implement addPages
method. One of the two addPage
methods should be called to
contribute pages to the editor. One adds complete (standalone) editors as
nested tabs. These editors will be created right away and will be hooked so
that key bindings, selection service etc. is compatible with the one for the
standalone case. The other method adds classes that implement
IFormPage
interface. These pages will be created lazily and
they will share the common key binding and selection service. Since 3.1,
FormEditor is a page change provider. It allows listeners to attach to it and
get notified when pages are changed. This new API in JFace allows dynamic
help to update on page changes.
Modifier and Type | Field and Description |
---|---|
protected Vector |
pages
An array of pages currently in the editor.
|
PAGE_CONTAINER_SITE
PROP_DIRTY, PROP_INPUT
PROP_TITLE
Constructor and Description |
---|
FormEditor()
The constructor.
|
Modifier and Type | Method and Description |
---|---|
int |
addPage(Control control)
Adds a simple SWT control as a page.
|
int |
addPage(IEditorPart editor,
IEditorInput input)
Adds a complete editor part to the multi-page editor.
|
int |
addPage(IFormPage page)
Adds the form page to this editor.
|
void |
addPage(int index,
Control control)
Adds a simple SWT control as a page.
|
void |
addPage(int index,
IEditorPart editor,
IEditorInput input)
Adds a complete editor part to the multi-page editor at the specified
position.
|
void |
addPage(int index,
IFormPage page)
Adds the form page to this editor at the specified index (0-based).
|
protected abstract void |
addPages()
Subclass should implement this method to add pages to the editor using
'addPage(IFormPage)' method.
|
void |
close(boolean save)
Closes the editor programmatically.
|
protected void |
commitPages(boolean onSave)
Commits all dirty pages in the editor.
|
protected void |
configurePage(int index,
IFormPage page)
Configures the form page.
|
protected Composite |
createPageContainer(Composite parent)
Creates the parent control for the container returned by
MultiPageEditorPart.getContainer() . |
protected void |
createPages()
Creates the common toolkit for this editor and adds pages to the editor.
|
protected FormToolkit |
createToolkit(Display display)
Creates the form toolkit.
|
void |
dispose()
Disposes the pages and the toolkit after disposing the editor itself.
|
void |
editorDirtyStateChanged()
Called to indicate that the editor has been made dirty or the changes
have been saved.
|
IFormPage |
findPage(String pageId)
Finds the page instance that has the provided id.
|
IEditorPart |
getActiveEditor()
Widens the visibility of the method in the superclass.
|
IFormPage |
getActivePageInstance()
Returns active page instance if the currently selected page index is not
-1, or
null if it is. |
protected int |
getCurrentPage()
Returns the current page index.
|
Object |
getSelectedPage()
Returns the selected page for the current active page index, either the
IEditorPart for editors or the Control for other pages.
|
FormToolkit |
getToolkit()
Returns the toolkit owned by this editor.
|
void |
init(IEditorSite site,
IEditorInput input)
Overrides super to plug in a different selection provider.
|
boolean |
isDirty()
Tests whether the editor is dirty by checking all the pages that
implement
IFormPage . |
protected void |
pageChange(int newPageIndex)
Notifies this multi-page editor that the page with the given id has been
activated.
|
void |
removePage(int pageIndex)
Overrides the superclass to remove the page from the page table.
|
IFormPage |
selectReveal(Object pageInput)
Iterates through the pages calling similar method until a page is found
that contains the desired page input.
|
protected void |
setActivePage(int pageIndex)
Sets the currently active page.
|
IFormPage |
setActivePage(String pageId)
Sets the active page using the unique page identifier.
|
IFormPage |
setActivePage(String pageId,
Object pageInput)
Sets the active page using the unique page identifier and sets its input
to the provided object.
|
protected void |
updateActionBarContributor(int pageIndex)
Notifies action bar contributor about page change.
|
activateSite, addPageChangedListener, createPartControl, createSite, deactivateSite, findEditors, getActivePage, getAdapter, getContainer, getControl, getEditor, getPageCount, getPageImage, getPageSite, getPageText, handlePropertyChange, initializePageSwitching, removePageChangedListener, setActiveEditor, setControl, setFocus, setPageImage, setPageText
checkSite, doSave, doSaveAs, getEditorInput, getEditorSite, getTitleToolTip, isSaveAsAllowed, isSaveOnCloseNeeded, setContentDescription, setInitializationData, setInput, setInputWithNotify, setPartName
addPartPropertyListener, addPropertyListener, firePartPropertyChanged, firePropertyChange, getConfigurationElement, getContentDescription, getDefaultImage, getOrientation, getPartName, getPartProperties, getPartProperty, getSite, getTitle, getTitleImage, removePartPropertyListener, removePropertyListener, setPartProperty, setSite, setTitle, setTitleImage, setTitleToolTip, showBusy
addListenerObject, clearListeners, getListeners, isListenerAttached, removeListenerObject
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addPropertyListener, getSite, getTitle, getTitleImage, removePropertyListener
protected Vector pages
IFormPage
, hence the size of this
array matches the number of pages as viewed by the user.
Subclasses can access this field but should not modify it.
public void init(IEditorSite site, IEditorInput input) throws PartInitException
init
in interface IEditorPart
init
in class MultiPageEditorPart
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.protected void createPages()
createPages
in class MultiPageEditorPart
addPages()
protected Composite createPageContainer(Composite parent)
MultiPageEditorPart
MultiPageEditorPart.getContainer()
.
Subclasses may extend and must call super implementation first.
createPageContainer
in class MultiPageEditorPart
parent
- the parent for all of the editors contents.null
.protected FormToolkit createToolkit(Display display)
FormColors
object to share resources across the multiple
editor instances.display
- the display to use when creating the toolkitprotected abstract void addPages()
public Object getSelectedPage()
MultiPageEditorPart
Note: clients may override this method to return a page
appropriate for their editors. Maybe be null
.
getSelectedPage
in interface IPageChangeProvider
getSelectedPage
in class MultiPageEditorPart
null
if there are no active pages.MultiPageEditorPart.getActivePage()
public int addPage(IFormPage page) throws PartInitException
page
- the form page to addPartInitException
public void addPage(int index, IFormPage page) throws PartInitException
index
- the position to add the page at (0-based)page
- the form page to addPartInitException
public int addPage(Control control)
addPage
in class MultiPageEditorPart
control
- the page control to addMultiPageEditorPart.setControl(int, Control)
public void addPage(int index, Control control)
addPage
in class MultiPageEditorPart
control
- the page control to addindex
- the index at which to add the page (0-based)MultiPageEditorPart.setControl(int, Control)
public boolean isDirty()
IFormPage
. If none of them is dirty, the method
delegates further processing to super.isDirty()
.isDirty
in interface ISaveablePart
isDirty
in class MultiPageEditorPart
true
if any of the pages in the editor are dirty,
false
otherwise.protected void commitPages(boolean onSave)
onSave
- true
if commit is performed as part
of the 'save' operation, false
otherwise.public int addPage(IEditorPart editor, IEditorInput input) throws PartInitException
addPage
in class MultiPageEditorPart
editor
- the nested editorinput
- the input for the nested editorPartInitException
- if a new page could not be createdMultiPageEditorPart.addPage(IEditorPart, IEditorInput)
public void addPage(int index, IEditorPart editor, IEditorInput input) throws PartInitException
addPage
in class MultiPageEditorPart
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 createdMultiPageEditorPart.addPage(int, IEditorPart, IEditorInput)
protected void configurePage(int index, IFormPage page) throws PartInitException
index
- the page indexpage
- the page to configurePartInitException
- if there are problems in configuring the pagepublic void removePage(int pageIndex)
removePage
in class MultiPageEditorPart
pageIndex
- the 0-based index of the page in the editorMultiPageEditorPart.addPage(Control)
,
MultiPageEditorPart.addPage(IEditorPart, IEditorInput)
public void editorDirtyStateChanged()
public void dispose()
dispose
in interface IWorkbenchPart
dispose
in class MultiPageEditorPart
public FormToolkit getToolkit()
public IEditorPart getActiveEditor()
getActiveEditor
in class MultiPageEditorPart
protected int getCurrentPage()
Another important difference is during the editor closing. When the tab folder is disposed, 'getActivePage()' will return -1, while this method will still return the last active page.
MultiPageEditorPart.getActivePage()
protected void pageChange(int newPageIndex)
MultiPageEditorPart
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.
pageChange
in class MultiPageEditorPart
newPageIndex
- the index of the activated pageMultiPageEditorPart.pageChange(int)
public IFormPage setActivePage(String pageId)
pageId
- the id of the page to switch topublic IFormPage findPage(String pageId)
pageId
- the id of the page to findnull
if not found.public IFormPage setActivePage(String pageId, Object pageInput)
pageId
- the id of the page to switch topageInput
- the page inputpublic IFormPage selectReveal(Object pageInput)
pageInput
- the object to select and revealnull
if no
page has the desired object.setActivePage(String, Object)
public IFormPage getActivePageInstance()
null
if it is.null
if no
page is currently active.protected void setActivePage(int pageIndex)
MultiPageEditorPart
setActivePage
in class MultiPageEditorPart
pageIndex
- the index of the page to be activated; the index must be validMultiPageEditorPart.setActivePage(int)
protected void updateActionBarContributor(int pageIndex)
pageIndex
- the index of the new pagepublic void close(boolean save)
save
- if true
, the content should be saved before
closing.
Copyright (c) 2000, 2015 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.