GEF v2.0

org.eclipse.gef.editparts
Class AbstractGraphicalEditPart

java.lang.Object
  |
  +--org.eclipse.gef.editparts.AbstractEditPart
        |
        +--org.eclipse.gef.editparts.AbstractGraphicalEditPart
All Implemented Interfaces:
EditPart, GraphicalEditPart, IAdaptable, RequestConstants
Direct Known Subclasses:
AbstractConnectionEditPart, FreeformGraphicalRootEditPart, GraphicalRootEditPart, org.eclipse.gef.ui.palette.PaletteEditPart

public abstract class AbstractGraphicalEditPart
extends AbstractEditPart
implements GraphicalEditPart

Abstract class which uses IFigures for visuals.


Inner Class Summary
protected  class AbstractGraphicalEditPart.AccessibleGraphicalEditPart
           
protected  class AbstractGraphicalEditPart.DefaultAccessibleAnchorProvider
           
 
Inner classes inherited from class org.eclipse.gef.editparts.AbstractEditPart
AbstractEditPart.EditPolicyIterator
 
Field Summary
protected  IFigure figure
           
protected  List handles
           
protected  List sourceConnections
           
protected  List targetConnections
           
 
Fields inherited from class org.eclipse.gef.editparts.AbstractEditPart
children, eventListeners, FLAG_ACTIVE, FLAG_FOCUS, FLAG_INITIALIZED, 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_CHILD, REQ_ALIGN_CHILDREN, REQ_ANCESTOR_DELETED, REQ_CONNECTION_END, REQ_CONNECTION_START, REQ_CREATE, REQ_CREATE_BENDPOINT, REQ_DELETE, REQ_DELETE_BENDPOINT, REQ_DELETE_DEPENDANT, REQ_DIRECT_EDIT, REQ_MOVE, REQ_MOVE_BENDPOINT, REQ_MOVE_CHILD, REQ_MOVE_CHILDREN, REQ_ORPHAN, REQ_ORPHAN_CHILDREN, REQ_RECONNECT_END, REQ_RECONNECT_SOURCE, REQ_RECONNECT_START, REQ_RECONNECT_TARGET, REQ_RESIZE, REQ_RESIZE_CHILD, REQ_RESIZE_CHILDREN, REQ_SELECTION, REQ_SELECTION_HOVER, REQ_SOURCE_DELETED, REQ_TARGET_DELETED
 
Constructor Summary
AbstractGraphicalEditPart()
           
 
Method Summary
 void activate()
          Indicates that editing has begun and the model may start changing.
protected  void addChildVisual(EditPart childEditPart, int index)
          Before performing the addition of the child EditPart to the model structure in super, its Figure is added to the graphical model.
protected  void addSourceConnection(ConnectionEditPart connection, int index)
           Adds a connection to this EditPart, the source.
protected  void addTargetConnection(ConnectionEditPart connection, int index)
           Adds a connection to this EditPart, the target.
protected abstract  IFigure createFigure()
          Returns the figure to be used as this part's visuals.
 void deactivate()
          Called by the managing EditPart(s).
 void dispose()
          Called when the EditPart will no longer be used.
protected  void fireRemovingSourceConnection(ConnectionEditPart connection, int index)
          Notifies listeners that a source connection has been added.
protected  void fireRemovingTargetConnection(ConnectionEditPart connection, int index)
          Notifies listeners that a source connection has been added.
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 source connection has been added.
 Object getAdapter(Class key)
           Returns the adapter of the given type, for example: IPropertySource.
 IFigure getContentPane()
          The figure into which children will be placed.
 DragTracker getDragTracker(Request request)
          Returns a DragTrack for the given Request.
 IFigure getFigure()
          Returns the graphical object of this.
protected  IFigure getLayer(Object layer)
          Returns the layer with the input name from the LayerManager from
protected  List getModelSourceConnections()
           Returns a List of the connection model objects for which this EditPart's model is the source.
protected  List getModelTargetConnections()
           Returns a List of the connection model objects for which this EditPart's model is the target.
protected  IFigure getParentingFigure()
           
 List getSourceConnections()
          Returns the connections for which this EditPart is the source.
 List getTargetConnections()
          Returns the connections for which this EditPart is the target.
protected  void primAddSourceConnection(ConnectionEditPart connection, int index)
           Performs the actual addition of a source connection.
