Class AbstractEditPart
- All Implemented Interfaces:
- IAdaptable,- EditPart,- RequestConstants
- Direct Known Subclasses:
- AbstractGraphicalEditPart,- AbstractTreeEditPart,- RootTreeEditPart
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 SummaryNested ClassesModifier and TypeClassDescriptionprotected static classIterates over aListof EditPolcies, skipping anynullvalues encountered.
- 
Field SummaryFieldsModifier and TypeFieldDescriptionThe List of children EditPartsprotected static final intThis flag is set duringactivate(), and reset ondeactivate()protected static final intThis flag indicates that the EditPart has focus.protected static final intThe left-most bit that is reserved by this class for setting flags.Fields inherited from interface org.eclipse.gef.EditPartSELECTED, SELECTED_NONE, SELECTED_PRIMARYFields inherited from interface org.eclipse.gef.RequestConstantsREQ_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 SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidactivate()Activates this EditPart, which in turn activates its children and EditPolicies.protected voidActivates all EditPolicies installed on this part.protected voidAdds a childEditPartto this EditPart.protected abstract voidaddChildVisual(EditPart child, int index) Performs the addition of the child's visual to this EditPart's Visual.voidaddEditPartListener(EditPartListener listener) Adds an EditPartListener.voidCalled after the EditPart has been added to its parent.protected EditPartcreateChild(Object model) Create the childEditPartfor the given model object.protected abstract voidCreates the initial EditPolicies and/or reserves slots for dynamic ones.voidDeactivates this EditPart, and in turn deactivates its children and EditPolicies.protected voidDeactivates all installed EditPolicies.protected final voidDeprecated.in 3.1protected final voiddebugFeedback(String message) Deprecated.in 3.1voideraseSourceFeedback(Request request) Erases source feedback for the givenRequest.voideraseTargetFeedback(Request request) Erases target feedback for the givenRequest.protected voidNotifiesEditPartListenersthat this EditPart has been activated.protected voidfireChildAdded(EditPart child, int index) NotifiesEditPartListenersthat a child has been added.protected voidNotifiesEditPartListenersthat this EditPart has been deactivated.protected voidfireRemovingChild(EditPart child, int index) NotifiesEditPartListenersthat a child is being removed.protected voidNotifiesEditPartListenersthat the selection has changed.protected AccessibleEditPartReturns theAccessibleEditPartadapter for this EditPart.<T> TgetAdapter(Class<T> key) Returns the specified adapter if recognized.Returns the List of childrenEditParts.getCommand(Request request) Subclasses should rarely extend this method.getEditPolicy(Object key) protected final Iterable<EditPolicy> Used internally to iterate over the installed EditPolicies.protected final AbstractEditPart.EditPolicyIteratorDeprecated, for removal: This API element is subject to removal in a future version.use UsegetEditPolicyIterable()instead.protected final <T> Iterator<T> getEventListeners(Class<T> clazz) Returns an iterator for the specified type of listenerprotected <T> Iterable<T> getEventListenersIterable(Class<T> listenerType) * Returns an Iterator for the specified type of listenerprotected final booleangetFlag(int flag) Returns the boolean value of the given flag.getModel()Returns the primary model object that this EditPart represents.Returns aListcontaining the children model objects.Returns the parentEditPart.getRoot()Returns theRootEditPart.intReturns the selected state of this EditPart.getTargetEditPart(Request request) Returns theEditPartwhich is the target of theRequest.Convenience method for returning theEditPartViewerfor this part.booleanhasFocus()Returns true if this EditPart has focus.voidinstallEditPolicy(Object key, EditPolicy editPolicy) Installs an EditPolicy for a specified role.booleanisActive()returnstrueif the EditPart is active.booleanBy default, an EditPart is regarded to be selectable.voidperformRequest(Request req) Subclasses should extend this method to handle Requests.voidrefresh()Refreshes all properties visually displayed by this EditPart.protected voidUpdates the set of children EditParts so that it is in sync with the model children.protected voidRefreshes this EditPart's visuals.protected voidregister()Registers itself in the viewer's various registries.protected final voidRegisters theAccessibleEditPartadapter.protected voidRegisters the model in theEditPartViewer.getEditPartRegistry().protected voidRegisters the visuals in theEditPartViewer.getVisualPartMap().protected voidremoveChild(EditPart child) Removes a childEditPart.protected abstract voidremoveChildVisual(EditPart child) Removes the child's visual from this EditPart's visual.voidremoveEditPartListener(EditPartListener listener) No reason to overridevoidremoveEditPolicy(Object key) No reason to overridevoidRemoves all references from theEditPartViewerto this EditPart.protected voidreorderChild(EditPart editpart, int index) Moves a childEditPartinto a lower index than it currently occupies.protected final voidsetFlag(int flag, boolean value) Sets the value of the specified flag.voidsetFocus(boolean value) Called byEditPartViewerto indicate that theEditParthas gained or lost keyboard focus.voidSet the primary model object that this EditPart represents.voidSets the parent EditPart.voidsetSelected(int value) Sets the selected state for this EditPart, which may be one of:EditPart.SELECTED_PRIMARYEditPart.SELECTEDEditPart.SELECTED_NONEAs only selectableEditParts may get selected, the method may only be called with a selected value ofEditPart.SELECTEDorEditPart.SELECTED_PRIMARYin case the receiver is selectable, i.e.voidshowSourceFeedback(Request request) Shows or updates source feedback for the givenRequest.voidshowTargetFeedback(Request request) Shows or updates target feedback for the givenRequest.toString()Describes this EditPart for developmental debugging purposes.booleanReturnstrueif thisEditPartunderstand the givenRequest.protected voidUndoes any registration performed byregister().protected final voidUnregisters theAccessibleEditPartadapter.protected voidUnregisters the model in theEditPartViewer.getEditPartRegistry().protected voidUnregisters the visuals in theEditPartViewer.getVisualPartMap().Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.eclipse.gef.EditPartgetDragTracker
- 
Field Details- 
FLAG_ACTIVEprotected static final int FLAG_ACTIVEThis flag is set duringactivate(), and reset ondeactivate()- See Also:
 
- 
FLAG_FOCUSprotected static final int FLAG_FOCUSThis flag indicates that the EditPart has focus.- See Also:
 
- 
MAX_FLAGprotected static final int MAX_FLAGThe left-most bit that is reserved by this class for setting flags. Subclasses may define additional flags starting at(MAX_FLAG << 1).- See Also:
 
- 
childrenThe List of children EditParts
 
- 
- 
Constructor Details- 
AbstractEditPartpublic AbstractEditPart()
 
- 
- 
Method Details- 
activatepublic void activate()Activates this EditPart, which in turn activates its children and EditPolicies. Subclasses should extend this method to add listeners to the model. Activation indicates that the EditPart is realized in an EditPartViewer.deactivate()is the inverse, and is eventually called on all EditParts.
- 
activateEditPoliciesprotected void activateEditPolicies()Activates all EditPolicies installed on this part. There is no reason to override this method.- See Also:
 
- 
addChildAdds a childEditPartto this EditPart. This method is called fromrefreshChildren(). The following events occur in the order listed:- The child is added to the childrenList, and its parent is set tothis
- 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
- EditPartListenersare notified that the child has been added.
 Subclasses should implement addChildVisual(EditPart, int).- Parameters:
- child- The- EditPartto add
- index- The index
- See Also:
 
- The child is added to the 
- 
addChildVisualPerforms the addition of the child's visual to this EditPart's Visual. The provided subclassesAbstractGraphicalEditPartandAbstractTreeEditPartalready implement this method correctly, so it is unlikely that this method should be overridden.- Parameters:
- child- The EditPart being added
- index- The child's position
- See Also:
 
- 
addEditPartListenerAdds an EditPartListener.- Specified by:
- addEditPartListenerin interface- EditPart
- Parameters:
- listener- the listener
 
- 
addNotifypublic void addNotify()Description copied from interface:EditPartCalled 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.
- 
createChildCreate the childEditPartfor the given model object. This method is called fromrefreshChildren().By default, the implementation will delegate to the EditPartViewer'sEditPartFactory. Subclasses may override this method instead of using a Factory.- Parameters:
- model- the Child model object
- Returns:
- The child EditPart
 
- 
createEditPoliciesprotected abstract void createEditPolicies()Creates the initial EditPolicies and/or reserves slots for dynamic ones. Should be implemented to install the initial EditPolicies based on the model's initial state.nullcan be used to reserve a "slot", should there be some desire to guarantee the ordering of EditPolcies.- See Also:
 
- 
deactivatepublic void deactivate()Deactivates this EditPart, and in turn deactivates its children and EditPolicies. Subclasses should extend this method to remove any listeners established inactivate()- Specified by:
- deactivatein interface- EditPart
- See Also:
 
- 
deactivateEditPoliciesprotected void deactivateEditPolicies()Deactivates all installed EditPolicies.
- 
debugDeprecated.in 3.1This method will log a message to GEF's trace/debug system if the corresponding flag for EditParts is set to true.- Parameters:
- message- a debug message
 
- 
debugFeedbackDeprecated.in 3.1This method will log the message to GEF's trace/debug system if the corrseponding flag for FEEDBACK is set to true.- Parameters:
- message- Message to be passed
 
- 
eraseSourceFeedbackErases source feedback for the givenRequest. By default, this responsibility is delegated to this part'sEditPolicies. Subclasses should rarely extend this method.  It is recommended that feedback be handled by EditPolicies, and not directly by the EditPart. - Specified by:
- eraseSourceFeedbackin interface- EditPart
- Parameters:
- request- identifies the type of feedback to erase.
- See Also:
 
- 
eraseTargetFeedbackErases target feedback for the givenRequest. 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. - Specified by:
- eraseTargetFeedbackin interface- EditPart
- Parameters:
- request- Command requesting the erase.
- See Also:
 
- 
fireActivatedprotected void fireActivated()NotifiesEditPartListenersthat this EditPart has been activated.
- 
fireChildAddedNotifiesEditPartListenersthat a child has been added.- Parameters:
- child-- EditPartbeing added as child.
- index- Position child is being added into.
 
- 
fireDeactivatedprotected void fireDeactivated()NotifiesEditPartListenersthat this EditPart has been deactivated.
- 
fireRemovingChildNotifiesEditPartListenersthat a child is being removed.- Parameters:
- child-- EditPartbeing removed.
- index- Position of the child in children list.
 
- 
fireSelectionChangedprotected void fireSelectionChanged()NotifiesEditPartListenersthat the selection has changed.
- 
getAccessibleEditPartReturns theAccessibleEditPartadapter for this EditPart. The same adapter instance must be used throughout the editpart's existence. Each adapter has a unique ID which is registered duringregister(). Accessibility clients can only refer to this editpart via that ID.- Returns:
- nullor an AccessibleEditPart adapter
 
- 
getAdapterReturns the specified adapter if recognized. Delegates to the workbench adapter mechanism.Additional adapter types may be added in the future. Subclasses should extend this method as needed. - Specified by:
- getAdapterin interface- IAdaptable
- See Also:
 
- 
getChildrenDescription copied from interface:EditPartReturns the List of childrenEditParts. 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.- Specified by:
- getChildrenin interface- EditPart
- Returns:
- a Listof children
- See Also:
 
- 
getCommandSubclasses should rarely extend this method. The default implementation combines the contributions from each installedEditPolicy. This method is implemented indirectly using EditPolicies.  It is recommended that Command creation be handled by EditPolicies, and not directly by the EditPart. - Specified by:
- getCommandin interface- EditPart
- Parameters:
- request- the Request
- Returns:
- a Command
- See Also:
 
- 
getEventListenersReturns an iterator for the specified type of listener- Parameters:
- clazz- the Listener type over which to iterate
- Returns:
- Iterator
 
- 
getEventListenersIterable* Returns an Iterator for the specified type of listener- Parameters:
- listenerType- the type of listeners to get
- Returns:
- an Iterable over the requested listeners
- Since:
- 3.14
 
- 
getEditPolicy- Specified by:
- getEditPolicyin interface- EditPart
- Parameters:
- key- the key identifying the EditPolicy
- Returns:
- nullor the EditPolicy installed with the given key
- See Also:
 
- 
getEditPolicyIterator@Deprecated(since="3.15", forRemoval=true) protected final AbstractEditPart.EditPolicyIterator getEditPolicyIterator()Deprecated, for removal: This API element is subject to removal in a future version.use UsegetEditPolicyIterable()instead.Used internally to iterate over the installed EditPolicies. While EditPolicy slots may be reserved withnull, the iterator only returns the non-null ones.- Returns:
- an EditPolicyIterator
 
- 
getEditPolicyIterableUsed internally to iterate over the installed EditPolicies.- Returns:
- an Iterable for the installed EditPolicies
- Since:
- 3.15
 
- 
getFlagprotected final boolean getFlag(int flag) Returns the boolean value of the given flag. Specifically, returnstrueif the bitwise AND of the specified flag and the internal flags field is non-zero.- Parameters:
- flag- Bitmask indicating which flag to return
- Returns:
- the requested flag's value
- See Also:
 
