private static String adjustNodeName(SWTBotTreeItem child, String nodeName) {
   List<String> nodes = child.getNodes();
   for (String node : nodes) {
     if (node.toUpperCase().startsWith(nodeName.toUpperCase())) {
       return node;
     }
   }
   return null;
 }
 /**
  * Checks for the Symbolic Reference node
  *
  * @throws Exception
  */
 @Test
 public void testExpandSymbolicRef() throws Exception {
   SWTBotTree tree = getOrOpenView().bot().tree();
   SWTBotTreeItem item = myRepoViewUtil.getSymbolicRefsItem(tree, repositoryFile).expand();
   List<String> children = item.getNodes();
   boolean found = false;
   for (String child : children) if (child.contains(Constants.HEAD)) found = true;
   assertTrue(found);
 }
  @Test
  public void testDeleteFileNotInProject() throws Exception {
    SWTBotTree tree = getOrOpenView().bot().tree();
    refreshAndWait();

    SWTBotTreeItem folder = findWorkdirNode(tree, PROJ2, FOLDER);
    folder.getNode(FILE1).select();

    ContextMenuHelper.clickContextMenu(
        tree, myUtil.getPluginLocalizedValue("RepoViewDeleteFile.label"));

    SWTBotShell confirm = bot.shell(UIText.DeleteResourcesOperationUI_confirmActionTitle);
    confirm.bot().button(IDialogConstants.OK_LABEL).click();
    bot.waitUntil(shellCloses(confirm));
    TestUtil.joinJobs(JobFamilies.REPO_VIEW_REFRESH);

    folder = findWorkdirNode(tree, PROJ2, FOLDER);
    assertThat(folder.getNodes(), not(hasItem(FILE1)));
    assertThat(folder.getNodes(), hasItem(FILE2));
  }
  @Test
  @Ignore // workspace model dosn't show non-workspace files ... yet ;)
  public void shouldShowNonWorkspaceFileInSynchronization() throws Exception {
    // given
    String name = "non-workspace.txt";
    File root = new File(getTestDirectory(), REPO1);
    File nonWorkspace = new File(root, name);
    BufferedWriter writer = new BufferedWriter(new FileWriter(nonWorkspace));
    writer.append("file content");
    writer.close();

    // when
    launchSynchronization(INITIAL_TAG, HEAD, true);

    // then
    SWTBotTree syncViewTree = bot.viewByTitle("Synchronize").bot().tree();
    SWTBotTreeItem workingTree = syncViewTree.expandNode(PROJ1);
    assertEquals(1, syncViewTree.getAllItems().length);
    assertEquals(1, workingTree.getNodes(name).size());
  }
  @Test
  public void testDeleteFileInProject() throws Exception {
    SWTBotTree tree = getOrOpenView().bot().tree();
    refreshAndWait();

    IProject project1 = ResourcesPlugin.getWorkspace().getRoot().getProject(PROJ1);
    // Make sure that the refresh doesn't happen on delete and cause a timeout
    project1.refreshLocal(IResource.DEPTH_INFINITE, null);

    SWTBotTreeItem folder = findWorkdirNode(tree, PROJ1, FOLDER);
    folder.getNode(FILE1).select();

    ContextMenuHelper.clickContextMenu(
        tree, myUtil.getPluginLocalizedValue("RepoViewDeleteFile.label"));

    SWTBotShell confirm = bot.shell("Delete Resources");
    confirm.bot().button(IDialogConstants.OK_LABEL).click();
    bot.waitUntil(shellCloses(confirm));
    TestUtil.joinJobs(JobFamilies.REPO_VIEW_REFRESH);

    folder = findWorkdirNode(tree, PROJ1, FOLDER);
    assertThat(folder.getNodes(), not(hasItem(FILE1)));
    assertThat(folder.getNodes(), hasItem(FILE2));
  }
  public static void addemailconnector(
      final SWTGefBot bot,
      final String name,
      final String from,
      final String to,
      final String subject,
      final String content) {
    bot.viewById(SWTBotTestUtil.VIEWS_PROPERTIES_PROCESS_GENERAL).show();
    SWTBotTestUtil.selectTabbedPropertyView(bot, "Connectors");
    bot.button("Add...").click();
    bot.waitUntil(Conditions.shellIsActive("Connectors"));

    bot.tree().setFocus();
    final SWTBotTreeItem wss = bot.tree().getTreeItem("Messaging").expand();

    String emailNode = null;
    for (final String child : wss.getNodes()) {

      if (child.contains("Email")) {
        emailNode = child;
      }
    }
    wss.getNode(emailNode).select();
    bot.button(IDialogConstants.NEXT_LABEL).click();

    bot.textWithLabel("Name *").setText(name);
    bot.button(IDialogConstants.NEXT_LABEL).click();

    bot.button(IDialogConstants.NEXT_LABEL).click();

    bot.textWithId(SWTBotConstants.SWTBOT_ID_EXPRESSIONVIEWER_TEXT, 0).setText(from);
    bot.textWithId(SWTBotConstants.SWTBOT_ID_EXPRESSIONVIEWER_TEXT, 1).setText(to);
    bot.waitUntil(Conditions.widgetIsEnabled(bot.button(IDialogConstants.NEXT_LABEL)));
    bot.button(IDialogConstants.NEXT_LABEL).click();

    bot.toolbarButtonWithId(ExpressionViewer.SWTBOT_ID_EDITBUTTON, 0).click();
    SWTBotTestUtil.setScriptExpression(bot, "subject", subject, null);

    // bot.button(IDialogConstants.OK_LABEL).click();

    bot.styledText().setText(content);

    /*bot.sleep(2000);
       bot.link(0).click();
       bot.sleep(2000);
       bot.button("Yes").click();
       bot.sleep(2000);

       bot.toolbarButtonWithId(ExpressionViewer.SWTBOT_ID_EDITBUTTON, 1).click();
       SWTBotTestUtil.setScriptExpression( bot,  "body",  content,  null );
    */

    bot.sleep(5000);

    bot.button(IDialogConstants.NEXT_LABEL).click();
    bot.button(IDialogConstants.FINISH_LABEL).click();

    bot.activeEditor().save();
    // DiagramEditPart dpart = (DiagramEditPart)
    // bot.gefEditor(bot.activeEditor().getTitle()).mainEditPart().part();
    // MainProcess proc = (MainProcess) dpart.resolveSemanticElement();
    // List<Connector> connectors = ModelHelper.getAllItemsOfType(proc,
    // ProcessPackage.Literals.CONNECTOR);
    /*	for(Connector c : connectors){
    		if(c.getDefinitionId().equals("email")){
    			for(ConnectorParameter p : c.getConfiguration().getParameters()){
    				if("message".equals(p.getKey())){


    					String htmlContent = ((Expression) p.getExpression()).getContent();
    					assertEquals("Invalid html content", HTML_CONTENT, htmlContent.replaceAll(" ","").replaceAll("\\s",""));
    				}
    			}

    }*/

  }