public abstract class PageBookView extends ViewPart implements IPartListener
Within the workbench there are many views which track the active part. If a
part is activated these views display some properties for the active part. A
simple example is the Outline View
, which displays the
outline for the active editor. To avoid loss of context when part activation
changes, these views may implement a multi-page approach. A separate page is
maintained within the view for each source view. If a part is activated the
associated page for the part is brought to top. If a part is closed the
associated page is disposed. PageBookView
is a base
implementation for multi page views.
PageBookView
s provide an IPageSite
for each of
their pages. This site is supplied during the page's initialization. The page
may supply a selection provider for this site. PageBookView
s
deal with these selection providers in a similar way to a workbench page's
SelectionService
. When a page is made visible, if its site
has a selection provider, then changes in the selection are listened for and
the current selection is obtained and fired as a selection change event.
Selection changes are no longer listened for when a page is made invisible.
This class should be subclassed by clients wishing to define new multi-page views.
When a PageBookView
is created the following methods are
invoked. Subclasses must implement these.
createDefaultPage
- called to create a default page for
the view. This page is displayed when the active part in the workbench does
not have a page.getBootstrapPart
- called to determine the active part in
the workbench. A page will be created for this partWhen a part is activated the base implementation does not know if a page should be created for the part. Therefore, it delegates creation to the subclass.
isImportant
- called when a workbench part is activated.
Subclasses return whether a page should be created for the new part.doCreatePage
- called to create a page for a particular
part in the workbench. This is only invoked when isImportant
returns true.When a part is closed the base implementation will destroy the page associated with the particular part. The page was created by a subclass, so the subclass must also destroy it. Subclasses must implement these.
doDestroyPage
- called to destroy a page for a particular
part in the workbench.Modifier and Type | Class and Description |
---|---|
protected static class |
PageBookView.PageRec
A data structure used to store the information about a single page within
a pagebook view.
|
protected class |
PageBookView.SelectionProvider
A selection provider/listener for this view.
|
PROP_TITLE
Modifier | Constructor and Description |
---|---|
protected |
PageBookView()
Creates a new pagebook view.
|
Modifier and Type | Method and Description |
---|---|
protected abstract IPage |
createDefaultPage(PageBook book)
Creates and returns the default page for this view.
|
void |
createPartControl(Composite parent)
The
PageBookView implementation of this
IWorkbenchPart method creates a PageBook
control with its default page showing. |
void |
dispose()
The
PageBookView implementation of this
IWorkbenchPart method cleans up all the pages. |
protected abstract PageBookView.PageRec |
doCreatePage(IWorkbenchPart part)
Creates a new page in the pagebook for a particular part.
|
protected abstract void |
doDestroyPage(IWorkbenchPart part,
PageBookView.PageRec pageRecord)
Destroys a page in the pagebook for a particular part.
|
protected boolean |
doesPageExist(IPage page)
Returns true if the page has already been created.
|
<T> T |
getAdapter(Class<T> key)
The
PageBookView implementation of this
IAdaptable method delegates to the current page, if it
implements IAdaptable . |
protected abstract IWorkbenchPart |
getBootstrapPart()
Returns the active, important workbench part for this view.
|
protected IWorkbenchPart |
getCurrentContributingPart()
Returns the part which contributed the current page to this view.
|
IPage |
getCurrentPage()
Returns the currently visible page for this view or
null
if no page is currently visible. |
IPage |
getDefaultPage()
Returns the default page for this view.
|
protected PageBook |
getPageBook()
Returns the pagebook control for this view.
|
protected PageBookView.PageRec |
getPageRec(IPage page)
Returns the page record for the given page of this view.
|
protected PageBookView.PageRec |
getPageRec(IWorkbenchPart part)
Returns the page record for the given part.
|
protected PageSite |
getPageSite(IPage page)
Returns the view site for the given page of this view.
|
protected PageBookView.SelectionProvider |
getSelectionProvider()
Returns the selectionProvider for this page book view.
|
protected <T> T |
getViewAdapter(Class<T> adapter)
Returns an adapter of the specified type, as provided by this view (not
the current page), or
null if this view does not provide
an adapter of the specified adapter. |
void |
init(IViewSite site)
Initializes this view with the given view site.
|
protected void |
initPage(IPageBookViewPage page)
Initializes the given page with a page site.
|
protected abstract boolean |
isImportant(IWorkbenchPart part)
Returns whether the given part should be added to this view.
|
void |
partActivated(IWorkbenchPart part)
The
PageBookView implementation of this
IPartListener method shows the page when the given part is
activated. |
void |
partBroughtToTop(IWorkbenchPart part)
The
PageBookView implementation of this
IPartListener method does nothing. |
void |
partClosed(IWorkbenchPart part)
The
PageBookView implementation of this
IPartListener method deal with the closing of the active
part. |
void |
partDeactivated(IWorkbenchPart part)
The
PageBookView implementation of this
IPartListener method does nothing. |
protected void |
partHidden(IWorkbenchPart part)
Make sure that the part is not considered if it is hidden.
|
void |
partOpened(IWorkbenchPart part)
Notifies this listener that the given part has been opened.
|
protected void |
partVisible(IWorkbenchPart part)
Make sure that the part is not considered if it is hidden.
|
void |
setFocus()
Asks this part to take focus within the workbench.
|
protected void |
showPageRec(PageBookView.PageRec pageRec)
Shows page contained in the given page record in this view.
|
checkSite, getViewSite, init, saveState, setContentDescription, setInitializationData, setPartName
addPartPropertyListener, addPropertyListener, firePartPropertyChanged, firePropertyChange, getConfigurationElement, getContentDescription, getDefaultImage, getOrientation, getPartName, getPartProperties, getPartProperty, getSite, getTitle, getTitleImage, getTitleToolTip, 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, getTitleToolTip, removePropertyListener
protected abstract IPage createDefaultPage(PageBook book)
Subclasses must implement this method.
Subclasses must call initPage with the new page (if it is an
IPageBookViewPage
) before calling createControl on the
page.
book
- the pagebook controlprotected void initPage(IPageBookViewPage page)
Subclasses should call this method after the page is created but before creating its controls.
Subclasses may override
page
- The page to initializepublic void createPartControl(Composite parent)
PageBookView
implementation of this
IWorkbenchPart
method creates a PageBook
control with its default page showing. Subclasses may extend.createPartControl
in interface IWorkbenchPart
createPartControl
in class WorkbenchPart
parent
- the parent controlpublic void dispose()
PageBookView
implementation of this
IWorkbenchPart
method cleans up all the pages. Subclasses
may extend.dispose
in interface IWorkbenchPart
dispose
in class WorkbenchPart
protected abstract PageBookView.PageRec doCreatePage(IWorkbenchPart part)
doDestroyPage
.
Subclasses must implement this method.
Subclasses must call initPage with the new page (if it is an
IPageBookViewPage
) before calling createControl on the
page.
part
- the input partdoDestroyPage(org.eclipse.ui.IWorkbenchPart, org.eclipse.ui.part.PageBookView.PageRec)
protected abstract void doDestroyPage(IWorkbenchPart part, PageBookView.PageRec pageRecord)
doCreatePage
.
Subclasses must implement this method.
part
- the input partpageRecord
- a page record for the partdoCreatePage(org.eclipse.ui.IWorkbenchPart)
protected boolean doesPageExist(IPage page)
page
- the page to testpublic <T> T getAdapter(Class<T> key)
PageBookView
implementation of this
IAdaptable
method delegates to the current page, if it
implements IAdaptable
.getAdapter
in interface IAdaptable
getAdapter
in class WorkbenchPart
key
- the adapter class to look upnull
if this object does not
have an adapter for the given classprotected <T> T getViewAdapter(Class<T> adapter)
null
if this view does not provide
an adapter of the specified adapter.
The default implementation returns null
. Subclasses may
override.
adapter
- the adapter class to look upnull
if
this object does not have an adapter for the given classprotected abstract IWorkbenchPart getBootstrapPart()
When the page book view is created it has no idea which part within the
workbook should be used to generate the first page. Therefore, it
delegates the choice to subclasses of PageBookView
.
Implementors of this method should return an active, important part in
the workbench or null
if none found.
Subclasses must implement this method.
null
if noneprotected IWorkbenchPart getCurrentContributingPart()
null
if no part contributed the current pagepublic IPage getCurrentPage()
null
if no page is currently visible.protected PageSite getPageSite(IPage page)
page
- the pagenull
if not foundpublic IPage getDefaultPage()
protected PageBook getPageBook()
null
if not initializedprotected PageBookView.PageRec getPageRec(IWorkbenchPart part)
part
- the partnull
if not
foundprotected PageBookView.PageRec getPageRec(IPage page)
page
- the pagenull
if not
foundprotected abstract boolean isImportant(IWorkbenchPart part)
Subclasses must implement this method.
part
- the input parttrue
if the part is relevant, and
false
otherwisepublic void init(IViewSite site) throws PartInitException
IViewPart
This method is automatically called by the workbench shortly after the part is instantiated. It marks the start of the views's lifecycle. Clients must not call this method.
init
in interface IViewPart
init
in class ViewPart
site
- the view sitePartInitException
- if this view was not initialized successfullypublic void partActivated(IWorkbenchPart part)
PageBookView
implementation of this
IPartListener
method shows the page when the given part is
activated. Subclasses may extend.partActivated
in interface IPartListener
part
- the part that was activatedIWorkbenchPage.activate(org.eclipse.ui.IWorkbenchPart)
public void partBroughtToTop(IWorkbenchPart part)
PageBookView
implementation of this
IPartListener
method does nothing. Subclasses may extend.partBroughtToTop
in interface IPartListener
part
- the part that was surfacedIWorkbenchPage.bringToTop(org.eclipse.ui.IWorkbenchPart)
public void partClosed(IWorkbenchPart part)
PageBookView
implementation of this
IPartListener
method deal with the closing of the active
part. Subclasses may extend.partClosed
in interface IPartListener
part
- the part that was closedIWorkbenchPage.hideView(IViewPart)
public void partDeactivated(IWorkbenchPart part)
PageBookView
implementation of this
IPartListener
method does nothing. Subclasses may extend.partDeactivated
in interface IPartListener
part
- the part that was deactivatedIWorkbenchPage.activate(IWorkbenchPart)
public void partOpened(IWorkbenchPart part)
IPartListener
partOpened
in interface IPartListener
part
- the part that was openedIWorkbenchPage.showView(String)
public void setFocus()
IWorkbenchPart
Clients should not call this method (the workbench calls this method at
appropriate times). To have the workbench activate a part, use
IWorkbenchPage.activate(IWorkbenchPart) instead
.
setFocus
in interface IWorkbenchPart
setFocus
in class WorkbenchPart
protected void showPageRec(PageBookView.PageRec pageRec)
The PageBookView
implementation of this method asks the
pagebook control to show the given page's control, and records that the
given page is now current. Subclasses may extend.
pageRec
- the page record containing the page to showprotected PageBookView.SelectionProvider getSelectionProvider()
protected void partHidden(IWorkbenchPart part)
part
- protected void partVisible(IWorkbenchPart part)
part
-
Copyright (c) 2000, 2015 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.