|
GEF v2.0 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--org.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.
| Indicates methods that are commonly overridden or even abstract |
| These methods might be overridden. Especially if you were extending this class directly. |
| Should rarely be overridden. |
| Essentially "internal" and should never be overridden. |
This class assumes no visual representation.
Subclasses AbstractGraphicalEditPart and AbstractTreeEditPart
add support for Figures and
TreeItems respectively.
AbstractEditPart provides support for, but does not require the usage of:
| Inner Class Summary | |
protected static class |
AbstractEditPart.EditPolicyIterator
Iterates over a List of EditPolcies, skipping
any null values encountered. |
| Field Summary | |
protected List |
children
|
protected EventListenerList |
eventListeners
Deprecated. do not reference, call getEventListeners(Class) instead. |
protected static int |
FLAG_ACTIVE
|
protected static int |
FLAG_FOCUS
|
protected static int |
FLAG_INITIALIZED
|
protected static int |
MAX_FLAG
The highest bit used as a bitmask in this class. |
| Fields inherited from interface org.eclipse.gef.EditPart |
SELECTED, SELECTED_NONE, SELECTED_PRIMARY |
| Constructor Summary | |
AbstractEditPart()
|
|
| Method Summary | |
void |
activate()
Initializes or reactivates
this part and hooks any needed listeners. |
protected void |
activateEditPolicies()
Activates all EditPolicies. |
protected void |
addChild(EditPart child,
int index)
Adds a child EditPart
to this EditPart. |
protected abstract void |
addChildVisual(EditPart child,
int index)
Performs the actual addition of the child to this EditPart. |
void |
addEditPartListener(EditPartListener listener)
Adds an editpart listener. |
protected EditPart |
createChild(Object model)
Override to create the child
EditPart for the given model object. |
protected ConnectionEditPart |
createConnection(Object model)
Creates a
ConnectionEditPart for the given model. |
protected abstract void |
createEditPolicies()
Creates
the initial EditPolicies and reserves slots for dynamic ones. |
protected ConnectionEditPart |
createOrFindConnection(Object model)
|
void |
deactivate()
Override this
method to remove any listeners established in activate(),
and ALWAYS call super.deactivate() to ensure
that children, etc., are also deactivated. |
protected void |
deactivateEditPolicies()
Deactivates all installed EditPolicies. |
protected void |
debug(String message)
This method will log the message to GEF's 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 debug system if the corrseponding flag for FEEDBACK is set to true. |
void |
dispose()
Called when the EditPart will no longer be used. |
protected void |
doInitialize()
Initializes the entire state of the EditPart. |
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()
|
protected void |
fireChildAdded(EditPart child,
int index)
Notifies listeners that a child has been added. |
protected void |
fireDeactivated()
|
protected void |
fireRemovingChild(EditPart child,
int index)
Notifies listeners prior to removing a child. |
protected void |
fireSelectionChanged()
Called when the selected state for this EditPart changes. |
protected AccessibleEditPart |
getAccessibleEditPart()
|
Object |
getAdapter(Class key)
Returns the adapter of the given type, for example: IPropertySource. |
List |
getChildren()
Returns a non-null List containing the children EditParts. |
Command |
getCommand(Request request)
Returns null or a command that performs the operation
specified by the Request. |
EditPolicy |
getEditPolicy(Object key)
Returns null or the EditPolicy installed with the given key. |
protected AbstractEditPart.EditPolicyIterator |
getEditPolicyIterator()
Used internally to iterate over the installed EditPolicies. |
protected Iterator |
getEventListeners(Class clazz)
|
protected boolean |
getFlag(int flag)
Returns the boolean value of the given flag. |
KeyHandler |
getKeyHandler()
Returns the KeyHandler for this EditPart or null. |
Object |
getModel()
Returns the primary model object for
this EditPart. |
protected List |
getModelChildren()
Returns a List containing the children model objects. |
EditPart |
getParent()
Returns the parent of this editpart. |
RootEditPart |
getRoot()
Returns the root EditPart. |
int |
getSelected()
Returns the selected state of this EditPart. |
EditPart |
getTargetEditPart(Request request)
Returns the EditPart which is the
target of the Request. |
protected EditPartViewer |
getViewer()
A convenience method which uses the Root to obtain the Viewer. |
boolean |
hasFocus()
Returns true if this EditPart has focus. |
protected void |
initialize()
Calls doInitialize() if shouldInitialize() returns true. |
void |
installEditPolicy(Object key,
EditPolicy editPolicy)
Installs the given EditPolicy using the given key or ID. |
protected boolean |
isActive()
Returns true if this EditPart is active. |
protected boolean |
isSelectable()
|
void |
performRequest(Request req)
Performs the specified Request. |
void |
refresh()
Refreshes all properties visually
displayed by this EditPart. |
protected void |
refreshChildren()
Refreshes the set of Children. |
protected void |
refreshVisuals()
Refreshes this part's visuals. |
protected void |
register()
Registers itself in the viewer's various registries. |
protected void |
registerAccessibility()
|
protected void |
registerModel()
|
protected void |
registerVisuals()
|
protected void |
removeChild(EditPart child)
Removes a child EditPart. |
protected abstract void |
removeChildVisual(EditPart child)
|
void |
removeEditPartListener(EditPartListener listener)
Removes a listener. |
void |
removeEditPolicy(Object key)
Uninstalls the edit policy if present. |
protected void |
reorderChild(EditPart editpart,
int index)
Bubbles and EditPart forward into a lower index than it
previously occupied. |
protected void |
setFlag(int flag,
boolean value)
Sets the value of the given flag to the appropriate value. |
void |
setFocus(boolean value)
Tells the EditPart whether it is the focus owner. |
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 of this EditPart. |
protected boolean |
shouldInitialize()
determines whether doInitialize() should be called. |
void |
showSourceFeedback(Request request)
Shows source feedback for the given Request. |
void |
showTargetFeedback(Request request)
Shows 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()
|
protected void |
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 |
getDragTracker |
| Field Detail |
protected static final int FLAG_INITIALIZED
protected static final int FLAG_FOCUS
protected static final int FLAG_ACTIVE
protected static final int MAX_FLAG
setFlag(int, boolean) and
getFlag(int) methods
with additional bitmasks iff those masks are greater than MAX_FLAG.
Example: static final int MY_FLAG = super.MAX_FLAG << 1;
protected List children
protected EventListenerList eventListeners
| Constructor Detail |
public AbstractEditPart()
| Method Detail |
public void activate()
Initializes or reactivates
this part and hooks any needed listeners.
This method is commonly overridden to add listeners to the model.
Subclasses should always call super.activate().
Activation indicates that the EditPart is realized in an EditPartViewer.
deactivate() is guaranteed to be called. Both may be called
multiple times.
During activation, and EditPart will generally:
activate in interface EditPartdeactivate()protected void activateEditPolicies()
Activates all EditPolicies. There is little reason to override this method.activate()
protected void addChild(EditPart child,
int index)
Adds a child EditPart
to this EditPart. If activated, this editpart will activate the child.
Notifies listeners that a child has been added. addChildVisual(EditPart, int)
is called to separate the act of performing the add from the act of activation and
the firing of notification to listeners.
Subclasses should generally override addChildVisual(EditPart, int) instead
of this method.
child - The EditPart to addindex - The indexaddChildVisual(EditPart, int),
removeChild(EditPart),
reorderChild(EditPart,int)
protected abstract void addChildVisual(EditPart child,
int index)
Performs the actual addition of the child to this EditPart.
Subclasses must supply additional code to update the visuals being used.
The provided subclasses 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)
Adds an editpart listener.addEditPartListener in interface EditPartprotected EditPart createChild(Object model)
Override to create the child
EditPart for the given model object.
This method is called from refreshChildren()
Subclasses may implement this method in place, or have it call
out to some type of EditPart factory associated with their application.
This method should be overriden together with getModelChildren().model - the Child model objectgetModelChildren()protected ConnectionEditPart createConnection(Object model)
Creates a
ConnectionEditPart for the given model.
Similar to createChild(Object).
called from refreshSourceConnections(),
and refreshTargetConnections().model - the connection model objectprotected ConnectionEditPart createOrFindConnection(Object model)
protected abstract void createEditPolicies()
Creates
the initial EditPolicies and reserves slots for dynamic ones.
Should be overridden to install the inital edit policies based on the
model's initial state.
null can be used to reserve a "slot", should there be
some desire to guarantee the ordering of EditPolcies.doInitialize(),
installEditPolicy(Object, EditPolicy)public void deactivate()
Override this
method to remove any listeners established in activate(),
and ALWAYS call super.deactivate() to ensure
that children, etc., are also deactivated. activate() may be called
again afterwards.deactivate in interface EditPartactivate()protected void deactivateEditPolicies()
Deactivates all installed EditPolicies.protected void debug(String message)
message - Message to be passedprotected void debugFeedback(String message)
message - Message to be passedpublic void dispose()
EditPartEditPart.deactivate(), such as unregistering
itself from the Viewer.dispose in interface EditPartprotected void doInitialize()
public void eraseSourceFeedback(Request request)
Erases source feedback for the given Request.
By default, this responsibility is delegated to this
part's EditPolicies. This method should not be overridden.eraseSourceFeedback in interface EditPartrequest - identifies the type of feedback to erase.showSourceFeedback(Request)public void eraseTargetFeedback(Request request)
Erases target feedback for the given Request.
By default, this responsibility is delegated to this
part's EditPolicies. This method should not be overridden.eraseTargetFeedback in interface EditPartrequest - Command requesting the erase.showTargetFeedback(Request)protected void fireActivated()
protected void fireChildAdded(EditPart child,
int index)
child - EditPart being added as child.index - Position child is being added into.protected void fireDeactivated()
protected void fireRemovingChild(EditPart child,
int index)
child - EditPart being removed.index - Position of the child in children list.protected void fireSelectionChanged()
public Object getAdapter(Class key)
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.getAdapter in interface IAdaptableIAdaptableprotected AccessibleEditPart getAccessibleEditPart()
public List getChildren()
Returns a non-null List containing the children EditParts.getChildren in interface EditPartEditPartspublic Command getCommand(Request request)
Returns null or a command that performs the operation
specified by the Request. This method should not be overridden.
By default, each installed EditPolicy will be given the opportunity
to return its contribution, and all contributions will be chained together
and returned.getCommand in interface EditPartRequest - A request describing the command to be created.EditPolicy.getCommand(Request)protected Iterator getEventListeners(Class clazz)
public EditPolicy getEditPolicy(Object key)
EditPartnull or the EditPolicy installed with the given key.getEditPolicy in interface EditPartprotected AbstractEditPart.EditPolicyIterator getEditPolicyIterator()
null, the iterator
only returns the non-null ones.protected boolean getFlag(int flag)
true if the bitwise AND of the bitmask
and the internal flags field is non-zero.flag - Bitmask indicating which flag to returnsetFlag(int,boolean)public KeyHandler getKeyHandler()
EditPartnull.getKeyHandler in interface EditPartpublic Object getModel()
Returns the primary model object for
this EditPart.getModel in interface EditPartprotected List getModelChildren()
Returns a List containing the children model objects.
Iff this EditPart's model is a composite, this method should be overridden
to returns its children.
refreshChildren() requires that this List be non-null.public EditPart getParent()
EditPartgetParent in interface EditPartpublic RootEditPart getRoot()
EditPartgetRoot in interface EditPartpublic int getSelected()
EditPartgetSelected in interface EditPartpublic EditPart getTargetEditPart(Request request)
Returns the EditPart which is the
target of the Request. This implementation determines
the target by delegating to its EditPolicies. An EditPart should not
understand any editing requests, instead, editing behavior is added by
installing EditPolicies.
The first non-null result returned by an
EditPolicy is returned. If no EditPolicy understand the request
(all EditPolicies return null),
this EditPart is not the target, and the request is forwarded
to the parent EditPart.getTargetEditPart in interface EditPartrequest - Describes the type of target desired.protected EditPartViewer getViewer()
public boolean hasFocus()
EditParthasFocus in interface EditPartprotected void initialize()
doInitialize() if shouldInitialize() returns true.
Sets a flag indicating that initialization has occurred.
public void installEditPolicy(Object key,
EditPolicy editPolicy)
installEditPolicy in interface EditPartkey - Identifier for the type of EditPolicy.editPolicy - the EditPolicy being added.removeEditPolicy(Object)protected boolean isActive()
protected boolean isSelectable()
public void performRequest(Request req)
EditPartperformRequest in interface EditPartpublic void refresh()
Refreshes all properties visually
displayed by this EditPart. The default implementation will call
refreshChildren() to update its structural features.
It also calls refreshVisuals() to update its own displayed properties.
This method should only be overridden if the previous four methods are not
sufficient.refresh in interface EditPartprotected void refreshChildren()
Refreshes the set of Children.
This method should not be overridden. createChild(Object)
and getModelChildren() should be overridden together.protected void refreshVisuals()
Refreshes this part's visuals. After creating the visuals, they should be
initialized and the updated in response to model changes by implementing
this method.protected void register()
Registers itself in the viewer's various registries.
If your EditPart has a 1-to-1 relationship with a visual object and a
1-to-1 relationship with a model object, the default implementation should
be sufficent.createConnection(Object),
unregister(),
EditPartViewer.getVisualPartMap(),
EditPartViewer.getEditPartRegistry()protected void registerAccessibility()
protected void registerModel()
protected void registerVisuals()
protected void removeChild(EditPart child)
Removes a child EditPart.
Calls removeChildVisual(EditPart) to separate the act of removal
from the process of deactivation and notification. dispose() is
called in refreshChildren() instead of here, since this method
could be used when reordering children.
Subclasses would generally override removeChildVisual(EditPart)
instead of this method.
child - EditPart being removedaddChild(EditPart,int)protected abstract void removeChildVisual(EditPart child)
public void removeEditPartListener(EditPartListener listener)
Removes a listener.removeEditPartListener in interface EditPartpublic void removeEditPolicy(Object key)
Uninstalls the edit policy if present.removeEditPolicy in interface EditPart
protected void reorderChild(EditPart editpart,
int index)
Bubbles and EditPart forward into a lower index than it
previously occupied.
This method is correctly implemented in the provided base classes.
This method is called from refreshChildren().child - EditPart being reorderedindex - Position into which it is being shifted
protected final void setFlag(int flag,
boolean value)
flag - Flag being setvalue - Value of the flag to be setgetFlag(int)public void setFocus(boolean value)
EditPartEditPartListener.selectedStateChanged(EditPart).setFocus in interface EditPartpublic void setModel(Object model)
Set the primary model object that this EditPart represents.
Listeners to the model should be added in {#activate()}, not here.
activate() and deactivate() may be called multiple times on an EditPart.setModel in interface EditPartpublic void setParent(EditPart parent)
Sets the parent EditPart.setParent in interface EditPartpublic void setSelected(int value)
sets the selected state of this EditPart.
This method should rarely be overridden.
Instead, EditPolicies that are selection-aware will listen for notification
of this property changing.setSelected in interface EditPartSelectionHandlesEditPolicyprotected boolean shouldInitialize()
determines whether doInitialize() should be called.
The provided abstract base classes correctly override this method to ensure
that the visuals exists prior to doInitialize().public void showSourceFeedback(Request request)
Shows source feedback for the given Request.
By default, this responsibility is delegated to this
part's EditPolicies. This method should not be overridden.showSourceFeedback in interface EditPartrequest - identifies the type of feedback to erase.eraseSourceFeedback(Request)public void showTargetFeedback(Request request)
Shows target feedback for the given Request.
By default, this responsibility is delegated to this
part's EditPolicies. This method should not be overridden.showTargetFeedback in interface EditPartrequest - identifies the type of feedback to erase.eraseTargetFeedback(Request)public String toString()
Describes this EditPart for developmental debugging purposes.toString in class Objectpublic boolean understandsRequest(Request req)
Returns true if this EditPart understand the given Request.
By default, this is determined by the installed EditPolicies.
![]() | EditParts should not understand any requests directly. ALL editing behavior is to be added by installing one or more EditPolicies into the EditPart. |
understandsRequest in interface EditPartrequest - identifies the type of feedback to erase.eraseTargetFeedback(Request)protected void unregister()
Undoes any registration performed by register().
The provided base classes will correctly unregister their visuals.protected void unregisterAccessibility()
protected void unregisterModel()
|
GEF v2.0 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||