- 
getModelDescription copied from interface:EditPartReturns the primary model object that this EditPart represents. EditParts may correspond to more than one model object, or even no model object. In practice, the Object returned is used by other EditParts to identify this EditPart. In addition, EditPolicies probably rely on this method to build Commands that operate on the model.
- 
getModelChildrenReturns aListcontaining 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.- Returns:
- the List of children
 
- 
getParentDescription copied from interface:EditPartReturns the parentEditPart. This method should only be called internally or by helpers such as EditPolicies.
- 
getRootDescription copied from interface:EditPartReturns theRootEditPart. This method should only be called internally or by helpers such as edit policies. The root can be used to get the viewer.- Specified by:
- getRootin interface- EditPart
- Returns:
- nullor the- RootEditPart
- See Also:
 
- 
getSelectedpublic int getSelected()Description copied from interface:EditPartReturns the selected state of this EditPart. This method should only be called internally or by helpers such as EditPolicies.- Specified by:
- getSelectedin interface- EditPart
- Returns:
- one of:
- See Also:
 
- 
getTargetEditPartReturns theEditPartwhich is the target of theRequest. The default implementation delegates this method to the installed EditPolicies. The first non-nullresult 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. - Specified by:
- getTargetEditPartin interface- EditPart
- Parameters:
- request- Describes the type of target desired.
- Returns:
- nullor the target- EditPart
- See Also:
 
- 
getViewerDescription copied from interface:EditPartConvenience method for returning theEditPartViewerfor this part.- Specified by:
- getViewerin interface- EditPart
- Returns:
- the EditPartViewerornull
- See Also:
 
- 
hasFocuspublic boolean hasFocus()Description copied from interface:EditPartReturns true if this EditPart has focus. The focus EditPart is a property of the EditPartViewer. The Viewer keeps this property in sync with its focus.
- 
installEditPolicyDescription copied from interface:EditPartInstalls an EditPolicy for a specified role. A role is is simply an Object used to identify the EditPolicy. An example of a role is layout.EditPolicy.LAYOUT_ROLEis generally used as the key for this EditPolicy.nullis a valid value for reserving a location.- Specified by:
- installEditPolicyin interface- EditPart
- Parameters:
- key- an identifier used to key the EditPolicy
- editPolicy- the EditPolicy
- See Also:
 
- 
isActivepublic boolean isActive()Description copied from interface:EditPartreturnstrueif the EditPart is active. Editparts are active afterEditPart.activate()is called, and untilEditPart.deactivate()is called.
- 
isSelectablepublic boolean isSelectable()By default, an EditPart is regarded to be selectable.- Specified by:
- isSelectablein interface- EditPart
- Returns:
- trueif the receiver can be selected
- See Also:
 
- 
performRequestSubclasses should extend this method to handle Requests. For now, the default implementation does not handle any requests.- Specified by:
- performRequestin interface- EditPart
- Parameters:
- req- the request to be performed
- See Also:
 
