/**
   * test the edge creation on auto refresh and unsynchro
   *
   * @throws Exception
   */
  public void testEdgeCreationAutoRefreshWithUnsynchronizedDiagram() throws Exception {
    changeSiriusPreference(SiriusPreferencesKeys.PREF_AUTO_REFRESH.name(), true);

    unsynchronizeDiagram(diagram);

    Model model = (Model) semanticModel;
    Activity activity = (Activity) model.getPackagedElements().get(0);
    List<ActivityNode> ownedNodes = getActivityOwnedNodes(activity);
    OpaqueAction source = (OpaqueAction) ownedNodes.get(0);
    OpaqueAction target = (OpaqueAction) ownedNodes.get(1);

    applyEdgeCreationTool(
        "Control Flow",
        diagram,
        (EdgeTarget) getFirstDiagramElement(diagram, source),
        (EdgeTarget) getFirstDiagramElement(diagram, target));

    ActivityEdge edge = activity.getEdges().get(0);
    assertNotNull(edge);
    DEdge edgeElement = getFirstEdgeElement(diagram, edge);
    assertNotNull(edgeElement);

    doTestUndoRedoAutoRefreshUnsynchronized(activity, edge);

    doTestCloseOpenUnsynchronized();
  }
 /** @generated */
 @Override
 protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info)
     throws ExecutionException {
   CallOperationAction newElement = UMLFactory.eINSTANCE.createCallOperationAction();
   EObject target = getElementToEdit();
   ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target, newElement);
   if (data.isPermitted()) {
     if (data.isPathDefined()) {
       if (!data.execute(target, newElement)) {
         return CommandResult.newErrorCommandResult(
             "Failed to follow the policy-specified for the insertion of the new element");
       }
     } else {
       Activity qualifiedTarget = (Activity) target;
       qualifiedTarget.getOwnedNodes().add(newElement);
     }
   } else {
     return CommandResult.newErrorCommandResult(
         "The active policy restricts the addition of this element");
   }
   ElementInitializers.getInstance().init_CallOperationAction_3010(newElement);
   doConfigure(newElement, monitor, info);
   ((CreateElementRequest) getRequest()).setNewElement(newElement);
   return CommandResult.newOKCommandResult(newElement);
 }
  private void doTestUndoRedoUnsynchronized(Activity activity, ActivityEdge edge) throws Exception {
    DEdge edgeElement;
    // undo the creation of the edge
    undo();
    assertTrue(activity.getEdges().isEmpty());
    edgeElement = getFirstEdgeElement(diagram, edge);
    assertNull(edgeElement);

    // redo the creation of the edge
    redo();
    ActivityEdge edge2 = activity.getEdges().get(0);
    edgeElement = getFirstEdgeElement(diagram, edge2);
    assertNotNull(edgeElement);
  }
  /** @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);
  }
  /** @generated */
  protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info)
      throws ExecutionException {
    ValueSpecificationAction newElement = UMLFactory.eINSTANCE.createValueSpecificationAction();

    Activity owner = (Activity) getElementToEdit();
    owner.getNodes().add(newElement);

    ElementInitializers.getInstance().init_ValueSpecificationAction_3089(newElement);

    doConfigure(newElement, monitor, info);

    ((CreateElementRequest) getRequest()).setNewElement(newElement);
    return CommandResult.newOKCommandResult(newElement);
  }
