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"; } }); }
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()); } }
/** * Creates a Java class with the specified name. * * @param projectName the name of the project the class should be created in * @param sourceFolder the name of the source folder in which the class should be created. * Typically "src" for normal Java projects, or "src/main/java" for Maven projects * @param packageName the name of the package the class should be created in * @param className the name of the class to be created */ public static void createJavaClass(final SWTWorkbenchBot bot, String sourceFolder, String projectName, String packageName, final String className) { SWTBotTreeItem project = SwtBotProjectActions.selectProject(bot, projectName); selectProjectItem(project, sourceFolder, packageName).select(); SwtBotTestingUtilities.performAndWaitForWindowChange(bot, new Runnable() { @Override public void run() { MenuItem menuItem = ContextMenuHelper.contextMenu(getProjectRootTree(bot), "New", "Class"); new SWTBotMenu(menuItem).click(); } }); SwtBotTestingUtilities.performAndWaitForWindowChange(bot, new Runnable() { @Override public void run() { bot.activeShell(); bot.textWithLabel("Name:").setText(className); SwtBotTestingUtilities.clickButtonAndWaitForWindowClose(bot, bot.button("Finish")); } }); }
/** * Creates a java class with the specified name. * * @param bot The SWTWorkbenchBot. * @param projectName The name of the project the class should be created in. * @param packageName The name of the package the class should be created in. * @param className The name of the java class to be created. */ public static void createJavaClass(final SWTWorkbenchBot bot, String projectName, String packageName, final String className) { SWTBotTreeItem project = SwtBotProjectActions.selectProject(bot, projectName); selectProjectItem(project, SOURCE_FOLDER, packageName).select(); SwtBotUtils.performAndWaitForWindowChange(bot, new Runnable() { @Override public void run() { MenuItem menuItem = ContextMenuHelper.contextMenu(getProjectRootTree(bot), "New", "Class"); new SWTBotMenu(menuItem).click(); } }); SwtBotUtils.performAndWaitForWindowChange(bot, new Runnable() { @Override public void run() { bot.activeShell(); bot.textWithLabel("Name:").setText(className); SwtBotUtils.clickButtonAndWaitForWindowChange(bot, bot.button("Finish")); } }); }