Class AbstractEditPartViewer
- All Implemented Interfaces:
EditPartViewer
,ISelectionProvider
- Direct Known Subclasses:
GraphicalViewerImpl
,TreeViewer
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.eclipse.gef.EditPartViewer
EditPartViewer.Conditional
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Provided for compatibility with existing code.void
Adds aTransferDragSourceListener
to this viewer.void
Provided for compatibility with existing code.void
Adds aTransferDropTargetListener
to this viewer.void
Adds a listener to be notified of viewer property changes.void
void
appendSelection
(EditPart editpart) Appends the specifiedEditPart
to the viewer's selection.abstract Control
createControl
(Composite parent) Optionally creates the defaultControl
using the default style.void
Removes the specifiedEditPart
from the current selection.void
Deselects all EditParts.final EditPart
findObjectAt
(org.eclipse.draw2d.geometry.Point pt) Returnsnull
or theEditPart
associated with the specified location.final EditPart
findObjectAtExcluding
(org.eclipse.draw2d.geometry.Point pt, Collection exclude) Returnsnull
or theEditPart
at the specified location, excluding the specified set.protected void
Fires selection changed to the registered listeners at the time called.void
flush()
Flushes all pending updates to the Viewer.Returns the contents of this Viewer.Returnsnull
or the MenuManager for this viewer.Returnsnull
or the SWTControl
for this viewer.protected DelegatingDragAdapter
Returnsnull
or the DelegatingDragAdapater.protected DelegatingDropAdapter
Returnsnull
or the DelegatingDropAdapater.protected DragSource
Returnsnull
or the DragSource.protected DropTarget
Returnsnull
or the DropTarget.Returns theEditDomain
to which this viewer belongs.Returns theEditPartFactory
for this viewer.Returns theMap
for registeringEditParts
by Keys.Returns the focusEditPart
.Returns theKeyHandler
for this viewer.getProperty
(String key) Returns the value of the given property.Returnsnull
, or the ResourceManager for this Viewer.Returns theRootEditPart
.Returns an unmodifiableList
containing zero or more selected editparts.Returns an ISelection containing a list of one or more EditPart.Returns the viewer's selection manager.Returns theMap
for associating visual parts with theirEditParts
.protected void
Called if and when theControl
is disposed.protected void
Called once the control has been set.protected void
Called whenever thedrag source
is automatically created.protected void
Called whenever thedrop target
is automatically created.protected void
init()
Called from the constructor.protected List
Returns the modifiable List of selected EditParts.protected void
Creates or disposes a DragSource as needed, and sets the supported transfer types.protected void
Creates or disposes a DropTarget as needed, and sets the supported transfer types.void
Used for accessibility purposes.void
Deprecated.void
Removes the specified drag source listener.void
Deprecated.void
Removes the specified drop target listener.void
removes the first instance of the specified property listener.void
void
Reveals the given EditPart if it is not visible.void
Replaces the current selection with the specifiedEditPart
.void
setContents
(Object contents) Creates anEditPart
for the provided model object using theEditPartFactory
.void
setContents
(EditPart editpart) Sets the contents for this Viewer.void
setContextMenu
(MenuManager manager) Sets the contextMenuManager
for this viewer.void
setControl
(Control control) Sets theControl
for this viewer.void
Sets the cursor for the viewer'sControl
.protected void
setDragSource
(DragSource source) Sets the drag source.protected void
setDropTarget
(DropTarget target) Sets the drop target.void
setEditDomain
(EditDomain editdomain) Sets theEditDomain
for this viewer.void
setEditPartFactory
(EditPartFactory factory) Sets the EditPartFactory.void
Sets the focus EditPart.void
setKeyHandler
(KeyHandler handler) Sets theKeyHandler
.void
setProperty
(String key, Object value) Sets a property on this viewer.void
setRootEditPart
(RootEditPart editpart) Sets the root of this viewer.void
setRouteEventsToEditDomain
(boolean value) Turns on/off the routing of events directly to the Editor.void
setSelection
(ISelection newSelection) Sets the selection to the given selection and fires selection changed.void
Sets the selection manager for this viewer.protected void
Called when the control is being set tonull
, but before it is null.void
Does nothing by default.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.eclipse.gef.EditPartViewer
findObjectAtExcluding
-
Field Details
-
selection
The raw list of selected editparts. -
constantSelection
The unmodifiable list of selected editparts. -
selectionListeners
Deprecated.The list of selection listeners. -
focusPart
Deprecated.The editpart specifically set to have focus. Note that if this value isnull
, the focus editpart is still implied to be the part with primary selection. Subclasses should call the accessor:getFocusEditPart()
whenever possible.
-
-
Constructor Details
-
AbstractEditPartViewer
public AbstractEditPartViewer()Constructs the viewer and callsinit()
.
-
-
Method Details
-
setSelectionManager
Description copied from interface:EditPartViewer
Sets the selection manager for this viewer.- Specified by:
setSelectionManager
in interfaceEditPartViewer
- Parameters:
model
- the new selection manager- See Also:
-
addDragSourceListener
Description copied from interface:EditPartViewer
Provided for compatibility with existing code.- Specified by:
addDragSourceListener
in interfaceEditPartViewer
- Parameters:
listener
- a drag source listener- See Also:
-
addDragSourceListener
Description copied from interface:EditPartViewer
Adds aTransferDragSourceListener
to this viewer. This has the side-effect of creating aDragSource
on the viewer's Control. A Control can only have a single DragSource. Clients must not create their own DragSource when using this method.- Specified by:
addDragSourceListener
in interfaceEditPartViewer
- Parameters:
listener
- the listener- See Also:
-
addDropTargetListener
Description copied from interface:EditPartViewer
Provided for compatibility with existing code.- Specified by:
addDropTargetListener
in interfaceEditPartViewer
- Parameters:
listener
- the listener- See Also:
-
addDropTargetListener
Description copied from interface:EditPartViewer
Adds aTransferDropTargetListener
to this viewer. This has the side-effect of creating aDropTarget
on the viewer's Control. A Control can only have a single DropTarget. Clients must not create their own DropTarget when using this method.- Specified by:
addDropTargetListener
in interfaceEditPartViewer
- Parameters:
listener
- the listener- See Also:
-
addPropertyChangeListener
Description copied from interface:EditPartViewer
Adds a listener to be notified of viewer property changes.- Specified by:
addPropertyChangeListener
in interfaceEditPartViewer
- Parameters:
listener
- the listener- See Also:
-
addSelectionChangedListener
- Specified by:
addSelectionChangedListener
in interfaceISelectionProvider
- See Also:
-
appendSelection
Description copied from interface:EditPartViewer
Appends the specifiedEditPart
to the viewer's selection. The EditPart becomes the new primary selection. Fires selection changed to allISelectionChangedListener
s.- Specified by:
appendSelection
in interfaceEditPartViewer
- Parameters:
editpart
- the EditPart to append- See Also:
-
createControl
Description copied from interface:EditPartViewer
Optionally creates the defaultControl
using the default style. The Control can also be created externally and then set into the Viewer.- Specified by:
createControl
in interfaceEditPartViewer
- Parameters:
parent
- the parent in which create the SWTControl
- Returns:
- the created Control for convenience
- See Also:
-
deselect
Description copied from interface:EditPartViewer
Removes the specifiedEditPart
from the current selection. If the selection becomes empty, the viewer'scontents
becomes the current selected part. The last EditPart in the new selection is madeprimary
.Fires selection changed to
ISelectionChangedListener
s.- Specified by:
deselect
in interfaceEditPartViewer
- Parameters:
editpart
- theEditPart
to deselect- See Also:
-
deselectAll
public void deselectAll()Description copied from interface:EditPartViewer
Deselects all EditParts. The viewer'scontents
becomes the current selection. Fires selection changed toISelectionChangedListener
s.- Specified by:
deselectAll
in interfaceEditPartViewer
- See Also:
-
handleDispose
Called if and when theControl
is disposed. Subclasses may extend this method to perform additional cleanup.- Parameters:
e
- the disposeevent
-
findObjectAt
Description copied from interface:EditPartViewer
Returnsnull
or theEditPart
associated with the specified location. The location is relative to the client area of the Viewer'sControl
. An EditPart is not directly visible. It is targeted using its visual part which it registered using thevisual part map
. What constitutes a visual part is viewer-specific. Examples include Figures and TreeItems.- Specified by:
findObjectAt
in interfaceEditPartViewer
- Parameters:
pt
- The location- Returns:
null
or an EditPart- See Also:
-
findObjectAtExcluding
public final EditPart findObjectAtExcluding(org.eclipse.draw2d.geometry.Point pt, Collection exclude) Description copied from interface:EditPartViewer
Returnsnull
or theEditPart
at the specified location, excluding the specified set. This method behaves similarly toEditPartViewer.findObjectAt(Point)
.- Specified by:
findObjectAtExcluding
in interfaceEditPartViewer
- Parameters:
pt
- The mouse locationexclude
- The set of EditParts to be excluded- Returns:
null
or an EditPart- See Also:
-
fireSelectionChanged
protected void fireSelectionChanged()Fires selection changed to the registered listeners at the time called. -
flush
public void flush()Description copied from interface:EditPartViewer
Flushes all pending updates to the Viewer.- Specified by:
flush
in interfaceEditPartViewer
- See Also:
-
getContextMenu
Description copied from interface:EditPartViewer
Returnsnull
or the MenuManager for this viewer. The menu manager is set usingEditPartViewer.setContextMenu(MenuManager)
.- Specified by:
getContextMenu
in interfaceEditPartViewer
- Returns:
null
or a MenuManager- See Also:
-
getContents
Description copied from interface:EditPartViewer
Returns the contents of this Viewer. The contents is the EditPart associated with the top-level model object. It is considered to be "The Diagram". If the user has nothing selected, the contents is implicitly the selected object.The Root of the Viewer is different. By constrast, the root is never selected or targeted, and does not correspond to something in the model.
- Specified by:
getContents
in interfaceEditPartViewer
- Returns:
- the contents
EditPart
- See Also:
-
getControl
Description copied from interface:EditPartViewer
Returnsnull
or the SWTControl
for this viewer. The control is either set explicitly or can be created by the viewer.- Specified by:
getControl
in interfaceEditPartViewer
- Returns:
- the SWT
Control
- See Also:
-
getDelegatingDragAdapter
Returnsnull
or the DelegatingDragAdapater. The adapter is created automatically whenaddDragSourceListener(TransferDragSourceListener)
is called.- Returns:
null
or the adapter
-
getDelegatingDropAdapter
Returnsnull
or the DelegatingDropAdapater. The adapter is created automatically whenaddDropTargetListener(TransferDropTargetListener)
is called.- Returns:
null
or the adapter
-
getDragSource
Returnsnull
or the DragSource. The drag source is created automatically whenaddDragSourceListener(TransferDragSourceListener)
is called.- Returns:
null
or the drag source
-
getDropTarget
Returnsnull
or the DropTarget. The drop target is created automatically whenaddDropTargetListener(TransferDropTargetListener)
is called.- Returns:
null
or the drop target
-
getEditDomain
Description copied from interface:EditPartViewer
Returns theEditDomain
to which this viewer belongs.- Specified by:
getEditDomain
in interfaceEditPartViewer
- Returns:
- the viewer's EditDomain
- See Also:
-
getEditPartFactory
Description copied from interface:EditPartViewer
Returns theEditPartFactory
for this viewer. The EditPartFactory is used to create the contents EditPart whenEditPartViewer.setContents(Object)
is called. It is made available so that other EditParts can use it to create their children or connection editparts.- Specified by:
getEditPartFactory
in interfaceEditPartViewer
- Returns:
- EditPartFactory
- See Also:
-
getEditPartRegistry
Description copied from interface:EditPartViewer
Returns theMap
for registeringEditParts
by Keys. EditParts may register themselves using any method, and may register themselves with multiple keys. The purpose of such registration is to allow an EditPart to be found by other EditParts, or by listeners of domain notifiers. By default, EditParts are registered by their model.Some models use a "domain" notification system, in which all changes are dispatched to a single listener. Such a listener might use this map to lookup editparts for a given model, and then ask the editpart to update.
- Specified by:
getEditPartRegistry
in interfaceEditPartViewer
- Returns:
- the registry map
- See Also:
-
getFocusEditPart
Description copied from interface:EditPartViewer
Returns the focusEditPart
. Focus refers to keyboard focus. This is the same concept as focus in a native Tree or Table. The User can change focus using the keyboard without affecting the currently selected objects. Never returnsnull
.- Specified by:
getFocusEditPart
in interfaceEditPartViewer
- Returns:
- the focus
EditPart
- See Also:
-
getKeyHandler
Description copied from interface:EditPartViewer
Returns theKeyHandler
for this viewer. The KeyHandler is sent KeyEvents by the currently activeTool
. This is important, because only the current tool knows if it is in a state in which keys should be ignored, such as during a drag. By default, only theSelectionTool
forwards keysrokes. It does not do so during a drag.- Specified by:
getKeyHandler
in interfaceEditPartViewer
- Returns:
null
or a KeyHandler- See Also:
-
getProperty
Description copied from interface:EditPartViewer
Returns the value of the given property. Returnsnull
if the property has not been set, or has been set to null.- Specified by:
getProperty
in interfaceEditPartViewer
- Parameters:
key
- the property's key- Returns:
- the given properties value or
null
. - See Also:
-
getResourceManager
Description copied from interface:EditPartViewer
Returnsnull
, or the ResourceManager for this Viewer. Once a viewer has a Control, clients may access the viewer's resource manager. Any resources constructed using this manager, but not freed, will be freed when the viewer's control is disposed. This does not mean that clients should be lazy about deallocating resources. If a resource is no longer needed but the viewer is still in use, the client must deallocate the resource.Typical usage is by EditParts contained inside the viewer. EditParts which are removed from the viewer should free their resources during
EditPart.removeNotify()
. When the viewer is disposed,removeNotify()
is not called, but the viewer's resource manager will be disposed anyway.The viewer's default resource manager is linked to JFace's
global shared resources
.- Specified by:
getResourceManager
in interfaceEditPartViewer
- Returns:
- the ResourceManager associated with this viewer
- See Also:
-
getRootEditPart
Description copied from interface:EditPartViewer
Returns theRootEditPart
. The RootEditPart is a special EditPart that serves as the parent to the contents editpart. The root is never selected. The root does not correspond to anything in the model. The User does not interact with the root.The RootEditPart has a single child: the
contents
.By defining the concept of "root", GEF allows the application's "real" EditParts to be more homogeneous. For example, all non-root EditParts have a parent. Also, it allows applications to change the type of root being used without affecting their own editpart implementation hierarchy.
- Specified by:
getRootEditPart
in interfaceEditPartViewer
- Returns:
- the RootEditPart
- See Also:
-
getSelectedEditParts
Description copied from interface:EditPartViewer
Returns an unmodifiableList
containing zero or more selected editparts. This list may be empty. In contrast, the inherited methodISelectionProvider.getSelection()
should not return an empty selection. When no editparts are selected, generally the contents editpart is considered to be selected. This list can be modified indirectly by calling other methods on the viewer.- Specified by:
getSelectedEditParts
in interfaceEditPartViewer
- Returns:
- a list containing zero or more editparts
- See Also:
-
getSelection
Returns an ISelection containing a list of one or more EditPart. WhenevergetSelectedEditParts()
returns an empty list, the contents editpart (getContents()
) is returned as the current selection.- Specified by:
getSelection
in interfaceEditPartViewer
- Specified by:
getSelection
in interfaceISelectionProvider
- See Also:
-
getSelectionManager
Description copied from interface:EditPartViewer
Returns the viewer's selection manager. The selection manager has complete control over the viewer's representation of selection. It provides theISelection
for the viewer, and manages all changes to the current selection.- Specified by:
getSelectionManager
in interfaceEditPartViewer
- Returns:
- the selection manager
- See Also:
-
getVisualPartMap
Description copied from interface:EditPartViewer
Returns theMap
for associating visual parts with theirEditParts
. This map is used for hit-testing. Hit testing is performed by first determining which visual part is hit, and then mapping that part to anEditPart
. What consistutes a visual part is viewer-specific. Examples includeFigures
andTreeItems
.- Specified by:
getVisualPartMap
in interfaceEditPartViewer
- Returns:
- the visual part map
- See Also:
-
hookControl
protected void hookControl()Called once the control has been set.- See Also:
-
hookDragSource
protected void hookDragSource()Called whenever thedrag source
is automatically created. -
hookDropTarget
protected void hookDropTarget()Called whenever thedrop target
is automatically created. -
init
protected void init()Called from the constructor. Subclasses may extend this method. -
primGetSelectedEditParts
Returns the modifiable List of selected EditParts.- Returns:
- the internal list of selected editparts
-
refreshDragSourceAdapter
protected void refreshDragSourceAdapter()Creates or disposes a DragSource as needed, and sets the supported transfer types. Clients should not need to call or override this method. -
refreshDropTargetAdapter
protected void refreshDropTargetAdapter()Creates or disposes a DropTarget as needed, and sets the supported transfer types. Clients should not need to call or override this method. -
registerAccessibleEditPart
Description copied from interface:EditPartViewer
Used for accessibility purposes.- Specified by:
registerAccessibleEditPart
in interfaceEditPartViewer
- Parameters:
acc
- the AccessibleEditPart- See Also:
-
removeDragSourceListener
Deprecated.Description copied from interface:EditPartViewer
Removes the specified drag source listener. If all listeners are removed, the DragSource that was created will be disposed.- Specified by:
removeDragSourceListener
in interfaceEditPartViewer
- Parameters:
listener
- the listener- See Also:
-
removeDragSourceListener
Description copied from interface:EditPartViewer
Removes the specified drag source listener. If all listeners are removed, the DragSource that was created will be disposed.- Specified by:
removeDragSourceListener
in interfaceEditPartViewer
- Parameters:
listener
- the listener- See Also:
-
removeDropTargetListener
Deprecated.Description copied from interface:EditPartViewer
Removes the specified drop target listener. If all listeners are removed, the DropTarget that was created will be disposed.- Specified by:
removeDropTargetListener
in interfaceEditPartViewer
- See Also:
-
removeDropTargetListener
Description copied from interface:EditPartViewer
Removes the specified drop target listener. If all listeners are removed, the DropTarget that was created will be disposed.- Specified by:
removeDropTargetListener
in interfaceEditPartViewer
- Parameters:
listener
- the listener- See Also:
-
removePropertyChangeListener
Description copied from interface:EditPartViewer
removes the first instance of the specified property listener.- Specified by:
removePropertyChangeListener
in interfaceEditPartViewer
- Parameters:
listener
- the listener to remove- See Also:
-
removeSelectionChangedListener
- Specified by:
removeSelectionChangedListener
in interfaceISelectionProvider
- See Also:
-
reveal
Description copied from interface:EditPartViewer
Reveals the given EditPart if it is not visible.- Specified by:
reveal
in interfaceEditPartViewer
- Parameters:
part
- the EditPart to reveal- See Also:
-
select
Description copied from interface:EditPartViewer
Replaces the current selection with the specifiedEditPart
. That part becomes the primary selection. Fires selection changed toISelectionChangedListener
s.- Specified by:
select
in interfaceEditPartViewer
- Parameters:
editpart
- the new selection- See Also:
-
setContextMenu
Description copied from interface:EditPartViewer
Sets the contextMenuManager
for this viewer. The MenuManager will be asked to create a Menu, which will be used as the context menu for this viewer's Control.- Specified by:
setContextMenu
in interfaceEditPartViewer
- Parameters:
manager
- theContextMenuProvider
- See Also:
-
setContents
Description copied from interface:EditPartViewer
Sets the contents for this Viewer. The contents can also be set usingEditPartViewer.setContents(Object)
.- Specified by:
setContents
in interfaceEditPartViewer
- Parameters:
editpart
- the contents- See Also:
-
setContents
Description copied from interface:EditPartViewer
Creates anEditPart
for the provided model object using theEditPartFactory
. That EditPart is then added to theRootEditPart
, and becomes the viewer's contents editpart.- Specified by:
setContents
in interfaceEditPartViewer
- Parameters:
contents
- the contents model object- See Also:
-
setControl
Description copied from interface:EditPartViewer
Sets theControl
for this viewer. The viewer's control is also set automatically ifEditPartViewer.createControl(Composite)
is called.- Specified by:
setControl
in interfaceEditPartViewer
- Parameters:
control
- the Control- See Also:
-
setCursor
Description copied from interface:EditPartViewer
Sets the cursor for the viewer'sControl
. This method should only be called byTools
.null
can be used to indicate that the default cursor should be restored.- Specified by:
setCursor
in interfaceEditPartViewer
- Parameters:
cursor
-null
or a Cursor- See Also:
-
setDragSource
Sets the drag source. Called fromrefreshDragSourceAdapter()
.- Parameters:
source
-null
or a drag source
-
setDropTarget
Sets the drop target. Called fromrefreshDropTargetAdapter()
.- Parameters:
target
- dropTargetnull
or a drop target
-
setEditDomain
Description copied from interface:EditPartViewer
Sets theEditDomain
for this viewer. The Viewer will route all mouse and keyboard events to the EditDomain.- Specified by:
setEditDomain
in interfaceEditPartViewer
- Parameters:
editdomain
- The EditDomain- See Also:
-
setEditPartFactory
Description copied from interface:EditPartViewer
Sets the EditPartFactory.- Specified by:
setEditPartFactory
in interfaceEditPartViewer
- Parameters:
factory
- the factory- See Also:
-
setFocus
Description copied from interface:EditPartViewer
Sets the focus EditPart.- Specified by:
setFocus
in interfaceEditPartViewer
- Parameters:
part
- the FocusPart.- See Also:
-
setKeyHandler
Description copied from interface:EditPartViewer
Sets theKeyHandler
.- Specified by:
setKeyHandler
in interfaceEditPartViewer
- Parameters:
handler
- the KeyHandler- See Also:
-
setProperty
Description copied from interface:EditPartViewer
Sets a property on this viewer. A viewer property is an arbitrary key-value pair that can be observed viaEditPartViewer.addPropertyChangeListener(PropertyChangeListener)
. Anull
value will remove the property from the viewer.- Specified by:
setProperty
in interfaceEditPartViewer
- Parameters:
key
- a unique string identifying the propertyvalue
- the properties new value ornull
to remove- See Also:
-
setRootEditPart
Description copied from interface:EditPartViewer
Sets the root of this viewer. The root should not be confused with the contents.- Specified by:
setRootEditPart
in interfaceEditPartViewer
- Parameters:
editpart
- the RootEditPart- See Also:
-
setRouteEventsToEditDomain
public void setRouteEventsToEditDomain(boolean value) Description copied from interface:EditPartViewer
Turns on/off the routing of events directly to the Editor. If supported by the viewer implementation, all Events should be routed to theEditDomain
rather than handled in the default way.- Specified by:
setRouteEventsToEditDomain
in interfaceEditPartViewer
- Parameters:
value
- true if the viewer should route events to the EditDomain- See Also:
-
setSelection
Sets the selection to the given selection and fires selection changed. The ISelection should be anIStructuredSelection
or it will be ignored.- Specified by:
setSelection
in interfaceISelectionProvider
- See Also:
-
unhookControl
protected void unhookControl()Called when the control is being set tonull
, but before it is null. -
unregisterAccessibleEditPart
Does nothing by default. Subclasses needing to add accessibility support should override this method.- Specified by:
unregisterAccessibleEditPart
in interfaceEditPartViewer
- Parameters:
acc
- the accessible part- See Also:
-