|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.ui.part.Page
roneditor.AbstractMultiViewerPage
public abstract class AbstractMultiViewerPage
This class is based roughly on GraphicalEditorWithFlyoutPalette
.
It is an IPage
that contains some GraphicalViewer
s and a
FlyoutPaletteComposite
and is able to change the current viewer. It
is meant to be used in a PageBookView
(especially
AbstractPageBookView
) like an editor. Like an editor this page has
its own EditDomain
and ActionRegistry
. A top model element
and a parent editor (from which this page is being called to show up) are set
in the constructor. A ZoomManagerDelegate
for a
ZoomComboContributionItem
is provided via getAdapter(Class)
to the workbench page's part service.
Prerequisites: The parent editor must provide non-null
instances of the following classes via getAdapter():
CommandStack
which will be used for this page's
EditDomain
and to update actions.
Plugin
whose preferences will be used by the
FlyoutPaletteComposite
to store states of the palette.
SelectionSynchronizer
to synchronize this page's
GraphicalViewer
with other EditPartViewer
s that show parts
of the parent 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
that can react on notifications of the EMF model. For this, subclasses may
implement
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.
AbstractMultiViewerPage.MultiViewerPageViewer
s (depending on
getNumberOfViewers()
) 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. Thumbnail
showing a miniature overview of the current viewer
is being installed below the palette.
ZoomInAction
, ZoomOutAction
and custom Actions in createActions()
. Some standard handles for
RetargetAction
s from the ActionFactory
besides zooming and
undo/redo are being registered if they have been created in
createActions()
: COPY, CUT, PASTE, DELETE.
A AbstractMultiViewerPage.MultiViewerPageViewer
notices if a mouse click occurs on it and
sets itself as the current viewer which performs the following updates:
ISelectionProvider
of the
IPageSite
.
ISelectionChangedListener
on the
viewer to be able to update the UpdateAction
s in its
ActionRegistry
on selection changes.
SelectionAction
s
in the ActionRegistry
.
Thumbnail
is being configured to show the new current
viewer.
ZoomManager
of the clicked viewer is set as delegating
target in the ZoomManagerDelegate
.
setViewersContents(int, EObject)
.
These methods have to be implemented by subclasses:
createActions()
: Actions may be registered with
getActionRegistry()
.SelectionAction
s if it changes!
#createContextMenuProvider()
: A
ContextMenuProviderWithActionRegistry
for the context menu of each
viewer.
createEditPartFactory()
: A suitable EditPartFactory
for the model elements.
createPaletteRoot()
: A PaletteRoot
defining what the
palette should contain.
getNumberOfViewers()
specifies how many viewers will be created
on the page.
getThumbSashWeights()
: Must return an array of two integers
describing the ratio of how the flyout composite's space is divided between
the palette and the thumbnail.
getViewerContents()
designates the objects that will be set as
contents for the viewers. This has to conform to
getNumberOfViewers()
.
setupKeyHandler(KeyHandler)
: In this method KeyStroke
s
may be associated with previously defined Actions in the passed
KeyHandler
which is the GraphicalViewer
's one.
Adapter.notifyChanged(org.eclipse.emf.common.notify.Notification)
:
This is optional, for reacting on model change notifications. May be just an
empty method.
Nested Class Summary | |
---|---|
class |
AbstractMultiViewerPage.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. |
Nested classes/interfaces inherited from interface org.eclipse.emf.common.notify.Adapter |
---|
org.eclipse.emf.common.notify.Adapter.Internal |
Field Summary | |
---|---|
private org.eclipse.gef.ui.actions.ActionRegistry |
actionRegistry
The action registry that hold the actions for this page. |
private AbstractMultiViewerPage.MultiViewerPageViewer |
currentViewer
The viewer that is showed in the Thumbnail ,
the current ISelectionProvider for this page's
IPageSite and
providing a ZoomManager for the zoom actions via a
ZoomManagerDelegate . |
private org.eclipse.gef.EditDomain |
editDomain
The EditDomain managing this page like an encapsulated editor. |
private org.eclipse.ui.IEditorPart |
editor
The editor that requested to display the model. |
private org.eclipse.gef.ui.palette.FlyoutPaletteComposite |
flyoutPaletteComposite
The main Control of this page. |
private org.eclipse.gef.KeyHandler |
keyHandler
A shared KeyHandler for the viewers on this page. |
private org.eclipse.emf.ecore.EObject |
model
The model which is shown in the viewer. |
private SelectionProviderIntermediate |
selectionProvider
This enables this page to switch the actual selection-providing viewer |
private org.eclipse.emf.common.notify.Notifier |
target
Target field for Adapter implementation. |
private org.eclipse.draw2d.parts.ScrollableThumbnail |
thumbnail
A thumbnail showing a miniature of what the viewer contains. |
private AbstractMultiViewerPage.MultiViewerPageViewer[] |
viewers
An array of the viewers hosted by this page. |
private ZoomManagerDelegate |
zoomManagerDelegate
This subclassed ZoomManager is set for the zoom actions and the
returned by getAdapter(Class) for the
ZoomComboContributionItem created in the
ActionBarContributor . |
Constructor Summary | |
---|---|
protected |
AbstractMultiViewerPage(org.eclipse.emf.ecore.EObject model,
org.eclipse.ui.IEditorPart editor)
|
Method Summary | |
---|---|
void |
commandStackChanged(java.util.EventObject event)
If some command manipulates the model the actions are updated so that actions are not only updated if a selection change occurs. |
protected abstract void |
createActions()
To be implemented by subclasses. |
protected abstract ContextMenuProviderWithActionRegistry |
createContextMenuProvider(org.eclipse.gef.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(org.eclipse.swt.widgets.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 org.eclipse.gef.EditPartFactory |
createEditPartFactory()
Subclasses must implement to specify the EditPartFactory that
should be used by this page's GraphicalViewer s. |
private org.eclipse.swt.widgets.Composite |
createGraphicalViewerComposite()
This method creates an configures some AbstractMultiViewerPage.MultiViewerPageViewer
according to getNumberOfViewers() and adds them to a
SashForm :
For each newly created graphical viewer
the shared editDomain is set,
a shared KeyHandler (configured via
setupKeyHandler(KeyHandler) ) is set,
it is registered with the editor 's
SelectionSynchronizer ,
a shared EditPartFactory returned by
createEditPartFactory() is set,
a unique ContextMenuProviderWithActionRegistry returned by
createContextMenuProvider(EditPartViewer) ,
an object of the array getViewerContents() returns is set
as the contents of the viewers. |
protected abstract org.eclipse.gef.palette.PaletteRoot |
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()
Unhooks the model, removes viewers from the editor 's
SelectionSynchronizer and deregisters this page as
currentViewer 's ISelectionChangedListener and
deactivates the thumbnail . |
protected org.eclipse.gef.ui.actions.ActionRegistry |
getActionRegistry()
|
java.lang.Object |
getAdapter(java.lang.Class adapter)
Extended to provide zoomManagerDelegate as ZoomManager . |
org.eclipse.swt.widgets.Control |
getControl()
|
private org.eclipse.gef.EditDomain |
getEditDomain()
|
org.eclipse.ui.IEditorPart |
getEditor()
|
protected org.eclipse.gef.KeyHandler |
getKeyHandler()
|
org.eclipse.emf.ecore.EObject |
getModel()
|
abstract int |
getNumberOfViewers()
|
private org.eclipse.gef.ui.parts.SelectionSynchronizer |
getSelectionSynchronizer()
|
org.eclipse.jface.action.IStatusLineManager |
getStatusLineManager()
This can be used to display messages in this page's status line. |
org.eclipse.emf.common.notify.Notifier |
getTarget()
|
protected abstract int[] |
getThumbSashWeights()
The two values in the returned array specify how the flyout composite's space is being divided between the palette entries and the thumbnail in the palette. |
org.eclipse.jface.action.IToolBarManager |
getToolBarManager()
This can be used to add actions to this page's tool bar. |
abstract org.eclipse.emf.ecore.EObject[] |
getViewerContents()
The viewer's are arranged horizontal and will be showing these objects in the order of the returned array from left to right. |
protected AbstractMultiViewerPage.MultiViewerPageViewer[] |
getViewers()
Method to get the array of viewers if needed to implement advanced editor features. |
org.eclipse.emf.ecore.EObject |
getViewersContents(int viewerPosition)
A method to access the object which is being displayed in a specific viewer. |
void |
init(org.eclipse.ui.part.IPageSite pageSite)
Hooks into the model. |
private void |
installActions()
Creates and registers actions. |
private void |
installThumbnailInPalette()
Creates a Thumbnail on the Control of this page's
PaletteViewer . |
boolean |
isAdapterForType(java.lang.Object type)
|
protected void |
registerHandleForEditorAction(java.lang.String id)
Registers an Action as a handler for a RetargetAction. |
void |
selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent event)
If a selection change occurs in the current viewer the UpdateAction s in the ActionRegistry are being updated. |
protected void |
setCurrentViewer(AbstractMultiViewerPage.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 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. |
void |
setTarget(org.eclipse.emf.common.notify.Notifier newTarget)
|
protected abstract void |
setupKeyHandler(org.eclipse.gef.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,
org.eclipse.emf.ecore.EObject model)
A method to set a new object to be displayed in a specific viewer. |
void |
switchViewerVisibility(int viewerPosition)
This method inverts the visibility of a viewer's control and relayouts the SashForm that the visible viewers on it share 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 |
Methods inherited from interface org.eclipse.emf.common.notify.Adapter |
---|
notifyChanged |
Field Detail |
---|
private final org.eclipse.gef.ui.actions.ActionRegistry actionRegistry
private org.eclipse.gef.ui.palette.FlyoutPaletteComposite flyoutPaletteComposite
Control
of this page.
private final org.eclipse.ui.IEditorPart editor
private final AbstractMultiViewerPage.MultiViewerPageViewer[] viewers
getNumberOfViewers()
.
private AbstractMultiViewerPage.MultiViewerPageViewer currentViewer
Thumbnail
,
ISelectionProvider
for this page's
IPageSite
and
ZoomManager
for the zoom actions via a
ZoomManagerDelegate
.
setCurrentViewer(roneditor.AbstractMultiViewerPage.MultiViewerPageViewer)
private org.eclipse.draw2d.parts.ScrollableThumbnail thumbnail
private org.eclipse.gef.EditDomain editDomain
EditDomain
managing this page like an encapsulated editor.
private final org.eclipse.emf.ecore.EObject model
private org.eclipse.emf.common.notify.Notifier target
Adapter
implementation.
private final ZoomManagerDelegate zoomManagerDelegate
ZoomManager
is set for the zoom actions and the
returned by getAdapter(Class)
for the
ZoomComboContributionItem
created in the
ActionBarContributor
. It delegates to the ZoomManager
of
currentViewer
.
private final SelectionProviderIntermediate selectionProvider
private org.eclipse.gef.KeyHandler keyHandler
KeyHandler
for the viewers on this page.
Constructor Detail |
---|
protected AbstractMultiViewerPage(org.eclipse.emf.ecore.EObject model, org.eclipse.ui.IEditorPart editor)
model
- The model element to be displayed in this page's
GraphicalViewer
.editor
- The editor that requested the model to be displayed.Method Detail |
---|
public org.eclipse.emf.ecore.EObject getModel()
public void init(org.eclipse.ui.part.IPageSite pageSite)
init
in interface org.eclipse.ui.part.IPageBookViewPage
init
in class org.eclipse.ui.part.Page
private void installActions()
RetargetAction
s are set:
ZoomInAction
and ZoomOutAction
(with
zoomManagerDelegate
),
ActionFactory
,
Except for zoom, undo, and redo, these handles have to be created by
subclasses via createActions()
and with appropriate IDs.
protected abstract void createActions()
getActionRegistry()
. WorkbenchPartAction
s should get the editor (getEditor()
)
as workbench part in their constructor. RetargetAction
s you may use
registerHandleForEditorAction(String)
with a string that matches
both the RetargetAction
's and the handle's ID.
In
setCurrentViewer(roneditor.AbstractMultiViewerPage.MultiViewerPageViewer)
the currentViewer
will be set with
SelectionAction.setSelectionProvider(ISelectionProvider)
for
SelectionAction
s.
to find out which actions will be created by
default.
protected void registerHandleForEditorAction(java.lang.String id)
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
.
public void createControl(org.eclipse.swt.widgets.Composite parent)
FlyoutPaletteComposite
is created and associated with the
Preferences
of the editor
's Plugin
.
createGraphicalViewerComposite()
a composite hosting
the AbstractMultiViewerPage.MultiViewerPageViewer
s is being created and set as graphical
control for the flyoutPaletteComposite
.
Thumbnail
is being created with
installThumbnailInPalette()
.
viewers
is set with
setCurrentViewer(roneditor.AbstractMultiViewerPage.MultiViewerPageViewer)
.
installActions()
.
createControl
in interface org.eclipse.ui.part.IPage
createControl
in class org.eclipse.ui.part.Page
private org.eclipse.gef.EditDomain getEditDomain()
EditDomain
with slightly modified
selection behaviour.protected abstract org.eclipse.gef.palette.PaletteRoot createPaletteRoot()
PaletteRoot
that should
be used by this page's EditDomain
and which defines the contents
of the palette.
PaletteRoot
for the EditDomain
of this page.private void installThumbnailInPalette()
Thumbnail
on the Control
of this page's
PaletteViewer
.
getThumbSashWeights()
protected abstract int[] getThumbSashWeights()
return new int[] { Palette_Weight, Thumb_Weight };
private org.eclipse.swt.widgets.Composite createGraphicalViewerComposite()
AbstractMultiViewerPage.MultiViewerPageViewer
according to getNumberOfViewers()
and adds them to a
SashForm
:
For each newly created graphical viewer
editDomain
is set,
KeyHandler
(configured via
setupKeyHandler(KeyHandler)
) is set,
editor
's
SelectionSynchronizer
,
EditPartFactory
returned by
createEditPartFactory()
is set,
ContextMenuProviderWithActionRegistry
returned by
createContextMenuProvider(EditPartViewer)
,
getViewerContents()
returns is set
as the contents of the viewers. This depends on the viewers' position.
ZoomManager
of the viewer is configured with some zoom
levels.
SashForm
composite holding all the viewers.protected org.eclipse.gef.KeyHandler getKeyHandler()
KeyHandler
for the viewers on
this page.public abstract int getNumberOfViewers()
getViewerContents()
,
createGraphicalViewerComposite()
public abstract org.eclipse.emf.ecore.EObject[] getViewerContents()
getNumberOfViewers()
!
viewers
.setViewersContents(int, EObject)
,
createGraphicalViewerComposite()
public org.eclipse.emf.ecore.EObject getViewersContents(int viewerPosition)
viewerPosition
- the position (starting with 0) of the viewer
setViewersContents(int, EObject)
public void setViewersContents(int viewerPosition, org.eclipse.emf.ecore.EObject model)
viewerPosition
- the position (starting with 0) of the viewergetViewerContents()
public void switchViewerVisibility(int viewerPosition)
viewerPosition
- the position (starting with 0) of the viewerprotected abstract void setupKeyHandler(org.eclipse.gef.KeyHandler kh)
KeyStroke
s with Actions
in the passed KeyHandler
} which is the one used for the
GraphicalViewers
.
createGraphicalViewerComposite()
protected abstract ContextMenuProviderWithActionRegistry createContextMenuProvider(org.eclipse.gef.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 org.eclipse.gef.EditPartFactory createEditPartFactory()
EditPartFactory
that
should be used by this page's GraphicalViewer
s.
EditPartFactory
for the GraphicalViewer
s of
this page.createGraphicalViewerComposite()
private org.eclipse.gef.ui.parts.SelectionSynchronizer getSelectionSynchronizer()
editor
's SelectionSynchronizer
public void dispose()
editor
's
SelectionSynchronizer
and deregisters this page as
currentViewer
's ISelectionChangedListener
and
deactivates the thumbnail
.
dispose
in interface org.eclipse.ui.part.IPage
dispose
in class org.eclipse.ui.part.Page
public org.eclipse.swt.widgets.Control getControl()
getControl
in interface org.eclipse.ui.part.IPage
getControl
in class org.eclipse.ui.part.Page
public void setFocus()
setFocus
in interface org.eclipse.ui.part.IPage
setFocus
in class org.eclipse.ui.part.Page
public void selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent event)
UpdateAction
s in the ActionRegistry
are being updated.
selectionChanged
in interface org.eclipse.jface.viewers.ISelectionChangedListener
protected void updateActions()
UpdateAction
s registered in the
actionRegistry
.
public java.lang.Object getAdapter(java.lang.Class adapter)
zoomManagerDelegate
as ZoomManager
.
getAdapter
in interface org.eclipse.core.runtime.IAdaptable
protected org.eclipse.gef.ui.actions.ActionRegistry getActionRegistry()
public org.eclipse.ui.IEditorPart getEditor()
public boolean isAdapterForType(java.lang.Object type)
isAdapterForType
in interface org.eclipse.emf.common.notify.Adapter
public void setTarget(org.eclipse.emf.common.notify.Notifier newTarget)
setTarget
in interface org.eclipse.emf.common.notify.Adapter
public org.eclipse.emf.common.notify.Notifier getTarget()
getTarget
in interface org.eclipse.emf.common.notify.Adapter
protected void setCurrentViewer(AbstractMultiViewerPage.MultiViewerPageViewer viewer)
Thumbnail
,
ISelectionProvider
for this page's
IPageSite
and
ZoomManager
for the zoom actions the
ZoomManagerDelegate
delegates to.
SelectionAction
s by calling
#updateSelectionActionsProvider()
and registers itself as an
ISelectionChangedListener
on the new current viewer to be able to
update its UpdateAction
s
viewer
- protected AbstractMultiViewerPage.MultiViewerPageViewer[] getViewers()
To set new contents for a viewer
setViewersContents(int, EObject)
should be used!
setViewersContents(int, EObject)
public org.eclipse.jface.action.IStatusLineManager getStatusLineManager()
IStatusLineManager
from the IActionBars
of
this page's IPageSite
public org.eclipse.jface.action.IToolBarManager getToolBarManager()
IToolBarManager
from the IActionBars
of this
page's IPageSite
public void commandStackChanged(java.util.EventObject event)
commandStackChanged
in interface org.eclipse.gef.commands.CommandStackListener
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |