Java Code Examples for org.eclipse.swtbot.swt.finder.widgets.SWTBotTree#select()

The following examples show how to use org.eclipse.swtbot.swt.finder.widgets.SWTBotTree#select() . 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: BotBdmQueriesEditor.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private void selectCustomQuery(String queryName) {
    SWTBotTree tree = getQueryListTree();
    tree.select(Messages.customQueriesOption);
    tree.expandNode(Messages.customQueriesOption);
    bot.waitUntil(new ConditionBuilder()
            .withTest(() -> {
                try {
                    tree.getTreeItem(Messages.customQueriesOption).getNode(queryName);
                    return true;
                } catch (WidgetNotFoundException e) {
                    return false;
                }
            })
            .withFailureMessage(() -> String.format("Can't find custom query %s", queryName))
            .create());
    tree.getTreeItem(Messages.customQueriesOption).getNode(queryName).select();
}
 
Example 2
Source File: ProblemsViewTestUtil.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Bulk-apply the common quickfix to multiple markers.
 * Autobuilding should be disabled, to avoid losing focus while selecting markers.
 *
 * @param bot
 *          the bot, must not be {@code null}
 * @param quickfixLabel
 *          label of the quickfix to apply, must not be {@code null}
 * @param markers
 *          markers to fix, must not be {@code null}
 */
public static void bulkApplyQuickfix(final SwtWorkbenchBot bot, final String quickfixLabel, final SWTBotTreeItem... markers) {

  // Select markers. Keep retrying if focus is lost at an inopportune moment.
  final SWTBotTree markersTreeBot = getMarkersTree(bot);
  do {
    markersTreeBot.select(markers);
  } while (markersTreeBot.selectionCount() != markers.length);

  // Open the Quick Fix dialog
  ContextActionUiTestUtil.clickContextMenu(markersTreeBot, QUICK_FIX_CONTEXT_MENU_ITEM_LABEL);
  bot.waitUntil(Conditions.shellIsActive(QUICK_FIX_DIALOG_TEXT));

  // Select the quickfix
  bot.tableWithLabel(SELECT_A_FIX_TABLE_LABEL).select(quickfixLabel);

  // Tick the markers' tickboxes
  final int locationColumnIndex = markersTreeBot.columns().indexOf(LOCATION_COLUMN_NAME);
  final Set<String> markerLocations = Stream.of(markers).map(marker -> marker.cell(locationColumnIndex)).collect(Collectors.toSet());
  final SWTBotTable tableBot = bot.tableWithLabel(PROBLEMS_TABLE_LABEL);
  for (int row = 0; tableBot.rowCount() > row; ++row) {
    if (markerLocations.contains(tableBot.cell(row, LOCATION_COLUMN_NAME))) {
      tableBot.getTableItem(row).check();
    }
  }

  bot.clickButton(FINISH_BUTTON_LABEL);
}
 
Example 3
Source File: ProjectExplorerTracesFolderTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * <p>
 * Action : Clear multiple Traces folder
 * <p>
 *
 * <pre>
 * Procedure : 1) Import 2 traces to different projects
 *             2) Open both traces.
 *             3) Select both Traces folders
 *             4) Right-click, Clear. Click Yes.
 * </pre>
 * <p>
 * Expected Results: A dialog should ask the user to confirm clearing of the
 * folders. Clicking Yes should remove everything under the selected folders
 * and close the traces.
 */
