public SWTBotGefEditPart addForEach(
      SWTBotGefEditPart toPart, String name, String startExpression, String finalExpression)
      throws Exception {
    appendActivity(toPart, "ForEach", name);
    SWTBot propsBot = propsView.bot();
    propsView.selectTab(2);

    SWTBotButton leftButton = propsBot.button(0);
    SWTBotButton rightButton = propsBot.button(1);

    leftButton.click();
    rightButton.click();
    propsBot.styledText(0).setText(startExpression);
    // Previous change must be saved otherwise we will see an ugly NPE.
    // This issue seems to be caused by SWTBot since the exception cannot
    // be seen by clicking the steps manually.
    save();
    propsBot.styledText(1).setText(finalExpression);
    save();

    // TODO: maybe delete the scope element
    SWTBotGefEditPart added = getEditPart(toPart, name);
    log.info("Added [part=" + added + ", name=" + name + "]");
    return added;
  }
 private void importFinish() {
   SWTBotShell shell = fBot.activeShell();
   final SWTBotButton finishButton = fBot.button("Finish");
   finishButton.click();
   fBot.waitUntil(Conditions.shellCloses(shell));
   SWTBotUtils.waitForJobs();
 }
  /** @throws Exception */
  private void checkTab(String tabName) throws Exception {
    SWTBotCTabItem tabItem = editor.bot().cTabItem(tabName);
    tabItem.setFocus();

    SWTBotTable table = editor.bot().table();
    SWTBotTableColumn tCol = table.header("Translation of");
    tCol.setFocus();
    tCol = table.header("Kind");
    tCol.setFocus();

    SWTBotButton bttn = editor.bot().button("Edit Source Model");
    assertFalse(bttn.isEnabled());
  }
Example #4
0
 @Test
 public void testImportWizardGeneralProjectWithWorkingSet() throws Exception {
   deleteAllProjects();
   assertProjectExistence(PROJ1, false);
   String workingSetName = "myWorkingSet";
   removeWorkingSet(workingSetName);
   SWTBotTree tree = getOrOpenView().bot().tree();
   String wizardTitle =
       NLS.bind(UIText.GitCreateProjectViaWizardWizard_WizardTitle, repositoryFile.getPath());
   // start wizard from PROJ1
   myRepoViewUtil.getWorkdirItem(tree, repositoryFile).expand().getNode(PROJ1).select();
   ContextMenuHelper.clickContextMenu(
       tree, myUtil.getPluginLocalizedValue("ImportProjectsCommand"));
   SWTBotShell shell = bot.shell(wizardTitle);
   shell = bot.shell(wizardTitle);
   // try import existing project first
   bot.radio(UIText.GitSelectWizardPage_ImportExistingButton).click();
   SWTBotButton button = shell.bot().button(IDialogConstants.NEXT_LABEL);
   // Set focus on the next button. If this is not done, Wizard Framework restores
   // the focus to the "Import as &General Project" radio button. Setting the focus on
   // the radio button selects the button and causes the test to fail.
   // See also SWTBot Bug 337465
   button.setFocus();
   button.click();
   shell.bot().text(UIText.WizardProjectsImportPage_ImportProjectsDescription);
   shell.bot().tree().getAllItems()[0].check();
   // add to working set
   shell.bot().checkBox("Add project to working sets").select();
   // create new working set
   shell.bot().button("Select...").click();
   SWTBotShell workingSetDialog = bot.shell("Select Working Sets");
   workingSetDialog.bot().button("New...").click();
   SWTBotShell newDialog = bot.shell("New Working Set");
   newDialog.bot().table().select("Java");
   newDialog.bot().button(IDialogConstants.NEXT_LABEL).click();
   newDialog.bot().text(0).setText(workingSetName);
   newDialog.bot().button(IDialogConstants.FINISH_LABEL).click();
   workingSetDialog.bot().table().getTableItem(workingSetName).check();
   workingSetDialog.bot().button(IDialogConstants.OK_LABEL).click();
   shell.bot().button(IDialogConstants.FINISH_LABEL).click();
   bot.waitUntil(Conditions.shellCloses(shell));
   assertProjectExistence(PROJ1, true);
   assertProjectInWorkingSet(workingSetName, PROJ1);
   assertProjectIsShared(PROJ1, true);
   removeWorkingSet(workingSetName);
 }
Example #5
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);
  }
Example #6
0
 @Override
 public String getToolTipText() throws RemoteException {
   return widget.getText();
 }
