public abstract class AbstractEditPart extends java.lang.Object implements EditPart, RequestConstants, IAdaptable
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.
| Modifier and Type | Class and Description |
|---|---|
protected static class |
AbstractEditPart.EditPolicyIterator
Iterates over a
List of EditPolcies, skipping any
null values encountered. |
| Modifier and Type | Field and Description |
|---|---|
protected java.util.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.
|
SELECTED, SELECTED_NONE, SELECTED_PRIMARYREQ_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 and Description |
|---|
AbstractEditPart() |
| Modifier and Type | Method and Description |
|---|---|
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(java.lang.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(java.lang.String message)
Deprecated.
in 3.1
|
protected void |
debugFeedback(java.lang.String message)
Deprecated.
in 3.1
|
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. |
java.lang.Object |
getAdapter(java.lang.Class key)
Returns the specified adapter if recognized.
|
java.util.List |
getChildren()
Returns the List of children
EditParts. |
Command |
getCommand(Request request)
Subclasses should rarely extend this method.
|
EditPolicy |
getEditPolicy(java.lang.Object key) |
protected AbstractEditPart.EditPolicyIterator |
getEditPolicyIterator()
Used internally to iterate over the installed EditPolicies.
|
protected java.util.Iterator |
getEventListeners(java.lang.Class clazz)
Returns an iterator for the specified type of listener
|
protected boolean |
getFlag(int flag)
Returns the boolean value of the given flag.
|
java.lang.Object |
getModel()
Returns the primary model object that this EditPart represents.
|
protected java.util.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(java.lang.Object key,
EditPolicy editPolicy)
Installs an EditPolicy for a specified role.
|
boolean |
isActive()
returns
true if the EditPart is active. |
boolean |
isSelectable()
By default, an EditPart is regarded to be selectable.
|
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(java.lang.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)
Called by
EditPartViewer to indicate that the EditPart
has gained or lost keyboard focus. |
void |
setModel(java.lang.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, which may be one of:
EditPart.SELECTED_PRIMARY
EditPart.SELECTED
EditPart.SELECTED_NONE. |
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. |
java.lang.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(). |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetDragTrackerprotected 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 java.util.List children
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 addedindex - The child's positionaddChild(EditPart, int),
AbstractGraphicalEditPart.removeChildVisual(EditPart)public void addEditPartListener(EditPartListener listener)
addEditPartListener in interface EditPartlistener - the listenerpublic void addNotify()
EditPartaddNotify in interface EditPartEditPart.addNotify()protected EditPart createChild(java.lang.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 objectprotected abstract void createEditPolicies()
null can be used to reserve a "slot",
should there be some desire to guarantee the ordering of EditPolcies.public void deactivate()
activate()deactivate in interface EditPartEditPart.deactivate(),
activate()protected void deactivateEditPolicies()
protected final void debug(java.lang.String message)
message - a debug messageprotected final void debugFeedback(java.lang.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 java.lang.Object getAdapter(java.lang.Class key)
Additional adapter types may be added in the future. Subclasses should extend this method as needed.
getAdapter in interface IAdaptableIAdaptable.getAdapter(java.lang.Class)public java.util.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 RequestEditPart.getCommand(Request),
EditPolicy.getCommand(Request)protected final java.util.Iterator getEventListeners(java.lang.Class clazz)
clazz - the Listener type over which to iteratepublic EditPolicy getEditPolicy(java.lang.Object key)
getEditPolicy in interface EditPartkey - the key identifying the EditPolicynull 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 returnsetFlag(int,boolean)public java.lang.Object getModel()
EditPartgetModel in interface EditPartnull or the primary model objectEditPart.getModel()protected java.util.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 EditPartnull or the parent 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 EditPartnull or the RootEditPartEditPart.getRoot()public int getSelected()
EditPartgetSelected 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 EditPartEditPartViewer or nullEditPart.getViewer()public boolean hasFocus()
EditParthasFocus in interface EditPartEditPart.hasFocus()public void installEditPolicy(java.lang.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.public boolean isSelectable()
isSelectable in interface EditParttrue if the receiver can be selectedEditPart.isSelectable()public 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.protected void refreshChildren()
refresh(), and may
also be called in response to notification from the model. This method
requires linear time to 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 existing EditParts with the set
of model children returned from getModelChildren(). EditParts
whose models no longer exist 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()
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(java.lang.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 childprotected 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)
EditPartViewer to indicate that the EditPart
has gained or lost keyboard focus. Focus is considered to be part of the
selected state. Therefore, only selectable EditParts are able to
obtain focus, and the method may thus only be called with a value of
true in case the receiver is selectable, i.e.
isSelectable() returns true.
The method should rarely be overridden. Instead, EditPolicies that are
selection-aware listen for notifications about the change of focus via
EditPartListener.selectedStateChanged(EditPart).setFocus in interface EditPartvalue - boolean indicating if this part has focusEditPart.setFocus(boolean),
EditPartListener.selectedStateChanged(EditPart),
SelectionEditPolicypublic void setModel(java.lang.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)
EditParts may get selected, the method may
only be called with a selected value of EditPart.SELECTED or
EditPart.SELECTED_PRIMARY in case the receiver is selectable,
i.e. isSelectable() returns true.
The method should rarely be overridden. Instead, EditPolicies that are
selection-aware listen for notifications about the change of selection
state via EditPartListener.selectedStateChanged(EditPart).setSelected in interface EditPartvalue - the selected valueEditPart.setSelected(int),
EditPartListener.selectedStateChanged(EditPart),
SelectionEditPolicypublic 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 java.lang.String toString()
toString in class java.lang.Objectpublic 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 typetrue 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.Copyright (c) IBM Corp. and others 2000, 2011. All Rights Reserved.