Java Code Examples for org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem#getItems()
The following examples show how to use
org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem#getItems() .
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: SwtBotWizardUtil.java From dsl-devkit with Eclipse Public License 1.0 | 6 votes |
/** * 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 2
Source File: CoreSwtbotTools.java From dsl-devkit with Eclipse Public License 1.0 | 6 votes |
/** * 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(); }
Example 3
Source File: MemoryDBManagement.java From tmxeditor8 with GNU General Public License v2.0 | 6 votes |
/** * 完整步骤:根据从 Excel 中读取的数据删除已保存的连接信息 * @param from * 功能入口,请使用 TSUIConstants 类的枚举; */ public void deleteConnection(Entry from) { mode = MemoryDatabaseManagementDialog.MANAGEMENT; openDBMgmgDialog(from); getDataConnect(mode); assertTrue("未在已保存的连接信息中找到该连接:" + connectionName, isConnectionSaved()); SWTBotTreeItem curDb = selectDBType(); int countBefore = curDb.getItems().length; curDb.expandNode(connectionName).select(); dialog.btnRemoveConn().click(); int countRemove = curDb.getItems().length; assertTrue("仍可在已保存的连接信息中找到该连接:" + connectionName, countBefore == countRemove+1 ); dialog.btnClose().click(); }
Example 4
Source File: FetchRemoteTracesTest.java From tracecompass with Eclipse Public License 2.0 | 6 votes |
private static void importProfiles() { openRemoteProfilePreferences(); TmfFileDialogFactory.setOverrideFiles(PROFILES_LOCATION); fBot.button("Import").click(); // Change the root path of every profile SWTBotTree tree = fBot.tree(1); for (SWTBotTreeItem profile : tree.getAllItems()) { for (SWTBotTreeItem node : profile.getItems()) { for (SWTBotTreeItem traceGroup : node.getItems()) { traceGroup.select(); fBot.textWithLabel("Root path:").setText(TRACE_LOCATION); } } } SWTBotUtils.pressOKishButtonInPreferences(fBot); }
Example 5
Source File: ProjectExplorerTraceActionsTest.java From tracecompass with Eclipse Public License 2.0 | 6 votes |
private static void verifyExperimentCopy(SWTBotTreeItem copiedExpItem, boolean isDeepCopied) { SWTBotTreeItem tracesFolder = SWTBotUtils.selectTracesFolder(fBot, TRACE_PROJECT_NAME); tracesFolder.expand(); SWTBotTreeItem[] traceItems = tracesFolder.getItems(); copiedExpItem.expand(); if (isDeepCopied) { /* * Traces folder should contain the previous two traces and the new folder for * the copied traces */ assertEquals(3, traceItems.length); copiedExpItem.getNode(RENAMED_EXP_DEEP_COPY + '/' + TRACE_NAME); copiedExpItem.getNode(RENAMED_EXP_DEEP_COPY + '/' + RENAMED_AS_NEW_TRACE_NAME); SWTBotTreeItem deepCopiedExpTracesFolder = SWTBotUtils.getTraceProjectItem(fBot, tracesFolder, RENAMED_EXP_DEEP_COPY); deepCopiedExpTracesFolder.expand(); SWTBotTreeItem[] expTracesFolderItems = deepCopiedExpTracesFolder.getItems(); assertEquals(2, expTracesFolderItems.length); for (SWTBotTreeItem traceItem : expTracesFolderItems) { testLinkStatus(traceItem, false); } } else { assertEquals(2, traceItems.length); copiedExpItem.getNode(TRACE_NAME); copiedExpItem.getNode(RENAMED_AS_NEW_TRACE_NAME); } }
Example 6
Source File: SystemCallLatencyScatterChartViewTest.java From tracecompass with Eclipse Public License 2.0 | 6 votes |
private Long recurseFindItem(SWTBotTreeItem item) { if (fSeriesName.equals(item.getText())) { Object data = item.widget.getData(); if (data instanceof TmfGenericTreeEntry) { ITmfTreeDataModel model = ((TmfGenericTreeEntry<?>) data).getModel(); if (model != null) { return model.getId(); } } } for (SWTBotTreeItem child : item.getItems()) { Long id = recurseFindItem(child); if (id >= 0) { return id; } } return -1L; }
Example 7
Source File: SwtBotTreeUtilities.java From google-cloud-eclipse with Apache License 2.0 | 6 votes |
/** * Wait until the given tree item has items, and return the first item. * * @throws TimeoutException if no items appear within the default timeout */ public static SWTBotTreeItem waitUntilTreeHasItems(SWTWorkbenchBot bot, SWTBotTreeItem treeItem) { bot.waitUntil( new DefaultCondition() { @Override public String getFailureMessage() { return "Tree items never appeared"; } @Override public boolean test() throws Exception { SWTBotTreeItem[] children = treeItem.getItems(); if (children.length == 1 && "".equals(children[0].getText())) { // Work around odd bug seen only on Windows and Linux. // https://github.com/GoogleCloudPlatform/google-cloud-eclipse/issues/2569 treeItem.collapse(); treeItem.expand(); children = treeItem.getItems(); } return children.length > 0; } }); return treeItem.getItems()[0]; }
Example 8
Source File: ProjectExplorerTracesFolderTest.java From tracecompass with Eclipse Public License 2.0 | 6 votes |
/** * <p> * Action : Import unrecognized (ignore) * <p> * * <pre> * Procedure : 1) redo 3.10, however unselect "Import unrecognized traces" * </pre> * <p> * Expected Results: unrecognized.log is not imported */ @Test public void test3_11ImportUnrecognizedIgnore() { String traceName = UNRECOGNIZED_LOG.getTraceName(); SWTBotTreeItem tracesFolderItem = SWTBotUtils.selectTracesFolder(fBot, TRACE_PROJECT_NAME); int numTraces = tracesFolderItem.getItems().length; SWTBotTreeItem traceItem = SWTBotUtils.getTreeItem(fBot, tracesFolderItem, traceName); String lastModified = getTraceProperty(traceItem, PROP_LAST_MODIFIED_PROPERTY); int optionFlags = ImportTraceWizardPage.OPTION_CREATE_LINKS_IN_WORKSPACE; importTrace(optionFlags, traceName); verifyTrace(UNRECOGNIZED_LOG, optionFlags); assertEquals(lastModified, getTraceProperty(traceItem, PROP_LAST_MODIFIED_PROPERTY)); assertEquals(numTraces, tracesFolderItem.getItems().length); }
Example 9
Source File: ProjectExplorerAnalysisTest.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
private static boolean supplementaryFileExists(SWTBotTreeItem traceNode, String filename) { // make sure that analysis are finished WaitUtils.waitForJobs(); try { ResourcesPlugin.getWorkspace().getRoot().getProject(TRACE_PROJECT_NAME).refreshLocal(IResource.DEPTH_INFINITE, null); } catch (CoreException e) { } // Make sure that all jobs are finished after refresh WaitUtils.waitForJobs(); traceNode.contextMenu().menu("Delete Supplementary Files...").click(); SWTBotShell shell = fBot.shell("Delete Resources"); SWTBot bot = shell.bot(); SWTBotTree tree = bot.tree(); SWTBotTreeItem traceSupplNode = SWTBotUtils.getTreeItem(bot, tree, traceNode.getText()); SWTBotTreeItem[] supplFileNodes = traceSupplNode.getItems(); boolean supplFound = false; for (SWTBotTreeItem swtBotTreeItem : supplFileNodes) { if (swtBotTreeItem.getText().equals(filename)) { supplFound = true; break; } } bot.button("Cancel").click(); fBot.waitUntil(Conditions.shellCloses(shell)); return supplFound; }
Example 10
Source File: SarosView.java From saros with GNU General Public License v2.0 | 5 votes |
@Override public List<String> getContacts() throws RemoteException { SWTBotTreeItem items = tree.getTreeItem(NODE_CONTACTS); List<String> contacts = new ArrayList<String>(); for (SWTBotTreeItem item : items.getItems()) contacts.add(item.getText()); return contacts; }
Example 11
Source File: ContextMenusInPEView.java From saros with GNU General Public License v2.0 | 5 votes |
private List<String> getTextOfItems(SWTBotTreeItem treeItem) { List<String> allItemTexts = new ArrayList<String>(); for (SWTBotTreeItem item : treeItem.getItems()) { allItemTexts.add(item.getText()); } return allItemTexts; }
Example 12
Source File: SwtBotProjectActions.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 5 votes |
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"); }
Example 13
Source File: NewCounterViewTest.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
private @Nullable SWTBotTreeItem retrieveTreeItem(SWTBotTreeItem rootItem, @NonNull String id) { if (rootItem.getNodes().contains(id)) { return rootItem.getNode(id); } for (SWTBotTreeItem child : rootItem.getItems()) { SWTBotTreeItem grandChild = retrieveTreeItem(child, id); if (grandChild != null) { return grandChild; } } return null; }
Example 14
Source File: CounterViewTest.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
private @Nullable SWTBotTreeItem retrieveTreeItem(SWTBotTreeItem rootItem, @NonNull String id) { if (rootItem.getNodes().contains(id)) { return rootItem.getNode(id); } for (SWTBotTreeItem child : rootItem.getItems()) { SWTBotTreeItem grandChild = retrieveTreeItem(child, id); if (grandChild != null) { return grandChild; } } return null; }
Example 15
Source File: ProjectExplorerAnalysisTest.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
private static Set<AnalysisNode> getAnalysisNodes(SWTWorkbenchBot bot, String name, boolean isExperiment) { SWTBotTreeItem traceNode = getExpandedTraceNode(bot, name, isExperiment); SWTBotTreeItem viewNode = traceNode.getNode("Views"); viewNode.expand(); SWTBotTreeItem[] analysisNodes = viewNode.getItems(); assertNotNull(analysisNodes); int length = analysisNodes.length; Set<AnalysisNode> actualNodes = new HashSet<>(); for (int i = 0; i < length; i++) { SWTBotTreeItem analysisNode = analysisNodes[i]; actualNodes.add(new AnalysisNode(analysisNode.getText(), analysisNode.isEnabled(), analysisNode.isVisible())); } return actualNodes; }
Example 16
Source File: StandardImportWizardTest.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
private static void verifyImport(int expectedLength) { SWTBotTreeItem tracesFolder = SWTBotUtils.selectTracesFolder(getSWTBot(), PROJECT_NAME); // Expand the tree to get children tracesFolder.expand(); SWTBotTreeItem[] traceItems = tracesFolder.getItems(); assertEquals(expectedLength, traceItems.length); }
Example 17
Source File: CoreSwtbotTools.java From dsl-devkit with Eclipse Public License 1.0 | 5 votes |
/** * Expansion of items in a SWTBotTree. Will try collapse and expand if there are no child nodes. * * @param bot * to work with, must not be {@code null} * @param item * to wait for, must not be {@code null} * @return {@code true} if expanded, {@code false} otherwise */ public static boolean waitForItem(final SWTWorkbenchBot bot, final SWTBotTreeItem item) { Assert.isNotNull(bot, ARGUMENT_BOT); Assert.isNotNull(item, ARGUMENT_ITEM); item.select(); safeBlockingExpand(bot, item); if (item.getItems().length == 0) { safeBlockingCollapse(bot, item); safeBlockingExpand(bot, item); } return item.getItems().length > 0; }
Example 18
Source File: SwtBotTreeUtilities.java From google-cloud-eclipse with Apache License 2.0 | 5 votes |
/** * Wait until the given tree item has a matching item, and return the item. * * @throws TimeoutException if no items appear within the default timeout */ public static SWTBotTreeItem getMatchingNode( SWTWorkbenchBot bot, SWTBotTreeItem parentItem, Matcher<String> childMatcher) { bot.waitUntil( new DefaultCondition() { @Override public String getFailureMessage() { return "Child item never appeared"; } @Override public boolean test() throws Exception { SWTBotTreeItem[] children = parentItem.getItems(); if (children.length == 1 && "".equals(children[0].getText())) { // Work around odd bug seen only on Windows and Linux. // https://github.com/GoogleCloudPlatform/google-cloud-eclipse/issues/2569 parentItem.collapse(); parentItem.expand(); children = parentItem.getItems(); } return Iterables.any(parentItem.getNodes(), childMatcher::matches); } }); for (SWTBotTreeItem child : parentItem.getItems()) { if (childMatcher.matches(child.getText())) { return child; } } throw new AssertionError("Child no longer present!"); }
Example 19
Source File: BarExporterTest.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
@Test public void testServerBuild() { SWTBotTestUtil.createNewDiagram(bot); final SWTBotEditor activeEditor = bot.activeEditor(); final String editorTitle = activeEditor.getTitle(); assertFalse("Error: first diagram name is empty.", editorTitle.isEmpty()); final BotExecutionDiagramPropertiesView executionTab = new BotProcessDiagramPropertiesViewFolder(bot) .selectExecutionTab(); executionTab.selectInstantiationFormTab().selectNone(); new BotGefProcessDiagramEditor(bot).selectElement("Step1"); executionTab.selectFormTab().selectNone(); // get the GEF editor to activate tools final SWTBotGefEditor gmfEditor = bot.gefEditor(editorTitle); // Create 2 Pools gmfEditor.activateTool("Pool"); gmfEditor.click(200, 500); new BotProcessDiagramPropertiesViewFolder(bot).selectExecutionTab().selectInstantiationFormTab().selectNone(); gmfEditor.activateTool("Pool"); gmfEditor.click(200, 800); new BotProcessDiagramPropertiesViewFolder(bot).selectExecutionTab().selectInstantiationFormTab().selectNone(); // Save Diagram bot.menu("File").menu("Save").click(); bot.waitUntil(BonitaBPMConditions.noPopupActive()); // Menu Server > Build... bot.menu("Server").menu("Build...").click(); // shell 'Build' final SWTBotShell shell = bot.shell(Messages.buildTitle); bot.waitUntil(Conditions.shellIsActive(Messages.buildTitle)); // select and check created Diagram in the Tree final SWTBotTree tree = bot.treeWithLabel("Select processes to export"); final SWTBotTreeItem diagramTreeItem = tree.getTreeItem(editorTitle); // check the diagram to export diagramTreeItem.select().check(); diagramTreeItem.expand(); // Number of pool in the diagram final int poolListSize = diagramTreeItem.getItems().length; assertEquals("Error: Diagram must contain 3 Pools.", 3, poolListSize); // unselect the first pool of the list diagramTreeItem.getNode(0).select(); diagramTreeItem.getNode(0).uncheck(); final List<String> poolTitleList = new ArrayList<>(3); final int poolTitleListSize = poolTitleList.size(); // check the selected pools for (int i = 1; i < poolTitleListSize; i++) { final SWTBotTreeItem poolTreeItem = diagramTreeItem.getNode(i); poolTitleList.set(i, poolTreeItem.getText()); final String poolName = getItemName(poolTitleList.get(i)); // test the good pool is checked assertFalse("Error: Pool " + i + " should be checked.", !poolTreeItem.isChecked()); assertFalse("Error: Pool selected is not the good one.", !poolName.equals("Pool" + i)); } // create tmp directory to write diagrams final File tmpBarFolder = new File(ProjectUtil.getBonitaStudioWorkFolder(), "testExportBar"); tmpBarFolder.deleteOnExit(); tmpBarFolder.mkdirs(); //set the path where files are saved final String tmpBarFolderPath = tmpBarFolder.getAbsolutePath(); bot.comboBoxWithLabel(Messages.destinationPath + " *").setText(tmpBarFolderPath); // click 'Finish' button to close 'Build' shell bot.waitUntil(Conditions.widgetIsEnabled(bot.button(IDialogConstants.FINISH_LABEL))); bot.button(IDialogConstants.FINISH_LABEL).click(); // click 'OK' button to close 'Export' shell bot.waitUntil(new ShellIsActiveWithThreadSTacksOnFailure(Messages.exportSuccessTitle), 10000); bot.button(IDialogConstants.OK_LABEL).click(); // wait the shell to close before checking creation of files bot.waitUntil(Conditions.shellCloses(shell)); // check pools files exist for (int i = 1; i < poolTitleListSize; i++) { final String tmpPoolTitle = poolTitleList.get(i); final String poolFileName = getItemName(tmpPoolTitle) + "--" + getItemVersion(tmpPoolTitle) + ".bar"; final File poolFile = new File(tmpBarFolderPath, poolFileName); poolFile.deleteOnExit(); assertTrue("Error: The Pool export must exist", poolFile.exists()); assertTrue("Error: The Pool export must be a file", poolFile.isFile()); } }
Example 20
Source File: FetchRemoteTracesTest.java From tracecompass with Eclipse Public License 2.0 | 4 votes |
/** * Test editing a profile */ @Test public void testEditProfile() { openRemoteProfilePreferences(); createProfile(); openRemoteProfilePreferences(); // The first tree is the preference "categories" on the left side, we // need to skip it SWTBotTree tree = fBot.tree(1); final String[] traceGroupNodePath = new String[] { PROFILE_NAME, CONNECTION_NODE_TEXT, TRACE_GROUP_NODE_TEXT }; // Initial order of traces SWTBotTreeItem traceGroupNode = getTreeItem(fBot, tree, traceGroupNodePath); SWTBotTreeItem[] traceNodes = traceGroupNode.getItems(); assertEquals(3, traceNodes.length); assertEquals(LTTNG_TRACE_FILE_PATTERN, traceNodes[0].getText()); assertEquals(SYSLOG_FILE_PATTERN, traceNodes[1].getText()); assertEquals(WILDCARD_PATTERN, traceNodes[2].getText()); // Test moving down a trace element SWTBotTreeItem traceNode = traceGroupNode.getNode(LTTNG_TRACE_FILE_PATTERN); traceNode.select(); fBot.button("Move Down").click(); traceGroupNode = getTreeItem(fBot, tree, traceGroupNodePath); traceNodes = traceGroupNode.getItems(); assertEquals(3, traceNodes.length); assertEquals(SYSLOG_FILE_PATTERN, traceNodes[0].getText()); assertEquals(LTTNG_TRACE_FILE_PATTERN, traceNodes[1].getText()); assertEquals(WILDCARD_PATTERN, traceNodes[2].getText()); // Test moving up a trace element traceNode = traceGroupNode.getNode(LTTNG_TRACE_FILE_PATTERN); traceNode.select(); fBot.button("Move Up").click(); traceGroupNode = getTreeItem(fBot, tree, traceGroupNodePath); traceNodes = traceGroupNode.getItems(); assertEquals(3, traceNodes.length); assertEquals(LTTNG_TRACE_FILE_PATTERN, traceNodes[0].getText()); assertEquals(SYSLOG_FILE_PATTERN, traceNodes[1].getText()); assertEquals(WILDCARD_PATTERN, traceNodes[2].getText()); // Test Copy/Paste traceNode = traceGroupNode.getNode(LTTNG_TRACE_FILE_PATTERN); traceNode.select().contextMenu("Copy").click(); traceNode.contextMenu("Paste").click(); traceNodes = traceGroupNode.getItems(); assertEquals(4, traceNodes.length); assertEquals(LTTNG_TRACE_FILE_PATTERN, traceNodes[0].getText()); assertEquals(LTTNG_TRACE_FILE_PATTERN, traceNodes[1].getText()); assertEquals(SYSLOG_FILE_PATTERN, traceNodes[2].getText()); assertEquals(WILDCARD_PATTERN, traceNodes[3].getText()); // Test Cut/Paste traceNode = traceGroupNode.getNode(LTTNG_TRACE_FILE_PATTERN); traceNode.select().contextMenu("Cut").click(); traceNode = traceGroupNode.getNode(SYSLOG_FILE_PATTERN); traceNode.select().contextMenu("Paste").click(); traceNodes = traceGroupNode.getItems(); assertEquals(4, traceNodes.length); assertEquals(LTTNG_TRACE_FILE_PATTERN, traceNodes[0].getText()); assertEquals(SYSLOG_FILE_PATTERN, traceNodes[1].getText()); assertEquals(LTTNG_TRACE_FILE_PATTERN, traceNodes[2].getText()); assertEquals(WILDCARD_PATTERN, traceNodes[3].getText()); // Test Delete traceNode = traceGroupNode.getNode(LTTNG_TRACE_FILE_PATTERN); traceNode.select().contextMenu("Delete").click(); traceNodes = traceGroupNode.getItems(); assertEquals(3, traceNodes.length); assertEquals(SYSLOG_FILE_PATTERN, traceNodes[0].getText()); assertEquals(LTTNG_TRACE_FILE_PATTERN, traceNodes[1].getText()); assertEquals(WILDCARD_PATTERN, traceNodes[2].getText()); // Copy to test Paste after Delete traceNode = traceGroupNode.getNode(LTTNG_TRACE_FILE_PATTERN); traceNode.select().contextMenu("Copy").click(); traceNode = traceGroupNode.select(SYSLOG_FILE_PATTERN, LTTNG_TRACE_FILE_PATTERN, WILDCARD_PATTERN); traceNode.pressShortcut(Keystrokes.DELETE); traceNodes = traceGroupNode.getItems(); assertEquals(0, traceNodes.length); // Paste after Delete traceGroupNode.contextMenu("Paste").click(); traceNodes = traceGroupNode.getItems(); assertEquals(1, traceNodes.length); assertEquals(LTTNG_TRACE_FILE_PATTERN, traceNodes[0].getText()); SWTBotUtils.pressOKishButtonInPreferences(fBot); deleteProfile(); }