protected  void primAddTargetConnection(ConnectionEditPart connection, int index)
           Performs the actual addition of a target connection.
protected  void primRemoveSourceConnection(ConnectionEditPart connection)
          Performs the actual removal of a source connection.
protected  void primRemoveTargetConnection(ConnectionEditPart editPart)
          Performs the actual removal of a target connection.
 void refresh()
          Called to force a refresh of all properties displayed by this EditPart.
protected  void refreshSourceConnections()
           Refreshes the set of Source Connections.
protected  void refreshTargetConnections()
           Refreshes the set of Target Connections.
protected  void registerVisuals()
           
protected  void removeChildVisual(EditPart childEditPart)
          Before removing the child EditPart from the model structure in super, its Figure is removed from the graphical model.
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)
          Reorders the child to be at the specified new position.
protected  void reorderSourceConnection(ConnectionEditPart editPart, int index)
           Bubbles the given source ConnectionEditPart into a lower index than it previously occupied.
protected  void reorderTargetConnection(ConnectionEditPart editPart, int index)
           Bubbles the given target ConnectionEditPart into a lower index than it previously occupied.
protected  void setFigure(IFigure figure)
          Sets the Figure representing the graphical content of this.
 void setLayoutConstraint(EditPart child, IFigure childFigure, Object constraint)
          A child can call this method to set the layout constraint for its figure.
protected  boolean shouldInitialize()
          Updates this EditPart.
protected  void unregister()
           Undoes any registration performed by AbstractEditPart.register().
 
Methods inherited from class org.eclipse.gef.editparts.AbstractEditPart
activateEditPolicies, addChild, addEditPartListener, createChild, createConnection, createEditPolicies, createOrFindConnection, deactivateEditPolicies, debug, debugFeedback, doInitialize, eraseSourceFeedback, eraseTargetFeedback, fireActivated, fireChildAdded, fireDeactivated, fireRemovingChild, fireSelectionChanged, getAccessibleEditPart, getChildren, getCommand, getEditPolicy, getEditPolicyIterator, getEventListeners, getFlag, getKeyHandler, getModel, getModelChildren, getParent, getRoot, getSelected, getTargetEditPart, getViewer, hasFocus, initialize, installEditPolicy, isActive, isSelectable, performRequest, refreshChildren, refreshVisuals, register, registerAccessibility, registerModel, removeChild, removeEditPartListener, removeEditPolicy, setFlag, setFocus, setModel, setParent, setSelected, showSourceFeedback, showTargetFeedback, toString, understandsRequest, 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, getKeyHandler, getModel, getParent, getRoot, getSelected, getTargetEditPart, hasFocus, installEditPolicy, performRequest, removeEditPartListener, removeEditPolicy, setFocus, setModel, setParent, setSelected, showSourceFeedback, showTargetFeedback, understandsRequest
 

Field Detail

figure

protected IFigure figure

handles

protected List handles

sourceConnections

protected List sourceConnections

targetConnections

protected List targetConnections
Constructor Detail

AbstractGraphicalEditPart

public AbstractGraphicalEditPart()
Method Detail

activate

public void activate()
Description copied from interface: EditPart
Indicates that editing has begun and the model may start changing. Called by the managing EditPart. The managing edit part may call EditPart.activate() and then EditPart.deactivate() multiple times on the receiver.

Activiation should initiate several things. First, the EditPart should begin to observe its model if appropriate, and should continue the observation until EditPart.deactivate() is called. The EditPart should create and activate all of its EditPolicies. EditPolicies may also observe the model, and should also stop observing when deactivated. Any EditParts managed by this EditPart should also be activated.

Specified by:
activate in interface EditPart
Overrides:
activate in class AbstractEditPart
Following copied from class: org.eclipse.gef.editparts.AbstractEditPart
See Also:
AbstractEditPart.deactivate()

addChildVisual

protected void addChildVisual(EditPart childEditPart,
                              int index)
Before performing the addition of the child EditPart to the model structure in super, its Figure is added to the graphical model.
Overrides:
addChildVisual in class AbstractEditPart
Parameters:
childEditPart - EditPart being added to the structure
index - Psotion the EditPart is being added into.

addSourceConnection

protected void addSourceConnection(ConnectionEditPart connection,
                                   int index)