Exemple #6
0
  /**
   * 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;
  }
Exemple #7
0
 /**
  * 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;
 }
Exemple #8
0
 public Set<ControlFlow> getControlFlows() {
   Set<ControlFlow> cfs = new HashSet<ControlFlow>();
   for (org.eclipse.uml2.uml.ActivityEdge uml_cf : uml_activity.getEdges()) {
     cfs.add(new ControlFlow(uml_cf));
   }
   return cfs;
 }
Exemple #9
0
 public Set<Node> getNodes() {
   Set<Node> nodes = new HashSet<Node>();
   for (org.eclipse.uml2.uml.ActivityNode n : uml_activity.getNodes()) {
     nodes.add(NodeFactory.getInstance(n));
   }
   return nodes;
 }
  /**
   * test the edge creation on auto refresh
   *
   * @throws Exception
   */
  public void testEdgeCreationAutoRefresh() throws Exception {
    changeSiriusPreference(SiriusPreferencesKeys.PREF_AUTO_REFRESH.name(), true);

    Model model = (Model) semanticModel;
    final Activity activity = (Activity) model.getPackagedElements().get(0);
    List<ActivityNode> ownedNodes = getActivityOwnedNodes(activity);
    OpaqueAction source = (OpaqueAction) ownedNodes.get(0);
    OpaqueAction target = (OpaqueAction) ownedNodes.get(1);

    applyEdgeCreationTool(
        "Control Flow",
        diagram,
        (EdgeTarget) getFirstDiagramElement(diagram, source),
        (EdgeTarget) getFirstDiagramElement(diagram, target));

    ActivityEdge edge = activity.getEdges().get(0);
    assertNotNull(edge);
    DEdge edgeElement = getFirstEdgeElement(diagram, edge);
    assertNotNull(edgeElement);

    assertEquals(
        "Wrong EdgeSourceArrow for Edge.",
        EdgeArrows.INPUT_ARROW_LITERAL,
        ((EdgeStyle) edgeElement.getStyle()).getSourceArrow());
    assertEquals(
        "Wrong EdgeTargetArrow for Edge.",
        EdgeArrows.NO_DECORATION_LITERAL,
        ((EdgeStyle) edgeElement.getStyle()).getTargetArrow());

    IDiagramEdgeEditPart gmfEP = (IDiagramEdgeEditPart) getEditPart(edgeElement, editorPart);
    assertNotNull(gmfEP);
    assertNotNull(gmfEP.getPolylineConnectionFigure());

    assertEquals(
        "Wrong Edge target",
        getFirstDiagramElement(diagram, target),
        ((Edge) gmfEP.getModel()).getSource().getElement());
    assertEquals(
        "Wrong Edge source",
        getFirstDiagramElement(diagram, source),
        ((Edge) gmfEP.getModel()).getTarget().getElement());

    doTestUndoRedoAutoRefresh(activity, edge);

    doTestCloseOpen();
  }
  private void doTestUndoRedoAutoRefreshUnsynchronized(final Activity activity, ActivityEdge edge)
      throws Exception {
    DEdge edgeElement;
    // undo the creation of the edge
    // domain.getCommandStack().undo(); // undo the refresh
    undo(); // undo the creation edge
    assertTrue(activity.getEdges().isEmpty());
    edgeElement = getFirstEdgeElement(diagram, edge);
    assertNull(edgeElement);

    // redo the creation of the edge
    redo();
    // domain.getCommandStack().redo();
    ActivityEdge edge2 = activity.getEdges().get(0);
    edgeElement = getFirstEdgeElement(diagram, edge2);
    assertNotNull(edgeElement);
  }
 private List<ActivityNode> getActivityOwnedNodes(Activity activity) {
   List<ActivityNode> ownedNodes = (List<ActivityNode>) activity.getNodes();
   if (!isOlderThanUML2_4_0()) {
     ownedNodes =
         (List<ActivityNode>)
             ReflectionHelper.invokeMethodWithoutExceptionWithReturn(
                 activity, "getOwnedNodes", new Class[] {}, new Object[] {});
   }
   return ownedNodes;
 }
  private void doTestCloseOpenUnsynchronized() {
    Model model;
    Activity activity;
    ActivityEdge edge;
    DEdge edgeElement;
    DialectUIManager.INSTANCE.closeEditor(editorPart, false);
    TestsUtil.synchronizationWithUIThread();

    diagram = (DDiagram) getRepresentations(REPRESENTATION_DESC_NAME).toArray()[0];
    assertNotNull(diagram);
    editorPart = DialectUIManager.INSTANCE.openEditor(session, diagram, new NullProgressMonitor());
    TestsUtil.synchronizationWithUIThread();

    model = (Model) semanticModel;
    activity = (Activity) model.getPackagedElements().get(0);
    edge = activity.getEdges().get(0);
    assertNotNull(edge);
    edgeElement = getFirstEdgeElement(diagram, edge);
    assertNotNull(edgeElement);
  }
 @VisitBefore(matchSubclasses = true)
 public void visitActivity(Activity activity) {
   if (EmfBehaviorUtil.isProcess(activity)) {
     OJAnnotatedClass activityClass = findJavaClass(activity);
     super.implementEventConsumption(activityClass, activity, getEventActions(activity));
     for (ActivityNode n : EmfActivityUtil.getActivityNodesRecursively(activity)) {
       if (n instanceof AcceptCallAction) {
         AcceptCallAction acc = (AcceptCallAction) n;
         Operation no = EmfActionUtil.getOperation(acc);
         OperationMap map = ojUtil.buildOperationMap(no);
         OJAnnotatedOperation oper =
             operationAnnotator.findOrCreateOperation(activity, activityClass, map, true);
         OJBlock mainBlock = oper.getBody();
         if (EmfBehaviorUtil.hasExecutionInstance(no)) {
           PropertyMap actionMap = ojUtil.buildStructuralFeatureMap(acc);
           final String EXECUTE_STATEMENT = "executeStatement";
           oper.getBody()
               .removeFromStatements(oper.getBody().findStatementRecursive(EXECUTE_STATEMENT));
           mainBlock.addToStatements(actionMap.setter() + "(result)");
         } else {
           for (OutputPin pin : acc.getResults()) {
             PropertyMap pinMap = ojUtil.buildStructuralFeatureMap(pin);
             PropertyMap parameterMap =
                 ojUtil.buildStructuralFeatureMap(EmfActionUtil.getLinkedTypedElement(pin));
             mainBlock.addToStatements(pinMap.setter() + "(" + parameterMap.fieldname() + ")");
           }
         }
         if (!EmfBehaviorUtil.hasExecutionInstance(no)) {
           for (InputPin pin : EmfActionUtil.getReplyAction(acc).getReplyValues()) {
             if (((Parameter) EmfActionUtil.getLinkedTypedElement(pin)).getDirection()
                 == ParameterDirectionKind.RETURN_LITERAL) {
               Jbpm5ObjectNodeExpressor expressor = new Jbpm5ObjectNodeExpressor(ojUtil);
               mainBlock.addToStatements(
                   "result=" + expressor.expressInputPinOrOutParamOrExpansionNode(mainBlock, pin));
             }
           }
         }
         if (!activity.conformsTo((Classifier) no.getOwner())
             && activity.getContext() != null
             && activity.getContext().conformsTo((Classifier) no.getOwner())) {
           // TODO find the right activity and delegate to it
         }
       } else if (EmfActionUtil.isEmbeddedTask(n)) {
         Action t = (Action) n;
         String stereotypeName =
             n instanceof OpaqueAction
                 ? StereotypeNames.EMBEDDED_SINGLE_SCREEN_TASK
                 : StereotypeNames.EMBEDDED_SCREEN_FLOW_TASK;
         for (TimeEvent d :
             getLibrary().getResponsibilityDefinition(t, stereotypeName).getDeadlines()) {
           OJPathName date = ojUtil.classifierPathname(getLibrary().getDateType());
           OJPathName task = ojUtil.classifierPathname(t);
           String consumerName = eventUtil.getEventConsumerName(d);
           OJOperation findOperation =
               activityClass.findOperation(consumerName, Arrays.asList(date, task));
           if (findOperation == null) {
             findOperation = new OJAnnotatedOperation(consumerName, new OJPathName("boolean"));
             activityClass.addToOperations(findOperation);
             findOperation.addParam("date", date);
             findOperation.addParam("task", task);
             findOperation.getBody().addToStatements("return false");
           }
         }
       }
     }
   }
 }
Exemple #15
0
 @Override
 public MadesModel getMadesModel() {
   return new MadesModel(uml_activity.getModel());
 }
Exemple #16
0
 public String getName() {
   return uml_activity.getName();
 }