|
Eclipse GEF 3.0.1 |
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.eclipse.gef.editparts.AbstractEditPart
The baseline implementation for the EditPart interface.
Since this is the default implementation of an interface, this document deals with
proper sub-classing of this implementation. This class is not the API. For
documentation on proper usage of the public API, see the documentation for the
interface itself: EditPart.
This class assumes no visual representation. Subclasses AbstractGraphicalEditPart and AbstractTreeEditPart add support for Figures and TreeItems respectively.
AbstractEditPart provides support for children. All AbstractEditPart's can potentially be containers for other EditParts.
| Nested Class Summary | |
protected static class |
AbstractEditPart.EditPolicyIterator
Iterates over a List of EditPolcies, skipping any null values
encountered. |
| Field Summary | |
protected List |
children
The List of children EditParts |
protected static int |
FLAG_ACTIVE
This flag is set during activate(), and reset on deactivate() |
protected static int |
FLAG_FOCUS
This flag indicates that the EditPart has focus. |
protected static int |
MAX_FLAG
The left-most bit that is reserved by this class for setting flags. |
| 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 | |
AbstractEditPart()
|
|
| Method Summary | |
void |
activate()
Activates this EditPart, which in turn activates its children and EditPolicies. |
protected void |
activateEditPolicies()
Activates all EditPolicies installed on this part. |
protected void |
addChild(EditPart child,
int index)
Adds a child EditPart to this
EditPart. |
protected abstract void |
addChildVisual(EditPart child,
int index)
Performs the addition of the child's visual to this EditPart's Visual. |
void |
addEditPartListener(EditPartListener listener)
Adds an EditPartListener. |
void |
addNotify()
Called after the EditPart has been added to its parent. |
protected EditPart |
createChild(Object model)
Create the child EditPart
for the given model object. |
protected abstract void |
createEditPolicies()
Creates the initial EditPolicies and/or reserves slots for dynamic ones. |
void |
deactivate()
Deactivates this EditPart, and in turn deactivates its children and EditPolicies. |
protected void |
deactivateEditPolicies()
Deactivates all installed EditPolicies. |
protected void |
debug(String message)
This method will log a message to GEF's trace/debug system if the corresponding flag for EditParts is set to true. |
protected void |
debugFeedback(String message)
This method will log the message to GEF's trace/debug system if the corrseponding flag for FEEDBACK is set to true. |
void |
eraseSourceFeedback(Request request)
Erases source feedback for the given Request. |
void |
eraseTargetFeedback(Request request)
Erases target feedback for the given Request. |
protected void |
fireActivated()
Notifies EditPartListeners that this
EditPart has been activated. |
protected void |
fireChildAdded(EditPart child,
int index)
Notifies EditPartListeners that a
child has been added. |
protected void |
fireDeactivated()
Notifies EditPartListeners that this
EditPart has been deactivated. |
protected void |
fireRemovingChild(EditPart child,
int index)
Notifies EditPartListeners that a
child is being removed. |
protected void |
fireSelectionChanged()
Notifies EditPartListeners that the
selection has changed. |
protected AccessibleEditPart |
getAccessibleEditPart()
Returns the AccessibleEditPart adapter for this EditPart. |
Object |
getAdapter(Class key)
Returns the specified adapter if recognized, for example: IPropertySource. |
List |
getChildren()
Returns the List of children EditParts. |
Command |
getCommand(Request request)
Subclasses should rarely extend this method. |
EditPolicy |
getEditPolicy(Object key)
|
protected AbstractEditPart.EditPolicyIterator |
getEditPolicyIterator()
Used internally to iterate over the installed EditPolicies. |
protected Iterator |
getEventListeners(Class clazz)
Returns an iterator for the specified type of listener |
protected boolean |
getFlag(int flag)
Returns the boolean value of the given flag. |
Object |
getModel()
Returns the primary model object that this EditPart represents. |
protected List |
getModelChildren()
Returns a List containing the children
model objects. |
EditPart |
getParent()
Returns the parent EditPart. |
RootEditPart |
getRoot()
Returns the RootEditPart. |
int |
getSelected()
Returns the selected state of this EditPart. |
EditPart |
getTargetEditPart(Request request)
Returns the EditPart which is the
target of the Request. |
EditPartViewer |
getViewer()
Convenience method for returning the EditPartViewer for this part. |
boolean |
hasFocus()
Returns true if this EditPart has focus. |
void |
installEditPolicy(Object key,
EditPolicy editPolicy)
Installs an EditPolicy for a specified role. |
boolean |
isActive()
returns true if the EditPart is active. |
boolean |
isSelectable()
Reserved for future use |
void |
performRequest(Request req)
Subclasses should extend this method to handle Requests. |
void |
refresh()
Refreshes all properties visually displayed by this EditPart. |
protected void |
refreshChildren()
Updates the set of children EditParts so that it is in sync with the model children. |
protected void |
refreshVisuals()
Refreshes this EditPart's visuals. |
protected void |
register()
Registers itself in the viewer's various registries. |
protected void |
registerAccessibility()
Registers the AccessibleEditPart adapter. |
protected void |
registerModel()
Registers the model in the EditPartViewer.getEditPartRegistry().
|
protected void |
registerVisuals()
Registers the visuals in the EditPartViewer.getVisualPartMap().
|
protected void |
removeChild(EditPart child)
Removes a child EditPart. |
protected abstract void |
removeChildVisual(EditPart child)
Removes the childs visual from this EditPart's visual. |
void |
removeEditPartListener(EditPartListener listener)
No reason to override |
void |
removeEditPolicy(Object key)
No reason to override |
void |
removeNotify()
Removes all references from the EditPartViewer to this EditPart. |
protected void |
reorderChild(EditPart editpart,
int index)
Moves a child EditPart into a lower index than it currently occupies. |
protected void |
setFlag(int flag,
boolean value)
Sets the value of the specified flag. |
void |
setFocus(boolean value)
Set the focus property to reflect the value in the EditPartViewer. |
void |
setModel(Object model)
Set the primary model object that this EditPart represents. |
void |
setParent(EditPart parent)
Sets the parent EditPart. |
void |
setSelected(int value)
sets the selected state for this EditPart. |
void |
showSourceFeedback(Request request)
Shows or updates source feedback for the given Request. |
void |
showTargetFeedback(Request request)
Shows or updates target feedback for the given Request. |
String |
toString()
Describes this EditPart for developmental debugging purposes. |
boolean |
understandsRequest(Request req)
Returns true if this
EditPart understand the given Request. |
protected void |
unregister()
Undoes any registration performed by register(). |
protected void |
unregisterAccessibility()
Unregisters the AccessibleEditPart adapter. |
protected void |
unregisterModel()
Unregisters the model in the EditPartViewer.getEditPartRegistry().
|
protected void |
unregisterVisuals()
Unregisters the visuals in the EditPartViewer.getVisualPartMap().
|
| 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 |
getDragTracker |
| Field Detail |
protected static final int FLAG_ACTIVE
activate(), and reset on deactivate()
protected static final int FLAG_FOCUS
protected static final int MAX_FLAG
(MAX_FLAG << 1).
protected List children
| Constructor Detail |
public AbstractEditPart()
| Method Detail |
public void activate()
deactivate() is the inverse, and is eventually called on
all EditParts.
activate in interface EditPartEditPart.activate(),
deactivate()protected void activateEditPolicies()
activate()
protected void addChild(EditPart child,
int index)
EditPart to this
EditPart. This method is called from refreshChildren(). The following events
occur in the order listed:
children List, and its parent is set to
this
addChildVisual(EditPart, int) is called to add the child's visual
EditPart.addNotify() is called on the child.
activate() is called if this part is active
EditPartListeners are notified that the child has been added.
Subclasses should implement addChildVisual(EditPart, int).
child - The EditPart to addindex - The indexaddChildVisual(EditPart, int),
removeChild(EditPart),
reorderChild(EditPart,int)
protected abstract void addChildVisual(EditPart child,
int index)
AbstractGraphicalEditPart
and AbstractTreeEditPart already implement this method correctly, so it is
unlikely that this method should be overridden.
child - The EditPart being added.index - The child's position.addChild(EditPart, int),
AbstractGraphicalEditPart.removeChildVisual(EditPart)public void addEditPartListener(EditPartListener listener)
addEditPartListener in interface EditPartlistener - the listenerpublic void addNotify()
EditPart
addNotify in interface EditPartEditPart.addNotify()protected EditPart createChild(Object model)
EditPart
for the given model object. This method is called from refreshChildren().
By default, the implementation will delegate to the EditPartViewer's
EditPartFactory. Subclasses may override this method instead of using a
Factory.
model - the Child model object
protected abstract void createEditPolicies()
null can be used to reserve a "slot", should there be some desire to
guarantee the ordering of EditPolcies.
EditPart.installEditPolicy(Object, EditPolicy)public void deactivate()
activate()
deactivate in interface EditPartEditPart.deactivate(),
activate()protected void deactivateEditPolicies()
protected final void debug(String message)
message - a debug messageprotected final void debugFeedback(String message)
message - Message to be passedpublic void eraseSourceFeedback(Request request)
Request. By default, this responsibility is delegated to this part's
EditPolicies. Subclasses should rarely extend this method.
| It is recommended that feedback be handled by EditPolicies, and not directly by the EditPart. |
eraseSourceFeedback in interface EditPartrequest - identifies the type of feedback to erase.showSourceFeedback(Request)public void eraseTargetFeedback(Request request)
Request. By default, this responsibility is delegated to this part's
EditPolicies. Subclasses should rarely extend this method.
| It is recommended that feedback be handled by EditPolicies, and not directly by the EditPart. |
eraseTargetFeedback in interface EditPartrequest - Command requesting the erase.showTargetFeedback(Request)protected void fireActivated()
EditPartListeners that this
EditPart has been activated.
protected void fireChildAdded(EditPart child,
int index)
EditPartListeners that a
child has been added.
child - EditPart being added as child.index - Position child is being added into.protected void fireDeactivated()
EditPartListeners that this
EditPart has been deactivated.
protected void fireRemovingChild(EditPart child,
int index)
EditPartListeners that a
child is being removed.
child - EditPart being removed.index - Position of the child in children list.protected void fireSelectionChanged()
EditPartListeners that the
selection has changed.
protected AccessibleEditPart getAccessibleEditPart()
AccessibleEditPart adapter for this EditPart. The same
adapter instance must be used throughout the editpart's existance. Each adapter has
a unique ID which is registered during register(). Accessibility clients
can only refer to this editpart via that ID.
null or an AccessibleEditPart adapterpublic Object getAdapter(Class key)
IPropertySource. Otherwise returns null.
By default, the following adapter types are handled:
IPropertySource - If getModel() is an IPropertySource it
will be returned. If getModel() is IAdaptable, it will be asked for its
IPropertySource adapter, and the result is returned.
AccessibleEditPart - If the adapter key is
AccessibleEditPart, then getAccessibleEditPart() is returned.
Additional adapter types may be added in the future. Subclasses should extend this method.
getAdapter in interface IAdaptableIAdaptable.getAdapter(java.lang.Class)public List getChildren()
EditPartEditParts. This method should rarely be
called, and is only made public so that helper objects of this EditPart, such as
EditPolicies, can obtain the children. The returned List may be by reference, and
should never be modified.
getChildren in interface EditPartList of childrenEditPart.getChildren()public Command getCommand(Request request)
EditPolicy. This method is implemented indirectly using EditPolicies.
| It is recommended that Command creation be handled by EditPolicies, and not directly by the EditPart. |
getCommand in interface EditPartrequest - the Request
EditPart.getCommand(Request),
EditPolicy.getCommand(Request)protected final Iterator getEventListeners(Class clazz)
clazz - the Listener type over which to iterate
public EditPolicy getEditPolicy(Object key)
getEditPolicy in interface EditPartkey - the key identifying the EditPolicy
null or the EditPolicy installed with the given keyEditPart.getEditPolicy(Object)protected final AbstractEditPart.EditPolicyIterator getEditPolicyIterator()
null, the iterator only returns the non-null ones.
protected final boolean getFlag(int flag)
true if
the bitwise AND of the specified flag and the internal flags field is non-zero.
flag - Bitmask indicating which flag to return
setFlag(int,boolean)public Object getModel()
EditPart
getModel in interface EditPartEditPart.getModel()protected List getModelChildren()
List containing the children
model objects. If this EditPart's model is a container, this method should be
overridden to returns its children. This is what causes children EditParts to be
created.
Callers must not modify the returned List. Must not return null.
public EditPart getParent()
EditPartEditPart. This method should only be called internally
or by helpers such as EditPolicies.
getParent in interface EditPartEditPart.getParent()public RootEditPart getRoot()
EditPartRootEditPart. This method should only be called internally or by
helpers such as edit policies. The Root can be used to get the Viewer.
getRoot in interface EditPartRootEditPartEditPart.getRoot()public int getSelected()
EditPart
getSelected in interface EditPartEditPart.getSelected()public EditPart getTargetEditPart(Request request)
EditPart which is the
target of the Request. The default implementation delegates this method
to the installed EditPolicies. The first non-null result returned by an
EditPolicy is returned. Subclasses should rarely extend this method.
| It is recommended that targeting be handled by EditPolicies, and not directly by the EditPart. |
getTargetEditPart in interface EditPartrequest - Describes the type of target desired.
null or the target EditPartEditPart.getTargetEditPart(Request),
EditPolicy.getTargetEditPart(Request)public EditPartViewer getViewer()
EditPartEditPartViewer for this part.
getViewer in interface EditPartEditPart.getViewer()public boolean hasFocus()
EditPart
hasFocus in interface EditPartEditPart.hasFocus()
public void installEditPolicy(Object key,
EditPolicy editPolicy)
EditPartEditPolicy.LAYOUT_ROLE is generally used as the key for this EditPolicy.
null is a valid value for reserving a location.
installEditPolicy in interface EditPartkey - an identifier used to key the EditPolicyeditPolicy - the EditPolicyEditPart.installEditPolicy(Object, EditPolicy)public boolean isActive()
EditParttrue if the EditPart is active. Editparts are active after
EditPart.activate() is called, and until EditPart.deactivate() is called.
isActive in interface EditParttrue if this EditPart is active.public boolean isSelectable()
isSelectable in interface EditPartpublic void performRequest(Request req)
performRequest in interface EditPartreq - the request to be performedEditPart.performRequest(Request)public void refresh()
refreshChildren() to update
its structural features. It also calls refreshVisuals() to update its own
displayed properties. Subclasses should extend this method to handle additional types
of structural refreshing.
refresh in interface EditPartprotected void refreshChildren()
refresh(), and may also be called in response to
notification from the model. This method requires linear time complete. Clients
should call this method as few times as possible. Consider also calling removeChild(EditPart) and addChild(EditPart, int) which run in constant
time.
The update is performed by comparing the exising EditParts with the set of model
children returned from getModelChildren(). EditParts whose model no longer
exists are removed. New models have their EditParts
created.
This method should not be overridden.
getModelChildren()protected void refreshVisuals()
refresh(),
and may also be called in response to notifications from the model. This method does
nothing by default. Subclasses may override.
protected void register()
unregister(),
EditPartViewer.getVisualPartMap(),
EditPartViewer.getEditPartRegistry()protected final void registerAccessibility()
AccessibleEditPart adapter.
getAccessibleEditPart()protected void registerModel()
EditPartViewer.getEditPartRegistry().
Subclasses should only extend this method if they need to register this EditPart in
additional ways.
protected void registerVisuals()
EditPartViewer.getVisualPartMap().
Subclasses should override this method for the visual part they support. AbstractGraphicalEditPart and AbstractTreeEditPart already do this.
protected void removeChild(EditPart child)
EditPart. This method is called from refreshChildren(). The following events occur in the order listed:
EditPartListeners are notified that the child is being removed
deactivate() is called if the child is active
EditPart.removeNotify() is called on the child.
removeChildVisual(EditPart) is called to remove the child's visual
object.
null
Subclasses should implement removeChildVisual(EditPart).
child - EditPart being removedaddChild(EditPart,int)protected abstract void removeChildVisual(EditPart child)
child - the child EditPartpublic void removeEditPartListener(EditPartListener listener)
removeEditPartListener in interface EditPartlistener - the listener being removedEditPart.removeEditPartListener(EditPartListener)public void removeEditPolicy(Object key)
removeEditPolicy in interface EditPartkey - the key identifying the EditPolicy to be removedEditPart.removeEditPolicy(Object)public void removeNotify()
EditPartViewer to this EditPart. This includes:
null if this EditPart has focus
unregister() this EditPart
In addition, removeNotify() is called recursively on all children
EditParts. Subclasses should extend this method to perform any additional
cleanup.
removeNotify in interface EditPartEditPart.removeNotify()
protected void reorderChild(EditPart editpart,
int index)
EditPart into a lower index than it currently occupies. This
method is called from refreshChildren().
editpart - the child being reorderedindex - new index for the child
protected final void setFlag(int flag,
boolean value)
MAX_FLAG.
flag - Flag being setvalue - Value of the flag to be setgetFlag(int)public void setFocus(boolean value)
EditPart
Focus is considered to be part of the selected state, changing this value
will fire EditPartListener.selectedStateChanged(EditPart).
IMPORTANT: This method should only be called by the EditPartViewer.
setFocus in interface EditPartvalue - boolean indicating if this part has focusEditPart.setFocus(boolean)public void setModel(Object model)
EditPartFactory when creating an
EditPart.
setModel in interface EditPartmodel - the ModelEditPart.setModel(Object)public void setParent(EditPart parent)
setParent in interface EditPartparent - the parent EditPartEditPart.setParent(EditPart)public void setSelected(int value)
setSelected in interface EditPartvalue - the selected valueSelectionEditPolicy,
EditPartListener.selectedStateChanged(EditPart),
EditPart.setSelected(int)public void showSourceFeedback(Request request)
Request. By default, this responsibility is delegated to this part's
EditPolicies. Subclasses should rarely extend this method.
| It is recommended that feedback be handled by EditPolicies, and not directly by the EditPart. |
showSourceFeedback in interface EditPartrequest - the RequestEditPolicy.showSourceFeedback(Request),
EditPart.showSourceFeedback(Request)public void showTargetFeedback(Request request)
Request. By default, this responsibility is delegated to this part's
EditPolicies. Subclasses should rarely extend this method.
| It is recommended that feedback be handled by EditPolicies, and not directly by the EditPart. |
showTargetFeedback in interface EditPartrequest - the RequestEditPolicy.showTargetFeedback(Request),
EditPart.showTargetFeedback(Request)public String toString()
public boolean understandsRequest(Request req)
true if this
EditPart understand the given Request. By default, this
responsibility is delegated to this part's installed EditPolicies.
| It is recommended that EditPolicies implement understandsRequest()
|
understandsRequest in interface EditPartreq - a Request describing an operation of some type
true if Request is understoodEditPart.understandsRequest(Request)protected void unregister()
register(). The provided base classes
will correctly unregister their visuals.
protected final void unregisterAccessibility()
AccessibleEditPart adapter.
protected void unregisterModel()
EditPartViewer.getEditPartRegistry().
Subclasses should only extend this method if they need to unregister this EditPart in
additional ways.
protected void unregisterVisuals()
EditPartViewer.getVisualPartMap().
Subclasses should override this method for the visual part they support. AbstractGraphicalEditPart and AbstractTreeEditPart already do this.
|
Eclipse GEF 3.0.1 |
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||