de.tu_berlin.cs.tfs.muvitorkit.ui
Class MuvitorPageBookView

java.lang.Object
  extended by org.eclipse.core.commands.common.EventManager
      extended by org.eclipse.ui.part.WorkbenchPart
          extended by org.eclipse.ui.part.ViewPart
              extended by org.eclipse.ui.part.PageBookView
                  extended by de.tu_berlin.cs.tfs.muvitorkit.ui.MuvitorPageBookView
All Implemented Interfaces:
IAdaptable, IExecutableExtension, IPartListener, IPersistable, IViewPart, IWorkbenchPart, IWorkbenchPart2, IWorkbenchPart3, IWorkbenchPartOrientation

public abstract class MuvitorPageBookView
extends PageBookView

This is a PageBookView for displaying some model EObject on an IPage. It is merely a wrapper for the contained MuvitorPage implementing IPage, as this is the only possibility Eclipse offers to show a customized page in a workbench view. The GraphicalViewers for editing are hosted in this MuvitorPage.

The user has to implement createPageForModel(EObject) to instantiate a MuvitorPage that is able to display or even edit the model.

The model to show is determined by the following mechanism:
It is expected that this view is opened via a call MuvitorTreeEditor.showView(String, EObject) where

This call sets the EObject's unique ID for the model as secondary ID of this view. So, the model to be shown can be determined by the secondary ID.

The AbstractTreeEditor instance will hide this view when its model is being deleted (for details see how IDUtil.getIDForModel(EObject) employs the Muvitor's MuvitorNotifierService).

Additionally this view registers itself an EMF adapter to the model EObject that reacts on notifications of the EMF model. For this, subclasses may override {#notifyChanged(Notification)}, especially to update the name of this IViewPart according to the model. For this, calculatePartName() must be implemented to represent the model's name as a string.

This class is based roughly on ContentOutline but does not provide selections e.g. to ISelectionServices. Selection are handled by the MuvitorPages.

Rating red

Nested Class Summary
 
Nested classes/interfaces inherited from class org.eclipse.ui.part.PageBookView
PageBookView.PageRec, PageBookView.SelectionProvider
 
Field Summary
 
Fields inherited from interface org.eclipse.ui.IWorkbenchPart
PROP_TITLE
 
Constructor Summary
MuvitorPageBookView()
           
 
Method Summary
protected abstract  String calculatePartName()
           
protected  IPage createDefaultPage(PageBook book)
           
protected abstract  IPage createPageForModel(EObject forModel)
          Subclasses must implement this method to create a IPage that displays the model.
protected  PageBookView.PageRec doCreatePage(IWorkbenchPart editor)
          Subclasses may override but must call super.
protected  void doDestroyPage(IWorkbenchPart part, PageBookView.PageRec rec)
          Subclasses may override but must call super.
protected  IWorkbenchPart getBootstrapPart()
           
 IEditorPart getEditor()
           
 EObject getModel()
           
protected  boolean isImportant(IWorkbenchPart part)
           
protected  void notifyChanged(Notification msg)
          By default, notifyChanged(Notification) calls setPartName(calculatePartName()).
 void partActivated(IWorkbenchPart part)
           
 void partBroughtToTop(IWorkbenchPart part)
           
 void setFocus()
           
protected  void showPageRec(PageBookView.PageRec pageRec)
           
 
Methods inherited from class org.eclipse.ui.part.PageBookView
createPartControl, dispose, doesPageExist, getAdapter, getCurrentContributingPart, getCurrentPage, getDefaultPage, getPageBook, getPageRec, getPageRec, getPageSite, getSelectionProvider, getViewAdapter, init, initPage, partClosed, partDeactivated, partHidden, partOpened, partVisible
 
Methods inherited from class org.eclipse.ui.part.ViewPart
checkSite, getViewSite, init, saveState, setContentDescription, setInitializationData, setPartName
 
Methods 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, 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, getTitleToolTip, removePropertyListener
 

Constructor Detail

MuvitorPageBookView

public MuvitorPageBookView()
Method Detail

getModel

public final EObject getModel()
Returns:
the model

calculatePartName

protected abstract String calculatePartName()
Returns:
The name this part should be set to, e.g. the name of the shown model accessible via getModel().

createPageForModel

protected abstract IPage createPageForModel(EObject forModel)
Subclasses must implement this method to create a IPage that displays the model. It may be advisable to ensure the model being an instance of the intended class(es) here.

Parameters:
forModel - The model to be displayed in the page.
Returns:
An IPage displaying the passed model.

notifyChanged

protected void notifyChanged(Notification msg)
By default, notifyChanged(Notification) calls setPartName(calculatePartName()).

Subclasses may override but must call super. notifyChanged(Notification) if they do not handle changing the part name themselves.


createDefaultPage

protected final IPage createDefaultPage(PageBook book)
Specified by:
createDefaultPage in class PageBookView

doCreatePage

protected PageBookView.PageRec doCreatePage(IWorkbenchPart editor)
Subclasses may override but must call super. doCreatePage(IWorkbenchPart). Note that this method returns a PageRec only once and null afterwards!.

Specified by:
doCreatePage in class PageBookView
Returns:
A PageRec with a new Page for the model determined by the secondaryID which is being resolved via IDUtil.
See Also:
#createPageForModel(Object)

doDestroyPage

protected void doDestroyPage(IWorkbenchPart part,
                             PageBookView.PageRec rec)
Subclasses may override but must call super. PageBookView.doDestroyPage(IWorkbenchPart, PageRec).

Specified by:
doDestroyPage in class PageBookView

getBootstrapPart

protected final IWorkbenchPart getBootstrapPart()
Specified by:
getBootstrapPart in class PageBookView

getEditor

public final IEditorPart getEditor()
Returns:

partActivated

public final void partActivated(IWorkbenchPart part)
Specified by:
partActivated in interface IPartListener
Overrides:
partActivated in class PageBookView

partBroughtToTop

public final void partBroughtToTop(IWorkbenchPart part)
Specified by:
partBroughtToTop in interface IPartListener
Overrides:
partBroughtToTop in class PageBookView

showPageRec

protected final void showPageRec(PageBookView.PageRec pageRec)
Overrides:
showPageRec in class PageBookView

isImportant

protected final boolean isImportant(IWorkbenchPart part)
Specified by:
isImportant in class PageBookView

setFocus

public void setFocus()
Specified by:
setFocus in interface IWorkbenchPart
Overrides:
setFocus in class PageBookView