/** @generated */
 private void addDestroyChildNodesCommand(ICompositeCommand cmd) {
   View view = (View) getHost().getModel();
   for (Iterator<?> nit = view.getChildren().iterator(); nit.hasNext(); ) {
     Node node = (Node) nit.next();
     switch (UMLVisualIDRegistry.getVisualID(node)) {
       case ParameterEditPart.VISUAL_ID:
         for (Iterator<?> it = node.getTargetEdges().iterator(); it.hasNext(); ) {
           Edge incomingLink = (Edge) it.next();
           if (UMLVisualIDRegistry.getVisualID(incomingLink)
               == CommentAnnotatedElementEditPart.VISUAL_ID) {
             DestroyReferenceRequest r =
                 new DestroyReferenceRequest(
                     incomingLink.getSource().getElement(),
                     null,
                     incomingLink.getTarget().getElement(),
                     false);
             cmd.add(new DestroyReferenceCommand(r));
             cmd.add(new DeleteCommand(getEditingDomain(), incomingLink));
             continue;
           }
         }
         cmd.add(
             new DestroyElementCommand(
                 new DestroyElementRequest(
                     getEditingDomain(), node.getElement(), false))); // directlyOwned: false
         // don't need explicit deletion of node as parent's view deletion would clean child views
         // as well
         // cmd.add(new
         // org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), node));
         break;
     }
   }
 }
 /** @generated */
 protected Command getDestroyElementCommand(DestroyElementRequest req) {
   View view = (View) getHost().getModel();
   CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
   cmd.setTransactionNestingEnabled(false);
   for (Iterator<?> it = view.getTargetEdges().iterator(); it.hasNext(); ) {
     Edge incomingLink = (Edge) it.next();
     if (UMLVisualIDRegistry.getVisualID(incomingLink)
         == CommentAnnotatedElementEditPart.VISUAL_ID) {
       DestroyReferenceRequest r =
           new DestroyReferenceRequest(
               incomingLink.getSource().getElement(),
               null,
               incomingLink.getTarget().getElement(),
               false);
       cmd.add(new DestroyReferenceCommand(r));
       cmd.add(new DeleteCommand(getEditingDomain(), incomingLink));
       continue;
     }
   }
   EAnnotation annotation = view.getEAnnotation("Shortcut"); // $NON-NLS-1$
   if (annotation == null) {
     // there are indirectly referenced children, need extra commands: true
     addDestroyChildNodesCommand(cmd);
     addDestroyShortcutsCommand(cmd, view);
     // delete host element
     cmd.add(new DestroyElementCommand(req));
   } else {
     cmd.add(new DeleteCommand(getEditingDomain(), view));
   }
   return getGEFWrapper(cmd.reduce());
 }
 /** @generated */
 private boolean isDefinitelyNotMyDiagramElement(View view) {
   int visualID = UMLVisualIDRegistry.getVisualID(view);
   switch (visualID) {
     case ActivityEditPart.VISUAL_ID:
     case LocalPreconditionEditPart.VISUAL_ID:
     case LocalPostconditionEditPart.VISUAL_ID:
     case CommentEditPart.VISUAL_ID:
     case AcceptEventActionEditPart.VISUAL_ID:
     case AcceptTimeEventActionEditPart.VISUAL_ID:
     case ActivityFinalNodeEditPart.VISUAL_ID:
     case DecisionNodeEditPart.VISUAL_ID:
     case MergeNodeEditPart.VISUAL_ID:
     case InitialNodeEditPart.VISUAL_ID:
     case DataStoreNodeEditPart.VISUAL_ID:
     case CentralBufferNodeEditPart.VISUAL_ID:
     case OpaqueActionEditPart.VISUAL_ID:
     case OpaqueAction_OutputPinEditPart.VISUAL_ID:
     case OpaqueAction_InputPinEditPart.VISUAL_ID:
     case FlowFinalNodeEditPart.VISUAL_ID:
     case ForkNodeEditPart.VISUAL_ID:
     case JoinNodeEditPart.VISUAL_ID:
     case PinEditPart.VISUAL_ID:
     case CreateObjectActionEditPart.VISUAL_ID:
     case CreateObjectAction_OutputPinEditPart.VISUAL_ID:
     case AddStructuralFeatureValueActionEditPart.VISUAL_ID:
     case AddStructuralFeatureValueAction_insertAt_InputPinEditPart.VISUAL_ID:
     case AddStructuralFeatureValueAction_value_InputPinEditPart.VISUAL_ID:
     case AddStructuralFeatureValueAction_object_InputPinEditPart.VISUAL_ID:
     case CallBehaviorActionEditPart.VISUAL_ID:
     case CallAction_OutputPinEditPart.VISUAL_ID:
     case CallAction_InputPinEditPart.VISUAL_ID:
     case CallOperationActionEditPart.VISUAL_ID:
     case CallOperationAction_InputPinEditPart.VISUAL_ID:
     case StructuredActivityNodeEditPart.VISUAL_ID:
     case StructuredActivityNode_StructuredActivityNodeEditPart.VISUAL_ID:
     case StructuredActivityNode_OpaqueActionEditPart.VISUAL_ID:
     case StructuredActivityNode_AcceptEventActionEditPart.VISUAL_ID:
     case StructuredActivityNode_AcceptTimeEventActionEditPart.VISUAL_ID:
     case StructuredActivityNode_ActivityFinalNodeEditPart.VISUAL_ID:
     case StructuredActivityNode_DecisionNodeEditPart.VISUAL_ID:
     case StructuredActivityNode_FlowFinalNodeEditPart.VISUAL_ID:
     case StructuredActivityNode_PinEditPart.VISUAL_ID:
     case StructuredActivityNode_CreateObjectActionEditPart.VISUAL_ID:
     case StructuredActivityNode_CallBehaviorActionEditPart.VISUAL_ID:
     case StructuredActivityNode_CallOperationActionEditPart.VISUAL_ID:
     case StructuredActivityNode_ForkNodeEditPart.VISUAL_ID:
     case StructuredActivityNode_JoinNodeEditPart.VISUAL_ID:
     case StructuredActivityNode_AddStructuralFeatureValueActionEditPart.VISUAL_ID:
     case StructuredActivityNode_DataStoreNodeEditPart.VISUAL_ID:
     case StructuredActivityNode_CentralBufferNodeEditPart.VISUAL_ID:
     case StructuredActivityNode_InputPinEditPart.VISUAL_ID:
     case StructuredActivityNode_OutputPinEditPart.VISUAL_ID:
     case StructuredActivityNode_ConditionalNodeEditPart.VISUAL_ID:
     case StructuredActivityNode_InitialNodeEditPart.VISUAL_ID:
     case OpaqueBehaviorEditPart.VISUAL_ID:
     case ActivityParameterNodeEditPart.VISUAL_ID:
     case SendSignalActionEditPart.VISUAL_ID:
     case ActivityPartitionEditPart.VISUAL_ID:
     case ActivityPartition_ActivityPartitionEditPart.VISUAL_ID:
     case ActivityPartition_AcceptEventActionEditPart.VISUAL_ID:
     case ActivityPartition_AcceptTimeEventActionEditPart.VISUAL_ID:
     case ActivityPartition_ActivityFinalNodeEditPart.VISUAL_ID:
     case ActivityPartition_DecisionNodeEditPart.VISUAL_ID:
     case ActivityPartition_MergeNodeEditPart.VISUAL_ID:
     case ActivityPartition_InitialNodeEditPart.VISUAL_ID:
     case ActivityPartition_DataStoreNodeEditPart.VISUAL_ID:
     case ActivityPartition_CentralBufferNodeEditPart.VISUAL_ID:
     case ActivityPartition_OpaqueActionEditPart.VISUAL_ID:
     case ActivityPartition_FlowFinalNodeEditPart.VISUAL_ID:
     case ActivityPartition_ForkNodeEditPart.VISUAL_ID:
     case ActivityPartition_JoinNodeEditPart.VISUAL_ID:
     case ActivityPartition_PinEditPart.VISUAL_ID:
     case ActivityPartition_CreateObjectActionEditPart.VISUAL_ID:
     case ActivityPartition_AddStructuralFeatureValueActionEditPart.VISUAL_ID:
     case ActivityPartition_CallBehaviorActionEditPart.VISUAL_ID:
     case ActivityPartition_CallOperationActionEditPart.VISUAL_ID:
     case ActivityPartition_StructuredActivityNodeEditPart.VISUAL_ID:
     case ActivityPartition_StructuredActivityNode_StructuredActivityNodeEditPart.VISUAL_ID:
     case StructuredActivityNode_StructuredActivityNode_InputPinEditPart.VISUAL_ID:
     case StructuredActivityNode_StructuredActivityNode_OutputPinEditPart.VISUAL_ID:
     case ActivityPartition_SendSignalActionEditPart.VISUAL_ID:
     case ActivityPartition_LoopNodeEditPart.VISUAL_ID:
     case ActivityPartition_ConditionalNodeEditPart.VISUAL_ID:
     case ActivityPartition_ExpansionRegionEditPart.VISUAL_ID:
     case ActivityPartition_ValueSpecificationActionEditPart.VISUAL_ID:
     case ValueSpecificationAction_OutputPinEditPart.VISUAL_ID:
     case LoopNodeEditPart.VISUAL_ID:
     case ConditionalNodeEditPart.VISUAL_ID:
     case ExpansionRegionEditPart.VISUAL_ID:
     case ExpansionNodeEditPart.VISUAL_ID:
     case ParameterSetEditPart.VISUAL_ID:
     case ParameterEditPart.VISUAL_ID:
     case ValueSpecificationActionEditPart.VISUAL_ID:
     case LocalPrecondition_LiteralStringEditPart.VISUAL_ID:
     case LocalPostcondition_LiteralStringEditPart.VISUAL_ID:
       return true;
   }
   return false;
 }
 /** @generated */
 private boolean isMyDiagramElement(View view) {
   return LocalPostcondition_LiteralStringEditPart.VISUAL_ID
       == UMLVisualIDRegistry.getVisualID(view);
 }
  /** @generated */
  protected Command getDestroyElementCommand(DestroyElementRequest req) {
    View view = (View) getHost().getModel();
    CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
    cmd.setTransactionNestingEnabled(false);
    for (Iterator<?> it = view.getTargetEdges().iterator(); it.hasNext(); ) {
      Edge incomingLink = (Edge) it.next();
      if (UMLVisualIDRegistry.getVisualID(incomingLink) == ControlFlowEditPart.VISUAL_ID) {
        DestroyElementRequest r = new DestroyElementRequest(incomingLink.getElement(), false);
        cmd.add(new DestroyElementCommand(r));
        cmd.add(new DeleteCommand(getEditingDomain(), incomingLink));
        continue;
      }
      if (UMLVisualIDRegistry.getVisualID(incomingLink) == ObjectFlowEditPart.VISUAL_ID) {
        DestroyElementRequest r = new DestroyElementRequest(incomingLink.getElement(), false);
        cmd.add(new DestroyElementCommand(r));
        cmd.add(new DeleteCommand(getEditingDomain(), incomingLink));
        continue;
      }
      if (UMLVisualIDRegistry.getVisualID(incomingLink) == ExceptionHandlerEditPart.VISUAL_ID) {
        DestroyElementRequest r = new DestroyElementRequest(incomingLink.getElement(), false);
        cmd.add(new DestroyElementCommand(r));
        cmd.add(new DeleteCommand(getEditingDomain(), incomingLink));
        continue;
      }
      if (UMLVisualIDRegistry.getVisualID(incomingLink)
          == CommentAnnotatedElementEditPart.VISUAL_ID) {
        DestroyReferenceRequest r =
            new DestroyReferenceRequest(
                incomingLink.getSource().getElement(),
                null,
                incomingLink.getTarget().getElement(),
                false);
        cmd.add(new DestroyReferenceCommand(r));
        cmd.add(new DeleteCommand(getEditingDomain(), incomingLink));
        continue;
      }
    }
    for (Iterator<?> it = view.getSourceEdges().iterator(); it.hasNext(); ) {
      Edge outgoingLink = (Edge) it.next();
      if (UMLVisualIDRegistry.getVisualID(outgoingLink) == ControlFlowEditPart.VISUAL_ID) {
        DestroyElementRequest r = new DestroyElementRequest(outgoingLink.getElement(), false);
        cmd.add(new DestroyElementCommand(r));
        cmd.add(new DeleteCommand(getEditingDomain(), outgoingLink));
        continue;
      }
      if (UMLVisualIDRegistry.getVisualID(outgoingLink) == ObjectFlowEditPart.VISUAL_ID) {
        DestroyElementRequest r = new DestroyElementRequest(outgoingLink.getElement(), false);
        cmd.add(new DestroyElementCommand(r));
        cmd.add(new DeleteCommand(getEditingDomain(), outgoingLink));
        continue;
      }
      if (UMLVisualIDRegistry.getVisualID(outgoingLink)
          == ActionLocalPreconditionEditPart.VISUAL_ID) {
        DestroyReferenceRequest r =
            new DestroyReferenceRequest(
                outgoingLink.getSource().getElement(),
                null,
                outgoingLink.getTarget().getElement(),
                false);
        cmd.add(
            new DestroyReferenceCommand(r) {

              protected CommandResult doExecuteWithResult(
                  IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException {
                EObject referencedObject = getReferencedObject();
                Resource resource = referencedObject.eResource();
                CommandResult result = super.doExecuteWithResult(progressMonitor, info);
                if (resource != null) {
                  resource.getContents().add(referencedObject);
                }
                return result;
              }
            });
        cmd.add(new DeleteCommand(getEditingDomain(), outgoingLink));
        continue;
      }
      if (UMLVisualIDRegistry.getVisualID(outgoingLink)
          == ActionLocalPostconditionEditPart.VISUAL_ID) {
        DestroyReferenceRequest r =
            new DestroyReferenceRequest(
                outgoingLink.getSource().getElement(),
                null,
                outgoingLink.getTarget().getElement(),
                false);
        cmd.add(
            new DestroyReferenceCommand(r) {

              protected CommandResult doExecuteWithResult(
                  IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException {
                EObject referencedObject = getReferencedObject();
                Resource resource = referencedObject.eResource();
                CommandResult result = super.doExecuteWithResult(progressMonitor, info);
                if (resource != null) {
                  resource.getContents().add(referencedObject);
                }
                return result;
              }
            });
        cmd.add(new DeleteCommand(getEditingDomain(), outgoingLink));
        continue;
      }
      if (UMLVisualIDRegistry.getVisualID(outgoingLink) == ExceptionHandlerEditPart.VISUAL_ID) {
        DestroyElementRequest r = new DestroyElementRequest(outgoingLink.getElement(), false);
        cmd.add(new DestroyElementCommand(r));
        cmd.add(new DeleteCommand(getEditingDomain(), outgoingLink));
        continue;
      }
    }
    EAnnotation annotation = view.getEAnnotation("Shortcut"); // $NON-NLS-1$
    if (annotation == null) {
      // there are indirectly referenced children, need extra commands: false
      addDestroyChildNodesCommand(cmd);
      addDestroyShortcutsCommand(cmd, view);
      // delete host element
      cmd.add(new DestroyElementCommand(req));
    } else {
      cmd.add(new DeleteCommand(getEditingDomain(), view));
    }
    return getGEFWrapper(cmd.reduce());
  }