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

The following examples show how to use org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem#isExpanded() . 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: SwtBotProjectHelper.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
public static SWTBotTreeItem expandNode(final AbstractSWTBot<?> bot, final String node) {
  SWTBotTreeItem item = null;
  if ((bot instanceof SWTBotTree)) {
    item = ((SWTBotTree)bot).getTreeItem(node);
  } else {
    if ((bot instanceof SWTBotTreeItem)) {
      item = ((SWTBotTreeItem)bot).getNode(node);
    }
  }
  boolean _isExpanded = item.isExpanded();
  boolean _not = (!_isExpanded);
  if (_not) {
    item.expand();
  }
  return item;
}
 
Example 2
Source File: SwtBotWizardUtil.java    From dsl-devkit with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Select a tree item.
 *
 * @param treeItem
 *          the tree node
 * @param name
 *          the name of the item to look for
 * @return true, if item was found and selected
 */
private static boolean selectTreeItem(final SWTBotTreeItem treeItem, final String name) {
  if (name.equals(treeItem.getText())) {
    treeItem.select();
    return true;
  }
  if (!treeItem.isExpanded()) {
    treeItem.expand();
  }
  for (SWTBotTreeItem item : treeItem.getItems()) {
    if (selectTreeItem(item, name)) {
      return true;
    }
  }
  return false;
}
 
Example 3
Source File: CoreSwtbotTools.java    From dsl-devkit with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Waits until the node collapses.
 *
 * @param bot
 *          bot to work with, must not be {@code null}
 * @param node
 *          node to wait for, must not be {@code null}
 */
public static void safeBlockingCollapse(final SWTWorkbenchBot bot, final SWTBotTreeItem node) {
  Assert.isNotNull(bot, ARGUMENT_BOT);
  Assert.isNotNull(node, ARGUMENT_NODE);
  if (node.isExpanded()) {
    node.collapse();
    try {
      bot.waitUntil(new DefaultCondition() {

        @Override
        @SuppressWarnings("PMD.JUnit4TestShouldUseTestAnnotation")
        public boolean test() {
          return !node.isExpanded();
        }

        @Override
        public String getFailureMessage() {
          return "Timeout for node to collapse";
        }
      }, TIMEOUT_FOR_NODE_TO_COLLAPSE_EXPAND);
    } catch (TimeoutException e) {
      // Try one last time and do not wait anymore
      node.collapse();
    }
  }
}
 
Example 4
Source File: CoreSwtbotTools.java    From dsl-devkit with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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;
}
 
Example 5
Source File: CoreSwtbotTools.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Waits until the node expands.
 *
 * @param bot
 *          bot to work with, must not be {@code null}
 * @param node
 *          node to wait for, must not be {@code null}
 */
public static void safeBlockingExpand(final SWTWorkbenchBot bot, final SWTBotTreeItem node) {
  Assert.isNotNull(bot, ARGUMENT_BOT);
  Assert.isNotNull(node, ARGUMENT_NODE);
  if (!node.isExpanded()) {
    node.expand();
    try {
      bot.waitUntil(new DefaultCondition() {

        @Override
        @SuppressWarnings("PMD.JUnit4TestShouldUseTestAnnotation")
        public boolean test() {
          return node.isExpanded();
        }

        @Override
        public String getFailureMessage() {
          return "Timeout for node to expand";
        }
      }, TIMEOUT_FOR_NODE_TO_COLLAPSE_EXPAND);

    } catch (TimeoutException e) {
      // Try one last time and do not wait anymore
      node.expand();
    }
  }
}
 
Example 6
Source File: CoreSwtbotTools.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Expands the node matching the given node texts.
 * The method is copied from SWTBotTreeItem with an additional check if the node is already expanded.
 *
 * @param bot
 *          tree item bot, must not be {@code null}
 * @param nodes
 *          the text on the node, must not be {@code null} or empty
 * @return the last tree node that was expanded, never {@code null}
 */
public static SWTBotTreeItem expandNode(final SWTBotTreeItem bot, final String... nodes) {
  Assert.isNotNull(bot, ARGUMENT_BOT);
  Assert.isNotNull(nodes, ARGUMENT_NODES);
  assertArgumentIsNotEmpty(nodes, ARGUMENT_NODES);
  SWTBotTreeItem item = bot;
  for (String node : nodes) {
    item = item.getNode(node);
    if (!item.isExpanded()) {
      item.expand();
    }
  }
  return item;
}
 
Example 7
Source File: BotBdmModelEditor.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public BotBdmModelEditor selectBusinessObject(String packageName, String businessObject) {
    SWTBotTreeItem packageItem = getBusinessObjectTree().getTreeItem(packageName);
    if (!packageItem.isExpanded()) {
        packageItem.expand();
    }
    SWTBotTreeItem node = packageItem.getNode(businessObject);
    if (!node.isSelected()) {
        node.select();
    }
    return this;
}
 
Example 8
Source File: BotBdmConstraintsEditor.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void selectBusinessObject(String packageName, String businessObject) {
    SWTBotTreeItem packageItem = getBusinessObjectTree().getTreeItem(packageName);
    if(!packageItem.isExpanded()) {
        packageItem.expand();
    }
    SWTBotTreeItem node = packageItem.getNode(businessObject);
    if(!node.isSelected()) {
        node.select();
    }
}
 
Example 9
Source File: BotTreeView.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public void selectFirstSequenceFlow(final String pPool) {
    waitUntilPoolDisplayed(pPool);
    final SWTBotTreeItem treeItem = overviewTree.getTreeItem(pPool);
    if (!treeItem.isExpanded()) {
        treeItem.expand();
    }
    treeItem.select("Sequence Flow");
}
 
Example 10
Source File: AbstractOutlineViewTest.java    From dsl-devkit with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Expands the given {@link SWTBotTreeItem} if it is not expanded already.
 *
 * @param treeItem
 *          the tree item to be expanded
 */
protected void expandIfNotExpanded(final SWTBotTreeItem treeItem) {
  if (!treeItem.isExpanded()) {
    treeItem.expand();
  }
}