Class PageBookView
- All Implemented Interfaces:
IAdaptable,IExecutableExtension,IPartListener,IPersistable,IViewPart,IWorkbenchPart,IWorkbenchPart2,IWorkbenchPart3,IWorkbenchPartOrientation
- Direct Known Subclasses:
AbstractDebugView,ContentOutline,PropertySheet,TemplatesView
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.
PageBookViews 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. PageBookViews
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 part
When 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 whenisImportantreturnstrue.
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classA data structure used to store the information about a single page within a pagebook view.protected classA selection provider/listener for this view. -
Field Summary
Fields inherited from interface org.eclipse.ui.IWorkbenchPart
PROP_TITLE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract IPagecreateDefaultPage(PageBook book) Creates and returns the default page for this view.voidcreatePartControl(Composite parent) ThePageBookViewimplementation of thisIWorkbenchPartmethod creates aPageBookcontrol with its default page showing.voiddispose()ThePageBookViewimplementation of thisIWorkbenchPartmethod cleans up all the pages.protected abstract PageBookView.PageRecdoCreatePage(IWorkbenchPart part) Creates a new page in the pagebook for a particular part.protected abstract voiddoDestroyPage(IWorkbenchPart part, PageBookView.PageRec pageRecord) Destroys a page in the pagebook for a particular part.protected booleandoesPageExist(IPage page) Returns true if the page has already been created.<T> TgetAdapter(Class<T> key) ThePageBookViewimplementation of thisIAdaptablemethod delegates to the current page, if it implementsIAdaptable.protected abstract IWorkbenchPartReturns the active, important workbench part for this view.protected IWorkbenchPartReturns the part which contributed the current page to this view.Returns the currently visible page for this view ornullif no page is currently visible.Returns the default page for this view.protected PageBookReturns the pagebook control for this view.protected PageBookView.PageRecgetPageRec(IWorkbenchPart part) Returns the page record for the given part.protected PageBookView.PageRecgetPageRec(IPage page) Returns the page record for the given page of this view.protected PageSitegetPageSite(IPage page) Returns the view site for the given page of this view.protected PageBookView.SelectionProviderReturns the selectionProvider for this page book view.protected <T> TgetViewAdapter(Class<T> adapter) Returns an adapter of the specified type, as provided by this view (not the current page), ornullif this view does not provide an adapter of the specified adapter.voidInitializes this view with the given view site.protected voidinitPage(IPageBookViewPage page) Initializes the given page with a page site.protected abstract booleanisImportant(IWorkbenchPart part) Returns whether the given part should be added to this view.voidpartActivated(IWorkbenchPart part) ThePageBookViewimplementation of thisIPartListenermethod shows the page when the given part is activated.voidThePageBookViewimplementation of thisIPartListenermethod does nothing.voidpartClosed(IWorkbenchPart part) ThePageBookViewimplementation of thisIPartListenermethod deal with the closing of the active part.voidThePageBookViewimplementation of thisIPartListenermethod does nothing.protected voidpartHidden(IWorkbenchPart part) Make sure that the part is not considered if it is hidden.voidpartOpened(IWorkbenchPart part) Notifies this listener that the given part has been opened.protected voidpartVisible(IWorkbenchPart part) Make sure that the part is not considered if it is hidden.voidsetFocus()Asks this part to take focus within the workbench.protected voidshowPageRec(PageBookView.PageRec pageRec) Shows page contained in the given page record in this view.Methods inherited from class org.eclipse.ui.part.ViewPart
checkSite, getViewSite, init, saveState, setContentDescription, setInitializationData, setPartNameMethods inherited from class org.eclipse.ui.part.WorkbenchPart
addPartPropertyListener, addPropertyListener, firePartPropertyChanged, firePropertyChange, getConfigurationElement, getContentDescription, getDefaultImage, getOrientation, getPartName, getPartProperties, getPartProperty, getSite, getTitle, getTitleImage, getTitleToolTip, removePartPropertyListener, removePropertyListener, setPartProperty, setSite, setTitle, setTitleImage, setTitleToolTip, showBusyMethods inherited from class org.eclipse.core.commands.common.EventManager
addListenerObject, clearListeners, getListeners, isListenerAttached, removeListenerObjectMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.eclipse.ui.IWorkbenchPart
addPropertyListener, getSite, getTitle, getTitleImage, getTitleToolTip, removePropertyListener
-
Constructor Details
-
PageBookView
protected PageBookView()Creates a new pagebook view.
-
-
Method Details
-
createDefaultPage
Creates and returns the default page for this view.Subclasses must implement this method.
Subclasses must call initPage with the new page (if it is an
IPageBookViewPage) before calling createControl on the page.- Parameters:
book- the pagebook control- Returns:
- the default page
-
initPage
Initializes the given page with a page site.Subclasses should call this method after the page is created but before creating its controls.
Subclasses may override
- Parameters:
page- The page to initialize
-
createPartControl
ThePageBookViewimplementation of thisIWorkbenchPartmethod creates aPageBookcontrol with its default page showing. Subclasses may extend.- Specified by:
createPartControlin interfaceIWorkbenchPart- Specified by:
createPartControlin classWorkbenchPart- Parameters:
parent- the parent control
-
dispose
public void dispose()ThePageBookViewimplementation of thisIWorkbenchPartmethod cleans up all the pages. Subclasses may extend.- Specified by:
disposein interfaceIWorkbenchPart- Overrides:
disposein classWorkbenchPart
-
doCreatePage
Creates a new page in the pagebook for a particular part. This page will be made visible whenever the part is active, and will be destroyed with a call todoDestroyPage.Subclasses must implement this method.
Subclasses must call initPage with the new page (if it is an
IPageBookViewPage) before calling createControl on the page.- Parameters:
part- the input part- Returns:
- the record describing a new page for this view
- See Also:
-
doDestroyPage
Destroys a page in the pagebook for a particular part. This page was returned as a result fromdoCreatePage.Subclasses must implement this method.
- Parameters:
part- the input partpageRecord- a page record for the part- See Also:
-
doesPageExist
Returns true if the page has already been created.- Parameters:
page- the page to test- Returns:
- true if this page has already been created.
-
getAdapter
ThePageBookViewimplementation of thisIAdaptablemethod delegates to the current page, if it implementsIAdaptable.- Specified by:
getAdapterin interfaceIAdaptable- Overrides:
getAdapterin classWorkbenchPart- Type Parameters:
T- the class type- Parameters:
key- the adapter class to look up- Returns:
- a object of the given class, or
nullif this object does not have an adapter for the given class
-
getViewAdapter
Returns an adapter of the specified type, as provided by this view (not the current page), ornullif this view does not provide an adapter of the specified adapter.The default implementation returns
null. Subclasses may override.- Parameters:
adapter- the adapter class to look up- Returns:
- a object castable to the given class, or
nullif this object does not have an adapter for the given class - Since:
- 3.2
-
getBootstrapPart
Returns the active, important workbench part for this view.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
nullif none found.Subclasses must implement this method.
- Returns:
- the active important part, or
nullif none
-
getCurrentContributingPart
Returns the part which contributed the current page to this view.- Returns:
- the part which contributed the current page or
nullif no part contributed the current page
-
getCurrentPage
Returns the currently visible page for this view ornullif no page is currently visible.- Returns:
- the currently visible page
-
getPageSite
Returns the view site for the given page of this view.- Parameters:
page- the page- Returns:
- the corresponding site, or
nullif not found
-
getDefaultPage
Returns the default page for this view.- Returns:
- the default page
-
getPageBook
Returns the pagebook control for this view.- Returns:
- the pagebook control, or
nullif not initialized
-
getPageRec
Returns the page record for the given part.- Parameters:
part- the part- Returns:
- the corresponding page record, or
nullif not found
-
getPageRec
Returns the page record for the given page of this view.- Parameters:
page- the page- Returns:
- the corresponding page record, or
nullif not found
-
isImportant
Returns whether the given part should be added to this view.Subclasses must implement this method.
- Parameters:
part- the input part- Returns:
trueif the part is relevant, andfalseotherwise
-
init
Description copied from interface:IViewPartInitializes this view with the given view site.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.
- Specified by:
initin interfaceIViewPart- Overrides:
initin classViewPart- Parameters:
site- the view site- Throws:
PartInitException- may be thrown from overrides
-
partActivated
ThePageBookViewimplementation of thisIPartListenermethod shows the page when the given part is activated. Subclasses may extend.- Specified by:
partActivatedin interfaceIPartListener- Parameters:
part- the part that was activated- See Also:
-
partBroughtToTop
ThePageBookViewimplementation of thisIPartListenermethod does nothing. Subclasses may extend.- Specified by:
partBroughtToTopin interfaceIPartListener- Parameters:
part- the part that was surfaced- See Also:
-
partClosed
ThePageBookViewimplementation of thisIPartListenermethod deal with the closing of the active part. Subclasses may extend.- Specified by:
partClosedin interfaceIPartListener- Parameters:
part- the part that was closed- See Also:
-
partDeactivated
ThePageBookViewimplementation of thisIPartListenermethod does nothing. Subclasses may extend.- Specified by:
partDeactivatedin interfaceIPartListener- Parameters:
part- the part that was deactivated- See Also:
-
partOpened
Description copied from interface:IPartListenerNotifies this listener that the given part has been opened.- Specified by:
partOpenedin interfaceIPartListener- Parameters:
part- the part that was opened- See Also:
-
setFocus
public void setFocus()Description copied from interface:IWorkbenchPartAsks this part to take focus within the workbench. Parts must assign focus to one of the controls contained in the part's parent composite.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.- Specified by:
setFocusin interfaceIWorkbenchPart- Specified by:
setFocusin classWorkbenchPart
-
showPageRec
Shows page contained in the given page record in this view. The page record must be one from this pagebook view.The
PageBookViewimplementation 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.- Parameters:
pageRec- the page record containing the page to show
-
getSelectionProvider
Returns the selectionProvider for this page book view.- Returns:
- a SelectionProvider
-
partHidden
Make sure that the part is not considered if it is hidden.- Parameters:
part- the part which got hidden- Since:
- 3.5
-
partVisible
Make sure that the part is not considered if it is hidden.- Parameters:
part- the part which got visible- Since:
- 3.5
-