Java Code Examples for org.eclipse.swtbot.swt.finder.widgets.SWTBotTable#rowCount()

The following examples show how to use org.eclipse.swtbot.swt.finder.widgets.SWTBotTable#rowCount() . 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: XMLAnalysesManagerPreferencePageTest.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * After each test, delete all analyses
 */
@After
public void after() {
    fBot.closeAllEditors();
    SWTBot bot = openXMLAnalysesPreferences().bot();
    SWTBotTable tableBot = bot.table(0);

    // Delete existing analysis files, if any
    int rowsCount = tableBot.rowCount();
    if (rowsCount > 0) {
        String[] itemNames = new String[rowsCount];
        for (int i = 0; i < rowsCount; ++i) {
            itemNames[i] = tableBot.getTableItem(i).getText();
        }
        tableBot.select(itemNames);
        bot.button("Delete").click();
        SWTBotShell deleteShell = bot.shell("Delete XML file(s)").activate();
        deleteShell.bot().button("Yes").click();
    }
    SWTBotUtils.pressOKishButtonInPreferences(bot);
}
 
Example 2
Source File: BotBdmConstraintsEditor.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
public BotBdmConstraintsEditor editConstraint(String packageName, String businessObject, String constraintName,
        String... selectFields) {
    selectBusinessObject(packageName, businessObject);
    getConstraintsTable().select(constraintName);
    SWTBotTable constraintsEditionTable = getConstraintsEditionTable();
    List<String> toCheck = Arrays.asList(selectFields);
    for (int i = 0; i < constraintsEditionTable.rowCount(); i++) {
        SWTBotTableItem tableItem = constraintsEditionTable.getTableItem(i);
        if (toCheck.contains(tableItem.getText())) {
            tableItem.check();
        } else {
            tableItem.uncheck();
        }
    }
    return this;
}
 
Example 3
Source File: BotBdmQueriesEditor.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
public BotBdmQueriesEditor setParameters(String queryName, Map<String, String> queryParam) {
    selectCustomQuery(queryName);
    // remove all existing parameters
    SWTBotTable queryParametersTable = getQueryParametersTable();
    int[] indexes = new int[queryParametersTable.rowCount()];
    for (int i = 0; i < indexes.length; i++) {
        indexes[i] = i;
    }
    queryParametersTable.select(indexes);
    bot.toolbarButtonWithId(QueryDetailsControl.REMOVE_PARAM_BUTTON_ID).click();
    bot.waitUntil(Conditions.shellIsActive(Messages.deleteQueryParamsConfirmTitle));
    SWTBotShell activeShell = bot.activeShell();
    activeShell.bot().button(IDialogConstants.YES_LABEL).click();
    bot.waitUntil(Conditions.shellCloses(activeShell));

    //add required parameters
    for (Entry<String, String> paramEntry : queryParam.entrySet()) {
        bot.toolbarButtonWithId(QueryDetailsControl.ADD_PARAM_BUTTON_ID).click();
        getQueryParametersTable().getTableItem(Messages.parameter).click();
        SWTBotText textBot = bot.textWithId(SWTBOT_ID_QUERY_PARAM_NAME_TEXTEDITOR);
        textBot.setText(paramEntry.getKey());
        textBot.pressShortcut(Keystrokes.CR);
        setType(queryName, paramEntry.getKey(), paramEntry.getValue());
    }
    return this;
}
 
Example 4
Source File: BotBdmIndexesEditor.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
public BotBdmIndexesEditor editIndex(String packageName, String businessObject, String indexName,
        String... selectFields) {
    selectBusinessObject(packageName, businessObject);
    SWTBotTable indexesTable = getIndexesTable();
    indexesTable.select(indexName);
    SWTBotTable availableFieldsTable = getAvailableFieldsTable();
    SWTBotTable indexedFieldsTable = getIndexedFieldsTable();
    // clean indexed table
    int count = indexedFieldsTable.rowCount();
    for (int i = 0; i < count; i++) {
        indexedFieldsTable.getTableItem(0).dragAndDrop(availableFieldsTable);
    }
    // Add selected fields
    for (String field : selectFields) {
        availableFieldsTable.getTableItem(field).dragAndDrop(indexedFieldsTable);
    }
    return this;
}
 
