Class ComponentEditPolicy

java.lang.Object
org.eclipse.gef.editpolicies.AbstractEditPolicy
org.eclipse.gef.editpolicies.ComponentEditPolicy
All Implemented Interfaces:
EditPolicy, RequestConstants
Direct Known Subclasses:
RootComponentEditPolicy

public abstract class ComponentEditPolicy extends AbstractEditPolicy
A model-based EditPolicy for components within a container. A model-based EditPolicy only knows about the host's model and the basic operations it supports. A component is anything that is inside a container. By default, ComponentEditPolicy understands being DELETEd from its container, and being ORPHANed from its container. Subclasses can add support to handle additional behavior specific to the model.

ORPHAN is forwarded to the parent EditPart for it to handle.

DELETE is also forwarded to the parent EditPart, but subclasses may also contribute to the delete by overriding createDeleteCommand(GroupRequest).

This EditPolicy is not a GraphicalEditPolicy, and should not be used to show feedback or interact with the host's visuals in any way.

This EditPolicy should not be used with ConnectionEditPart. Connections do not really have a parent; use ConnectionEditPolicy.

Since:
2.0
  • Constructor Details

    • ComponentEditPolicy

      public ComponentEditPolicy()
  • Method Details

    • createDeleteCommand

      protected Command createDeleteCommand(GroupRequest deleteRequest)
      Override to contribute to the component's being deleted.
      Parameters:
      deleteRequest - the DeleteRequest
      Returns:
      Command null or a contribution to the delete
    • getCommand

      public Command getCommand(Request request)
      Factors the incoming Request into ORPHANs and DELETEs.
      Specified by:
      getCommand in interface EditPolicy
      Overrides:
      getCommand in class AbstractEditPolicy
      Parameters:
      request - the Request
      Returns:
      null or a Command contribution
      See Also:
    • getDeleteCommand

      protected Command getDeleteCommand(GroupRequest request)
      Calls and returns createDeleteCommand(GroupRequest). This method is here for historical reasons and used to perform additional function.
      Parameters:
      request - the DeleteRequest
      Returns:
      a delete command
    • getOrphanCommand

      protected Command getOrphanCommand()
      Returns the command contribution for orphaning this component from its container. By default, ORPHAN is redispatched to the host's parent as an ORPHAN_CHILDREN Request. The parents contribution is then returned.
      Returns:
      the contribution obtained from the host's parent.