public void testOpenDiagramRepresentation() throws Exception {
   SWTBotTreeItem modelElementItem =
       localSession.getLocalSessionBrowser().perSemantic().expandNode("root").click();
   final UIDiagramRepresentation diagramRepresentation =
       localSession
           .newDiagramRepresentation("root" + " package entities")
           .on(modelElementItem)
           .withDefaultName()
           .ok();
   final SWTBotSiriusDiagramEditor editor = diagramRepresentation.open().getEditor();
   assertEditorIsNotError("editor was an error one", editor);
 }
Ejemplo n.º 2
0
  /** @throws Exception if the test fails */
  public void testSTD043() throws Exception {

    final UIResource sessionAirdResource =
        new UIResource(designerProject, FILE_DIR, SESSION_FILE_043);
    UILocalSession localSession = designerPerspective.openSessionFromFile(sessionAirdResource);

    // create functionalTree diagram

    SWTBotTreeItem rootSemantic = localSession.getLocalSessionBrowser().perSemantic();
    SWTBotUtils.clickContextMenu(
        rootSemantic.expandNode("RootPackage").select(),
        REPRESENTATION_INSTANCE_NAME_DIAGRAM_043); // Category().selectSirius(VIEWPOINT_NAME_043)
    SWTBotShell confirmBoxDiagram = bot.shell(Messages.createRepresentationInputDialog_Title);
    SWTBotButton ok = bot.button("OK");
    bot.waitUntil(new ItemEnabledCondition(ok));
    ok.click();

    UIDiagramRepresentation diagram =
        localSession
            .getLocalSessionBrowser()
            .perCategory()
            .selectViewpoint(VIEWPOINT_NAME_043)
            .selectRepresentation(REPRESENTATION_NAME_DIAGRAM_043)
            .selectRepresentationInstance(
                REPRESENTATION_INSTANCE_NAME_DIAGRAM_043, UIDiagramRepresentation.class)
            .open();

    // -feed diagram with functions
    // f =
    // SWTBotDesignerHelper.getDesignerEditor("RootPackage package entities(EPackage Rootpackage)");
    SWTBotSiriusDiagramEditor editordiagram = diagram.getEditor();
    editordiagram.activateTool("Package");
    editordiagram.click(200, 100);

    editordiagram.activateTool("Class");
    editordiagram.click(50, 100);

    editordiagram.drag(NEW_EPACKAGE_CREATED, 250, 250);
    // WARNING: we are obliged to test with +2 for X, as it sems that GMF
    // put +2 in the w of the dragged node!
    // (MCH checked, and it doesn't seem to come from SWTBot)
    assertTrue(
        checkNewLocation(
            editordiagram, diagram.getEditor().getEditPart(NEW_EPACKAGE_CREATED), 252, 250));

    // -manipulate the position of model element
    editordiagram.drag(
        /* NEW_ECLASS_CREATED */ 50 + X_MARGING_FOR_NOT_CLICKING_LABEL_NODE,
        100 + Y_MARGING_FOR_NOT_CLICKING_LABEL_NODE,
        150,
        150);
    assertNotNull(editordiagram);
    assertNotNull(diagram.getEditor());
    assertNotNull(diagram.getEditor().getEditPart(NEW_ECLASS_CREATED));
    assertTrue(
        checkNewLocation(
            editordiagram, diagram.getEditor().getEditPart(NEW_ECLASS_CREATED), 140, 130));

    // -save the diagram
    // -close the diagram and session
    localSession.close(true);

    // -reopen it
    localSession = designerPerspective.openSessionFromFile(sessionAirdResource);
    diagram =
        localSession
            .getLocalSessionBrowser()
            .perCategory()
            .selectViewpoint(VIEWPOINT_NAME_043)
            .selectRepresentation(REPRESENTATION_NAME_DIAGRAM_043)
            .selectRepresentationInstance(
                REPRESENTATION_INSTANCE_NAME_DIAGRAM_043, UIDiagramRepresentation.class)
            .open();
    editordiagram = diagram.getEditor();

    // -check the position of model element are not changed
    assertTrue(
        checkNewLocation(
            editordiagram, diagram.getEditor().getEditPart(NEW_ECLASS_CREATED), 140, 130));
    assertTrue(
        checkNewLocation(
            editordiagram, diagram.getEditor().getEditPart(NEW_EPACKAGE_CREATED), 252, 250));
    // -add modelElement in order they overlay
    editordiagram.activateTool("Package");
    editordiagram.click(350, 150);
    editordiagram.drag(NEW_EPACKAGE_CREATED_2, 248, 248);

    editordiagram.activateTool("Class");
    editordiagram.click(50, 50);
    editordiagram.drag(
        50 + X_MARGING_FOR_NOT_CLICKING_LABEL_NODE,
        50 + Y_MARGING_FOR_NOT_CLICKING_LABEL_NODE,
        138,
        128);

    assertTrue(
        checkNewLocation(
            editordiagram, diagram.getEditor().getEditPart(NEW_ECLASS_CREATED_2), 138, 128));
    assertTrue(
        checkNewLocation(
            editordiagram, diagram.getEditor().getEditPart(NEW_EPACKAGE_CREATED_2), 248, 248));

    bot.sleep(4000);
    // -use the 'arrange' function

    localSession.close(false);
  }