Example 5
Source File: SWTBotTestUtil.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @param bot
 * @param variableName
 */
public static void setVariableExpression(final SWTGefBot bot, final String variableName) {
    bot.waitUntil(Conditions.shellIsActive(editExpression));
    bot.tableWithLabel(expressionTypeLabel).select("Variable");
    bot.sleep(1000);
    // select the variable
    final SWTBotTable tableVar = bot.table(1);
    for (int i = 0; i < tableVar.rowCount(); i++) {
        final SWTBotTableItem tableItem = tableVar.getTableItem(i);
        if (tableItem.getText().startsWith(variableName + " --")) {
            tableItem.select();
            break;
        }
    }
    bot.waitUntil(Conditions.widgetIsEnabled(bot.button(IDialogConstants.OK_LABEL)));
    bot.button(IDialogConstants.OK_LABEL).click();
}
 
Example 6
Source File: SwtBotTestingUtilities.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
/**
 * Click on all table cells in column {@code col} with the contents {@code value}. Selection
 * should be the last cell clicked upon.
 */
public static void clickOnTableCellValue(SWTBotTable table, int col, String value) {
  String column = table.columns().get(col);
  for (int row = 0; row < table.rowCount(); row++) {
    String cellValue = table.cell(row, column);
    if (cellValue.equals(value)) {
      table.click(row, col);
      break;
    }
  }
}
 
Example 7
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 8
Source File: CoreSwtbotTools.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Returns items from a table.
 *
 * @param bot
 *          to work with, must not be {@code null}
 * @param table
 *          to look for items in, must not be {@code null}
 * @return list of table items, never {@code null}
 */
public static List<SWTBotTableItem> tableItems(final SWTWorkbenchBot bot, final SWTBotTable table) {
  Assert.isNotNull(bot, ARGUMENT_BOT);
  Assert.isNotNull(table, ARGUMENT_TABLE);
  waitForTableItem(bot, table);
  List<SWTBotTableItem> items = null;
  for (int i = 0; i < table.rowCount(); i++) {
    items = new ArrayList<SWTBotTableItem>(Arrays.asList(table.getTableItem(i)));
  }
  return items;
}
 
Example 9
Source File: SwtBotUtils.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
public static void clickOnTableCellValue(SWTBotTable table, int col, String value) {
  String column = table.columns().get(col);
  for (int row = 0; row < table.rowCount(); row++) {
    String cellValue = table.cell(row, column);
    if (cellValue.equals(value)) {
      table.click(row, col);
      break;
    }
  }
}
 
Example 10
Source File: SWTBotTestUtil.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public static List<String> listExpressionProposal(final SWTBot bot, final int index) {
    bot.toolbarButtonWithId(SWTBOT_ID_EXPRESSIONVIEWER_DROPDOWN, index).click();
    final SWTBotShell proposalShell = bot.shellWithId(SWTBOT_ID_EXPRESSIONVIEWER_PROPOSAL_SHELL);
    final SWTBot proposalBot = proposalShell.bot();
    final SWTBotTable proposalTAble = proposalBot.tableWithId(SWTBOT_ID_EXPRESSIONVIEWER_PROPOSAL_TABLE);

    final List<String> result = new ArrayList<>();
    for (int i = 0; i < proposalTAble.rowCount(); i++) {
        result.add(proposalTAble.getTableItem(i).getText());
    }
    proposalShell.close();
    return result;
}
 
Example 11
Source File: XMLAnalysesManagerPreferencePageTest.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Test the check/uncheck buttons
 */