Adds a connection to this EditPart, the source. The connection will have its source set to this EditPart, The connection will be conditionally activated. primAddSourceConnection(ConnectionEditPart, int) is called to separate the act of adding the connection from the activation and firing of notification. Subclasses should generally override primAddSourceConnection(ConnectionEditPart, int);
Parameters:
connection - Connection being added
index - Index where it is being added
See Also:
primAddSourceConnection(ConnectionEditPart, int), removeSourceConnection(org.eclipse.gef.ConnectionEditPart)

addTargetConnection

protected void addTargetConnection(ConnectionEditPart connection,
                                   int index)
Adds a connection to this EditPart, the target.
Parameters:
connection - Connection being added
index - Index where it is being added
See Also:
removeTargetConnection(ConnectionEditPart), addSourceConnection(ConnectionEditPart,int)

createFigure

protected abstract IFigure createFigure()
Returns the figure to be used as this part's visuals.

deactivate

public void deactivate()
Description copied from interface: EditPart
Called by the managing EditPart(s). The managing EditPart(s) may call EditPart.activate() and then EditPart.deactivate() multiple times on the receiver. The EditPart should unhook all listeners to the model, and should deactivate its EditPolicies. It may be reactivated later. The EditPart should deactivate all EditParts that it manages.
Specified by:
deactivate in interface EditPart
Overrides:
deactivate in class AbstractEditPart
Following copied from class: org.eclipse.gef.editparts.AbstractEditPart
See Also:
AbstractEditPart.activate()

dispose

public void dispose()
Description copied from interface: EditPart
Called when the EditPart will no longer be used. The EditPart should perform cleanup that cannot be performed in EditPart.deactivate(), such as unregistering itself from the Viewer.
Specified by:
dispose in interface EditPart
Overrides:
dispose in class AbstractEditPart

fireRemovingSourceConnection

protected void fireRemovingSourceConnection(ConnectionEditPart connection,
                                            int index)
Notifies listeners that a source connection has been added.
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 source connection has been added.
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.
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 source connection has been added.
Parameters:
connection - ConnectionEditPart being added as child.
index - Position child is being added into.

getAdapter

public Object getAdapter(Class key)
Description copied from class: AbstractEditPart
Returns the adapter of the given type, for example: IPropertySource. If your model implements IPropertySource, or if it is IAdaptable then there is no reason to override this method. Or, if you do not need propertysheet support. EditParts are the objects sent out as selection to other viewers. If you have viewers that require additional adapter types, return them here.
Specified by:
getAdapter in interface IAdaptable
Overrides:
getAdapter in class AbstractEditPart
Following copied from class: org.eclipse.gef.editparts.AbstractEditPart
See Also:
IAdaptable

getContentPane

public IFigure getContentPane()
Description copied from interface: GraphicalEditPart
The figure into which children will be placed. Should not return null, but may return the same figure as getFigure(). An example would be a GraphicalEditPart that uses a ScrollPane, which looks like this:
ScrollPane - returned by getFigure()
Viewport - (internal, does the scrolling)
View - returned by getContentPane()

A ScrollPane already has a special child, so the GraphicalEditPart's children will get added to the View

Specified by:
getContentPane in interface GraphicalEditPart

getDragTracker

public DragTracker getDragTracker(Request request)
Returns a DragTrack for the given Request. The Request object will indicate the context of the drag.
Specified by:
getDragTracker in interface EditPart
Parameters:
Request - A Request describing the type of drag.

getFigure

public final IFigure getFigure()
Returns the graphical object of this.
Specified by:
getFigure in interface GraphicalEditPart
Returns:
The graphical part as a IFigure

getLayer

protected IFigure getLayer(Object layer)
Returns the layer with the input name from the LayerManager from
Parameters:
layer - Name of the Layer to be returned
Returns:
The layer with the given name.

getModelSourceConnections

protected List getModelSourceConnections()
Returns a List of the connection model objects for which this EditPart's model is the source. refreshSourceConnections() requires that this List be non-null. For each connection model object, AbstractEditPart.createConnection(Object) will be called to obtain a corresponding ConnectionEditPart.

getModelTargetConnections

protected List getModelTargetConnections()
Returns a List of the connection model objects for which this EditPart's model is the target. refreshTargetConnections() requires that this List be non-null. For each connection model object, AbstractEditPart.createConnection(Object) will be called to obtain a corresponding ConnectionEditPart.

getParentingFigure

