Class AbstractGraphicalEditPart
- All Implemented Interfaces:
IAdaptable
,EditPart
,GraphicalEditPart
,RequestConstants
- Direct Known Subclasses:
AbstractConnectionEditPart
,GraphicalRootEditPart
,SimpleRootEditPart
GraphicalEditPart
.
This is an implementation class, and the documentation here is targeted at subclassing this class. Callers of public API should refer to the interface's documentation.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected class
A default implementation ofAccessibleEditPart
.protected class
The default implementation ofAccessibleAnchorProvider
returned ingetAdapter(Class)
.Nested classes/interfaces inherited from class org.eclipse.gef.editparts.AbstractEditPart
AbstractEditPart.EditPolicyIterator
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.eclipse.draw2d.IFigure
The Figureprotected List
List of source ConnectionEditPartsprotected List
List of source ConnectionEditPartsFields inherited from class org.eclipse.gef.editparts.AbstractEditPart
children, FLAG_ACTIVE, FLAG_FOCUS, MAX_FLAG
Fields inherited from interface org.eclipse.gef.EditPart
SELECTED, SELECTED_NONE, SELECTED_PRIMARY
Fields inherited from interface org.eclipse.gef.RequestConstants
REQ_ADD, REQ_ALIGN, REQ_ALIGN_CHILDREN, REQ_CLONE, REQ_CONNECTION_END, REQ_CONNECTION_START, REQ_CREATE, REQ_CREATE_BENDPOINT, REQ_DELETE, REQ_DELETE_DEPENDANT, REQ_DIRECT_EDIT, REQ_MOVE, REQ_MOVE_BENDPOINT, REQ_MOVE_CHILDREN, REQ_OPEN, REQ_ORPHAN, REQ_ORPHAN_CHILDREN, REQ_RECONNECT_SOURCE, REQ_RECONNECT_TARGET, REQ_RESIZE, REQ_RESIZE_CHILDREN, REQ_SELECTION, REQ_SELECTION_HOVER
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
activate()
ExtendsAbstractEditPart.activate()
to also activate all source ConnectionEditParts.protected void
addChildVisual
(EditPart childEditPart, int index) Adds the child's Figure to thecontentPane
.void
addNodeListener
(NodeListener listener) Adds a NodeListener to the EditPart.void
Called after the EditPart has been added to its parent.protected void
addSourceConnection
(ConnectionEditPart connection, int index) Adds a source ConnectionEditPart at the specified index.protected void
addTargetConnection
(ConnectionEditPart connection, int index) Adds a target ConnectionEditPart at the specified index.protected ConnectionEditPart
createConnection
(Object model) Creates aConnectionEditPart
for the given model.protected abstract org.eclipse.draw2d.IFigure
Creates theFigure
to be used as this part's visuals.protected ConnectionEditPart
createOrFindConnection
(Object model) Searches for an existingConnectionEditPart
in the Viewer'sEditPart registry
and returns it if one is found.void
ExtendsAbstractEditPart.deactivate()
to also deactivate the source ConnectionEditParts.protected void
fireRemovingSourceConnection
(ConnectionEditPart connection, int index) Notifies listeners that a source connection has been removed.protected void
fireRemovingTargetConnection
(ConnectionEditPart connection, int index) Notifies listeners that a target connection has been removed.protected void
fireSourceConnectionAdded
(ConnectionEditPart connection, int index) Notifies listeners that a source connection has been added.protected void
fireTargetConnectionAdded
(ConnectionEditPart connection, int index) Notifies listeners that a target connection has been added.<T> T
getAdapter
(Class<T> key) ExtendsAbstractEditPart.getAdapter(Class)
to handle additional adapter types.org.eclipse.draw2d.IFigure
Implemented to delegate togetFigure()
by default.getDragTracker
(Request request) Overridden to return a defaultDragTracker
for GraphicalEditParts.org.eclipse.draw2d.IFigure
The default implementation callscreateFigure()
if the figure is currentlynull
.protected org.eclipse.draw2d.IFigure
A convenience method for obtaining the specified layer from theLayerManager
.protected List
Returns theList
of the connection model objects for which this EditPart's model is the source.protected List
Returns theList
of the connection model objects for which this EditPart's model is the target.Returns the source connections for this GraphicalEditPart.Returns the target connections for this GraphicalEditPart.boolean
A GraphicalEditPart is considered selectable, if it is active and its figure is showing.protected void
primAddSourceConnection
(ConnectionEditPart connection, int index) Adds the specified sourceConnectionEditPart
at an index.protected void
primAddTargetConnection
(ConnectionEditPart connection, int index) Adds the specified targetConnectionEditPart
at an index.protected void
primRemoveSourceConnection
(ConnectionEditPart connection) Removes the specified sourceConnectionEditPart
from thesourceConnections
List.protected void
primRemoveTargetConnection
(ConnectionEditPart connection) Removes the specified targetConnectionEditPart
from thetargetConnections
List.void
refresh()
ExtendsAbstractEditPart.refresh()
to refresh two additional structural features: source and target connections.protected void
Updates the set of source ConnectionEditParts so that it is in sync with the model source connections.protected void
Updates the set of target ConnectionEditParts so that it is in sync with the model target connections.protected void
Registers the EditPart's Figure in the Viewer.protected void
removeChildVisual
(EditPart childEditPart) Remove the child's Figure from thecontentPane
.void
removeNodeListener
(NodeListener listener) Removes the first occurance of the specified listener from the list of listeners.void
ExtendsAbstractEditPart.removeNotify()
to cleanupConnectionEditParts
.protected void
removeSourceConnection
(ConnectionEditPart connection) Removes the given connection for which this EditPart is the source.protected void
removeTargetConnection
(ConnectionEditPart connection) Removes the given connection for which this EditPart is the target.protected void
reorderChild
(EditPart child, int index) This method is extended to preserve a LayoutManager constraint if one exists.protected void
reorderSourceConnection
(ConnectionEditPart connection, int index) Moves a sourceConnectionEditPart
into a lower index than it currently occupies.protected void
reorderTargetConnection
(ConnectionEditPart connection, int index) Moves a targetConnectionEditPart
into a lower index than it currently occupies.protected void
setFigure
(org.eclipse.draw2d.IFigure figure) Sets the Figurevoid
setLayoutConstraint
(EditPart child, org.eclipse.draw2d.IFigure childFigure, Object constraint) Sets the specified constraint for a child's Figure on thecontent pane
figure for this GraphicalEditPart.protected void
Implemented to remove the Figure from the Viewer's registry.Methods inherited from class org.eclipse.gef.editparts.AbstractEditPart
activateEditPolicies, addChild, addEditPartListener, createChild, createEditPolicies, deactivateEditPolicies, debug, debugFeedback, eraseSourceFeedback, eraseTargetFeedback, fireActivated, fireChildAdded, fireDeactivated, fireRemovingChild, fireSelectionChanged, getAccessibleEditPart, getChildren, getCommand, getEditPolicy, getEditPolicyIterator, getEventListeners, getFlag, getModel, getModelChildren, getParent, getRoot, getSelected, getTargetEditPart, getViewer, hasFocus, installEditPolicy, isActive, performRequest, refreshChildren, refreshVisuals, register, registerAccessibility, registerModel, removeChild, removeEditPartListener, removeEditPolicy, setFlag, setFocus, setModel, setParent, setSelected, showSourceFeedback, showTargetFeedback, toString, understandsRequest, unregister, unregisterAccessibility, unregisterModel
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.eclipse.gef.EditPart
addEditPartListener, eraseSourceFeedback, eraseTargetFeedback, getChildren, getCommand, getEditPolicy, getModel, getParent, getRoot, getSelected, getTargetEditPart, getViewer, hasFocus, installEditPolicy, isActive, performRequest, removeEditPartListener, removeEditPolicy, setFocus, setModel, setParent, setSelected, showSourceFeedback, showTargetFeedback, understandsRequest
-
Field Details
-
figure
protected org.eclipse.draw2d.IFigure figureThe Figure -
sourceConnections
List of source ConnectionEditParts -
targetConnections
List of source ConnectionEditParts
-
-
Constructor Details
-
AbstractGraphicalEditPart
public AbstractGraphicalEditPart()
-
-
Method Details
-
activate
public void activate()ExtendsAbstractEditPart.activate()
to also activate all source ConnectionEditParts.- Specified by:
activate
in interfaceEditPart
- Overrides:
activate
in classAbstractEditPart
- See Also:
-
addChildVisual
Adds the child's Figure to thecontentPane
.- Specified by:
addChildVisual
in classAbstractEditPart
- Parameters:
childEditPart
- The EditPart being addedindex
- The child's position- See Also:
-
addNodeListener
Description copied from interface:GraphicalEditPart
Adds a NodeListener to the EditPart. Duplicate calls result in duplicate notification.- Specified by:
addNodeListener
in interfaceGraphicalEditPart
- Parameters:
listener
- the Listener- See Also:
-
addNotify
public void addNotify()Description copied from interface:EditPart
Called after the EditPart has been added to its parent. This is used to indicate to the EditPart that it should refresh itself for the first time.- Specified by:
addNotify
in interfaceEditPart
- Overrides:
addNotify
in classAbstractEditPart
- See Also:
-
addSourceConnection
Adds a source ConnectionEditPart at the specified index. This method is called fromrefreshSourceConnections()
. There should be no reason to call or override this method. Source connection are created as a result of overridinggetModelSourceConnections()
.primAddSourceConnection(ConnectionEditPart, int)
is called to perform the actual update of thesourceConnections
List
. The connection will have its source set tothis
.If active, this EditPart will activate the ConnectionEditPart.
Finally, all
NodeListener
s are notified of the new connection.- Parameters:
connection
- Connection being addedindex
- Index where it is being added
-
addTargetConnection
Adds a target ConnectionEditPart at the specified index. This method is called fromrefreshTargetConnections()
. There should be no reason to call or override this method. Target connection are created as a result of overridinggetModelTargetConnections()
.primAddTargetConnection(ConnectionEditPart, int)
is called to perform the actual update of thetargetConnections
List
. The connection will have its target set tothis
.Finally, all
NodeListener
s are notified of the new connection.- Parameters:
connection
- Connection being addedindex
- Index where it is being added
-
createConnection
Creates aConnectionEditPart
for the given model. Similar toAbstractEditPart.createChild(Object)
. This method is called indirectly duringrefreshSourceConnections()
, andrefreshTargetConnections()
.The default implementation goes to the EditPartViewer's
EditPartFactory
to create the connection. This method should not be overridden unless factories are not being used.- Parameters:
model
- the connection model object- Returns:
- the new ConnectionEditPart
-
createFigure
protected abstract org.eclipse.draw2d.IFigure createFigure()Creates theFigure
to be used as this part's visuals. This is called fromgetFigure()
if the figure has not been created.- Returns:
- a Figure
-
createOrFindConnection
Searches for an existingConnectionEditPart
in the Viewer'sEditPart registry
and returns it if one is found. Otherwise,createConnection(Object)
is called to create a new ConnectionEditPart. Override this method only if you need to find an existing connection some other way.- Parameters:
model
- the Connection's model- Returns:
- the ConnectionEditPart
-
deactivate
public void deactivate()ExtendsAbstractEditPart.deactivate()
to also deactivate the source ConnectionEditParts. Subclasses should extend this method to remove any listeners added inactivate()
.- Specified by:
deactivate
in interfaceEditPart
- Overrides:
deactivate
in classAbstractEditPart
- See Also:
-
fireRemovingSourceConnection
Notifies listeners that a source connection has been removed. Called fromremoveSourceConnection(ConnectionEditPart)
. There is no reason for subclasses to call or override this method.- Parameters:
connection
-ConnectionEditPart
being added as child.index
- Position child is being added into.
-
fireRemovingTargetConnection
Notifies listeners that a target connection has been removed. Called fromremoveTargetConnection(ConnectionEditPart)
. There is no reason for subclasses to call or override this method.- Parameters:
connection
-ConnectionEditPart
being added as child.index
- Position child is being added into.
-
fireSourceConnectionAdded
Notifies listeners that a source connection has been added. Called fromaddSourceConnection(ConnectionEditPart, int)
. There is no reason for subclasses to call or override this method.- Parameters:
connection
-ConnectionEditPart
being added as child.index
- Position child is being added into.
-
fireTargetConnectionAdded
Notifies listeners that a target connection has been added. Called fromaddTargetConnection(ConnectionEditPart, int)
. There is no reason for subclasses to call or override this method.- Parameters:
connection
-ConnectionEditPart
being added as child.index
- Position child is being added into.
-
getAdapter
ExtendsAbstractEditPart.getAdapter(Class)
to handle additional adapter types. Currently, these types includeAccessibleHandleProvider
andAccessibleAnchorProvider
. Subclasses should extend this method to support additional adapter types, or to replace the default provided adapters.- Specified by:
getAdapter
in interfaceIAdaptable
- Overrides:
getAdapter
in classAbstractEditPart
- See Also:
-
getContentPane
public org.eclipse.draw2d.IFigure getContentPane()Implemented to delegate togetFigure()
by default. Subclasses may overwrite in case theIFigure
returned bygetFigure()
is a composite figure and child figures should be added to one of its children instead of the figure itself.- Specified by:
getContentPane
in interfaceGraphicalEditPart
- Returns:
- the content pane Figure
- See Also:
-
getDragTracker
Overridden to return a defaultDragTracker
for GraphicalEditParts.- Specified by:
getDragTracker
in interfaceEditPart
- Parameters:
request
- aRequest
indicating the context of the drag- Returns:
null
or a DragTracker- See Also:
-
getFigure
public org.eclipse.draw2d.IFigure getFigure()The default implementation callscreateFigure()
if the figure is currentlynull
.- Specified by:
getFigure
in interfaceGraphicalEditPart
- Returns:
- this EditPart's Figure
- See Also:
-
getLayer
A convenience method for obtaining the specified layer from theLayerManager
.- Parameters:
layer
- ID of the Layer- Returns:
- The requested layer or
null
if it doesn't exist
-
getModelSourceConnections
Returns theList
of the connection model objects for which this EditPart's model is the source.refreshSourceConnections()
calls this method. For each connection model object,createConnection(Object)
will be called automatically to obtain a correspondingConnectionEditPart
.Callers must not modify the returned List.
- Returns:
- the List of model source connections
-
getModelTargetConnections
Returns theList
of the connection model objects for which this EditPart's model is the target.refreshTargetConnections()
calls this method. For each connection model object,createConnection(Object)
will be called automatically to obtain a correspondingConnectionEditPart
.Callers must not modify the returned List.
- Returns:
- the List of model target connections
-
getSourceConnections
Description copied from interface:GraphicalEditPart
Returns the source connections for this GraphicalEditPart. This method should only be called by the EditPart itself, and its helpers such as EditPolicies.- Specified by:
getSourceConnections
in interfaceGraphicalEditPart
- Returns:
- the source connections
- See Also:
-
getTargetConnections
Description copied from interface:GraphicalEditPart
Returns the target connections for this GraphicalEditPart. This method should only be called by the EditPart itself, and its helpers such as EditPolicies.- Specified by:
getTargetConnections
in interfaceGraphicalEditPart
- Returns:
- the target connections
- See Also:
-
isSelectable
public boolean isSelectable()A GraphicalEditPart is considered selectable, if it is active and its figure is showing.- Specified by:
isSelectable
in interfaceEditPart
- Overrides:
isSelectable
in classAbstractEditPart
- Returns:
true
if the receiver can be selected- See Also:
-
primAddSourceConnection
Adds the specified sourceConnectionEditPart
at an index. This method is used to update thesourceConnections
List. This method is called fromaddSourceConnection(ConnectionEditPart, int)
. Subclasses should not call or override this method.- Parameters:
connection
- the ConnectionEditPartindex
- the index of the add
-
primAddTargetConnection
Adds the specified targetConnectionEditPart
at an index. This method is used to update thetargetConnections
List. This method is called fromaddTargetConnection(ConnectionEditPart, int)
. Subclasses should not call or override this method.- Parameters:
connection
- the ConnectionEditPartindex
- the index of the add
-
primRemoveSourceConnection
Removes the specified sourceConnectionEditPart
from thesourceConnections
List. This method is called fromremoveSourceConnection(ConnectionEditPart)
. Subclasses should not call or override this method.- Parameters:
connection
- Connection to remove.
-
primRemoveTargetConnection
Removes the specified targetConnectionEditPart
from thetargetConnections
List. This method is called fromremoveTargetConnection(ConnectionEditPart)
. Subclasses should not call or override this method.- Parameters:
connection
- Connection to remove.
-
refresh
public void refresh()ExtendsAbstractEditPart.refresh()
to refresh two additional structural features: source and target connections. Subclasses should probably overrideAbstractEditPart.refreshVisuals()
instead of this method.- Specified by:
refresh
in interfaceEditPart
- Overrides:
refresh
in classAbstractEditPart
- See Also:
-
refreshSourceConnections
protected void refreshSourceConnections()Updates the set of source ConnectionEditParts so that it is in sync with the model source connections. This method is called fromrefresh()
, and may also be called in response to notification from the model.The update is performed by comparing the existing source ConnectionEditParts with the set of model source connections returned from
getModelSourceConnections()
. EditParts whose model no longer exists areremoved
. New models have their ConnectionEditPartscreated
. Subclasses should overridegetModelSourceChildren()
.This method should not be overridden.
-
refreshTargetConnections
protected void refreshTargetConnections()Updates the set of target ConnectionEditParts so that it is in sync with the model target connections. This method is called fromrefresh()
, and may also be called in response to notification from the model.The update is performed by comparing the existing source ConnectionEditParts with the set of model source connections returned from
getModelTargetConnections()
. EditParts whose model no longer exists areremoved
. New models have their ConnectionEditPartscreated
. Subclasses should overridegetModelTargetChildren()
.This method should not be overridden.
-
registerVisuals
protected void registerVisuals()Registers the EditPart's Figure in the Viewer. This is what makes it possible for the Viewer to map a mouse location to an EditPart.- Overrides:
registerVisuals
in classAbstractEditPart
- See Also:
-
removeChildVisual
Remove the child's Figure from thecontentPane
.- Specified by:
removeChildVisual
in classAbstractEditPart
- Parameters:
childEditPart
- the child EditPart- See Also:
-
removeNodeListener
Description copied from interface:GraphicalEditPart
Removes the first occurance of the specified listener from the list of listeners. Does nothing if the listener was not present.- Specified by:
removeNodeListener
in interfaceGraphicalEditPart
- Parameters:
listener
- the listener being removed- See Also:
-
removeNotify
public void removeNotify()ExtendsAbstractEditPart.removeNotify()
to cleanupConnectionEditParts
.- Specified by:
removeNotify
in interfaceEditPart
- Overrides:
removeNotify
in classAbstractEditPart
- See Also:
-
removeSourceConnection
Removes the given connection for which this EditPart is the source.
Fires notification.
Inverse ofaddSourceConnection(ConnectionEditPart, int)
- Parameters:
connection
- Connection being removed
-
removeTargetConnection
Removes the given connection for which this EditPart is the target.
Fires notification.
Inverse ofaddTargetConnection(ConnectionEditPart, int)
- Parameters:
connection
- Connection being removed
-
reorderChild
This method is extended to preserve a LayoutManager constraint if one exists.- Overrides:
reorderChild
in classAbstractEditPart
- Parameters:
child
- the child being reorderedindex
- new index for the child- See Also:
-
reorderSourceConnection
Moves a sourceConnectionEditPart
into a lower index than it currently occupies. This method is called fromrefreshSourceConnections()
.- Parameters:
connection
- the ConnectionEditPartindex
- the new index
-
reorderTargetConnection
Moves a targetConnectionEditPart
into a lower index than it currently occupies. This method is called fromrefreshTargetConnections()
.- Parameters:
connection
- the ConnectionEditPartindex
- the new index
-
setFigure
protected void setFigure(org.eclipse.draw2d.IFigure figure) Sets the Figure- Parameters:
figure
- the Figure
-
setLayoutConstraint
public void setLayoutConstraint(EditPart child, org.eclipse.draw2d.IFigure childFigure, Object constraint) Description copied from interface:GraphicalEditPart
Sets the specified constraint for a child's Figure on thecontent pane
figure for this GraphicalEditPart. The constraint will be applied to the content pane'sLayoutManager
.revalidate()
is called on the content pane, which will cause it to layout during the next update.- Specified by:
setLayoutConstraint
in interfaceGraphicalEditPart
- Parameters:
child
- the child GraphicalEditPart whose constraint is being setchildFigure
- the Figure whose constraint is being setconstraint
- the constraint for the draw2dLayoutManager
- See Also:
-
unregisterVisuals
protected void unregisterVisuals()Implemented to remove the Figure from the Viewer's registry.- Overrides:
unregisterVisuals
in classAbstractEditPart
- See Also:
-