@Test
public void test3_35ClearMultipleTracesFolder() {
    int optionFlags = ImportTraceWizardPage.OPTION_CREATE_LINKS_IN_WORKSPACE;
    SWTBotTreeItem tracesFolder1 = SWTBotUtils.selectTracesFolder(fBot, TRACE_PROJECT_NAME);
    SWTBotShell shell = openTraceFoldersImport(tracesFolder1);
    importTrace(shell, null, null, optionFlags, new ImportConfirmationSupplier(), CUSTOM_TEXT_LOG.getTracePath());
    verifyTrace(CUSTOM_TEXT_LOG, optionFlags, CUSTOM_TEXT_LOG.getTraceName(), CUSTOM_TEXT_TRACE_TYPE, TRACE_PROJECT_NAME);

    SWTBotUtils.createProject(DEFAULT_PROJECT_NAME);
    SWTBotTreeItem tracesFolder2 = SWTBotUtils.selectTracesFolder(fBot, DEFAULT_PROJECT_NAME);
    shell = openTraceFoldersImport(tracesFolder2);
    importTrace(shell, null, null, optionFlags, new ImportConfirmationSupplier(), LTTNG_KERNEL_TRACE.getTracePath());
    verifyTrace(LTTNG_KERNEL_TRACE, optionFlags, LTTNG_KERNEL_TRACE.getTraceName(), LTTNG_KERNEL_TRACE_TYPE, DEFAULT_PROJECT_NAME);

    SWTBotTree tree = fBot.viewByTitle("Project Explorer").bot().tree();
    tree.select(tracesFolder1, tracesFolder2);
    tree.contextMenu().menu("Clear").click();
    SWTBot deleteConfirmationShellBot = fBot.shell("Confirm Clear").bot();
    deleteConfirmationShellBot.button("Yes").click();
    fBot.waitWhile(ConditionHelpers.isEditorOpened(fBot, CUSTOM_TEXT_LOG.getTraceName()));
    fBot.waitWhile(ConditionHelpers.isEditorOpened(fBot, LTTNG_KERNEL_TRACE.getTraceName()));
    SWTBotUtils.waitUntil(folder -> folder.getNodes().isEmpty(), tracesFolder1, "Traces folder (tracesFolder1) not empty");
    SWTBotUtils.waitUntil(folder -> folder.getNodes().isEmpty(), tracesFolder2, "Traces folder (tracesFolder2) not empty");

    SWTBotUtils.deleteProject(DEFAULT_PROJECT_NAME, fBot);
}
 
Example 4
Source File: ControlViewTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Test enable event (all tracepoints) on channel level
 */
protected void testEnableUstEvents() {
    SWTBotTreeItem channelItem = SWTBotUtils.getTreeItem(fBot, fTree,
            getNodeName(),
            ControlViewSwtBotUtil.SESSION_GROUP_NAME,
            getSessionName(), ControlViewSwtBotUtil.UST_DOMAIN_NAME,
            UST_CHANNEL_NAME);
    assertEquals(UST_CHANNEL_NAME, channelItem.getText());

    channelItem.select();
    SWTBotMenu menuBot = channelItem.contextMenu(ControlViewSwtBotUtil.ENABLE_EVENT_MENU_ITEM);
    menuBot.click();

    SWTBotShell shell = fBot.shell(ControlViewSwtBotUtil.ENABLE_EVENT_DIALOG_TITLE).activate();
    SWTBotTree tracepointsTree = shell.bot().tree();
    tracepointsTree.select(ControlViewSwtBotUtil.ALL_TREE_NODE);
    shell.bot().button(ControlViewSwtBotUtil.DIALOG_OK_BUTTON).click();
    WaitUtils.waitForJobs();

    SWTBotTreeItem eventItem = SWTBotUtils.getTreeItem(fBot, fTree,
            getNodeName(),
            ControlViewSwtBotUtil.SESSION_GROUP_NAME,
            getSessionName(),
            ControlViewSwtBotUtil.UST_DOMAIN_NAME,
            UST_CHANNEL_NAME,
            ControlViewSwtBotUtil.ALL_EVENTS_NAME);
    assertEquals(ControlViewSwtBotUtil.ALL_EVENTS_NAME, eventItem.getText());
}
 
