Java 类org.eclipse.swtbot.swt.finder.results.WidgetResult 实例源码

项目:google-cloud-eclipse    文件:SwtBotTreeUtilities.java   
/**
 * Gets the item matching the given name from a tree item.
 * 
 * @param widget the tree item to search
 * @param nodeText the text on the node
 * @return the child tree item with the specified text
 */
public static TreeItem getTreeItem(final TreeItem widget, final String nodeText) {
  return UIThreadRunnable.syncExec(new WidgetResult<TreeItem>() {
    @Override
    public TreeItem run() {
      TreeItem[] items = widget.getItems();
      for (TreeItem item : items) {
        if (item.getText().equals(nodeText)) {
          return item;
        }
      }
      return null;
    }
  });
}
项目:dsl-devkit    文件:ContextActionUiTestUtil.java   
/**
 * Returns the context menu item identified by the given labels.
 * When a context menu 'Compile' exists with the sub context menu 'All Invalids',
 * then the context menu 'All Invalids' is returned when giving the labels 'Compile' and 'All Invalids'.
 *
 * @param bot
 *          the {@link AbstractSWTBot} on which to infer the context menu
 * @param labels
 *          the labels on the context menus
 * @return the context menu item, {@code null} if the context menu item could not be found
 */
private static MenuItem getContextMenuItem(final AbstractSWTBot<? extends Control> bot, final String... labels) {
  return UIThreadRunnable.syncExec(new WidgetResult<MenuItem>() {
    @Override
    public MenuItem run() {
      MenuItem menuItem = null;
      Control control = bot.widget;

      // MenuDetectEvent
      Event event = new Event();
      control.notifyListeners(SWT.MenuDetect, event);
      if (event.doit) {
        Menu menu = control.getMenu();
        for (String text : labels) {
          Matcher<?> matcher = allOf(instanceOf(MenuItem.class), withMnemonic(text));
          menuItem = show(menu, matcher);
          if (menuItem != null) {
            menu = menuItem.getMenu();
          } else {
            hide(menu);
            break;
          }
        }
        return menuItem;
      } else {
        return null;
      }
    }
  });
}
项目:gwt-eclipse-plugin    文件:SwtBotTreeActions.java   
/**
 * Gets the item matching the given name from a tree item.
 *
 * @param widget the tree item to search
 * @param nodeText the text on the node.
 * @return the child tree item with the specified text.
 */
public static TreeItem getTreeItem(final TreeItem widget, final String nodeText) {
  return UIThreadRunnable.syncExec(new WidgetResult<TreeItem>() {
    @Override
    public TreeItem run() {
      TreeItem[] items = widget.getItems();
      for (TreeItem item : items) {
        if (item.getText().equals(nodeText)) {
          return item;
        }
      }
      return null;
    }
  });
}