Package org.eclipse.gef
Class EditDomain
java.lang.Object
org.eclipse.gef.EditDomain
- Direct Known Subclasses:
DefaultEditDomain
The collective state of a GEF "application", loosely defined by a
CommandStack, one or more EditPartViewers, and the active Tool. An EditDomain
is usually tied with an Eclipse
IEditorPart
). However, the distinction between EditorPart and EditDomain was
made to allow for much flexible use of the Graphical Editing Framework.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addViewer
(EditPartViewer viewer) Adds an EditPartViewer into the EditDomain.void
focusGained
(FocusEvent event, EditPartViewer viewer) Called when one of the EditDomain's Viewers receives keyboard focus.void
focusLost
(FocusEvent event, EditPartViewer viewer) Called when one of the EditDomain's Viewers is losing keyboard focus.Returns the active ToolReturns the CommandStack.Returns the default tool for this edit domain.Returns the palette viewer currently associated with this domain.void
keyDown
(KeyEvent keyEvent, EditPartViewer viewer) Called when a key is pressed on a Viewer.void
keyTraversed
(TraverseEvent traverseEvent, EditPartViewer viewer) Called when a traversal occurs on a viewer.void
keyUp
(KeyEvent keyEvent, EditPartViewer viewer) Called when a key is released on a Viewer.void
Loads the default Tool.void
mouseDoubleClick
(MouseEvent mouseEvent, EditPartViewer viewer) Called when the mouse button has been double-clicked on a Viewer.void
mouseDown
(MouseEvent mouseEvent, EditPartViewer viewer) Called when the mouse button has been pressed on a Viewer.void
mouseDrag
(MouseEvent mouseEvent, EditPartViewer viewer) Called when the mouse has been dragged within a Viewer.void
mouseHover
(MouseEvent mouseEvent, EditPartViewer viewer) Called when the mouse has hovered on a Viewer.void
mouseMove
(MouseEvent mouseEvent, EditPartViewer viewer) Called when the mouse has been moved on a Viewer.void
mouseUp
(MouseEvent mouseEvent, EditPartViewer viewer) Called when the mouse button has been released on a Viewer.void
mouseWheelScrolled
(Event event, EditPartViewer viewer) Called by the DomainEventDispatcher when the mouse wheel has been scrolled.void
nativeDragFinished
(DragSourceEvent event, EditPartViewer viewer) Called when a native drag has finished on a Viewer.void
nativeDragStarted
(DragSourceEvent event, EditPartViewer viewer) Called when a native drag has started on a Viewer.void
removeViewer
(EditPartViewer viewer) Removes a previously added viewer from the EditDomain.void
setActiveTool
(Tool tool) Sets the active Tool for this EditDomain.void
setCommandStack
(CommandStack stack) Sets theCommandStack
.void
setDefaultTool
(Tool tool) Sets the default Tool, which is used if the Palette does not provide a defaultvoid
setPaletteRoot
(PaletteRoot root) Sets the PalatteRoot for this EditDomain.void
setPaletteViewer
(PaletteViewer palette) Sets thePaletteViewer
for this EditDomainvoid
viewerEntered
(MouseEvent mouseEvent, EditPartViewer viewer) Called when the mouse enters a Viewer.void
viewerExited
(MouseEvent mouseEvent, EditPartViewer viewer) Called when the mouse exits a Viewer.
-
Constructor Details
-
EditDomain
public EditDomain()Constructs an EditDomain and loads the default tool.
-
-
Method Details
-
addViewer
Adds an EditPartViewer into the EditDomain. A viewer is most likely placed in aWorkbenchPart
of some form, such as the IEditorPart or an IViewPart.- Parameters:
viewer
- The EditPartViewer
-
focusGained
Called when one of the EditDomain's Viewers receives keyboard focus.- Parameters:
event
- The SWT focus eventviewer
- the Viewer that received the event.
-
focusLost
Called when one of the EditDomain's Viewers is losing keyboard focus.- Parameters:
event
- The SWT focus eventviewer
- the Viewer that received the event.
-
getActiveTool
Returns the active Tool- Returns:
- the active Tool
-
getCommandStack
Returns the CommandStack. Command stacks could potentially be shared across domains depending on the application.- Returns:
- The command stack
-
getDefaultTool
Returns the default tool for this edit domain. This will be aSelectionTool
unless specifically replaced usingsetDefaultTool(Tool)
.- Returns:
- The default Tool for this domain
-
getPaletteViewer
Returns the palette viewer currently associated with this domain.- Returns:
- The current palette viewer
- Since:
- 1.0
-
keyDown
Called when a key is pressed on a Viewer.- Parameters:
keyEvent
- The SWT key eventviewer
- The source of the event.
-
keyTraversed
Called when a traversal occurs on a viewer.- Parameters:
traverseEvent
- the SWT traverse eventviewer
- the source of the event- Since:
- 3.1
-
keyUp
Called when a key is released on a Viewer.- Parameters:
keyEvent
- The SWT key eventviewer
- the source of the event.
-
loadDefaultTool
public void loadDefaultTool()Loads the default Tool. If a palette has been provided and that palette has a default, then that tool is loaded. If not, the EditDomain's default tool is loaded. By default, this is theSelectionTool
. -
mouseDoubleClick
Called when the mouse button has been double-clicked on a Viewer.- Parameters:
mouseEvent
- The SWT mouse eventviewer
- The source of the event.
-
mouseDown
Called when the mouse button has been pressed on a Viewer.- Parameters:
mouseEvent
- The SWT mouse eventviewer
- The source of the event.
-
mouseDrag
Called when the mouse has been dragged within a Viewer.- Parameters:
mouseEvent
- The SWT mouse eventviewer
- The source of the event.
-
mouseHover
Called when the mouse has hovered on a Viewer.- Parameters:
mouseEvent
- The SWT mouse eventviewer
- The source of the event.
-
mouseMove
Called when the mouse has been moved on a Viewer.- Parameters:
mouseEvent
- The SWT mouse eventviewer
- The viewer that the mouse event is over.
-
mouseUp
Called when the mouse button has been released on a Viewer.- Parameters:
mouseEvent
- The SWT mouse eventviewer
- The source of the event.
-
mouseWheelScrolled
Called by the DomainEventDispatcher when the mouse wheel has been scrolled.- Parameters:
event
- The SWT eventviewer
- The source of the event
-
nativeDragFinished
Called when a native drag has finished on a Viewer.- Parameters:
event
- The DragSourceEventviewer
- The viewer where the drag finished
-
nativeDragStarted
Called when a native drag has started on a Viewer.- Parameters:
event
- The DragSourceEventviewer
- The viewer where the drag started
-
removeViewer
Removes a previously added viewer from the EditDomain. A Viewer that is removed from the EditDomain will no longer forward input to the domain and its active Tool.- Parameters:
viewer
- the Viewer being removed
-
setCommandStack
Sets theCommandStack
.- Parameters:
stack
- the CommandStack
-
setDefaultTool
Sets the default Tool, which is used if the Palette does not provide a default- Parameters:
tool
-null
or a Tool
-
setPaletteRoot
Sets the PalatteRoot for this EditDomain. If the EditDomain already knows about a PaletteViewer, this root will be set into the palette viewer also. Loads the default Tool after the root has been set.It is recommended that the palette root not be set multiple times. Some components (such as the PaletteCustomizerDialog for the PaletteViewer) might still hold on to the old root. If the input has changed or needs to be refreshed, just remove all the children from the root and add the new ones.
- Parameters:
root
- the palette's root
-
setPaletteViewer
Sets thePaletteViewer
for this EditDomain- Parameters:
palette
- the PaletteViewer
-
setActiveTool
Sets the active Tool for this EditDomain. If a current Tool is active, it is deactivated. The new Tool is told its EditDomain, and is activated.- Parameters:
tool
- the Tool
-
viewerEntered
Called when the mouse enters a Viewer.- Parameters:
mouseEvent
- the SWT mouse eventviewer
- the Viewer being entered
-
viewerExited
Called when the mouse exits a Viewer.- Parameters:
mouseEvent
- the SWT mouse eventviewer
- the Viewer being exited
-