本文整理汇总了Java中org.eclipse.swtbot.swt.finder.widgets.SWTBotTree类的典型用法代码示例。如果您正苦于以下问题:Java SWTBotTree类的具体用法?Java SWTBotTree怎么用?Java SWTBotTree使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SWTBotTree类属于org.eclipse.swtbot.swt.finder.widgets包,在下文中一共展示了SWTBotTree类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: removeNature
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree; //导入依赖的package包/类
public void removeNature() {
SWTBotTree tree = setupTreeForMenu(this.projectName);
SWTBotMenu menu = new SWTBotMenu(
ContextMenuHelper.contextMenu(tree, new String[] { "GW4E", "Remove GW4E Nature" }));
menu.click();
bot.waitUntil(new DefaultCondition() {
@Override
public boolean test() throws Exception {
boolean b = ClasspathManager
.hasGW4EClassPathContainer(ResourceManager.getProject(projectName));
return !b;
}
@Override
public String getFailureMessage() {
return "GW4E ClassPath Container not removed";
}
});
}
示例2: assertMenuEnabled
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree; //导入依赖的package包/类
public void assertMenuEnabled(String[] menus, boolean[] states, String... nodes) {
SWTBotTree tree = setupTreeForMenu(nodes);
SWTBotMenu menu = new SWTBotMenu(ContextMenuHelper.contextMenu(tree, menus[0]));
assertEquals("Invalid state ", states[0], menu.isEnabled());
String[] submenus = new String[menus.length - 1];
System.arraycopy(menus, 1, submenus, 0, menus.length - 1);
boolean[] substates = new boolean[states.length - 1];
System.arraycopy(states, 1, substates, 0, states.length - 1);
for (int i = 0; i < submenus.length; i++) {
String submenu = submenus[i];
SWTBotMenu sm = menu.contextMenu(submenu);
assertEquals("Invalid state ", substates[i], sm.isEnabled());
}
}
示例3: convertExistingProject
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree; //导入依赖的package包/类
public void convertExistingProject() throws CoreException {
SWTBotTree tree = getProjectTree();
SWTBotTreeItem item = tree.expandNode(this.projectName);
item.setFocus();
item.select();
SWTBotMenu menu = item.contextMenu("Configure").contextMenu("Convert to GW4E");
menu.click();
bot.waitUntil(new DefaultCondition() {
@Override
public boolean test() throws Exception {
boolean b = GW4ENature
.hasGW4ENature(ResourceManager.getProject(projectName));
return b;
}
@Override
public String getFailureMessage() {
return "GraphWalker has not GraphWalker Nature ";
}
});
cleanBuild();
}
示例4: prepareConvertTo
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree; //导入依赖的package包/类
private ConvertDialog prepareConvertTo(String project, String packageRootFragment, String pkg,
String targetFilename, String targetFormat, String... nodes) {
SWTBotTree tree = getProjectTree();
SWTBotTreeItem item = tree.expandNode(nodes);
item.select();
item.setFocus();
SWTBotMenu menu = item.contextMenu("GW4E").contextMenu("Convert to...");
menu.click();
bot.waitUntil(Conditions.shellIsActive("GW4E Conversion File"));
SWTBotShell shell = bot.shell("GW4E Conversion File");
ConvertDialog cd = new ConvertDialog(shell);
return cd;
}
示例5: hasErrorsInProblemsView
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree; //导入依赖的package包/类
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;
}
示例6: error_message_should_contain_delegate_shortcut_id
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree; //导入依赖的package包/类
@Test
public void error_message_should_contain_delegate_shortcut_id() throws Exception {
final LogListener logListener = new LogListener();
Platform.addLogListener(logListener);
final String projectName = "ContextualLaunchableTesterTest";
new JavaProjectKit(projectName);
final SWTBotView view = bot.viewByTitle("Project Explorer");
view.show();
final SWTBotTree tree = view.bot().tree();
tree.setFocus();
tree.select(projectName).contextMenu("Coverage As").click();
Platform.removeLogListener(logListener);
final IStatus actualStatus = logListener.statuses.get(1);
assertEquals(EclEmmaUIPlugin.ID, actualStatus.getPlugin());
assertEquals(
"Launch shortcut 'org.eclipse.eclemma.ui.ContextualLaunchableTesterTest.fakeShortcut' enablement expression caused exception.",
actualStatus.getMessage());
assertEquals(
"No property tester contributes a property org.eclipse.eclemma.unknownProperty to type class org.eclipse.core.internal.resources.Project",
actualStatus.getException().getMessage());
}
示例7: getUniqueTreeItem
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree; //导入依赖的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.");
}
示例8: testShowInBookmarksView
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree; //导入依赖的package包/类
@Test
public void testShowInBookmarksView() throws TimeoutException {
// Given
IWorkbenchPage activePage = UIThreadRunnable
.syncExec(() -> PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage());
assertNotNull(activePage);
// When
bookmarksService.showInBookmarksView(activePage, new BookmarkId("bookmark21"), true);
// Then
SWTBotTree botTree = bookmarksViewDriver.tree();
Waiter.waitUntil("bookmark not selected", () -> {
assertThat(botTree.selection().get(0).get(0)).isEqualTo("bookmark21");
return true;
});
}
示例9: openView
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree; //导入依赖的package包/类
/**
* Open view.
*
* @param bot
* to work with, must not be {@code null}
* @param category
* the category, must not be {@code null}
* @param view
* the name of the view, must not be {@code null}
*/
public static void openView(final SWTWorkbenchBot bot, final String category, final String view) {
Assert.isNotNull(bot, ARGUMENT_BOT);
Assert.isNotNull(category, "category");
Assert.isNotNull(view, ARGUMENT_VIEW);
bot.menu("Window").menu("Show View").menu("Other...").click();
bot.shell("Show View").activate();
final SWTBotTree tree = bot.tree();
for (SWTBotTreeItem item : tree.getAllItems()) {
if (category.equals(item.getText())) {
CoreSwtbotTools.waitForItem(bot, item);
final SWTBotTreeItem[] node = item.getItems();
for (SWTBotTreeItem swtBotTreeItem : node) {
if (view.equals(swtBotTreeItem.getText())) {
swtBotTreeItem.select();
}
}
}
}
assertTrue("View or Category found", bot.button().isEnabled());
bot.button("OK").click();
}
示例10: expandNode
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree; //导入依赖的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;
}
示例11: createJavaProject
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree; //导入依赖的package包/类
/**
* Create a java project with the specified project name. This function opens up the Java
* Perspective.
*
* @param bot The current SWTWorkbenchBot object
* @param projectName Name of java project to be created
*/
public static void createJavaProject(SWTWorkbenchBot bot, String projectName) {
// Open Java Perspective
bot.perspectiveById("org.eclipse.jdt.ui.JavaPerspective").activate();
// Open the list of new project wizards
bot.menu("File").menu("New").menu("Project...").click();
// Select the Java project
SWTBotTree projectSelectionTree = bot.tree();
SWTBotTreeItem projectSelectionTreeItem =
SwtBotTreeActions.getUniqueTreeItem(bot, projectSelectionTree, "Java", "Java Project");
SwtBotTreeActions.selectTreeItem(bot, projectSelectionTreeItem, "Java Project");
bot.button("Next >").click();
// Configure the project and then create it
bot.textWithLabel("Project name:").setText(projectName);
SwtBotUtils.clickButtonAndWaitForWindowChange(bot, bot.button("Finish"));
}
示例12: getUniqueTreeItem
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree; //导入依赖的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.");
}
示例13: createJavaProject
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree; //导入依赖的package包/类
/**
* Creates a java project with the specified project name.
*
* @param bot the SWTWorkbenchBot
* @param projectName the name of the java project to create
*/
public static void createJavaProject(SWTWorkbenchBot bot, String projectName) {
// Open Java Perspective
bot.perspectiveById("org.eclipse.jdt.ui.JavaPerspective").activate();
// Open the list of new project wizards
bot.menu("File").menu("New").menu("Project...").click();
// Select the Java project
SWTBotTree projectSelectionTree = bot.tree();
SWTBotTreeItem projectSelectionGoogleTreeItem =
SwtBotTreeActions.getUniqueTreeItem(bot, projectSelectionTree, "Java", "Java Project");
SwtBotTreeActions.selectTreeItem(bot, projectSelectionGoogleTreeItem, "Java Project");
bot.button("Next >").click();
// Configure the project and then create it
bot.textWithLabel("Project name:").setText(projectName);
SwtBotUtils.clickButtonAndWaitForWindowChange(bot, bot.button("Finish"));
}
示例14: createUiBinder
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree; //导入依赖的package包/类
public static void createUiBinder(final SWTWorkbenchBot bot, String projectName,
String packageName, String name, boolean generateSampleContent, boolean generateComments) {
// Open the list of new project wizards
bot.menu("File").menu("New").menu("Other...").click();
// Select the Web App project wizard
SWTBotTree projectSelectionTree = bot.tree();
SWTBotTreeItem projectSelectionGoogleTreeItem = SwtBotTreeActions
.getUniqueTreeItem(bot, projectSelectionTree, "GWT Classes", "UiBinder").expand();
SwtBotTreeActions.selectTreeItem(bot, projectSelectionGoogleTreeItem, "UiBinder");
bot.button("Next >").click();
// Configure the UiBinder and then create it
String sourceFolder = projectName + "/" + SOURCE_FOLDER;
bot.textWithLabel("Source folder:").setText(sourceFolder);
bot.textWithLabel("Package:").setText(packageName);
bot.textWithLabel("Name:").setText(name);
SwtBotUtils.setCheckBox(bot.checkBox("Generate sample content"),
generateSampleContent);
SwtBotUtils.setCheckBox(bot.checkBox("Generate comments"), generateComments);
SwtBotUtils.clickButtonAndWaitForWindowChange(bot, bot.button("Finish"));
}
示例15: doesProjectExist
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree; //导入依赖的package包/类
/**
* Returns true if the specified project can be found in the 'Package Explorer' or 'Project View',
* otherwise returns false. Throws a WidgetNotFoundException exception if the 'Package Explorer'
* or 'Project Explorer' view cannot be found.
*
* @param bot The SWTWorkbenchBot.
* @param projectName The name of the project to be found.
* @return if the project exists
*/
public static boolean doesProjectExist(final SWTWorkbenchBot bot, String projectName) {
SWTBotView explorer = getPackageExplorer(bot);
if (explorer == null) {
throw new WidgetNotFoundException(
"Could not find the 'Package Explorer' or 'Project Explorer' view.");
}
// Select the root of the project tree in the explorer view
Widget explorerWidget = explorer.getWidget();
Tree explorerTree = bot.widget(widgetOfType(Tree.class), explorerWidget);
SWTBotTreeItem[] allItems = new SWTBotTree(explorerTree).getAllItems();
for (int i = 0; i < allItems.length; i++) {
if (allItems[i].getText().equals(projectName)) {
return true;
}
}
return false;
}