Example #7
0
 @Override
 public boolean isActive() throws RemoteException {
   return widget.isActive();
 }
Example #8
0
 @Override
 public boolean isEnabled() throws RemoteException {
   return widget.isEnabled();
 }
Example #9
0
 @Override
 public void setFocus() throws RemoteException {
   widget.setFocus();
 }
Example #10
0
 @Override
 public void click() throws RemoteException {
   widget.click();
 }
Example #11
0
 @Override
 public IRemoteBotMenu contextMenu(String text) throws RemoteException {
   return RemoteBotMenu.getInstance().setWidget(widget.contextMenu(text));
 }
 /**
  * Adds External Jar File to Project Build Path. If External Jar File already exists and
  * 'overwriteIfExists' parameter is set to true, it is overwritten
  *
  * @param externalJarLocation
  * @param projectName
  * @return
  */
 public static String addExternalJar(
     final String externalJarLocation, final String projectName, boolean overwriteIfExists) {
   assertTrue(
       "External Jar Location cannot be empty but is " + externalJarLocation,
       externalJarLocation != null && externalJarLocation.length() > 0);
   SWTBotExt bot = new SWTEclipseExt().openPropertiesOfProject(projectName);
   bot.shell(IDELabel.Shell.PROPERTIES_FOR + " " + projectName).activate().bot();
   bot.tree()
       .expandNode(IDELabel.JavaBuildPathPropertiesEditor.JAVA_BUILD_PATH_TREE_ITEM_LABEL)
       .select();
   bot.sleep(Timing.time3S());
   bot.tabItem(IDELabel.JavaBuildPathPropertiesEditor.LIBRARIES_TAB_LABEL).activate();
   final SWTBotButton btn = bot.button(IDELabel.Button.ADD_VARIABLE);
   btn.click();
   bot.sleep(Timing.time2S());
   // workaround because first click is not working when test is run via maven
   try {
     bot.shell(IDELabel.Shell.NEW_VARIABLE_CLASS_PATH_ENTRY).activate();
   } catch (WidgetNotFoundException wnfe) {
     btn.click();
     bot.sleep(Timing.time2S());
     bot.shell(IDELabel.Shell.NEW_VARIABLE_CLASS_PATH_ENTRY).activate();
   }
   String jarFileName = new File(externalJarLocation).getName();
   String variableEntryName = jarFileName.toUpperCase() + "_LOCATION";
   boolean externalJarExists = false;
   for (int i = 0; i < bot.table().rowCount(); i++) {
     if (bot.table().getTableItem(i).getText().split(" - ")[0].equals(variableEntryName)) {
       bot.table().getTableItem(i).select();
       externalJarExists = true;
       break;
     }
   }
   bot.button(IDELabel.Button.CONFIGURE_VARIABLES).click();
   bot.shell(IDELabel.Shell.PREFERENCES_FILTERED).activate();
   if (externalJarExists && overwriteIfExists) {
     bot.button(IDELabel.Button.EDIT).click();
     bot.shell(IDELabel.Shell.EDIT_VARIABLE_ENTRY).activate();
     bot.textWithLabel(IDELabel.NewVariableEntryDialog.PATH_TEXT_LABEL)
         .setText(externalJarLocation);
   } else {
     bot.button(IDELabel.Button.NEW).click();
     bot.shell(IDELabel.Shell.NEW_VARIABLE_ENTRY).activate();
     bot.textWithLabel(IDELabel.NewVariableEntryDialog.NAME_TEXT_LABEL).setText(variableEntryName);
     bot.textWithLabel(IDELabel.NewVariableEntryDialog.PATH_TEXT_LABEL)
         .setText(externalJarLocation);
   }
   bot.clickButton(IDELabel.Button.OK).click();
   String result = TableHelper.getSelectionText(bot.table());
   bot.waitUntil(new ActiveShellTitleMatches(bot, "Preferences \\(Filtered\\)"), Timing.time3S());
   bot.clickButton(IDELabel.Button.OK).click();
   bot.waitUntil(
       new ActiveShellTitleMatches(bot, IDELabel.Shell.NEW_VARIABLE_CLASS_PATH_ENTRY),
       Timing.time3S());
   bot.clickButton(IDELabel.Button.OK).click();
   bot.waitUntil(
       new ActiveShellTitleMatches(bot, IDELabel.Shell.PROPERTIES_FOR + " " + projectName),
       Timing.time3S());
   bot.clickButton(IDELabel.Button.OK).click();
   new SWTUtilExt(bot).waitForNonIgnoredJobs();
   return result;
 }