Java 类org.eclipse.swtbot.swt.finder.widgets.SWTBotTree 实例源码

项目:gw4e.project    文件:GW4EProject.java   
public void removeNature() {
    SWTBotTree tree = setupTreeForMenu(this.projectName);
    SWTBotMenu menu = new SWTBotMenu(
            ContextMenuHelper.contextMenu(tree, new String[] { "GW4E", "Remove GW4E Nature" }));
    menu.click();

    bot.waitUntil(new DefaultCondition() {
        @Override
        public boolean test() throws Exception {
            boolean b = ClasspathManager
                    .hasGW4EClassPathContainer(ResourceManager.getProject(projectName));
            return !b;
        }

        @Override
        public String getFailureMessage() {
            return "GW4E ClassPath Container not removed";
        }
    });
}
项目:gw4e.project    文件:GW4EProject.java   
public void assertMenuEnabled(String[] menus, boolean[] states, String... nodes) {
    SWTBotTree tree = setupTreeForMenu(nodes);

    SWTBotMenu menu = new SWTBotMenu(ContextMenuHelper.contextMenu(tree, menus[0]));
    assertEquals("Invalid state ", states[0], menu.isEnabled());

    String[] submenus = new String[menus.length - 1];
    System.arraycopy(menus, 1, submenus, 0, menus.length - 1);
    boolean[] substates = new boolean[states.length - 1];
    System.arraycopy(states, 1, substates, 0, states.length - 1);
    for (int i = 0; i < submenus.length; i++) {
        String submenu = submenus[i];
        SWTBotMenu sm = menu.contextMenu(submenu);
        assertEquals("Invalid state ", substates[i], sm.isEnabled());
    }
}
项目:gw4e.project    文件:GW4EProject.java   
public void convertExistingProject() throws CoreException {
    SWTBotTree tree = getProjectTree();
    SWTBotTreeItem item = tree.expandNode(this.projectName);
    item.setFocus();
    item.select();
    SWTBotMenu menu = item.contextMenu("Configure").contextMenu("Convert to GW4E");
    menu.click();
    bot.waitUntil(new DefaultCondition() {
        @Override
        public boolean test() throws Exception {
            boolean b = GW4ENature
                    .hasGW4ENature(ResourceManager.getProject(projectName));
            return b;
        }

        @Override
        public String getFailureMessage() {
            return "GraphWalker has not GraphWalker Nature ";
        }
    });
    cleanBuild();
}
项目:gw4e.project    文件:GW4EProject.java   
private ConvertDialog prepareConvertTo(String project, String packageRootFragment, String pkg,
        String targetFilename, String targetFormat, String... nodes) {
    SWTBotTree tree = getProjectTree();
    SWTBotTreeItem item = tree.expandNode(nodes);
    item.select();
    item.setFocus();

    SWTBotMenu menu = item.contextMenu("GW4E").contextMenu("Convert to...");
    menu.click();

    bot.waitUntil(Conditions.shellIsActive("GW4E Conversion File"));
    SWTBotShell shell = bot.shell("GW4E Conversion File");

    ConvertDialog cd = new ConvertDialog(shell);
    return cd;
}
项目:gw4e.project    文件:ProblemView.java   
public static boolean hasErrorsInProblemsView(SWTWorkbenchBot bot) {
    // Open Problems View by Window -> show view -> Problems
    bot.menu("Window").menu("Show View").menu("Problems").click();

    SWTBotView view = bot.viewByTitle("Problems");
    view.show();
    SWTBotTree tree = view.bot().tree();

    for (SWTBotTreeItem item : tree.getAllItems()) {
        String text = item.getText();
        if (text != null && text.startsWith("Errors")) {
            return true;
        }
    }

    return false;
}
项目:eclemma    文件:ContextualLaunchableTesterTest.java   
@Test
public void error_message_should_contain_delegate_shortcut_id() throws Exception {
    final LogListener logListener = new LogListener();
    Platform.addLogListener(logListener);

    final String projectName = "ContextualLaunchableTesterTest";
    new JavaProjectKit(projectName);

    final SWTBotView view = bot.viewByTitle("Project Explorer");
    view.show();
    final SWTBotTree tree = view.bot().tree();
    tree.setFocus();
    tree.select(projectName).contextMenu("Coverage As").click();

    Platform.removeLogListener(logListener);

    final IStatus actualStatus = logListener.statuses.get(1);
    assertEquals(EclEmmaUIPlugin.ID, actualStatus.getPlugin());
    assertEquals(
            "Launch shortcut 'org.eclipse.eclemma.ui.ContextualLaunchableTesterTest.fakeShortcut' enablement expression caused exception.",
            actualStatus.getMessage());
    assertEquals(
            "No property tester contributes a property org.eclipse.eclemma.unknownProperty to type class org.eclipse.core.internal.resources.Project",
            actualStatus.getException().getMessage());
}
项目:google-cloud-eclipse    文件:SwtBotTreeUtilities.java   
/**
 * Given a tree that contains an entry with <code>itemName</code> and a direct child with a name
 * matching <code>subchildName</code>, return its tree item.
 *
 * This method is useful when there is the possibility of a tree having two similarly-named
 * top-level nodes.
 *
 * @param mainTree the tree
 * @param itemName the name of a top-level node in the tree
 * @param subchildName the name of a direct child of the top-level node (used to uniquely select
 *        the appropriate tree item for the given top-level node name)
 * @return the tree item corresponding to the top-level node with <code>itemName</code>that has a
 *         direct child with <code>subchildName</code>. If there are multiple tree items that
 *         satisfy this criteria, then the first one (in the UI) will be returned
 *
 * @throws WidgetNotFoundException if no such node can be found
 */
