/**
   * test the edge creation on manual refresh
   *
   * @throws Exception
   */
  public void testEdgeCreationManualRefreshWithUnsynchronizedDiagram() throws Exception {
    changeSiriusPreference(SiriusPreferencesKeys.PREF_AUTO_REFRESH.name(), false);

    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);

    doTestUndoRedoUnsynchronized(activity, edge);

    refresh(diagram);

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

    doTestCloseOpenUnsynchronized();
  }
  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);
  }
예제 #3
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;
 }
  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);
  }
  /**
   * 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 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);
  }