Example 5
Source File: SWTBotTestUtil.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public static void selectElementFromFormOverview(final SWTGefBot bot, final String widgetName) {
    final SWTBotView view = bot.viewById(SWTBotTestUtil.VIEWS_TREE_OVERVIEW);
    view.show();
    view.setFocus();
    final SWTBotTree tree = bot.treeWithId(BONITA_OVERVIEW_TREE_ID);
    tree.setFocus();
    bot.waitUntil(Conditions.widgetIsEnabled(tree.getTreeItem(widgetName)));
    tree.select(widgetName);
}
 
Example 6
Source File: DeleteSpecHandlerTest.java    From tlaplus with MIT License 4 votes vote down vote up
@Test
public void deleteMultipleSpecs() throws CoreException, IOException {
	// Make sure there are no specs at first
	assertEquals(0, Activator.getSpecManager().getSpecs().size());
	
	// create a valid path
	File fileA = File.createTempFile("DeleteMultiSpecA", TLAConstants.Files.TLA_EXTENSION);
	fileA.delete();
	// Create the spec file
	ResourcesPlugin.getWorkspace().run(ResourceHelper.createTLAModuleCreationOperation(new Path(fileA.getAbsolutePath())),
			new NullProgressMonitor());
	// Create the spec
	final Spec spec = Spec.createNewSpec("SpecA", fileA.getAbsolutePath(), false, new NullProgressMonitor());
	// Register the spec
	Activator.getSpecManager().addSpec(spec);

	// create a second valid path
	File fileB = File.createTempFile("DeleteMultiSpecB", TLAConstants.Files.TLA_EXTENSION);
	fileB.delete();
	// Create the spec file
	ResourcesPlugin.getWorkspace().run(ResourceHelper.createTLAModuleCreationOperation(new Path(fileB.getAbsolutePath())),
			new NullProgressMonitor());
	// Create the spec
	Spec specB = Spec.createNewSpec("SpecB", fileB.getAbsolutePath(), false, new NullProgressMonitor());
	// Register the spec
	Activator.getSpecManager().addSpec(specB);

	// Make sure there are no specs at first
	assertEquals(2, Activator.getSpecManager().getSpecs().size());
	
	Activator.getSpecManager().setSpecLoaded(spec);
	
	// Trigger update so that both specs show up in the explorer
	UIHelper.runUISync(new Runnable() {
		public void run() {
			ToolboxExplorer.refresh();
            final HashMap<String, String> parameters = new HashMap<String, String>();
            parameters.put(OpenSpecHandler.PARAM_SPEC, spec.getName());

            // runs the command
            UIHelper.runCommand(OpenSpecHandler.COMMAND_ID, parameters);
		}
	});
	
	bot.waitUntil(new SpecEditorOpenCondition(fileA.getName()));
	
	// Make sure one spec is open and has an editor
	assertEquals(1, UIHelper.getActivePage().getEditorReferences().length);
	assertNotNull(Activator.getSpecManager().getSpecLoaded());

	// Select tree
	SWTBotView specExplorer = bot.viewById(ToolboxExplorer.VIEW_ID);
	specExplorer.setFocus();

	// select tree items
	final SWTBotTree specExplorerTree = specExplorer.bot().tree();
	specExplorerTree.select(bot.tree().getTreeItem("SpecA [ " + fileA.getName() + " ]"),
			bot.tree().getTreeItem("SpecB [ " + fileB.getName() + " ]"));
	
	// main menu delete
	bot.menu("Edit").menu("Delete").click();

	// click the two dialogs that confirm deletion
	bot.shell("Delete specification?").activate();
	bot.button("Yes").click();
	bot.shell("Delete specification?").activate();
	bot.button("Yes").click();
	
	// Make sure all specs are gone
	assertEquals(0, Activator.getSpecManager().getSpecs().size());
	
	// Make sure no editor remained open
	assertEquals(0, UIHelper.getActivePage().getEditorReferences().length);
}
 
Example 7
Source File: BotPageflowPropertySection.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
private void selectForm(final String formName) {
    final SWTBotTree tree = bot.treeWithId(SWTBotConstants.APPLICATION_SECTION_FORMS_SELECTION_TREE);
    tree.select(formName);
}