@Override
 public boolean test() {
   int count = tree.getItems().size();
   log.trace("Count of found tree items:" + count);
   if (count > 0) {
     return true;
   }
   return false;
 }
 private static org.eclipse.swt.widgets.TreeItem findTreeItem(
     ReferencedComposite referencedComposite, int treeIndex, int treeItemIndex) {
   Tree tree = new DefaultTree(referencedComposite, treeIndex);
   new WaitUntil(new TreeHasChildren(tree));
   logger.debug("Searching for tree item with index: " + treeIndex);
   List<TreeItem> items = tree.getItems();
   if (items.size() < treeItemIndex + 1) {
     SWTLayerException exception = new SWTLayerException("No matching tree item found");
     exception.addMessageDetail("Tree Index: " + treeIndex);
     exception.addMessageDetail("Tree Item Index: " + treeItemIndex);
     exception.addMessageDetail("Tree has these " + items.size() + " Tree Items:");
     for (TreeItem treeItem : items) {
       exception.addMessageDetail("  " + treeItem.getText());
     }
     throw exception;
   } else {
     return tree.getItems().get(treeItemIndex).getSWTWidget();
   }
 }
 private static org.eclipse.swt.widgets.TreeItem findTreeItem(
     ReferencedComposite referencedComposite, int treeIndex, String... treeItemPath) {
   org.eclipse.swt.widgets.TreeItem result = null;
   Tree tree = new DefaultTree(referencedComposite, treeIndex);
   new WaitUntil(new TreeHasChildren(tree));
   List<TreeItem> items = tree.getItems();
   int index = 0;
   while (index < treeItemPath.length) {
     String pathItem = treeItemPath[index];
     logger.debug("Searching for tree item with label: " + pathItem);
     TreeItem tiItem = null;
     boolean isFound = false;
     Iterator<TreeItem> itTreeItem = items.iterator();
     while (itTreeItem.hasNext() && (!isFound)) {
       tiItem = itTreeItem.next();
       if (tiItem.getText().equals(pathItem)) {
         isFound = true;
       }
     }
     if (isFound) {
       // It's not last item of Tree Item Path
       if (index < (treeItemPath.length - 1)) {
         new WaitUntil(new TreeItemHasMinChildren(tiItem, 1), TimePeriod.NORMAL, false);
         items = tiItem.getItems();
       } else {
         result = tiItem.getSWTWidget();
       }
     } else {
       SWTLayerException exception = new SWTLayerException("No matching tree item found");
       exception.addMessageDetail("Tree Index: " + treeIndex);
       StringBuffer sbPath = new StringBuffer("");
       for (String treeItem : treeItemPath) {
         if (sbPath.length() > 0) {
           sbPath.append(" > ");
         }
         sbPath.append(treeItem);
       }
       exception.addMessageDetail("Tree Item Path: " + sbPath.toString());
       exception.addMessageDetail("Unalbe to find path item with text: " + pathItem);
       exception.addMessageDetail(
           "These Tree Items have been found at level where path item "
               + pathItem
               + " was expected:");
       for (TreeItem treeItem : items) {
         exception.addMessageDetail("  " + treeItem.getText());
       }
       throw exception;
     }
     index++;
   }
   return result;
 }
Exemple #4
0
  /**
   * Gets the task repositories.
   *
   * @return the task repositories
   */
  public List<TaskRepository> getTaskRepositories() {
    List<TaskRepository> repositories = new ArrayList<TaskRepository>();

    Tree tree;
    try {
      tree = getRepositoriesTree();
    } catch (SWTLayerException e) {
      return new ArrayList<TaskRepository>();
    }
    for (TreeItem item : tree.getItems()) {
      repositories.add(new TaskRepository(item));
    }
    return repositories;
  }
 @Override
 public boolean test() {
   return tree.getItems().size() > 0;
 }