protected final IFigure getParentingFigure()
                                    throws Exception

getSourceConnections

public List getSourceConnections()
Description copied from interface: GraphicalEditPart
Returns the connections for which this EditPart is the source. This method should only be called internally or by helpers such as edit policies.
Specified by:
getSourceConnections in interface GraphicalEditPart

getTargetConnections

public List getTargetConnections()
Description copied from interface: GraphicalEditPart
Returns the connections for which this EditPart is the target. This method should only be called internally or by helpers such as edit policies.
Specified by:
getTargetConnections in interface GraphicalEditPart

primAddSourceConnection

protected void primAddSourceConnection(ConnectionEditPart connection,
                                       int index)
Performs the actual addition of a source connection.
Parameters:
connection - The connection to add.
index - Position connection is being added.
See Also:
addSourceConnection(ConnectionEditPart,int)

primAddTargetConnection

protected void primAddTargetConnection(ConnectionEditPart connection,
                                       int index)
Performs the actual addition of a target connection. A target connection is a connection whose target is this EditPart.
Parameters:
connection - The connection being added.
index - Position connection is being added.
See Also:
addTargetConnection(ConnectionEditPart,int)

primRemoveSourceConnection

protected void primRemoveSourceConnection(ConnectionEditPart connection)
Performs the actual removal of a source connection.
Parameters:
connection - Connection to remove.
See Also:
removeSourceConnection(ConnectionEditPart)

primRemoveTargetConnection

protected void primRemoveTargetConnection(ConnectionEditPart editPart)
Performs the actual removal of a target connection.
Parameters:
connection - Connection to remove.
See Also:
removeTargetConnection(ConnectionEditPart)

refresh

public void refresh()
Description copied from interface: EditPart
Called to force a refresh of all properties displayed by this EditPart.
Specified by:
refresh in interface EditPart
Overrides:
refresh in class AbstractEditPart

refreshSourceConnections

protected void refreshSourceConnections()
Refreshes the set of Source Connections. This method should not be overridden. AbstractEditPart.createConnection(Object) and getModelSourceConnections() should be overridden together.

refreshTargetConnections

protected void refreshTargetConnections()
Refreshes the set of Target Connections. This method should not be overridden. AbstractEditPart.createConnection(Object) and getModelTargetConnections() should be overridden together.

registerVisuals

protected void registerVisuals()
Overrides:
registerVisuals in class AbstractEditPart

removeChildVisual

protected void removeChildVisual(EditPart childEditPart)
Before removing the child EditPart from the model structure in super, its Figure is removed from the graphical model.
Overrides:
removeChildVisual in class AbstractEditPart
Parameters:
childEditPart - EditPart being removed from the structure

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)
Reorders the child to be at the specified new position. The child's contraints are saved, it is removed from the structure, and added back at the index given. Its constraints are then set back to it.
Overrides:
reorderChild in class AbstractEditPart
Parameters:
child - EditPart being reordered.
index - PosPosition being reordered to.

reorderSourceConnection

protected void reorderSourceConnection(ConnectionEditPart editPart,
                                       int index)
Bubbles the given source ConnectionEditPart into a lower index than it previously occupied.
Parameters:
connection - Connection being reordered
index - the new Position into which the connection is being placed.

reorderTargetConnection

protected void reorderTargetConnection(ConnectionEditPart editPart,
                                       int index)
Bubbles the given target ConnectionEditPart into a lower index than it previously occupied.
Parameters:
connection - Connection being reordered
index - the new Position into which the connection is being placed.

setFigure

protected void setFigure(IFigure figure)
Sets the Figure representing the graphical content of this.
Parameters:
figure - Figure being set.

setLayoutConstraint

public void setLayoutConstraint(EditPart child,
                                IFigure childFigure,
                                Object constraint)
Description copied from interface: GraphicalEditPart
A child can call this method to set the layout constraint for its figure.
Specified by:
setLayoutConstraint in interface GraphicalEditPart

shouldInitialize

protected boolean shouldInitialize()
Updates this EditPart. Update is done only in the presence of a set Figure.
Overrides:
shouldInitialize in class AbstractEditPart

unregister

protected void unregister()
Description copied from class: AbstractEditPart
Undoes any registration performed by AbstractEditPart.register(). The provided base classes will correctly unregister their visuals.
Overrides:
unregister in class AbstractEditPart

GEF v2.0