- 
refreshpublic void refresh()Refreshes all properties visually displayed by this EditPart. The default implementation will callrefreshChildren()to update its structural features. It also callsrefreshVisuals()to update its own displayed properties. Subclasses should extend this method to handle additional types of structural refreshing.
- 
refreshChildrenprotected void refreshChildren()Updates the set of children EditParts so that it is in sync with the model children. This method is called fromrefresh(), 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 callingremoveChild(EditPart)andaddChild(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 areremoved. New models have their EditPartscreated.This method should not be overridden. - See Also:
 
- 
refreshVisualsprotected void refreshVisuals()Refreshes this EditPart's visuals. This method is called byrefresh(), and may also be called in response to notifications from the model. This method does nothing by default. Subclasses may override.
- 
registerprotected 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 sufficient.- See Also:
 
- 
registerAccessibilityprotected final void registerAccessibility()Registers theAccessibleEditPartadapter.- See Also:
 
- 
registerModelprotected void registerModel()Registers the model in theEditPartViewer.getEditPartRegistry(). Subclasses should only extend this method if they need to register this EditPart in additional ways.
- 
registerVisualsprotected void registerVisuals()Registers the visuals in theEditPartViewer.getVisualPartMap(). Subclasses should override this method for the visual part they support.AbstractGraphicalEditPartandAbstractTreeEditPartalready do this.
- 
removeChildRemoves a childEditPart. This method is called fromrefreshChildren(). The following events occur in the order listed:- EditPartListenersare 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.
- The child's parent is set to null
 Subclasses should implement removeChildVisual(EditPart).- Parameters:
- child- EditPart being removed
- See Also:
 
- 
removeChildVisualRemoves the child's visual from this EditPart's visual. Subclasses should implement this method to support the visual type they introduce, such as Figures or TreeItems.- Parameters:
- child- the child EditPart
 
- 
removeEditPartListenerNo reason to override- Specified by:
- removeEditPartListenerin interface- EditPart
- Parameters:
- listener- the listener being removed
- See Also:
 
- 
removeEditPolicyNo reason to override- Specified by:
- removeEditPolicyin interface- EditPart
- Parameters:
- key- the key identifying the EditPolicy to be removed
- See Also:
 
- 
removeNotifypublic void removeNotify()Removes all references from theEditPartViewerto this EditPart. This includes:- deselecting this EditPart if selected
- setting the Viewer's focus to nullif 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.- Specified by:
- removeNotifyin interface- EditPart
- See Also:
 
- 
reorderChildMoves a childEditPartinto a lower index than it currently occupies. This method is called fromrefreshChildren().- Parameters:
- editpart- the child being reordered
- index- new index for the child
 
- 
setFlagprotected final void setFlag(int flag, boolean value) Sets the value of the specified flag. Flag values are declared as static constants. Subclasses may define additional constants aboveMAX_FLAG.- Parameters:
- flag- Flag being set
- value- Value of the flag to be set
- See Also:
 
- 
setFocuspublic void setFocus(boolean value) Called byEditPartViewerto indicate that theEditParthas gained or lost keyboard focus. Focus is considered to be part of the selected state. Therefore, only selectableEditParts are able to obtain focus, and the method may thus only be called with a value oftruein case the receiver is selectable, i.e.isSelectable()returnstrue. The method should rarely be overridden. Instead, EditPolicies that are selection-aware listen for notifications about the change of focus viaEditPartListener.selectedStateChanged(EditPart).
- 
setModelSet the primary model object that this EditPart represents. This method is used by anEditPartFactorywhen creating an EditPart.
- 
setParentSets the parent EditPart. There is no reason to override this method.
- 
setSelectedpublic void setSelected(int value) Sets the selected state for this EditPart, which may be one of: As only selectableEditParts may get selected, the method may only be called with a selected value ofEditPart.SELECTEDorEditPart.SELECTED_PRIMARYin case the receiver is selectable, i.e.isSelectable()returnstrue. The method should rarely be overridden. Instead, EditPolicies that are selection-aware listen for notifications about the change of selection state viaEditPartListener.selectedStateChanged(EditPart).- Specified by:
- setSelectedin interface- EditPart
- Parameters:
- value- the selected value
- See Also:
 
- 
showSourceFeedbackShows or updates source feedback for the givenRequest. 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. - Specified by:
- showSourceFeedbackin interface- EditPart
- Parameters:
- request- the Request
- See Also:
 
- 
showTargetFeedbackShows or updates target feedback for the givenRequest. 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. - Specified by:
- showTargetFeedbackin interface- EditPart
- Parameters:
- request- the Request
- See Also:
 
- 
toStringDescribes this EditPart for developmental debugging purposes.
- 
understandsRequestReturnstrueif thisEditPartunderstand the givenRequest. By default, this responsibility is delegated to this part's installed EditPolicies.  It is recommended that EditPolicies implement understandsRequest()- Specified by:
- understandsRequestin interface- EditPart
- Parameters:
- req- a- Requestdescribing an operation of some type
- Returns:
- trueif Request is understood
- See Also:
 
- 
unregisterprotected void unregister()Undoes any registration performed byregister(). The provided base classes will correctly unregister their visuals.
- 
unregisterAccessibilityprotected final void unregisterAccessibility()Unregisters theAccessibleEditPartadapter.
- 
unregisterModelprotected void unregisterModel()Unregisters the model in theEditPartViewer.getEditPartRegistry(). Subclasses should only extend this method if they need to unregister this EditPart in additional ways.
- 
unregisterVisualsprotected void unregisterVisuals()Unregisters the visuals in theEditPartViewer.getVisualPartMap(). Subclasses should override this method for the visual part they support.AbstractGraphicalEditPartandAbstractTreeEditPartalready do this.
 
-