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

The following examples show how to use org.eclipse.swtbot.swt.finder.widgets.SWTBotTable#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: XMLAnalysesManagerPreferencePageTest.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Test the edit function
 */
@Test
public void testEdit() {
    // Import valid analysis files
    SWTBot bot = openXMLAnalysesPreferences().bot();
    importAnalysis(bot, FILES_EDIT.length, getRelativePaths(VALID_FILES_FOLDER, FILES_EDIT));

    // Open the editor
    SWTBotTable tablebot = bot.table(0);
    tablebot.select(FILES_EDIT);
    bot.button("Edit...").click();

    SWTBotUtils.pressOKishButtonInPreferences(bot);

    // Check that the editors were opened
    // No need to actually check that they are active
    for (String editFile : FILES_EDIT) {
        fBot.editorByTitle(editFile + EXTENSION).isActive();
    }
}
 
Example 2
Source File: XMLAnalysesManagerPreferencePageTest.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Test the export function
 */
@Test
public void testExport() {
    // Import valid analysis file
    SWTBot bot = openXMLAnalysesPreferences().bot();
    final String fileNameXml = FILE_EXPORT + EXTENSION;
    importAnalysis(bot, 1, TEST_FILES_FOLDER + VALID_FILES_FOLDER + fileNameXml);

    // Setup target folder
    File targetDirectory = new File(TEMP_DIRECTORY);
    DirectoryDialogFactory.setOverridePath(targetDirectory.getAbsolutePath());

    // Export
    SWTBotTable tableBot = bot.table(0);
    tableBot.select(FILE_EXPORT);
    bot.button("Export").click();

    // Check that the file was created
    File targetFile = new File(targetDirectory, fileNameXml);
    assertTrue(targetFile.toString(), targetFile.exists());

    SWTBotUtils.pressOKishButtonInPreferences(bot);
}
 
Example 3
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 4
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 5
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 6
Source File: XMLAnalysesManagerPreferencePageTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Test the deletion of files
 */
@Test
public void testDelete() {
    // Import valid analysis file
    SWTBot bot = openXMLAnalysesPreferences().bot();
    importAnalysis(bot, FILES_DELETE.length, getRelativePaths(VALID_FILES_FOLDER, FILES_DELETE));

    SWTBotTable tablebot = bot.table(0);

    // Open editor for first file
    tablebot.select(FILES_DELETE[0]);
    bot.button("Edit...").click();

    // Delete files
    tablebot.select(FILES_DELETE);
    bot.button("Delete").click();

    // Check that the confirmation pop-up is displayed
    SWTBotShell deleteShell = bot.shell("Delete XML file(s)").activate();
    deleteShell.bot().button("Yes").click();

    // Check that the files do not exist anymore
    for (String deleteFile : FILES_DELETE) {
        assertFalse(deleteFile, tablebot.containsItem(deleteFile));
    }

    // Check that the opened editor was closed
    fBot.editors().forEach(editor -> {
        if (editor != null) {
            if (editor.getTitle().equals(FILES_DELETE[0] + EXTENSION)) {
                fail("Editor is still open: " + FILES_DELETE[0] + EXTENSION);
            }
        }
    });

    SWTBotUtils.pressOKishButtonInPreferences(bot);
}
 
Example 7
Source File: BotBdmModelEditor.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * The attribute type has to be a String!
 */
public BotBdmModelEditor setAttributeLength(String packageName, String businessObject, String attribute,
        String length) {
    SWTBotTable attributeTable = getAttributeTable(packageName, businessObject);
    attributeTable.select(attribute);
    bot.comboBoxWithLabel(Messages.length).setText(length);
    return this;
}
 
Example 8
Source File: BotBdmIndexesEditor.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public BotBdmIndexesEditor moveField(String packageName, String businessObject, String indexName, String field,
        int position) {
    selectBusinessObject(packageName, businessObject);
    SWTBotTable indexesTable = getIndexesTable();
    indexesTable.select(indexName);
    SWTBotTable indexedFieldsTable = getIndexedFieldsTable();
    indexedFieldsTable.getTableItem(field).dragAndDrop(indexedFieldsTable.getTableItem(position));
    return this;
}
 
Example 9
Source File: SWTBotTestUtil.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public static void selectExpressionProposal(final SWTBot bot, final String storageExpressionName,
        final String returnType, 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 int row = proposalTAble.indexOf(storageExpressionName + " -- " + returnType, 0);
    if (row == -1) {
        throw new WidgetNotFoundException(storageExpressionName + " not found in proposals");
    }
    proposalTAble.select(row);
    proposalTAble.pressShortcut(Keystrokes.CR);
    bot.waitUntil(Conditions.shellCloses(proposalShell));
}
 
Example 10
Source File: BotAddConnectorDialog.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Select the variable to store the connector output.
 *
 * @param pVariableId
 */
public void selectOutputVariable(final String pVariableId) {
    final SWTBotText text = bot.text(0);
    text.setFocus();
    bot.toolbarButtonWithId("expressionViewerDropDown", 0).click();
    final SWTBot proposalBot = bot.shellWithId("expressionViewerProposalShell").bot();
    final SWTBotTable proposalTAble = proposalBot.tableWithId("expressionViewerProposalTable");
    proposalTAble.select(pVariableId);; //1st value
    SWTBotTestUtil.pressEnter();
}
 
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: ColorsViewTest.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Test color by making all events yellow
 */
@Test
public void testYellow() {
    SWTBotView viewBot = fBot.viewById(ColorsView.ID);
    viewBot.setFocus();
    final String insert = "Insert new color setting";
    final String increasePriority = "Increase priority";
    final String decreasePriority = "Decrease priority";
    final String delete = "Delete color setting";
    viewBot.toolbarButton(insert).click();
    viewBot.toolbarButton(insert).click();
    viewBot.toolbarButton(insert).click();
    viewBot.toolbarButton(insert).click();
    viewBot.toolbarButton(increasePriority).click();
    viewBot.toolbarButton(decreasePriority).click();
    viewBot.toolbarButton(delete).click();
    viewBot.bot().label(0).setFocus();
    viewBot.toolbarButton(delete).click();
    viewBot.bot().label(0).setFocus();
    viewBot.toolbarButton(delete).click();
    final RGB foreground = new RGB(0, 0, 0);
    final RGB background = new RGB(255, 255, 0);
    // Simulate the side effects of picking a color because we cannot
    // control native Color picker dialog in SWTBot.
    final ColorSetting[] cs = new ColorSetting[1];
    UIThreadRunnable.syncExec(new VoidResult() {
        @Override
        public void run() {
            cs[0] = new ColorSetting(foreground, background, foreground, new PassAll());
            ColorSettingsManager.setColorSettings(cs);
        }
    });
    final SWTBotTable eventsEditor = SWTBotUtils.activeEventsEditor(fBot).bot().table();
    // should fix race condition of loading the trace
    WaitUtils.waitForJobs();
    eventsEditor.select(2);
    final SWTBotTableItem tableItem = eventsEditor.getTableItem(2);
    RGB fgc = UIThreadRunnable.syncExec(new Result<RGB>() {
        @Override
        public RGB run() {
            return tableItem.widget.getForeground().getRGB();
        }
    });
    RGB bgc = UIThreadRunnable.syncExec(new Result<RGB>() {
        @Override
        public RGB run() {
            return tableItem.widget.getBackground().getRGB();
        }
    });
    assertEquals("Fg", foreground, fgc);
    assertEquals("Bg", background, bgc);
    // reset color settings
    UIThreadRunnable.syncExec(new VoidResult() {
        @Override
        public void run() {
            ColorSettingsManager.setColorSettings(new ColorSetting[0]);
        }
    });
}
 
Example 13
Source File: FlameChartViewTest.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Test manipulating valid and invalid mapping files (add, remove and change
 * priority of files)
 *
 * @throws IOException
 *             Missing file
 */
@Test
public void testManipulatingMappingFiles() throws IOException {

    // 1- Open valid mapping files and invalid mapping file
    URL mapUrlA = CtfTmfTestTraceUtils.class.getResource("cyg-profile-mapping.txt");
    URL mapUrlB = CtfTmfTestTraceUtils.class.getResource("dummy-mapping.txt");
    URL mapUrlC = CtfTmfTestTraceUtils.class.getResource("invalid-cyg-profile-mapping.txt");
    URL mapUrlD = CtfTmfTestTraceUtils.class.getResource("random.out");
    URL mapUrlE = CtfTmfTestTraceUtils.class.getResource("win32Random.exe");

    String absoluteFileA = FileLocator.toFileURL(mapUrlA).getFile();
    String absoluteFileB = FileLocator.toFileURL(mapUrlB).getFile();
    String absoluteFileC = FileLocator.toFileURL(mapUrlC).getFile();
    String absoluteFileD = FileLocator.toFileURL(mapUrlD).getFile();
    String absoluteFileE = FileLocator.toFileURL(mapUrlE).getFile();
    String[] overrideFiles = { absoluteFileA, absoluteFileA, absoluteFileB, absoluteFileC, absoluteFileD, absoluteFileE };
    TmfFileDialogFactory.setOverrideFiles(overrideFiles);

    SWTBotShell shell = openSymbolProviderDialog();
    final SWTBot symbolDialog = shell.bot();
    symbolDialog.button("Add...").click();
    final SWTBot errorDialog = sfBot.shell("Import failure").bot();
    errorDialog.button("OK").click();
    final SWTBotTable table = symbolDialog.table();
    assertEquals(4, table.rowCount());
    assertEquals(absoluteFileA, table.getTableItem(0).getText());
    assertEquals(absoluteFileB, table.getTableItem(1).getText());
    assertEquals(absoluteFileD, table.getTableItem(2).getText());
    assertEquals(absoluteFileE, table.getTableItem(3).getText());

    // 2- Change priority of mapping files
    table.select(0);
    symbolDialog.button("Down").click().click().click();
    assertEquals(absoluteFileB, table.getTableItem(0).getText());
    assertEquals(absoluteFileD, table.getTableItem(1).getText());
    assertEquals(absoluteFileE, table.getTableItem(2).getText());
    assertEquals(absoluteFileA, table.getTableItem(3).getText());

    symbolDialog.button("Up").click().click().click();
    assertEquals(absoluteFileA, table.getTableItem(0).getText());
    assertEquals(absoluteFileB, table.getTableItem(1).getText());
    assertEquals(absoluteFileD, table.getTableItem(2).getText());
    assertEquals(absoluteFileE, table.getTableItem(3).getText());

    // 3- Remove multiple mapping files
    table.select(0, 1);
    symbolDialog.button("Remove").click();
    assertEquals(2, table.rowCount());

    // 4- Close symbol provider dialog
    symbolDialog.button("Cancel").click();
}