Runtime

org.eclipse.gmf.runtime.diagram.ui.editpolicies
Class CreationEditPolicy

java.lang.Object
  extended byorg.eclipse.gef.editpolicies.AbstractEditPolicy
      extended byorg.eclipse.gmf.runtime.diagram.ui.editpolicies.CreationEditPolicy
All Implemented Interfaces:
EditPolicy, RequestConstants

public class CreationEditPolicy
extends AbstractEditPolicy

This edit policy returns the command that will create a new notational view for a the given request.


Field Summary
 
Fields inherited from interface org.eclipse.gef.EditPolicy
COMPONENT_ROLE, CONNECTION_BENDPOINTS_ROLE, CONNECTION_ENDPOINTS_ROLE, CONNECTION_ROLE, CONTAINER_ROLE, DIRECT_EDIT_ROLE, GRAPHICAL_NODE_ROLE, LAYOUT_ROLE, NODE_ROLE, PRIMARY_DRAG_ROLE, SELECTION_FEEDBACK_ROLE, TREE_CONTAINER_ROLE
 
Fields inherited from interface org.eclipse.gef.RequestConstants
REQ_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 Summary
CreationEditPolicy()
           
 
Method Summary
 Command getCommand(Request request)
           
protected  Command getCreateCommand(CreateViewRequest request)
          Called in response to a REQ_CREATE request.
protected  Command getCreateElementAndViewCommand(CreateViewAndElementRequest request)
          Method getCreateElementAndViewCommand.
protected  Command getReparentCommand(ChangeBoundsRequest request)
          return a command to reparent both the semantic and view elements.
protected  ICommand getReparentCommand(IGraphicalEditPart gep)
          Return the command to reparent the supplied editpart's semantic and notation elements.
protected  ICommand getReparentViewCommand(IGraphicalEditPart gep)
          Return the command to reparent the supplied editpart's view only.
 EditPart getTargetEditPart(Request request)
          Return the host if this editpolicy understands the supplied request.
protected  boolean shouldReparent(EObject element, EObject newContext)
          Determines if a semantic reparent is being performed.
 boolean understandsRequest(Request request)
          Understands REQ_CREATE and REQ_ADD request types.
 
Methods inherited from class org.eclipse.gef.editpolicies.AbstractEditPolicy
activate, deactivate, debugFeedback, eraseSourceFeedback, eraseTargetFeedback, getHost, setHost, showSourceFeedback, showTargetFeedback, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CreationEditPolicy

public CreationEditPolicy()
Method Detail

getCommand

public Command getCommand(Request request)
Returns:
Command for the REQ_CREATE request. If the request is of type CreateViewAndElementRequest then a command to create the semantic, and the view will
See Also:
EditPolicy.getCommand(org.eclipse.gef.Request)

understandsRequest

public boolean understandsRequest(Request request)
Understands REQ_CREATE and REQ_ADD request types.


shouldReparent

protected boolean shouldReparent(EObject element,
                                 EObject newContext)
Determines if a semantic reparent is being performed.

Parameters:
element - element being reparented
newContext - the new container element
Returns:
true if the supplied elemnet's container is not equals to the supplied newContext.\; otherwise false.

getReparentCommand

protected Command getReparentCommand(ChangeBoundsRequest request)
return a command to reparent both the semantic and view elements.

Parameters:
request - the request
Returns:
command

getReparentCommand

protected ICommand getReparentCommand(IGraphicalEditPart gep)
Return the command to reparent the supplied editpart's semantic and notation elements.

Parameters:
gep - the editpart being reparented
Returns:
A CompositeCommand2 that will reparent both the semantic and notation elements.

getReparentViewCommand

protected ICommand getReparentViewCommand(IGraphicalEditPart gep)
Return the command to reparent the supplied editpart's view only.

Parameters:
gep - the editpart being reparented
Returns:
A command to reparent the notation element.

getCreateCommand

protected Command getCreateCommand(CreateViewRequest request)
Called in response to a REQ_CREATE request. Creates a compound command and populated with the following commands for each element to be created:
  1. a CreateCommandfor each of the request's view descriptor.

Parameters:
request - a create request (understands instances of CreateViewRequest).
Returns:
a command to satify the request; null if the request is not understood.

getCreateElementAndViewCommand

protected Command getCreateElementAndViewCommand(CreateViewAndElementRequest request)
Method getCreateElementAndViewCommand.

Parameters:
request -
Returns:
Command Which creates the sematnic and the view command for the given CreateViewAndElementRequest

getTargetEditPart

public EditPart getTargetEditPart(Request request)
Return the host if this editpolicy understands the supplied request.


Runtime

Guidelines for using Eclipse APIs.

Copyright (c) IBM Corp., Borland Software Corp., and others 2005,2006. All rights reserved.