/** * Set the node's parents : create in appropriate container and set extra parent reference if * necessary. * * @param newElement the element in creation * @param request request to create a node * @param elementToEdit the element the executing command edits * @return false if command must be cancelled */ public static boolean setNodeParents( ActivityNode newElement, IEditCommandRequest request, EObject elementToEdit) { // simply take the command edited element EObject owner = elementToEdit; // create in appropriate model container if (owner instanceof Activity) { ((Activity) owner).getOwnedNodes().add(newElement); } else if (owner instanceof StructuredActivityNode) { ((StructuredActivityNode) owner).getNodes().add(newElement); } else { // incorrect model container return false; } // // add extra parent reference // if(elementToEdit != owner) { // EObject childHolder = elementToEdit; // if(childHolder instanceof InterruptibleActivityRegion) { // ((InterruptibleActivityRegion)childHolder).getNodes().add(newElement); // } else if(childHolder instanceof ActivityPartition) { // ((ActivityPartition)childHolder).getNodes().add(newElement); // } else { // // incorrect referencing parent // return false; // } // } return true; }
/** * Set the activity partition's parents : create in appropriate container and set extra parent * reference if necessary. * * @param newElement the element in creation * @param request request to create a node * @param elementToEdit the element the executing command edits * @return false if command must be cancelled */ public static boolean setActivityPartitionParents( ActivityPartition newElement, IEditCommandRequest request, EObject elementToEdit) { // check whether there is a model container parameter. EObject owner = elementToEdit; // create in appropriate model container if (owner instanceof Activity) { ((Activity) owner).getOwnedGroups().add(newElement); } else if (owner instanceof ActivityPartition) { ((ActivityPartition) owner).getSubpartitions().add(newElement); } else { // incorrect model container return false; } // // add extra parent reference // if(elementToEdit != owner) { // EObject childHolder = elementToEdit; // if(childHolder instanceof ActivityPartition) { // ((ActivityPartition)childHolder).getSubpartitions().add(newElement); // } else { // // incorrect referencing parent // return false; // } // } return true; }