本文整理汇总了Java中org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem.expand方法的典型用法代码示例。如果您正苦于以下问题:Java SWTBotTreeItem.expand方法的具体用法?Java SWTBotTreeItem.expand怎么用?Java SWTBotTreeItem.expand使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem
的用法示例。
在下文中一共展示了SWTBotTreeItem.expand方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getUniqueTreeItem
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; //导入方法依赖的package包/类
/**
* 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.");
}
示例2: waitUntilTreeItemHasItem
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; //导入方法依赖的package包/类
/**
* Blocks the caller until the tree item has the given item text.
*
* @param tree the tree item to search
* @param nodeText the item text to look for
* @throws org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException if the item could not
* be found within the timeout period
*/
private static void waitUntilTreeItemHasItem(SWTBot bot, final SWTBotTreeItem tree,
final String nodeText) {
// Attempt #1
if (!waitUntilTreeHasItemImpl(bot, tree.widget, nodeText)) {
// Attempt #2: Something went wrong, try to cautiously reopen it.
bot.sleep(1000);
// There isn't a method to collapse, so double-click instead
tree.doubleClick();
bot.waitUntil(new TreeCollapsedCondition(tree.widget));
bot.sleep(1000);
tree.expand();
bot.waitUntil(new TreeExpandedCondition(tree.widget));
if (!waitUntilTreeHasItemImpl(bot, tree.widget, nodeText)) {
printTree(tree.widget);
throw new TimeoutException(
String.format("Timed out waiting for %s, giving up...", nodeText));
}
}
}
示例3: selectTreeItem
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; //导入方法依赖的package包/类
/**
* 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;
}
示例4: expandNode
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; //导入方法依赖的package包/类
/**
* 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;
}
示例5: getUniqueTreeItem
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; //导入方法依赖的package包/类
/**
* 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.");
}
示例6: waitUntilTreeItemHasItem
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; //导入方法依赖的package包/类
/**
* Blocks the caller until the tree item has the given item text.
*
* @param tree the tree item to search
* @param nodeText the item text to look for
* @throws org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException if the item could not
* be found within the timeout period
*/
private static void waitUntilTreeItemHasItem(SWTBot bot, final SWTBotTreeItem tree,
final String nodeText) {
// Attempt #1
if (!waitUntilTreeHasItemImpl(bot, tree.widget, nodeText)) {
// Attempt #2: Something went wrong, try to cautiously reopen it.
bot.sleep(1000);
// There isn't a method to collapse, so double-click instead
tree.doubleClick();
bot.waitUntil(new TreeCollapsedCondition(tree.widget));
bot.sleep(1000);
tree.expand();
bot.waitUntil(new TreeExpandedCondition(tree.widget));
if (!waitUntilTreeHasItemImpl(bot, tree.widget, nodeText)) {
printTree(tree.widget);
throw new TimeoutException(
String.format("Timed out waiting for %s, giving up...", nodeText));
}
}
}
示例7: waitUntilTreeHasText
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; //导入方法依赖的package包/类
/**
* Blocks the caller until all of the direct children of the tree have text. The assumption is
* that the tree does not have any "empty" children.
*
* TODO: Refactor some of this logic; it follows the same general pattern as
* {@link #waitUntilTreeItemHasItem(SWTBot, SWTBotTreeItem, String)}.
*
* @param tree the tree to search
* @throws TimeoutException if all of the direct children of the tree do not have text within the
* timeout period
*/
public static void waitUntilTreeHasText(SWTBot bot, final SWTBotTreeItem tree)
throws TimeoutException {
// Attempt #1
if (!waitUntilTreeHasTextImpl(bot, tree.widget)) {
// Attempt #2: Something went wrong, try to cautiously reopen it.
bot.sleep(1000);
// There isn't a method to collapse, so double-click instead
tree.doubleClick();
bot.waitUntil(new TreeCollapsedCondition(tree.widget));
bot.sleep(1000);
tree.expand();
bot.waitUntil(new TreeExpandedCondition(tree.widget));
if (!waitUntilTreeHasTextImpl(bot, tree.widget)) {
printTree(tree.widget);
throw new TimeoutException(
"Timed out waiting for text of the tree's children, giving up...");
}
}
}
示例8: getGraphmlProperties
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; //导入方法依赖的package包/类
public GraphModelProperties getGraphmlProperties(String folder, String pkg, String filename) {
SWTBotTreeItem pti = getProjectTreeItem(this.projectName);
pti.expand();
SWTBotTreeItem fileItem = null;
if (pkg == null) {
fileItem = pti.expandNode(folder, filename);
} else {
fileItem = pti.expandNode(folder, pkg, filename);
}
bot.waitUntil(new isItemExpandedInTree(pti.getNode(folder)));
fileItem.setFocus();
fileItem.select();
bot.waitUntil(new isItemSelectedInTree(fileItem));
fileItem.click();
bot.waitUntil(new isItemSelected(fileItem));
SWTBotMenu fileMenu = bot.menu("File");
fileMenu.menu("Properties").click();
bot.waitUntil(Conditions.shellIsActive("Properties for " + filename));
SWTBotShell shell = bot.shell("Properties for " + filename);
GraphModelProperties gp = new GraphModelProperties(shell.bot(), this.projectName, folder, pkg, filename);
return gp;
}
示例9: waitUntilTreeHasText
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; //导入方法依赖的package包/类
/**
* Blocks the caller until all of the direct children of the tree have text. The assumption is
* that the tree does not have any "empty" children.
*
* @param tree the tree to search
* @throws TimeoutException if any of the direct children of the tree do not have text within the
* timeout period
*/
public static void waitUntilTreeHasText(SWTBot bot, final SWTBotTreeItem tree)
throws TimeoutException {
// TODO: Refactor some of this logic; it follows the same general pattern as
// {@link #waitUntilTreeItemHasItem(SWTBot, SWTBotTreeItem, String)}.
// Attempt #1
if (!waitUntilTreeHasTextImpl(bot, tree.widget)) {
// Attempt #2: Something went wrong, try to cautiously reopen it.
bot.sleep(1000);
// There isn't a method to collapse, so double-click instead
tree.doubleClick();
bot.waitUntil(new TreeCollapsedCondition(tree.widget));
bot.sleep(1000);
tree.expand();
bot.waitUntil(new TreeExpandedCondition(tree.widget));
if (!waitUntilTreeHasTextImpl(bot, tree.widget)) {
printTree(tree.widget);
throw new TimeoutException(
"Timed out waiting for text of the tree's children, giving up...");
}
}
}
示例10: safeBlockingExpand
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; //导入方法依赖的package包/类
/**
* 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();
}
}
}
示例11: checkForModelExistenceUI
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; //导入方法依赖的package包/类
private SWTBotTreeItem checkForModelExistenceUI(final SWTBotTreeItem treeItem) {
try {
treeItem.expand();
SWTBotTreeItem models = treeItem.getNode("models");
models.expand();
return models.getNode(TEST_MODEL).select();
} catch(AssertionFailedException e) {
Assert.fail(e.getMessage());
}
return null;
}
示例12: expandTreeItem
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; //导入方法依赖的package包/类
private void expandTreeItem(final SWTBotTreeItem treeItem, final boolean generateDocu) {
OrdersOverviewPart ordersOverviewPart = (OrdersOverviewPart) wbBot.partByTitle("Orders Overview").getPart()
.getObject();
ordersOverviewPart.setOverSteerNodeItemExpandedForTest(Boolean.TRUE);
treeItem.expand();
ordersOverviewPart.setOverSteerNodeItemExpandedForTest(null);
if (generateDocu) {
generateDocu("order_tree_node_expanded");
}
}
示例13: expandTreeItemAndGenerateDocu
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; //导入方法依赖的package包/类
/**
* @param treeItem
*/
private void expandTreeItemAndGenerateDocu(final SWTBotTreeItem treeItem) {
OrdersOverviewPart ordersOverviewPart = (OrdersOverviewPart) wbBot.partByTitle("Orders Overview").getPart()
.getObject();
ordersOverviewPart.setOverSteerNodeItemExpandedForTest(Boolean.TRUE);
treeItem.expand();
bot.sleep(100);
scenariooWriterHelper.writeStep("order_number_2_expanded", PageName.ORDER_OVERVIEW, screenshot());
ordersOverviewPart.setOverSteerNodeItemExpandedForTest(null);
}
开发者ID:scenarioo,项目名称:scenarioo-example-swtbot-e4,代码行数:13,代码来源:ShowAllOrderItemsInOrderOverviewTest.java
示例14: testPlotEditor
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; //导入方法依赖的package包/类
@Test
public void testPlotEditor() {
IVizServiceFactory fakeFactory = new BasicVizServiceFactory();
fakeFactory.register(new CSVVizService());
factoryHolder.setVizServiceFactory(fakeFactory);
// Close the initial eclipse welcome view, if one exists
try {
bot.viewByTitle("Welcome").close();
} catch (WidgetNotFoundException e) {
// We expect that the SWTBot will throw an exception if Eclipse
// doesn't start with a welcome view, so there is nothing to do here
}
// Open the fib8.csv file in the plot editor.
SWTBotTreeItem node = bot.tree().getAllItems()[0];
node.expand();
node.getNode("fib8.csv").select();
node.getNode("fib8.csv").doubleClick();
// Test the plot series selection dialog.
SWTBotToolbarButton button;
button = bot.activeEditor().bot().toolbarButton(0);
button.click();
bot.shell("Select a series").activate();
bot.tree().select("f(x)");
bot.button("OK").click();
// Check that the data tab is present
bot.cTabItem("Data").activate();
bot.cTabItem("Plot").activate();
// Test the editor closing menu option.
button = bot.activeEditor().bot().toolbarButton(1).click();
return;
}
示例15: deleteLaunchConfigs
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; //导入方法依赖的package包/类
public static void deleteLaunchConfigs(final SWTWorkbenchBot bot) {
SwtBotUtils.print("\tDeleting launch configs");
SwtBotLaunchManagerActions.terminateAllLaunchConfigs(bot);
SwtBotMenuActions.openDebugConfiguration(bot);
// TODO change to Messages.get
SWTBotTreeItem subTree = bot.tree(0).getTreeItem("GWT Development Mode (DevMode)");
subTree.expand();
SWTBotTreeItem[] items = subTree.getItems();
if (items != null && items.length > 0) {
for (int i=0; i < items.length; i++) {
SwtBotUtils.print("\t\tDeleting launcher i=" + i);
items[i].contextMenu("Delete").click();
SwtBotUtils.performAndWaitForWindowChange(bot, new Runnable() {
@Override
public void run() {
bot.button("Yes").click();
}
});
bot.sleep(500);
}
}
bot.button("Close").click();
SwtBotUtils.print("\tDeleted launch configs");
}