/** @generated */
 protected Command getConnectionCompleteCommand(CreateConnectionRequest request) {
   if (request instanceof CreateConnectionRequestEx) {
     if (request.getStartCommand() == null || !request.getStartCommand().canExecute()) {
       return UnexecutableCommand.INSTANCE;
     }
     CreateConnectionRequestEx requestEx = (CreateConnectionRequestEx) request;
     if (!DiagramEditPart.MODEL_ID.equals(requestEx.getModelID())) {
       return null;
     }
     int[] visualIds = requestEx.getVisualIds();
     CompoundCommand result = new CompoundCommand();
     for (int i = 0; i < visualIds.length; i++) {
       int nextVisualId = visualIds[i];
       switch (nextVisualId) {
         case TransitionEditPart.VISUAL_ID:
           result.appendIfCanExecute(new CreateTransition4001Command(requestEx));
           break;
       }
     }
     if (result.getCommandList().size() != 1 || !result.canExecute()) {
       // Cannot create several connections at once.
       return UnexecutableCommand.INSTANCE;
     }
     return request
         .getStartCommand()
         .chain(
             new WrappingCommand(
                 TransactionUtil.getEditingDomain(
                     ((Node) getHost().getModel()).getDiagram().getElement()),
                 result));
   }
   return null;
 }
	protected Command getConnectionCompleteCommand(
			CreateConnectionRequest request) {
		MenuRelationConnectionCommand comd = (MenuRelationConnectionCommand) request.getStartCommand();

		LFWBasicElementObj target = (LFWBasicElementObj) getHost().getModel();
		comd.setTarget(target);
		return comd;
	}
  /**
   * @see
   *     org.eclipse.gef.editpolicies.GraphicalNodeEditPolicy#getConnectionCompleteCommand(org.eclipse.gef.requests.CreateConnectionRequest)
   */
  protected Command getConnectionCompleteCommand(CreateConnectionRequest request) {
    ConnectionCommand command = (ConnectionCommand) request.getStartCommand();

    // dont allow connection if there is already a connection between source and target
    // and of the same type.
    EdgeContainer ec = ((INode) getHost().getModel()).getRoot().getEdgeContainer();
    if (ec.containsEdge(command.getSourceNode(), (INode) getHost().getModel(), command.getType())) {
      return null;
    }

    // dont allow connection if source node is an ancestor of target
    AbstractAsset parent = (AbstractAsset) getHost().getModel();
    while (parent != null) {
      parent = parent.getParent();
      if (parent == command.getSourceNode()) {
        return null;
      }
    }

    // check meta node policy
    Object m = getHost().getModel();
    if (m instanceof MetaNode) {
      String edgeType = ((MetaNode) m).getEdgeType();
      if (edgeType != null && !edgeType.equals(command.getType())) {
        return null;
      }
    }

    // dont allow self-connection
    if (command.getSourceNode() == getHost().getModel()) {
      return null;
    }

    // dont allow connection if target node is an ancestor of source
    parent = (AbstractAsset) command.getSourceNode();
    while (parent != null) {
      parent = parent.getParent();
      if (parent == (AbstractAsset) getHost().getModel()) {
        return null;
      }
    }

    command.setTargetNode((INode) getHost().getModel());

    return command;
  }
示例#4
0
 @Override
 protected Command getConnectionCompleteCommand(CreateConnectionRequest request) {
   ConnectionDrawCommand cmd = (ConnectionDrawCommand) request.getStartCommand();
   cmd.setTarget((WorkflowNode) getHost().getModel());
   return cmd;
 }
 @Override
 protected Command getConnectionCompleteCommand(CreateConnectionRequest request) {
   CreateConnectionCommand cmd = (CreateConnectionCommand) request.getStartCommand();
   cmd.setTarget((DiagramNodeModel) getHost().getModel());
   return cmd;
 }