public static SWTBotTreeItem getUniqueTreeItem(final SWTBot bot, final SWTBotTree mainTree,
    String itemName, String subchildName) {
  for (SWTBotTreeItem item : mainTree.getAllItems()) {
    if (itemName.equals(item.getText())) {
      try {
        item.expand();
        waitUntilTreeHasText(bot, item);
        if (item.getNode(subchildName) != null) {
          return item;
        }
      } catch (WidgetNotFoundException ex) {
        // Ignore
      }
    }
  }

  throw new WidgetNotFoundException(
      "The " + itemName + " node with a child of " + subchildName + " must exist in the tree.");
}
项目:mesfavoris    文件:ShowInBookmarksViewOperationTest.java   
@Test
public void testShowInBookmarksView() throws TimeoutException {
    // Given
    IWorkbenchPage activePage = UIThreadRunnable
            .syncExec(() -> PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage());
    assertNotNull(activePage);

    // When
    bookmarksService.showInBookmarksView(activePage, new BookmarkId("bookmark21"), true);

    // Then
    SWTBotTree botTree = bookmarksViewDriver.tree();
    Waiter.waitUntil("bookmark not selected", () -> {
        assertThat(botTree.selection().get(0).get(0)).isEqualTo("bookmark21");
        return true;
    });
}
项目:dsl-devkit    文件:CoreSwtbotTools.java   
/**
 * Open view.
 *
 * @param bot
 *          to work with, must not be {@code null}
 * @param category
 *          the category, must not be {@code null}
 * @param view
 *          the name of the view, must not be {@code null}
 */
public static void openView(final SWTWorkbenchBot bot, final String category, final String view) {
  Assert.isNotNull(bot, ARGUMENT_BOT);
  Assert.isNotNull(category, "category");
  Assert.isNotNull(view, ARGUMENT_VIEW);
  bot.menu("Window").menu("Show View").menu("Other...").click();
  bot.shell("Show View").activate();
  final SWTBotTree tree = bot.tree();

  for (SWTBotTreeItem item : tree.getAllItems()) {
    if (category.equals(item.getText())) {
      CoreSwtbotTools.waitForItem(bot, item);
      final SWTBotTreeItem[] node = item.getItems();

      for (SWTBotTreeItem swtBotTreeItem : node) {
        if (view.equals(swtBotTreeItem.getText())) {
          swtBotTreeItem.select();
        }
      }
    }
  }
  assertTrue("View or Category found", bot.button().isEnabled());
  bot.button("OK").click();
}
项目:dsl-devkit    文件:CoreSwtbotTools.java   
/**
 * Attempts to expand all nodes along the path specified by the node array parameter.
 * The method is copied from SWTBotTree with an additional check if the node is already expanded.
 *
 * @param bot
 *          tree bot, must not be {@code null}
 * @param nodes
 *          node path to expand, must not be {@code null} or empty
 * @return the last tree item that was expanded, or {@code null} if no item was found
 */
