/** * * <!-- begin-user-doc --> * <!-- end-user-doc --> * <!-- begin-model-doc --> * A Variable is accessible by Actions within its scope (the Activity or StructuredActivityNode * that owns it). result = (if scope<>null then scope.allOwnedNodes()->includes(a) else * a.containingActivity()=activityScope endif) * * <p>From package UML::Activities. * * @param variable The receiving '<em><b>Variable</b></em>' model object. * <!-- end-model-doc --> * @generated NOT */ public static boolean isAccessibleBy(Variable variable, Action a) { StructuredActivityNode scope = variable.getScope(); return scope != null ? scope.allOwnedNodes().contains(a) : a.containingActivity() == variable.getActivityScope(); }
/** * 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; }
/** @generated */ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { ExpansionNode newElement = UMLFactory.eINSTANCE.createExpansionNode(); StructuredActivityNode owner = (StructuredActivityNode) getElementToEdit(); owner.getNodes().add(newElement); ExpansionRegion childHolder = (ExpansionRegion) getElementToEdit(); childHolder.getInputElements().add(newElement); ElementInitializers.getInstance().init_ExpansionNode_3074(newElement); doConfigure(newElement, monitor, info); ((CreateElementRequest) getRequest()).setNewElement(newElement); return CommandResult.newOKCommandResult(newElement); }