Java Code Examples for org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem#getText()

The following examples show how to use org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem#getText() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ConditionHelpers.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Is a tree node available
 *
 * @param name
 *            the name of the node
 * @param tree
 *            the parent tree
 * @return ICondition for verification
 */
public static ICondition isTreeNodeAvailable(final String name, final SWTBotTree tree) {
    return new SWTBotTestCondition() {
        @Override
        public boolean test() throws Exception {
            try {
                final SWTBotTreeItem[] treeItems = tree.getAllItems();
                for (SWTBotTreeItem ti : treeItems) {
                    final String text = ti.getText();
                    if (text.equals(name)) {
                        return true;
                    }
                }
            } catch (Exception e) {
            }
            return false;
        }

        @Override
        public String getFailureMessage() {
            return NLS.bind("No child of tree {0} found with text {1}. Child items: {2}",
                    new String[] { tree.toString(), name, Arrays.toString(tree.getAllItems()) });
        }
    };
}
 
Example 2
Source File: SwtBotProjectActions.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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;
}
 
Example 3
Source File: ContextMenusInSarosView.java    From saros with GNU General Public License v2.0 5 votes vote down vote up
protected final void logError(Logger log, Throwable t, SWTBotTree tree, SWTBotTreeItem treeItem) {
  String treeItemText = null;
  String treeText = null;
  try {
    treeText = tree == null ? "not found" : tree.getText();
    treeItemText = treeItem == null ? "not found" : treeItem.getText();
  } catch (RuntimeException e) {
    log.error(e.getMessage(), e);
  }
  log.error(t.getMessage() + "@ tree: " + treeText + ", tree item: " + treeItemText, t);
}