public static SWTBotTreeItem expandNode(final SWTBotTree bot, final String... nodes) {
  Assert.isNotNull(bot, ARGUMENT_BOT);
  Assert.isNotNull(nodes, ARGUMENT_NODES);
  assertArgumentIsNotEmpty(nodes, ARGUMENT_NODES);
  new SWTBot().waitUntil(widgetIsEnabled(bot));
  SWTBotTreeItem item = bot.getTreeItem(nodes[0]);
  if (!item.isExpanded()) {
    item.expand();
  }

  final List<String> asList = new ArrayList<String>(Arrays.asList(nodes));
  asList.remove(0);
  if (!asList.isEmpty()) {
    item = expandNode(item, asList.toArray(new String[asList.size()]));
  }

  return item;
}
项目:gwt-eclipse-plugin    文件:SwtBotUtils.java   
/**
 * Create a java project with the specified project name. This function opens up the Java
 * Perspective.
 *
 * @param bot The current SWTWorkbenchBot object
 * @param projectName Name of java project to be created
 */
public static void createJavaProject(SWTWorkbenchBot bot, String projectName) {
  // Open Java Perspective
  bot.perspectiveById("org.eclipse.jdt.ui.JavaPerspective").activate();

  // Open the list of new project wizards
  bot.menu("File").menu("New").menu("Project...").click();

  // Select the Java project
  SWTBotTree projectSelectionTree = bot.tree();
  SWTBotTreeItem projectSelectionTreeItem =
      SwtBotTreeActions.getUniqueTreeItem(bot, projectSelectionTree, "Java", "Java Project");
  SwtBotTreeActions.selectTreeItem(bot, projectSelectionTreeItem, "Java Project");

  bot.button("Next >").click();

  // Configure the project and then create it
  bot.textWithLabel("Project name:").setText(projectName);

  SwtBotUtils.clickButtonAndWaitForWindowChange(bot, bot.button("Finish"));
}
项目:gwt-eclipse-plugin    文件:SwtBotTreeActions.java   
/**
 * Given a tree that contains an entry with <code>itemName</code> and a direct child with a name
 * matching <code>subchildName</code>, return its tree item.
 *
 * This method is useful when there is the possibility of a tree having two similarly-named
 * top-level nodes.
 *
 * @param mainTree the tree
 * @param itemName the name of a top-level node in the tree
 * @param subchildName the name of a direct child of the top-level node (used to uniquely select
 *        the appropriate tree item for the given top-level node name)
 * @return the tree item corresponding to the top-level node with <code>itemName</code>that has a
 *         direct child with <code>subchildName</code>. If there are multiple tree items that
 *         satisfy this criteria, then the first one (in the UI) will be returned
 *
 * @throws IllegalStateException if no such node can be found
 */
public static SWTBotTreeItem getUniqueTreeItem(final SWTBot bot, final SWTBotTree mainTree,
    String itemName, String subchildName) {
  for (SWTBotTreeItem item : mainTree.getAllItems()) {
    if (itemName.equals(item.getText())) {
      try {
        item.expand();
        SwtBotTreeActions.waitUntilTreeHasText(bot, item);
        if (item.getNode(subchildName) != null) {
          return item;
        }
      } catch (WidgetNotFoundException e) {
        // Ignore
      }
    }
  }

  throw new IllegalStateException("The '" + itemName + "' node with a child of '" + subchildName
      + "' must exist in the tree.");
}
项目:gwt-eclipse-plugin    文件:SwtBotProjectActions.java   
/**
 * Creates a java project with the specified project name.
 *
 * @param bot the SWTWorkbenchBot
 * @param projectName the name of the java project to create
 */
