|
 |
|
|
org.eclipse.gef.editparts
Class AbstractGraphicalEditPart
java.lang.Object
org.eclipse.gef.editparts.AbstractEditPart
org.eclipse.gef.editparts.AbstractGraphicalEditPart
-
All Implemented Interfaces:
-
EditPart,
GraphicalEditPart,
RequestConstants
-
Direct Known Subclasses:
-
AbstractConnectionEditPart,
GraphicalRootEditPart,
SimpleRootEditPart
- public abstract class AbstractGraphicalEditPart
- extends
AbstractEditPart
- implements
GraphicalEditPart
Default implementation for
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.
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
|
Method Summary
|
void
|
activate
()
Extends
AbstractEditPart.activate() to also activate all source
ConnectionEditParts. |
protected void
|
addChildVisual
(
EditPart childEditPart,
int index)
Adds the child's Figure to the
contentPane . |
void
|
addNodeListener
(
NodeListener listener)
Adds a NodeListener to the EditPart. |
void
|
addNotify
()
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
(java.lang.Object model)
Creates a
ConnectionEditPart for the given
model. |
protected abstract
IFigure
|
createFigure
()
Creates the Figure to be used as this part's visuals. |
protected
ConnectionEditPart
|
createOrFindConnection
(java.lang.Object model)
Searches for an existing
ConnectionEditPart in the Viewer's
EditPart registry and returns it if one is found.
|
void
|
deactivate
()
Extends
AbstractEditPart.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. |
java.lang.Object
|
getAdapter
(java.lang.Class key)
Extends
AbstractEditPart.getAdapter(Class) to handle additional adapter types.
|
IFigure
|
getContentPane
()
If the children's Figures should be |
DragTracker
|
getDragTracker
(
Request request)
Overridden to return a default DragTracker for GraphicalEditParts. |
IFigure
|
getFigure
()
The default implementation calls
createFigure() if the figure is currently
null . |
protected
IFigure
|
getLayer
(java.lang.Object layer)
A convenience method for obtaining the specified layer from the
LayerManager . |
protected java.util.List
|
getModelSourceConnections
()
Returns the List of the connection
model objects for which this EditPart's model is the source. |
protected java.util.List
|
getModelTargetConnections
()
Returns the List of the connection
model objects for which this EditPart's model is the target. |
java.util.List
|
getSourceConnections
()
Returns the source connections for this GraphicalEditPart. |
java.util.List
|
getTargetConnections
()
Returns the target connections for this GraphicalEditPart. |
protected void
|
primAddSourceConnection
(
ConnectionEditPart connection,
int index)
Adds the specified source ConnectionEditPart at an index. |
protected void
|
primAddTargetConnection
(
ConnectionEditPart connection,
int index)
Adds the specified target ConnectionEditPart at an index. |
protected void
|
primRemoveSourceConnection
(
ConnectionEditPart connection)
Removes the specified source ConnectionEditPart from the
sourceConnections List. |
protected void
|
primRemoveTargetConnection
(
ConnectionEditPart connection)
Removes the specified target ConnectionEditPart from the
targetConnections List. |
void
|
refresh
()
Extends
AbstractEditPart.refresh() to refresh two additional structural
features: source and target connections. |
protected void
|
refreshSourceConnections
()
Updates the set of source
ConnectionEditParts so that it is in sync with the model source connections. |
protected void
|
refreshTargetConnections
()
Updates the set of target
ConnectionEditParts so that it is in sync with the model target connections. |
protected void
|
registerVisuals
()
Registers the EditPart's Figure in the Viewer. |
protected void
|
removeChildVisual
(
EditPart childEditPart)
Remove the child's Figure from the
contentPane . |
void
|
removeNodeListener
(
NodeListener listener)
Removes the first occurance of the specified listener from the list of listeners. |
void
|
removeNotify
()
Extends
AbstractEditPart.removeNotify() to cleanup
ConnectionEditParts . |
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 source ConnectionEditPart into a lower index than it currently
occupies. |
protected void
|
reorderTargetConnection
(
ConnectionEditPart connection,
int index)
Moves a target ConnectionEditPart into a lower index than it currently
occupies. |
protected void
|
setFigure
(
IFigure figure)
Sets the Figure |
void
|
setLayoutConstraint
(
EditPart child,
IFigure childFigure,
java.lang.Object constraint)
Sets the specified constraint for a child's Figure on the
content pane figure for this GraphicalEditPart. |
protected void
|
unregisterVisuals
()
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,
isSelectable,
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,
isSelectable,
performRequest,
removeEditPartListener,
removeEditPolicy,
setFocus,
setModel,
setParent,
setSelected,
showSourceFeedback,
showTargetFeedback,
understandsRequest
|
figure
protected
IFigure figure
- The Figure
sourceConnections
protected java.util.List sourceConnections
- List of source ConnectionEditParts
targetConnections
protected java.util.List targetConnections
- List of source ConnectionEditParts
AbstractGraphicalEditPart
public AbstractGraphicalEditPart()
activate
public void activate()
- Extends
AbstractEditPart.activate() to also activate all source
ConnectionEditParts.
-
-
Specified by:
-
activate
in interface
EditPart
-
Overrides:
-
activate
in class
AbstractEditPart
-
-
See Also:
-
EditPart.activate()
addChildVisual
protected void addChildVisual(
EditPart childEditPart,
int index)
- Adds the child's Figure to the
contentPane .
-
-
Specified by:
-
addChildVisual
in class
AbstractEditPart
-
-
Parameters:
-
childEditPart - The EditPart being added -
index - The child's position -
See Also:
-
AbstractEditPart.addChildVisual(EditPart, int)
addNodeListener
public void addNodeListener(
NodeListener listener)
-
Description copied from interface:
GraphicalEditPart
- Adds a NodeListener to the EditPart. Duplicate calls result in duplicate notification.
-
-
Specified by:
-
addNodeListener
in interface
GraphicalEditPart
-
-
Parameters:
-
listener - the Listener -
See Also:
-
GraphicalEditPart.addNodeListener(org.eclipse.gef.NodeListener)
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 interface
EditPart
-
Overrides:
-
addNotify
in class
AbstractEditPart
-
-
See Also:
-
EditPart.addNotify()
addSourceConnection
protected void addSourceConnection(
ConnectionEditPart connection,
int index)
- Adds a source ConnectionEditPart at the specified index. This method is called
from
refreshSourceConnections() . There should be no reason to call or override
this method. Source connection are created as a result of overriding
getModelSourceConnections() .
primAddSourceConnection(ConnectionEditPart, int) is called to perform the
actual update of the
sourceConnections List . The connection will
have its source set to this .
If active, this EditPart will activate the ConnectionEditPart.
Finally, all
NodeListener s are notified of the new connection.
-
-
-
Parameters:
-
connection - Connection being added -
index - Index where it is being added
addTargetConnection
protected void addTargetConnection(
ConnectionEditPart connection,
int index)
- Adds a target ConnectionEditPart at the specified index. This method is called
from
refreshTargetConnections() . There should be no reason to call or override
this method. Target connection are created as a result of overriding
getModelTargetConnections() .
primAddTargetConnection(ConnectionEditPart, int) is called to perform the
actual update of the
targetConnections List . The connection will
have its target set to this .
Finally, all
NodeListener s are notified of the new connection.
-
-
-
Parameters:
-
connection - Connection being added -
index - Index where it is being added
createConnection
protected
ConnectionEditPart createConnection(java.lang.Object model)
- Creates a
ConnectionEditPart for the given
model. Similar to
AbstractEditPart.createChild(Object) . This method is called
indirectly during
refreshSourceConnections() , and
refreshTargetConnections() .
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
IFigure createFigure()
- Creates the
Figure to be used as this part's visuals. This is
called from
getFigure() if the figure has not been created.
-
-
-
Returns:
- a Figure
createOrFindConnection
protected
ConnectionEditPart createOrFindConnection(java.lang.Object model)
- Searches for an existing
ConnectionEditPart in the Viewer's
EditPart 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()
- Extends
AbstractEditPart.deactivate() to
also deactivate the source ConnectionEditParts. Subclasses should extend this
method to remove any listeners added in
activate() .
-
-
Specified by:
-
deactivate
in interface
EditPart
-
Overrides:
-
deactivate
in class
AbstractEditPart
-
-
See Also:
-
EditPart.deactivate()
fireRemovingSourceConnection
protected void fireRemovingSourceConnection(
ConnectionEditPart connection,
int index)
- Notifies listeners that a source connection has
been removed. Called from
removeSourceConnection(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
protected void fireRemovingTargetConnection(
ConnectionEditPart connection,
int index)
- Notifies listeners that a target connection has
been removed. Called from
removeTargetConnection(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
protected void fireSourceConnectionAdded(
ConnectionEditPart connection,
int index)
- Notifies listeners that a source connection has
been added. Called from
addSourceConnection(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
protected void fireTargetConnectionAdded(
ConnectionEditPart connection,
int index)
- Notifies listeners that a target connection has
been added. Called from
addTargetConnection(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
public java.lang.Object getAdapter(java.lang.Class key)
- Extends
AbstractEditPart.getAdapter(Class) to handle additional adapter types.
Currently, these types include
AccessibleHandleProvider and
AccessibleAnchorProvider . Subclasses should extend this method to support
additional adapter types, or to replace the default provided adapaters.
-
-
Overrides:
-
getAdapter
in class
AbstractEditPart
-
-
See Also:
-
org.eclipse.core.runtime.IAdaptable#getAdapter(Class)
getContentPane
public
IFigure getContentPane()
- If the children's Figures should be
-
-
Specified by:
-
getContentPane
in interface
GraphicalEditPart
-
-
Returns:
- the content pane Figure
-
See Also:
-
getContentPane()
getDragTracker
public
DragTracker getDragTracker(
Request request)
- Overridden to return a default
DragTracker for GraphicalEditParts.
-
-
Specified by:
-
getDragTracker
in interface
EditPart
-
-
Parameters:
-
request - a Request indicating the context of the drag
-
Returns:
-
null or a DragTracker -
See Also:
-
EditPart.getDragTracker(Request)
getFigure
public
IFigure getFigure()
- The default implementation calls
createFigure() if the figure is currently
null .
-
-
Specified by:
-
getFigure
in interface
GraphicalEditPart
-
-
Returns:
- this EditPart's Figure
-
See Also:
-
GraphicalEditPart.getFigure()
getLayer
protected
IFigure getLayer(java.lang.Object layer)
- A convenience method for obtaining the specified layer from the
LayerManager .
-
-
-
Parameters:
-
layer - ID of the Layer
-
Returns:
- The requested layer or
null if it doesn't exist
getModelSourceConnections
protected java.util.List getModelSourceConnections()
- Returns the
List 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
corresponding
ConnectionEditPart .
Callers must not modify the returned List.
-
-
-
Returns:
- the List of model source connections
getModelTargetConnections
protected java.util.List getModelTargetConnections()
- Returns the
List 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
corresponding
ConnectionEditPart .
Callers must not modify the returned List.
-
-
-
Returns:
- the List of model target connections
getSourceConnections
public java.util.List 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 interface
GraphicalEditPart
-
-
Returns:
- the source connections
-
See Also:
-
GraphicalEditPart.getSourceConnections()
getTargetConnections
public java.util.List 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 interface
GraphicalEditPart
-
-
Returns:
- the target connections
-
See Also:
-
GraphicalEditPart.getTargetConnections()
primAddSourceConnection
protected void primAddSourceConnection(
ConnectionEditPart connection,
int index)
- Adds the specified source
ConnectionEditPart at an index. This method is
used to update the
sourceConnections List. This method is called from
addSourceConnection(ConnectionEditPart, int) . Subclasses should not call or override
this method.
-
-
-
Parameters:
-
connection - the ConnectionEditPart -
index - the index of the add
primAddTargetConnection
protected void primAddTargetConnection(
ConnectionEditPart connection,
int index)
- Adds the specified target
ConnectionEditPart at an index. This method is
used to update the
targetConnections List. This method is called from
addTargetConnection(ConnectionEditPart, int) . Subclasses should not call or override
this method.
-
-
-
Parameters:
-
connection - the ConnectionEditPart -
index - the index of the add
primRemoveSourceConnection
protected void primRemoveSourceConnection(
ConnectionEditPart connection)
- Removes the specified source
ConnectionEditPart from the
sourceConnections List. This method is called from
removeSourceConnection(ConnectionEditPart) . Subclasses should not call or override
this method.
-
-
-
Parameters:
-
connection - Connection to remove.
primRemoveTargetConnection
protected void primRemoveTargetConnection(
ConnectionEditPart connection)
- Removes the specified target
ConnectionEditPart from the
targetConnections List. This method is called from
removeTargetConnection(ConnectionEditPart) . Subclasses should not call or override
this method.
-
-
-
Parameters:
-
connection - Connection to remove.
refresh
public void refresh()
- Extends
AbstractEditPart.refresh() to refresh two additional structural
features: source and target connections. Subclasses should probably
override
AbstractEditPart.refreshVisuals() instead of this method.
-
-
Specified by:
-
refresh
in interface
EditPart
-
Overrides:
-
refresh
in class
AbstractEditPart
-
-
See Also:
-
EditPart.refresh()
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 from
refresh() , and may also be called in response to
notification from the model.
The update is performed by comparing the exising source ConnectionEditParts with the
set of model source connections returned from
getModelSourceConnections() .
EditParts whose model no longer exists are
removed . New models have their
ConnectionEditParts
created . Subclasses should
override getModelSourceChildren() .
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 from
refresh() , and may also be called in response to
notification from the model.
The update is performed by comparing the exising source ConnectionEditParts with the
set of model source connections returned from
getModelTargetConnections() .
EditParts whose model no longer exists are
removed . New models have their
ConnectionEditParts
created . Subclasses should
override getModelTargetChildren() .
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 class
AbstractEditPart
-
-
See Also:
-
AbstractEditPart.registerVisuals()
removeChildVisual
protected void removeChildVisual(
EditPart childEditPart)
- Remove the child's Figure from the
contentPane .
-
-
Specified by:
-
removeChildVisual
in class
AbstractEditPart
-
-
Parameters:
-
childEditPart - the child EditPart -
See Also:
-
AbstractEditPart.removeChildVisual(EditPart)
removeNodeListener
public void removeNodeListener(
NodeListener listener)
-
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 interface
GraphicalEditPart
-
-
Parameters:
-
listener - the listener being removed -
See Also:
-
GraphicalEditPart.removeNodeListener(org.eclipse.gef.NodeListener)
removeNotify
public void removeNotify()
- Extends
AbstractEditPart.removeNotify() to cleanup
ConnectionEditParts .
-
-
Specified by:
-
removeNotify
in interface
EditPart
-
Overrides:
-
removeNotify
in class
AbstractEditPart
-
-
See Also:
-
removeNotify()
removeSourceConnection
protected void removeSourceConnection(
ConnectionEditPart connection)
- Removes the given connection for which this EditPart is the source.
Fires notification.
Inverse of
addSourceConnection(ConnectionEditPart, int)
-
-
-
Parameters:
-
connection - Connection being removed
removeTargetConnection
protected void removeTargetConnection(
ConnectionEditPart connection)
- Removes the given connection for which this EditPart is the target.
Fires notification.
Inverse of
addTargetConnection(ConnectionEditPart, int)
-
-
-
Parameters:
-
connection - Connection being removed
reorderChild
protected void reorderChild(
EditPart child,
int index)
- This method is extended to preserve a LayoutManager constraint if one exists.
-
-
Overrides:
-
reorderChild
in class
AbstractEditPart
-
-
Parameters:
-
child - the child being reordered -
index - new index for the child -
See Also:
-
AbstractEditPart.reorderChild(EditPart, int)
reorderSourceConnection
protected void reorderSourceConnection(
ConnectionEditPart connection,
int index)
- Moves a source
ConnectionEditPart into a lower index than it currently
occupies. This method is called from
refreshSourceConnections() .
-
-
-
Parameters:
-
connection - the ConnectionEditPart -
index - the new index
reorderTargetConnection
protected void reorderTargetConnection(
ConnectionEditPart connection,
int index)
- Moves a target
ConnectionEditPart into a lower index than it currently
occupies. This method is called from
refreshTargetConnections() .
-
-
-
Parameters:
-
connection - the ConnectionEditPart -
index - the new index
setFigure
protected void setFigure(
IFigure figure)
- Sets the Figure
-
-
-
Parameters:
-
figure - the Figure
setLayoutConstraint
public void setLayoutConstraint(
EditPart child,
IFigure childFigure,
java.lang.Object constraint)
-
Description copied from interface:
GraphicalEditPart
- Sets the specified constraint for a child's Figure on the
content pane figure for this GraphicalEditPart. The constraint will be applied to the
content pane's
LayoutManager . revalidate() is
called on the content pane, which will cause it to layout during the next update.
-
-
Specified by:
-
setLayoutConstraint
in interface
GraphicalEditPart
-
-
Parameters:
-
child - the child GraphicalEditPart whose constraint is being set -
childFigure - the Figure whose constraint is being set -
constraint - the constraint for the draw2d
LayoutManager
-
See Also:
-
setLayoutConstraint(EditPart, IFigure, Object)
unregisterVisuals
protected void unregisterVisuals()
- Implemented to remove the Figure from the Viewer's registry.
-
-
Overrides:
-
unregisterVisuals
in class
AbstractEditPart
-
-
See Also:
-
AbstractEditPart.unregisterVisuals()
Copyright (c) IBM Corp. and others 2000, 2007. All Rights Reserved.
|
|
|