/** @generated */ protected CommandResult doExecuteWithResultGen(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { JoinNode newElement = UMLFactory.eINSTANCE.createJoinNode(); Activity owner = (Activity) getElementToEdit(); owner.getNodes().add(newElement); ActivityPartition childHolder = (ActivityPartition) getElementToEdit(); childHolder.getNodes().add(newElement); doConfigure(newElement, monitor, info); ((CreateElementRequest) getRequest()).setNewElement(newElement); return CommandResult.newOKCommandResult(newElement); }
/** * 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; }