public static void createJavaProject(SWTWorkbenchBot bot, String projectName) {
  // Open Java Perspective
  bot.perspectiveById("org.eclipse.jdt.ui.JavaPerspective").activate();

  // Open the list of new project wizards
  bot.menu("File").menu("New").menu("Project...").click();

  // Select the Java project
  SWTBotTree projectSelectionTree = bot.tree();
  SWTBotTreeItem projectSelectionGoogleTreeItem =
      SwtBotTreeActions.getUniqueTreeItem(bot, projectSelectionTree, "Java", "Java Project");
  SwtBotTreeActions.selectTreeItem(bot, projectSelectionGoogleTreeItem, "Java Project");

  bot.button("Next >").click();

  // Configure the project and then create it
  bot.textWithLabel("Project name:").setText(projectName);

  SwtBotUtils.clickButtonAndWaitForWindowChange(bot, bot.button("Finish"));
}
项目:gwt-eclipse-plugin    文件:SwtBotProjectActions.java   
public static void createUiBinder(final SWTWorkbenchBot bot, String projectName,
    String packageName, String name, boolean generateSampleContent, boolean generateComments) {
  // Open the list of new project wizards
  bot.menu("File").menu("New").menu("Other...").click();

  // Select the Web App project wizard
  SWTBotTree projectSelectionTree = bot.tree();
  SWTBotTreeItem projectSelectionGoogleTreeItem = SwtBotTreeActions
      .getUniqueTreeItem(bot, projectSelectionTree, "GWT Classes", "UiBinder").expand();
  SwtBotTreeActions.selectTreeItem(bot, projectSelectionGoogleTreeItem, "UiBinder");
  bot.button("Next >").click();

  // Configure the UiBinder and then create it
  String sourceFolder = projectName + "/" + SOURCE_FOLDER;
  bot.textWithLabel("Source folder:").setText(sourceFolder);
  bot.textWithLabel("Package:").setText(packageName);
  bot.textWithLabel("Name:").setText(name);

  SwtBotUtils.setCheckBox(bot.checkBox("Generate sample content"),
      generateSampleContent);
  SwtBotUtils.setCheckBox(bot.checkBox("Generate comments"), generateComments);

  SwtBotUtils.clickButtonAndWaitForWindowChange(bot, bot.button("Finish"));
}
项目:gwt-eclipse-plugin    文件:SwtBotProjectActions.java   
/**
 * Returns true if the specified project can be found in the 'Package Explorer' or 'Project View',
 * otherwise returns false. Throws a WidgetNotFoundException exception if the 'Package Explorer'
 * or 'Project Explorer' view cannot be found.
 *
 * @param bot The SWTWorkbenchBot.
 * @param projectName The name of the project to be found.
 * @return if the project exists
 */
public static boolean doesProjectExist(final SWTWorkbenchBot bot, String projectName) {
  SWTBotView explorer = getPackageExplorer(bot);
  if (explorer == null) {
    throw new WidgetNotFoundException(
        "Could not find the 'Package Explorer' or 'Project Explorer' view.");
  }

  // Select the root of the project tree in the explorer view
  Widget explorerWidget = explorer.getWidget();
  Tree explorerTree = bot.widget(widgetOfType(Tree.class), explorerWidget);
  SWTBotTreeItem[] allItems = new SWTBotTree(explorerTree).getAllItems();
  for (int i = 0; i < allItems.length; i++) {
    if (allItems[i].getText().equals(projectName)) {
      return true;
    }
  }
  return false;
}
项目:gwt-eclipse-plugin    文件:SwtBotProjectActions.java   
/**
 * Returns true if there are errors in the Problem view. Returns false otherwise.
 */
public static boolean hasErrorsInProblemsView(SWTWorkbenchBot bot) {
  // Open Problems View by Window -> show view -> Problems
  bot.menu("Window").menu("Show View").menu("Problems").click();

  SWTBotView view = bot.viewByTitle("Problems");
  view.show();
  SWTBotTree tree = view.bot().tree();

  for (SWTBotTreeItem item : tree.getAllItems()) {
    String text = item.getText();
    if (text != null && text.startsWith("Errors")) {
      return true;
    }
  }

  return false;
}
项目:gwt-eclipse-plugin    文件:SwtBotProjectActions.java   
/**
 * Returns the specified project. Throws a WidgetNotFoundException if the 'Package Explorer' or
 * 'Project Explorer' view cannot be found or if the specified project cannot be found.
 *
 * @param bot The SWTWorkbenchBot.
 * @param projectName The name of the project to select.
 * @return the tree
 */
public static SWTBotTreeItem selectProject(final SWTWorkbenchBot bot, String projectName) {
  /*
   * Choose either the Package Explorer View or the Project Explorer view. Eclipse 3.3 and 3.4
   * start with the Java Perspective, which has the Package Explorer View open by default, whereas
   * Eclipse 3.5 starts with the Resource Perspective, which has the Project Explorer View open.
   */
  SWTBotView explorer = getPackageExplorer(bot);
  for (SWTBotView view : bot.views()) {
    if (view.getTitle().equals("Package Explorer")
        || view.getTitle().equals("Project Explorer")) {
      explorer = view;
      break;
    }
  }

  if (explorer == null) {
    throw new WidgetNotFoundException(
        "Could not find the 'Package Explorer' or 'Project Explorer' view.");
  }

  // Select the root of the project tree in the explorer view
  Widget explorerWidget = explorer.getWidget();
  Tree explorerTree = bot.widget(widgetOfType(Tree.class), explorerWidget);
  return new SWTBotTree(explorerTree).getTreeItem(projectName).select();
}
项目:gw4e.project    文件:OutLineView.java   
public Map<String,SWTBotTreeItem> geVisibleTreeItems () {
    Map<String,SWTBotTreeItem> temp = new HashMap<String,SWTBotTreeItem>();
    SWTBotTree tree = botView.bot().treeWithId(GW4EOutlinePage.GW_WIDGET_ID,GW4EOutlinePage.GW_OUTLINE_ELEMENTS_TREE);
    SWTBotTreeItem[] items = tree.getAllItems();
    for (SWTBotTreeItem swtBotTreeItem : items) {
        if (swtBotTreeItem.isVisible()) temp.put(swtBotTreeItem.getText(),swtBotTreeItem);
    }
    return temp;
}
项目:gw4e.project    文件:GW4EProject.java   
private SWTBotTree setupTreeForMenu(String... nodes) {
    SWTBotTree tree = getProjectTree();
    SWTBotTreeItem item = tree.expandNode(nodes);
    item.setFocus();
    item.select();
    return tree;
}
项目:gw4e.project    文件:GW4EProject.java   
public SWTBotMenu canGenerateSource(boolean enabled, String... nodes) {
    SWTBotTree tree = getProjectTree();
    SWTBotTreeItem item = tree.expandNode(nodes);
    item.setFocus();
    item.select();
    SWTBotMenu menu = item.contextMenu("GW4E").contextMenu("Generate Test and Interface");
    assertEquals("Invalid state ", enabled, menu.isEnabled());
    return menu;
}
项目:gw4e.project    文件:GW4EProject.java   
public void generateSource(String... nodes) {
    SWTBotTree tree = getProjectTree();
    SWTBotTreeItem item = tree.expandNode(nodes);
    item.setFocus();
    item.select();
    SWTBotMenu menu = item.contextMenu("GW4E").contextMenu("Generate Test and Interface");
    assertEquals("Invalid state ", true, menu.isEnabled());
    Display.getDefault().asyncExec(new Runnable() {
        @Override
        public void run() {
            menu.click();
        }
    });

}
项目:gw4e.project    文件:ProblemView.java   
public String getMessage(int rowNumber, String type) {
    final int MESSAGE_COLUMN = 0;
    SWTBotTree tree = botView.bot().tree();
    SWTBotTreeItem[] items = tree.getAllItems();
    for (SWTBotTreeItem item : items) {
        if (item.getText().contains(type)) {
            return item.expand().getItems()[rowNumber].row().get(MESSAGE_COLUMN);
        }
    }
    return "";
}
项目:gw4e.project    文件:ProblemView.java   
public int getCountofType(String type) {
    SWTBotTree tree = botView.bot().tree();
    SWTBotTreeItem[] items = tree.getAllItems();
    for (SWTBotTreeItem item : items) {
        if (item.getText().contains(type)) {
            return item.expand().getItems().length;
        }
    }
    return 0;
}
项目:gw4e.project    文件:GW4EProjectPreference.java   
public GW4EProjectProperties openPropertiesPage ( ) {
    SWTBotTree tree = getProjectTree();
    SWTBotTreeItem item = tree.expandNode(this.projectName);
    item.setFocus();
    item.select();

    ICondition condition = new DefaultCondition () {
        @Override
        public boolean test() throws Exception {
            SWTBotTreeItem treeItem = tree.getTreeItem(projectName);
            return treeItem.isSelected();
        }

        @Override
        public String getFailureMessage() {
            return "Project " + projectName + " not selected ";
        }

    };
    bot.waitUntil(condition);
    bot.menu( "File").menu("Properties").click();        
    bot.waitUntil(Conditions.shellIsActive("Properties for " + projectName));
    SWTBotShell shell = bot.shell("Properties for " + projectName).activate();
    shell.bot().tree().select("GW4E");
    bot.waitUntil(Conditions.waitForWidget(WidgetMatcherFactory.withId( ProjectPropertyPage.PROJECT_PROPERTY_PAGE_WIDGET_ID, ProjectPropertyPage.PROJECT_PROPERTY_PAGE_WIDGET_SECURITY_LEVEL_FOR_ABSTRACT_CONTEXT)));
    return new GW4EProjectProperties(bot,shell);
}
项目:gw4e.project    文件:GW4EPreferencePage.java   
private void showConsolePreference(SWTBotShell shell) {
    SWTBotTree tree = bot.tree().select("Run/Debug");
    SWTBotTreeItem item = tree.getTreeItem("Console");
    item.click();
    SWTBotCheckBox button = bot.checkBoxWithLabel("Limit console output");
    if (button.isChecked()) button.click();
}
项目:gw4e.project    文件:ConsolePreferencePage.java   
private void showConsolePreference(SWTBotShell shell) {
    SWTBotTree tree = bot.tree().select("Run/Debug");
    tree.expandNode("Run/Debug", true);

    SWTBotTreeItem[] items = tree.getAllItems();
    for (SWTBotTreeItem swtBotTreeItem : items) {
        if (swtBotTreeItem.getText().equalsIgnoreCase("Run/Debug")) {
            swtBotTreeItem.getNode("Console").select();
        }
    }

    try {
        int max = 10;
        for (int i = 0; i < max; i++) {
            SWTBotCheckBox button = bot.checkBox(i);
            if (button.getText().equalsIgnoreCase("&Limit console output")) {
                if (button.isChecked()) {
                    button.click();
                    break;
                }
            }
        } 
    } catch (Exception e) {
    }

    String name = "OK";
    if (GW4EPlatform.isEclipse47()) name = "Apply and Close";
    bot.button(name).click();
}
项目:gw4e.project    文件:ModelRefactoring.java   
public void refactorModelName (String newName,String [] nodes) {
    SWTBotTree tree = getProjectTree();
    SWTBotTreeItem item = tree.expandNode(nodes);
    item.select();
    item.setFocus();

    SWTBotMenu menu = item.contextMenu("Refactor").contextMenu("Rename...");
    menu.click();

    bot.waitUntil(Conditions.shellIsActive("Rename Resource"));
    SWTBotShell shell = bot.shell("Rename Resource");

    SWTBotText text = shell.bot().textWithLabel("New name:");
    text.setText(newName);

    ICondition condition = new DefaultCondition () {
        @Override
        public boolean test() throws Exception {
            return shell.bot().button("OK").isEnabled();
        }

        @Override
        public String getFailureMessage() {
            return "OK button not enabled";
        }
    };

    bot.waitUntil(condition);

    shell.bot().button("OK").click();

    bot.waitUntil(Conditions.shellCloses(shell));
}
项目:gw4e.project    文件:ModelRefactoring.java   
public void refactorRenameFolder (String [] nodes, String name) {
    SWTBotTree tree = getProjectTree();
    SWTBotTreeItem item = tree.expandNode(nodes);
    item.select();
    item.setFocus();

    SWTBotMenu menu = item.contextMenu("Refactor").contextMenu("Rename...");
    menu.click();

    bot.waitUntil(Conditions.shellIsActive("Rename Package"));
    SWTBotShell shell = bot.shell("Rename Package");


    SWTBotText text = shell.bot().textWithLabel("New name:");
    text.setText(name);

    ICondition condition = new DefaultCondition () {
        @Override
        public boolean test() throws Exception {
            return shell.bot().button("OK").isEnabled();
        }

        @Override
        public String getFailureMessage() {
            return "OK button not enabled";
        }
    };

    bot.waitUntil(condition);

    shell.bot().button("OK").click();

    bot.waitUntil(Conditions.shellCloses(shell), 30 * 1000);
}
项目:gw4e.project    文件:ModelRefactoring.java   
public void refactorMoveModel (String [] nodes,String [] destination, String name) {
    SWTBotTree tree = getProjectTree();
    SWTBotTreeItem item = tree.expandNode(nodes);
    item.select();
    item.setFocus();

    SWTBotMenu menu = item.contextMenu("Refactor").contextMenu("Move...");
    menu.click();

    bot.waitUntil(Conditions.shellIsActive("Move"));
    SWTBotShell shell = bot.shell("Move");

    SWTBotTree packageTree = shell.bot().treeWithLabel("Choose destination for '"+ name + "':");
    SWTBotTreeItem target = packageTree.expandNode(destination);
    target.select();
    target.setFocus();

    ICondition condition = new DefaultCondition () {
        @Override
        public boolean test() throws Exception {
            return shell.bot().button("OK").isEnabled();
        }

        @Override
        public String getFailureMessage() {
            return "OK button not enabled";
        }
    };

    bot.waitUntil(condition);

    shell.bot().button("OK").click();

    bot.waitUntil(Conditions.shellCloses(shell));
}
项目:google-cloud-eclipse    文件:SwtBotTreeUtilities.java   
/**
 * Wait until the given tree has items, and return the first item.
 * 
 * @throws TimeoutException if no items appear within the default timeout
 */
public static SWTBotTreeItem waitUntilTreeHasItems(SWTWorkbenchBot bot, final SWTBotTree tree) {
  bot.waitUntil(new DefaultCondition() {
    @Override
    public String getFailureMessage() {
      return "Tree items never appeared";
    }

    @Override
    public boolean test() throws Exception {
      return tree.hasItems();
    }
  });
  return tree.getAllItems()[0];
}
项目:google-cloud-eclipse    文件:SwtBotTreeUtilities.java   
/**
 * Wait until the given tree has not items.
 * 
 * @throws TimeoutException if no items appear within the default timeout
 */
public static void waitUntilTreeHasNoItems(SWTWorkbenchBot bot, final SWTBotTree tree) {
  bot.waitUntil(new DefaultCondition() {
    @Override
    public String getFailureMessage() {
      return "Tree items never disappeared";
    }

    @Override
    public boolean test() throws Exception {
      return !tree.hasItems();
    }
  });
}
项目:google-cloud-eclipse    文件:SwtBotProjectActions.java   
/**
 * Returns true if the specified project is found in the 'Package Explorer' or 'Project View',
 * otherwise returns false. Throws a WidgetNotFoundException exception if the 'Package Explorer'
 * or 'Project Explorer' view cannot be found.
 *
 * @param projectName the name of the project to be found
 * @return true if the project is found, and false if not found
 */
public static boolean projectFound(final SWTWorkbenchBot bot, String projectName) {
  SWTBotView explorer = getExplorer(bot);

  // Select the root of the project tree in the explorer view
  Widget explorerWidget = explorer.getWidget();
  Tree explorerTree = bot.widget(widgetOfType(Tree.class), explorerWidget);
  for (SWTBotTreeItem item : new SWTBotTree(explorerTree).getAllItems()) {
    if (item.getText().equals(projectName)) {
      return true;
    }
  }
  return false;
}
项目:google-cloud-eclipse    文件:SwtBotProjectActions.java   
/**
 * Returns the specified project.
 *
 * @param projectName the name of the project to select
 * @return the selected tree item
 * @throws WidgetNotFoundException if the 'Package Explorer' or 'Project Explorer' view cannot be
 *         found or if the specified project cannot be found.
 */
public static SWTBotTreeItem selectProject(final SWTWorkbenchBot bot, String projectName) {
  SWTBotView explorer = getExplorer(bot);

  // Select the root of the project tree in the explorer view
  Widget explorerWidget = explorer.getWidget();
  Tree explorerTree = bot.widget(widgetOfType(Tree.class), explorerWidget);
  return new SWTBotTree(explorerTree).getTreeItem(projectName).select();
}
项目:dsl-devkit    文件:SwtBotWizardUtil.java   
/**
 * Select a folder in a project.
 *
 * @param bot
 *          the bot
 * @param folderName
 *          the folder name
 */
public static void selectProjectFolder(final SwtWorkbenchBot bot, final String folderName) {
  SWTBotView packageExplorer = bot.viewByTitle("Project Explorer");
  packageExplorer.show();
  Composite comp = (Composite) packageExplorer.getWidget();
  final Tree tree = bot.widget(WidgetMatcherFactory.widgetOfType(Tree.class), comp);
  PlatformUI.getWorkbench().getDisplay().syncExec(() -> {
    SWTBotTree botTree = new SWTBotTree(tree);
    if (!selectItem(botTree, folderName)) {
      fail("folder was not found");
    }
  });
}
项目:dsl-devkit    文件:SwtBotWizardUtil.java   
/**
 * Select a TreeItem with the given name in a tree.
 *
 * @param tree
 *          the tree in which the item is searched
 * @param name
 *          the name of the required item
 * @return true, if the item was selected
 */
