Class AbstractEditPart

    • Field Detail

      • FLAG_FOCUS

        protected static final int FLAG_FOCUS
        This flag indicates that the EditPart has focus.
        See Also:
        Constant Field Values
      • MAX_FLAG

        protected static final int MAX_FLAG
        The left-most bit that is reserved by this class for setting flags. Subclasses may define additional flags starting at (MAX_FLAG << 1).
        See Also:
        Constant Field Values
      • children

        protected java.util.List children
        The List of children EditParts
    • Constructor Detail

      • AbstractEditPart

        public AbstractEditPart()
    • Method Detail

      • activate

        public 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.
        Specified by:
        activate in interface EditPart
        See Also:
        EditPart.activate(), deactivate()
      • activateEditPolicies

        protected void activateEditPolicies()
        Activates all EditPolicies installed on this part. There is no reason to override this method.
        See Also:
        activate()
      • addNotify

        public void addNotify()
        Description copied from interface: EditPart
        Called 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.
        Specified by:
        addNotify in interface EditPart
        See Also:
        EditPart.addNotify()
      • createChild

        protected EditPart createChild​(java.lang.Object model)
        Create the child 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.

        Parameters:
        model - the Child model object
        Returns:
        The child EditPart
      • createEditPolicies

        protected abstract void createEditPolicies()
        Creates the initial EditPolicies and/or reserves slots for dynamic ones. Should be implemented to install the inital EditPolicies 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.
        See Also:
        EditPart.installEditPolicy(Object, EditPolicy)
      • deactivate

        public void deactivate()
        Deactivates this EditPart, and in turn deactivates its children and EditPolicies. Subclasses should extend this method to remove any listeners established in activate()
        Specified by:
        deactivate in interface EditPart
        See Also:
        EditPart.deactivate(), activate()
      • deactivateEditPolicies

        protected void deactivateEditPolicies()
        Deactivates all installed EditPolicies.
      • debug

        protected final void debug​(java.lang.String message)
        Deprecated.
        in 3.1
        This 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
      • debugFeedback

        protected final void debugFeedback​(java.lang.String message)
        Deprecated.
        in 3.1
        This 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
      • eraseSourceFeedback

        public void eraseSourceFeedback​(Request request)
        Erases source feedback for the given 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.
        Specified by:
        eraseSourceFeedback in interface EditPart
        Parameters:
        request - identifies the type of feedback to erase.
        See Also:
        showSourceFeedback(Request)
      • eraseTargetFeedback

        public void eraseTargetFeedback​(Request request)
        Erases target feedback for the given 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.
        Specified by:
        eraseTargetFeedback in interface EditPart
        Parameters:
        request - Command requesting the erase.
        See Also:
        showTargetFeedback(Request)
      • fireActivated

        protected void fireActivated()
        Notifies EditPartListeners that this EditPart has been activated.
      • fireChildAdded

        protected void fireChildAdded​(EditPart child,
                                      int index)
        Notifies EditPartListeners that a child has been added.
        Parameters:
        child - EditPart being added as child.
        index - Position child is being added into.
      • fireDeactivated

        protected void fireDeactivated()
        Notifies EditPartListeners that this EditPart has been deactivated.
      • fireRemovingChild

        protected void fireRemovingChild​(EditPart child,
                                         int index)
        Notifies EditPartListeners that a child is being removed.
        Parameters:
        child - EditPart being removed.
        index - Position of the child in children list.
      • fireSelectionChanged

        protected void fireSelectionChanged()
        Notifies EditPartListeners that the selection has changed.
      • getAccessibleEditPart

        protected AccessibleEditPart getAccessibleEditPart()
        Returns the 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.
        Returns:
        null or an AccessibleEditPart adapter
      • getAdapter

        public java.lang.Object getAdapter​(java.lang.Class key)
        Returns 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:
        getAdapter in interface IAdaptable
        See Also:
        IAdaptable.getAdapter(java.lang.Class)
      • getChildren

        public java.util.List getChildren()
        Description copied from interface: EditPart
        Returns the List of children EditParts. 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:
        getChildren in interface EditPart
        Returns:
        a List of children
        See Also:
        EditPart.getChildren()
      • getCommand

        public Command getCommand​(Request request)
        Subclasses should rarely extend this method. The default implementation combines the contributions from each installed EditPolicy. 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:
        getCommand in interface EditPart
        Parameters:
        request - the Request
        Returns:
        a Command
        See Also:
        EditPart.getCommand(Request), EditPolicy.getCommand(Request)
      • getEventListeners

        protected final java.util.Iterator getEventListeners​(java.lang.Class clazz)
        Returns an iterator for the specified type of listener
        Parameters:
        clazz - the Listener type over which to iterate
        Returns:
        Iterator
      • getEditPolicyIterator

        protected final AbstractEditPart.EditPolicyIterator getEditPolicyIterator()
        Used internally to iterate over the installed EditPolicies. While EditPolicy slots may be reserved with null, the iterator only returns the non-null ones.
        Returns:
        an EditPolicyIterator
      • getFlag

        protected final boolean getFlag​(int flag)
        Returns the boolean value of the given flag. Specifically, returns true if 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:
        setFlag(int,boolean)
      • getModel

        public java.lang.Object getModel()
        Description copied from interface: EditPart
        Returns 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.
        Specified by:
        getModel in interface EditPart
        Returns:
        null or the primary model object
        See Also:
        EditPart.getModel()
      • getModelChildren

        protected java.util.List getModelChildren()
        Returns a 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.

        Returns:
        the List of children
      • getParent

        public EditPart getParent()
        Description copied from interface: EditPart
        Returns the parent EditPart. This method should only be called internally or by helpers such as EditPolicies.
        Specified by:
        getParent in interface EditPart
        Returns:
        null or the parent EditPart
        See Also:
        EditPart.getParent()
      • getTargetEditPart

        public EditPart getTargetEditPart​(Request request)
        Returns the 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.
        Specified by:
        getTargetEditPart in interface EditPart
        Parameters:
        request - Describes the type of target desired.
        Returns:
        null or the target EditPart
        See Also:
        EditPart.getTargetEditPart(Request), EditPolicy.getTargetEditPart(Request)
      • hasFocus

        public boolean hasFocus()
        Description copied from interface: EditPart
        Returns 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.
        Specified by:
        hasFocus in interface EditPart
        Returns:
        true if the EditPart has focus
        See Also:
        EditPart.hasFocus()
      • installEditPolicy

        public void installEditPolicy​(java.lang.Object key,
                                      EditPolicy editPolicy)
        Description copied from interface: EditPart
        Installs 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_ROLE is generally used as the key for this EditPolicy. null is a valid value for reserving a location.
        Specified by:
        installEditPolicy in interface EditPart
        Parameters:
        key - an identifier used to key the EditPolicy
        editPolicy - the EditPolicy
        See Also:
        EditPart.installEditPolicy(Object, EditPolicy)
      • isSelectable

        public boolean isSelectable()
        By default, an EditPart is regarded to be selectable.
        Specified by:
        isSelectable in interface EditPart
        Returns:
        true if the receiver can be selected
        See Also:
        EditPart.isSelectable()
      • performRequest

        public void performRequest​(Request req)
        Subclasses should extend this method to handle Requests. For now, the default implementation does not handle any requests.
        Specified by:
        performRequest in interface EditPart
        Parameters:
        req - the request to be performed
        See Also:
        EditPart.performRequest(Request)
      • refresh

        public 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. Subclasses should extend this method to handle additional types of structural refreshing.
        Specified by:
        refresh in interface EditPart
      • refreshChildren

        protected void refreshChildren()
        Updates the set of children EditParts so that it is in sync with the model children. This method is called from 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.

        See Also:
        getModelChildren()
      • refreshVisuals

        protected void refreshVisuals()
        Refreshes this EditPart's visuals. This method is called by refresh(), and may also be called in response to notifications from the model. This method does nothing by default. Subclasses may override.
      • registerAccessibility

        protected final void registerAccessibility()
        Registers the AccessibleEditPart adapter.
        See Also:
        getAccessibleEditPart()
      • registerModel

        protected void registerModel()
        Registers the model in the EditPartViewer.getEditPartRegistry(). Subclasses should only extend this method if they need to register this EditPart in additional ways.
      • removeChildVisual

        protected abstract void removeChildVisual​(EditPart child)
        Removes the childs 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
      • removeNotify

        public void removeNotify()
        Removes all references from the EditPartViewer to this EditPart. This includes:
        • deselecting this EditPart if selected
        • setting the Viewer's focus to 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.

        Specified by:
        removeNotify in interface EditPart
        See Also:
        EditPart.removeNotify()
      • reorderChild

        protected void reorderChild​(EditPart editpart,
                                    int index)
        Moves a child EditPart into a lower index than it currently occupies. This method is called from refreshChildren().
        Parameters:
        editpart - the child being reordered
        index - new index for the child
      • setFlag

        protected final void setFlag​(int flag,
                                     boolean value)
        Sets the value of the specified flag. Flag values are decalared as static constants. Subclasses may define additional constants above MAX_FLAG.
        Parameters:
        flag - Flag being set
        value - Value of the flag to be set
        See Also:
        getFlag(int)
      • setModel

        public void setModel​(java.lang.Object model)
        Set the primary model object that this EditPart represents. This method is used by an EditPartFactory when creating an EditPart.
        Specified by:
        setModel in interface EditPart
        Parameters:
        model - the Model
        See Also:
        EditPart.setModel(Object)
      • toString

        public java.lang.String toString()
        Describes this EditPart for developmental debugging purposes.
        Overrides:
        toString in class java.lang.Object
        Returns:
        a description
      • understandsRequest

        public boolean understandsRequest​(Request req)
        Returns 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()
        Specified by:
        understandsRequest in interface EditPart
        Parameters:
        req - a Request describing an operation of some type
        Returns:
        true if Request is understood
        See Also:
        EditPart.understandsRequest(Request)
      • unregister

        protected void unregister()
        Undoes any registration performed by register(). The provided base classes will correctly unregister their visuals.
      • unregisterAccessibility

        protected final void unregisterAccessibility()
        Unregisters the AccessibleEditPart adapter.
      • unregisterModel

        protected void unregisterModel()
        Unregisters the model in the EditPartViewer.getEditPartRegistry(). Subclasses should only extend this method if they need to unregister this EditPart in additional ways.