@Test
public void testCheckButtons() {
    SWTBot bot = openXMLAnalysesPreferences().bot();

    SWTBotTable tableBot = bot.table(0);

    // Delete existing analysis files, if any
    int rowsCount = tableBot.rowCount();
    if (rowsCount > 0) {
        String[] itemNames = new String[rowsCount];
        for (int i = 0; i < rowsCount; ++i) {
            itemNames[i] = tableBot.getTableItem(i).getText();
        }
        tableBot.select(itemNames);
        bot.button("Delete").click();
        SWTBotShell deleteShell = bot.shell("Delete XML file(s)").activate();
        deleteShell.bot().button("Yes").click();
    }

    // Import files
    int preRowCount = tableBot.rowCount();
    importAnalysis(bot, FILES_BUTTONS.length, getRelativePaths(VALID_FILES_FOLDER, FILES_BUTTONS));
    int postRowCount = tableBot.rowCount();
    assertEquals(preRowCount + FILES_BUTTONS.length, postRowCount);

    // Uncheck selected
    int preCheckCount = SWTBotUtils.getTableCheckedItemCount(tableBot);
    int uncheckCount = 2;
    String[] toUncheck = Arrays.copyOfRange(FILES_BUTTONS, 0, uncheckCount);
    tableBot.select(toUncheck);
    bot.button(UNCHECK_SELECTED).click();
    int postCheckCount = SWTBotUtils.getTableCheckedItemCount(tableBot);
    assertEquals(UNCHECK_SELECTED, preCheckCount - uncheckCount, postCheckCount);

    // Check selected
    tableBot.select(toUncheck);
    bot.button(CHECK_SELECTED).click();
    postCheckCount = SWTBotUtils.getTableCheckedItemCount(tableBot);
    assertEquals(CHECK_SELECTED, preCheckCount, postCheckCount);

    // Uncheck all
    bot.button(UNCHECK_ALL).click();
    postCheckCount = SWTBotUtils.getTableCheckedItemCount(tableBot);
    assertEquals(UNCHECK_ALL, 0, postCheckCount);

    // Check all
    bot.button(CHECK_ALL).click();
    postCheckCount = SWTBotUtils.getTableCheckedItemCount(tableBot);
    assertEquals(CHECK_ALL, postRowCount, postCheckCount);

    SWTBotUtils.pressOKishButtonInPreferences(bot);
}
 
Example 12
Source File: OrganizationCreationTest.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
/**
 * @author Florine Boudin
 * @throws InterruptedException
 */
@Test
public void addNewUsersInACMETest() throws InterruptedException {
    // open shell "Manage organization"
    bot.menu("Organization").menu("Define...").click();
    bot.waitUntil(Conditions.shellIsActive(Messages.manageOrganizationTitle));

    SWTBotTable table = bot.table();
    Assert.assertNotNull(table);

    // Set Description of the new Organisation
    final int idxBonita = table.indexOf("ACME  (" + Messages.active + ")", 0);
    Assert.assertTrue("Error: No ACME found in the table", idxBonita != -1);

    // go to the next shell
    table.click(idxBonita, 0);

    for (int i = 0; i < 3; i++) {
        bot.waitUntil(Conditions.widgetIsEnabled(bot.button(IDialogConstants.NEXT_LABEL)), 1000);
        bot.button(IDialogConstants.NEXT_LABEL).click();
    }

    // in the user shell, get table of user list
    table = bot.table();
    Assert.assertNotNull("Error: No user table found", table);

    final int nbUsers = table.rowCount();

    //add new user Elton John
    final SWTBotButton addButton = bot.button("Add");

    addButton.click();

    Assert.assertEquals("Error : wrong number of added users", nbUsers + 1, table.rowCount());

    bot.textWithLabel(Messages.userName + " *").setText("elton.john");
    bot.textWithLabel(Messages.password + " *").setText("bpm");

    bot.comboBoxWithLabel(Messages.manager).setSelection("william.jobs");
    Assert.assertEquals("Error: Manager is not selected", "william.jobs",
            bot.comboBoxWithLabel(Messages.manager).getText());

    bot.tabItem("General").activate();
    bot.textWithLabel(Messages.firstName).setText("Elton");
    bot.textWithLabel(Messages.lastName).setText("John");

    Assert.assertEquals("Error: First name user is not setted", "Elton",
            bot.textWithLabel(Messages.firstName).getText());
    Assert.assertEquals("Error: Last name user is not setted", "John", bot.textWithLabel(Messages.lastName).getText());

    bot.tabItem(Messages.membership + " *").activate();
    bot.comboBoxWithLabel("Group").setSelection("/acme");
    bot.comboBoxWithLabel("Role").setSelection("member");
    // Finish the user add
    bot.waitUntil(Conditions.widgetIsEnabled(bot.button(IDialogConstants.FINISH_LABEL)));
    bot.button(IDialogConstants.FINISH_LABEL).click();
    bot.waitUntil(Conditions.shellIsActive(Messages.organizationHasBeenModifiedTitle));
    bot.button(IDialogConstants.NO_LABEL).click();
}