public static boolean selectItem(final SWTBotTree tree, final String name) {
  SWTBotTreeItem[] items = tree.getAllItems();
  for (SWTBotTreeItem item : items) {
    if (selectTreeItem(item, name)) {
      return true;
    }
  }
  return false;
}
项目:dsl-devkit    文件:CoreSwtbotTools.java   
/**
 * Find tree item.
 * <p>
 * <em>Note</em>: Throws an AssertionError if the item could not be found.
 * </p>
 *
 * @param bot
 *          to work with, must not be {@code null}
 * @param tree
 *          to search in, must not be {@code null}
 * @param item
 *          to search, must not be {@code null}
 * @return the {@link SWTBotTreeItem}, never {@code null}
 */
public static SWTBotTreeItem findTreeItem(final SWTWorkbenchBot bot, final SWTBotTree tree, final String item) {
  Assert.isNotNull(bot, ARGUMENT_BOT);
  Assert.isNotNull(tree, "tree");
  Assert.isNotNull(item, ARGUMENT_ITEM);
  int itemCount = 0;
  boolean itemFound = false;
  SWTBotTreeItem botTreeItem = null;
  CoreSwtbotTools.waitForTreeItem(bot, tree);

  do {
    for (SWTBotTreeItem treeItem : tree.getAllItems()) {
      itemCount = treeItem.rowCount();
      if (item.equals(treeItem.getText())) {
        itemFound = true;
        botTreeItem = treeItem;
        break;
      } else {
        for (SWTBotTreeItem treeNode : tree.getAllItems()) {
          CoreSwtbotTools.waitForItem(bot, treeNode);
          itemCount = treeNode.rowCount();
        }
      }
    }
  } while (itemCount > 0);

  assertTrue("Searching TreeItem", itemFound);

  return botTreeItem;

}
项目:scenarioo-example-swtbot-e4    文件:ScenariooTestWrapper.java   
protected void clickContextMenuActionForTreeItem(final SWTBotTree tree, final SWTBotTreeItem treeItem,
        final String actionName) {
    SWTBotMenu contextMenuAction = treeItem.contextMenu(actionName);
    contextMenuAction.click();
    closeContextMenu(contextMenuAction);
    bot.sleep(500);
}
项目:scenarioo-example-swtbot-e4    文件:ScenariooTestWrapper.java   
/**
 * 
 * @param tree
 * @param orderNumber
 * @param actionName
 * @return SWTBotMenu
 */
@Deprecated
protected SWTBotMenu getContextMenuAndGenerateDocu(final SWTBotTree tree, final String orderNumber,
        final String actionName) {

    final SWTBotTreeItem treeItem = tree.getTreeItem(orderNumber);
    return getContextMenuAndGenerateDocu(tree, treeItem, actionName);
}
项目:scenarioo-example-swtbot-e4    文件:ScenariooTestWrapper.java   
/**
 * 
 * @param tree
 * @param treeItem
 * @param actionName
 * @return SWTBotMenu
 */
protected SWTBotMenu getContextMenuAndGenerateDocu(final SWTBotTree tree, final SWTBotTreeItem treeItem,
        final String actionName) {

    openContextMenuForTreeItem(tree, treeItem);
    final SWTBotMenu menuAction = treeItem.contextMenu(actionName);

    scenariooWriterHelper.writeStep("context_menu_opened", PageName.ORDER_OVERVIEW, screenshot());
    return menuAction;
}
项目:scenarioo-example-swtbot-e4    文件:ScenariooTestWrapper.java   
protected void openContextMenuForTreeItem(final SWTBotTree tree, final SWTBotTreeItem treeItem) {

        Display.getDefault().syncExec(new Runnable() {

            @Override
            public void run() {
                Menu menu = tree.widget.getMenu();
                Point menuItemLocation = getMenuItemLocation(treeItem);
                menu.setLocation(menuItemLocation.x, menuItemLocation.y);
                menu.setVisible(true);
            }
        });
        bot.sleep(100);
    }