|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.ui.part.Page
de.tu_berlin.cs.tfs.muvitorkit.ui.MuvitorPage
public abstract class MuvitorPage
This is an IPage
that contains some GraphicalViewer
s as well
as a FlyoutPaletteComposite
and that manages changing of the current
viewer. It is meant to be used in a MuvitorPageBookView
like a
regular graphical GEF editor. Like an GEF editor this page has its own
EditDomain
and ActionRegistry
but uses the
CommandStack
and some general action instances (which we call shared)
from the main MuvitorTreeEditor
.
On calling MuvitorTreeEditor.showView(String, EObject)
) with the ID
(as in plugin.xml) of this page's parent MuvitorPageBookView
, the top
model element and a parent editor are set in the constructor. A
ZoomManagerDelegate
for a ZoomComboContributionItem
is
provided via getAdapter(Class)
to the workbench page's part service.
This class should be used in the MuvitorKit (with a central
MuvitorTreeEditor
) only. But for documentation, the following
enumerates what the main editor provides to this page via getAdapter():
CommandStack
which will be used for this page's
EditDomain
and to update actions.
SelectionSynchronizer
to synchronize this page's
GraphicalViewer
with EditPartViewer
s in other view components
of this editor that show parts of the main editor's model.
KeyHandler
(optional, may be null) which will be set as parent
for the Keyhandler of this page's GraphicalViewer
.
When initialized and in createControl(Composite)
this class does the
following:
EObject
model
to be able to react on notifications of the EMF model. Subclasses may use
this as described below.
CommandStackListener
on the
editor's CommandStack
to update actions on command stack changes.
FlyoutPaletteComposite
is being created which uses the
Preferences
of the Plugin
delivered by the parent editor.
MuvitorPage.MultiViewerPageViewer
s (the number depends on
getViewerContents()
are being created and added to the
SelectionSynchronizer
delivered by the parent editor. The objects
returned by getViewerContents()
are set as contents of these
viewers. ScrollableThumbnail
showing a miniature overview of the current
viewer is being installed below the palette.
ZoomInAction
, ZoomOutAction
and custom Actions defined in the abstract method
createCustomActions()
. Handles for some standard
RetargetAction
s from the ActionFactory
besides zooming and
undo/redo are being registered if they have been created in
createCustomActions()
: COPY, CUT, PASTE, DELETE. createCustomActions()
.
This page uses an own minimally modified kind of edit part viewer, the
MuvitorPage.MultiViewerPageViewer
. Such a viewer notices if a mouse click occurs
on it and sets itself as the current viewer which performs the following
updates by calling setCurrentViewer(MultiViewerPageViewer)
for
itself:
ISelectionProvider
of the
IPageSite
, so all components and in particular all
SelectionAction
s of the editor are aware of the current selection in
the current viewer.
ISelectionChangedListener
on the
viewer to be able to update the UpdateAction
s in its
ActionRegistry
on selection changes.
ScrollableThumbnail
is being redirected to show the new
current viewer.
ZoomManager
of the clicked viewer is set as delegating target
in the ZoomManagerDelegate
, so the central
ZoomComboContributionItem
in the editor's action bar acts on the
currently selected viewer.
setViewersContents(int, EObject)
. As well, you may hide or restore a
particular viewer on this page with
setViewerVisibility(int, boolean)
The following methods have to be implemented by subclasses. Consider the documentation of each method as well, as they provide some hints!
createCustomActions()
: custom actions may be registered here.
createContextMenuProvider(EditPartViewer)
: must return a
ContextMenuProviderWithActionRegistry
defining the context menu for
the passed viewer.
createEditPartFactory()
: must return a suitable
EditPartFactory
to create edit parts for the model elements.
createPaletteRoot()
: must return a MuvitorPaletteRoot
defining what the palette should contain.
getThumbSashWeights()
: must return an array of two integers
describing the ratio of how the fly-out composite's space is divided between
the palette and the thumbnail.
getViewerContents()
specifies the objects that will be set as
contents for the viewers.
setupKeyHandler(KeyHandler)
: In this method KeyStroke
s
may be associated with previously defined actions for the viewers.
notifyChanged(Notification)
: Optionally, this may be overridden for
reacting on model change notifications. See there for details on overriding.
This page is prepared to work with the MuvitorKits animation package; it
implements the IGraphicalViewerProvider
interface.
Originally, this class was considered to roughly work like
GraphicalEditorWithFlyoutPalette
.
Nested Class Summary | |
---|---|
class |
MuvitorPage.MultiViewerPageViewer
This local class extends ScrollingGraphicalViewer by a
MouseListener that sets this viewer as the page's current viewer
when a mouse click occurs on this viewer. |
static class |
MuvitorPage.MuvitorRulerProvider
|
Constructor Summary | |
---|---|
MuvitorPage(MuvitorPageBookView view)
|
Method Summary | |
---|---|
void |
commandStackChanged(EventObject event)
If some command manipulates the model and is put to the command stack the actions are updated. |
protected abstract ContextMenuProviderWithActionRegistry |
createContextMenuProvider(EditPartViewer viewer)
Subclasses must implement to specify the ContextMenuProviderWithActionRegistry that should be used by this
page's GraphicalViewer s and is responsible to show the created
actions in the context menu. |
void |
createControl(Composite parent)
This method creates all the visual parts and configures them: A FlyoutPaletteComposite is created and associated with the
Preferences of the #editor 's Plugin . |
protected abstract void |
createCustomActions()
To be implemented by subclasses. |
protected abstract EditPartFactory |
createEditPartFactory()
Subclasses must implement to specify the EditPartFactory that
should be used by this page's GraphicalViewer s. |
protected abstract MuvitorPaletteRoot |
createPaletteRoot()
Subclasses must implement to specify the PaletteRoot that should be used by this page's EditDomain and which defines the contents of the
palette. |
void |
dispose()
Stops listening to the model, removes viewers from the #editor 's
SelectionSynchronizer , stops listening to the global selection
service, and deactivates the thumbnail . |
protected ActionRegistry |
getActionRegistry()
|
Object |
getAdapter(Class clazz)
Extended to provide zoomManagerDelegate as ZoomManager . |
Control |
getControl()
|
MuvitorPage.MultiViewerPageViewer |
getCurrentViewer()
|
MuvitorTreeEditor |
getEditor()
|
EObject |
getModel()
|
int |
getNumberOfViewers()
|
protected KeyHandler |
getSharedKeyHandler()
Configures the keyHandler with standard key strokes like DEL
(for DeleteAction ) and F2 (for direct edit). |
IStatusLineManager |
getStatusLineManager()
This can be used to display messages in this page's status line. |
protected int[] |
getThumbSashWeights()
The two values in the returned array specify how the fly-out composite's space is being divided between the palette entries and the thumbnail in the palette. |
IToolBarManager |
getToolBarManager()
This can be used to add actions to this page's tool bar. |
GraphicalViewer |
getViewer(EObject forModel)
Method to get the viewer showing a specific model. |
protected abstract EObject[] |
getViewerContents()
The viewer's are arranged horizontally and will be showing these objects in the order of the returned array from left to right. |
protected List<MuvitorPage.MultiViewerPageViewer> |
getViewers()
Method to get the list of viewers if needed to implement advanced editor features. |
EObject |
getViewersContents(int viewerPosition)
A method to access the object which is being displayed in a specific viewer. |
void |
init(IPageSite pageSite)
Registers this page as eAdapter listener on its model and as listener on the parent MuvitorTreeEditor 's CommandStack . |
protected void |
notifyChanged(Notification msg)
By default, an Adapter will be registered with this page's model that passes notifications to this method, which subclasses are expected to override. |
protected IAction |
registerAction(IAction action)
Registers an IAction instance with this page's
ActionRegistry . |
protected IAction |
registerActionAsHandler(IAction action)
Registers an IAction instance with this page's
ActionRegistry and sets it as the handler action (in this page)
for a RetargetAction that has been defined in the
MuvitorActionBarContributor with the same ID as the action. |
protected IAction |
registerSharedAction(String id)
Registers an IAction instance from the parent
MuvitorTreeEditor 's ActionRegistry with this page's
action registry. |
protected IAction |
registerSharedActionAsHandler(String id)
Registers an IAction instance from the parent editor's
ActionRegistry with this page's action registry and sets it as
the handler action (in this page) for a RetargetAction that has
been defined in the MuvitorActionBarContributor with the same ID
as the action. |
void |
selectionChanged(IWorkbenchPart part,
ISelection selection)
If a selection change occurs in the one of the editor components (possibly in the current viewer) the UpdateAction s in this page's
ActionRegistry are being updated. |
protected void |
setCurrentViewer(MuvitorPage.MultiViewerPageViewer viewer)
This method sets the current graphical viewer of this page which implies that the passed viewer will be shown in the Thumbnail ,
becomes the current ISelectionProvider in the
SelectionProviderIntermediate for this page's IPageSite
and
provides the ZoomManager for the zoom actions the
ZoomManagerDelegate delegates to. |
void |
setFocus()
Sets focus to a part in the page. |
protected abstract void |
setupKeyHandler(KeyHandler kh)
Subclasses must implement to associate KeyStroke s with Actions in
the passed KeyHandler which is the one used for the
GraphicalViewers . |
void |
setViewersContents(int viewerPosition,
EObject model)
A method to set a new object to be shown in a specific viewer. |
void |
setViewerVisibility(int viewerPosition,
boolean visible)
This method sets the visibility of a viewer's control and relayouts the SashForm so that the visible viewers on it occupy the remaining space. |
protected void |
updateActions()
Updates all UpdateAction s registered in the
actionRegistry . |
Methods inherited from class org.eclipse.ui.part.Page |
---|
getSite, makeContributions, setActionBars |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MuvitorPage(MuvitorPageBookView view)
view
- the MuvitorPageBookView that hosts this pageMethod Detail |
---|
public final EObject getModel()
public void init(IPageSite pageSite)
MuvitorTreeEditor
's CommandStack
.
Subclasses may extendto perform further initializations butm ust call
super implementation! Remember to clean them up in dispose()
if
needed!.
init
in interface IPageBookViewPage
init
in class Page
protected abstract void createCustomActions()
In his method, you can create IAction instances to be used in this page;
in the viewers' context menu, by keys, or on the page's tool bar. For
this, there are four methods that should cover all needs:
registerAction(IAction)
,
registerActionAsHandler(IAction)
,
registerSharedAction(String)
, and
registerSharedActionAsHandler(String)
. See their documentation
for a description, when to use which method.
To put actions on the tool bar, you may add them to the tool bar manager
(see getToolBarManager()
) after registering.
WorkbenchPartAction
s and SelectionAction
s created here
should get the editor (getEditor()
) as workbench part in their
constructor.
Consider sharing actions instances with the main editor, if possible!
createActions()
protected final IAction registerAction(IAction action)
IAction
instance with this page's
ActionRegistry
.
Call this method in createCustomActions()
if you want to use an
action instance in the context menu or put it on the page's tool bar.
Do not use this method if you
RetargetAction
defined in the MuvitorActionBarContributor
(use registerActionAsHandler(IAction)
instead), or
registerSharedAction(String)
instead), or
DeleteAction
) (use registerSharedActionAsHandler(String)
instead).
action
- the action to be registered
createCustomActions()
,
createActions()
,
getToolBarManager()
protected final IAction registerActionAsHandler(IAction action)
IAction
instance with this page's
ActionRegistry
and sets it as the handler action (in this page)
for a RetargetAction
that has been defined in the
MuvitorActionBarContributor
with the same ID as the action.
Call this method in createCustomActions()
if you want to use an
action instance (as a handler for a RetargetAction) in the context menu
or put it on the page's tool bar.
Do not use this method if you
registerAction(IAction)
instead), or
registerSharedAction(String)
instead), or
DeleteAction
) (use registerSharedActionAsHandler(String)
instead).
PageBookView.partActivated(org.eclipse.ui.IWorkbenchPart)
takes
care about refreshing the global action handlers for the ViewSite with
the global action handlers defined for the SubActionBars
of this
IPageSite
.
action
- the action to be registered
createCustomActions()
,
createActions()
,
getToolBarManager()
protected final IAction registerSharedAction(String id)
IAction
instance from the parent
MuvitorTreeEditor
's ActionRegistry
with this page's
action registry.
Call this method in createCustomActions()
if you want to reuse
an action instance from the editor in the context menu or put it on the
page's tool bar. Considering this for most Actions is strongly advised!
Do not use this method if you
registerAction(IAction)
instead), or
RetargetAction
defined in the MuvitorActionBarContributor
(use registerActionAsHandler(IAction)
instead), or
DeleteAction
) (use
registerSharedActionAsHandler(String)
instead).
id
- the ID of the action to be retrieved from the parent editor's
action registry
createCustomActions()
,
createActions()
,
getToolBarManager()
protected final IAction registerSharedActionAsHandler(String id)
IAction
instance from the parent editor's
ActionRegistry
with this page's action registry and sets it as
the handler action (in this page) for a RetargetAction
that has
been defined in the MuvitorActionBarContributor
with the same ID
as the action.
Call this method in createCustomActions()
if you want to reuse
an action handler for a RetargetAction from the editor in the context
menu or put it on the page's tool bar. Considering this for most handle
Actions is strongly advised!
Do not use this method if you
registerAction(IAction)
instead), or
registerActionAsHandler(IAction)
instead), or
registerSharedAction(String)
instead).
PageBookView.partActivated(org.eclipse.ui.IWorkbenchPart)
takes
care about refreshing the global action handlers for the ViewSite with
the global action handlers defined for the SubActionBars
of this
IPageSite
.
id
- the ID of the action to be retrieved from the parent editor's
action registry
createCustomActions()
,
createActions()
,
getToolBarManager()
public final void createControl(Composite parent)
FlyoutPaletteComposite
is created and associated with the
Preferences
of the #editor
's Plugin
.
createGraphicalViewerComposite()
a composite hosting
the MuvitorPage.MultiViewerPageViewer
s is being created and set as graphical
control for the flyoutPaletteComposite
.
ScrollableThumbnail
is being created with
installThumbnailInPalette()
.
viewers
is set with
setCurrentViewer(MuvitorPage.MultiViewerPageViewer)
.
selectionProvider
intermediate is set as selection
provider for this page's site.
createActions()
.
createControl
in interface IPage
createControl
in class Page
Page.createControl(org.eclipse.swt.widgets.Composite)
protected abstract MuvitorPaletteRoot createPaletteRoot()
EditDomain
and which defines the contents of the
palette.
Use a MuvitorPaletteRoot
for convenience.
MuvitorPaletteRoot
for the EditDomain
of this
page.protected int[] getThumbSashWeights()
return new int[] { Palette_Weight, Thumb_Weight };
The
pair (3,1) is a good default value, but you may override this method.
protected final KeyHandler getSharedKeyHandler()
keyHandler
with standard key strokes like DEL
(for DeleteAction
) and F2 (for direct edit).
KeyHandler
for the viewers on
this page.setupKeyHandler(KeyHandler)
public final int getNumberOfViewers()
getViewerContents()
,
createGraphicalViewerComposite()
public final MuvitorPage.MultiViewerPageViewer getCurrentViewer()
setCurrentViewer(MultiViewerPageViewer)
protected abstract EObject[] getViewerContents()
getNumberOfViewers()
!
viewers
.setViewersContents(int, EObject)
,
createGraphicalViewerComposite()
public final EObject getViewersContents(int viewerPosition)
viewerPosition
- the position (starting with 0) of the viewer
setViewersContents(int, EObject)
public final GraphicalViewer getViewer(EObject forModel)
IGraphicalViewerProvider
A sample implementation could look like this:
public GraphicalViewer getViewer(final EObject model) { for (final GraphicalViewer viewer : viewers) { if (viewer.getContents() != null && viewer.getContents().getModel() == model) { return viewer; } } return null; }
getViewer
in interface IGraphicalViewerProvider
forModel
- the model element shown in the viewer
null
public final void setViewersContents(int viewerPosition, EObject model)
viewerPosition
- the position (starting with 0) of the viewergetViewerContents()
public final void setViewerVisibility(int viewerPosition, boolean visible)
viewerPosition
- the position (starting with 0) of the viewerprotected abstract void setupKeyHandler(KeyHandler kh)
KeyStroke
s with Actions in
the passed KeyHandler
which is the one used for the
GraphicalViewers
.
May be left empty.
createControl(Composite)
protected abstract ContextMenuProviderWithActionRegistry createContextMenuProvider(EditPartViewer viewer)
ContextMenuProviderWithActionRegistry
that should be used by this
page's GraphicalViewer
s and is responsible to show the created
actions in the context menu.
viewer
- The graphical viewer for context menu provider
ContextMenuProviderWithActionRegistry
for the
specified GraphicalViewer
.createGraphicalViewerComposite()
protected abstract EditPartFactory createEditPartFactory()
EditPartFactory
that
should be used by this page's GraphicalViewer
s.
EditPartFactory
for the GraphicalViewer
s of
this page.createGraphicalViewerComposite()
public void dispose()
#editor
's
SelectionSynchronizer
, stops listening to the global selection
service, and deactivates the thumbnail
.
May be extended by subclasses to perform further cleaning up for
initializations done in init(IPageSite)
but super implementation
must be called!
dispose
in interface IPage
dispose
in class Page
public final Control getControl()
getControl
in interface IPage
getControl
in class Page
public final void setFocus()
setFocus
in interface IPage
setFocus
in class Page
public final void selectionChanged(IWorkbenchPart part, ISelection selection)
UpdateAction
s in this page's
ActionRegistry
are being updated.
selectionChanged
in interface ISelectionListener
protected final void updateActions()
UpdateAction
s registered in the
actionRegistry
.
public Object getAdapter(Class clazz)
zoomManagerDelegate
as ZoomManager
.
Subclasses may extend further, but must call super implementation!
getAdapter
in interface IAdaptable
protected final ActionRegistry getActionRegistry()
public final MuvitorTreeEditor getEditor()
protected final void setCurrentViewer(MuvitorPage.MultiViewerPageViewer viewer)
Thumbnail
,
ISelectionProvider
in the
SelectionProviderIntermediate
for this page's IPageSite
and
ZoomManager
for the zoom actions the
ZoomManagerDelegate
delegates to.
viewer
- protected final List<MuvitorPage.MultiViewerPageViewer> getViewers()
To set new contents for a viewer
setViewersContents(int, EObject)
should be used!
setViewersContents(int, EObject)
public final IStatusLineManager getStatusLineManager()
IStatusLineManager
from the IActionBars
of
this page's IPageSite
public final IToolBarManager getToolBarManager()
IToolBarManager
from the IActionBars
of this
page's IPageSite
public final void commandStackChanged(EventObject event)
MuvitorTreeEditor
!
commandStackChanged
in interface CommandStackListener
protected void notifyChanged(Notification msg)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |