Search in sources :

Example 1 with SWTBotText

use of org.eclipse.swtbot.swt.finder.widgets.SWTBotText in project translationstudio8 by heartsome.

the class ProjectRename method renamePrj.

/**
	 * 重命名项目
	 * @param oldName
	 *            旧项目名称
	 * @param newName
	 *            新项目名称
	 */
private void renamePrj(Entry from, String oldName, String newName, ExpectedResult expectedResult, String invalidChar, boolean overwrite) {
    // 先取消选中项目,避免后面没有找到匹配项目时仍有之前选中的项目被误操作
    treePrj.unselect();
    Waits.prjExistOnTree(oldName);
    // 选择项目并重命名
    treePrj.select(oldName);
    switch(from) {
        case CONTEXT_MENU:
            {
                viewPrjTree.ctxMenuRename().click();
                break;
            }
        case SHORTCUT:
            {
                treePrj.pressShortcut(Keystrokes.F2);
                break;
            }
        default:
            {
                assertTrue("错误的入口参数:" + from, false);
            }
    }
    // 进入重命名状态
    SWTBotText txtPrjName = viewPrjTree.bot().text(oldName);
    // 输入新名称并回车确认
    txtPrjName.typeText(newName + "\n");
    // 不同步的问题暂不考虑——若要解决,思路是判断是否出现不同步的信息,若有则刷新后重试重命名,直到达到最大重试次数后放弃。
    if (HSBot.bot().shells().length > 1) {
        // FIXME: 可能需要修改这种判断方式,试试 activeShell()?
        Waits.progressFinished();
        String title = HSBot.bot().activeShell().getText();
        String errMsg = "重命名出错。对话框标题:" + title;
        switch(expectedResult) {
            case SUCCESS:
                {
                    // 验证结果
                    assertRenamed(oldName, newName);
                    break;
                }
            case INVALID_NAME:
                {
                    if (title.equals(TsUIConstants.getString("dlgTitleRenameProblems"))) {
                        RenameProblemsDialog rpd = new RenameProblemsDialog(newName, invalidChar);
                        assertTrue("未正确显示项目名非法的信息。", rpd.isInvalidMsgVisible());
                        assertTrue(rpd.btnOK().isEnabled());
                        rpd.btnOK().click();
                        Waits.shellClosed(rpd);
                        assertNotRenamed(oldName, newName);
                    } else {
                        assertTrue(errMsg, false);
                    }
                    break;
                }
            case DUPLICATED_NAME:
                {
                    if (title.equals(TsUIConstants.getString("dlgTitleProjectExists"))) {
                        ProjectExistsDialog ped = new ProjectExistsDialog(newName);
                        assertTrue("未正确显示项目名称已存在的信息。", ped.isProjectExistsMsgVisible());
                        assertTrue(ped.btnYes().isEnabled());
                        assertTrue(ped.btnNo().isEnabled());
                        if (overwrite) {
                            ped.btnYes().click();
                            Waits.shellClosed(ped);
                            Waits.progressFinished();
                            assertRenamed(oldName, newName);
                        } else {
                            ped.btnNo().click();
                            Waits.shellClosed(ped);
                            Waits.progressFinished();
                            assertNotOverwritten(oldName, newName);
                        }
                    } else {
                        assertTrue(errMsg, false);
                    }
                    break;
                }
            default:
                {
                    assertTrue(errMsg, false);
                }
        }
    } else {
        // 重命名正常,验证结果
        assertRenamed(oldName, newName);
    }
}
Also used : RenameProblemsDialog(net.heartsome.cat.ts.test.ui.dialogs.RenameProblemsDialog) ProjectExistsDialog(net.heartsome.cat.ts.test.ui.dialogs.ProjectExistsDialog) SWTBotText(org.eclipse.swtbot.swt.finder.widgets.SWTBotText)

Example 2 with SWTBotText

use of org.eclipse.swtbot.swt.finder.widgets.SWTBotText in project translationstudio8 by heartsome.

the class XlfEditor method gotoSeg.

/**
	 * 跳到指定文本段
	 * @param segNum
	 *            文本段行号
	 */
public void gotoSeg(int segNum) {
    getNatTable();
    nattable.click(1, 1);
    int targetRowIndex;
    if (isHorizontalLayout()) {
        targetRowIndex = segNum - 1;
    } else {
        targetRowIndex = (segNum - 1) * 2;
    }
    int selectedRowIndex = nattable.indexOfSelectedRow(positionOfTargetTextColumn());
    // 先判断指定文本段是否已经被选中,若未被选中才继续
    if (segNum != 1 && targetRowIndex != selectedRowIndex) {
        SWTBotText text = editorBot.text(lineNumLastValue);
        text.setText(String.valueOf(segNum));
        text.pressShortcut(Keystrokes.LF);
        lineNumLastValue = String.valueOf(segNum);
        // 确认选中了指定文本段
        bot.waitUntil(new IsSegmentSelected(this, targetRowIndex));
    }
}
Also used : IsSegmentSelected(net.heartsome.cat.ts.test.ui.waits.IsSegmentSelected) SWTBotText(org.eclipse.swtbot.swt.finder.widgets.SWTBotText)

Example 3 with SWTBotText

use of org.eclipse.swtbot.swt.finder.widgets.SWTBotText in project xtext-xtend by eclipse.

the class AbstractRefactoringSwtBotTest method renameInXtendEditor.

public void renameInXtendEditor(final SWTBotEclipseEditor xtendEditor, final String newName, final String dialogName) {
    final SWTBotMenu renameMenuItem = SwtBotProjectHelper.clickableContextMenu(xtendEditor, "Refactor", "Rename Element");
    renameMenuItem.click();
    boolean _isUseInlineRefactoring = this.testParams.isUseInlineRefactoring();
    if (_isUseInlineRefactoring) {
        this.waitForLinkedMode();
        xtendEditor.typeText(newName);
        boolean _isUsePreview = this.testParams.isUsePreview();
        if (_isUsePreview) {
            xtendEditor.pressShortcut(SWT.CTRL, SWT.CR);
            AbstractRefactoringSwtBotTest.bot.shell(dialogName).activate();
            AbstractRefactoringSwtBotTest.bot.button("OK").click();
        } else {
            xtendEditor.pressShortcut(KeyStroke.getInstance(SWT.LF));
        }
    } else {
        SWTBot _bot = AbstractRefactoringSwtBotTest.bot.shell(dialogName).activate().bot();
        final Procedure1<SWTBot> _function = (SWTBot it) -> {
            SWTBotText _textWithLabel = it.textWithLabel("New name:");
            _textWithLabel.setText(newName);
            boolean _isUsePreview_1 = this.testParams.isUsePreview();
            if (_isUsePreview_1) {
                it.button("Preview >").click();
            }
            it.button("OK").click();
        };
        ObjectExtensions.<SWTBot>operator_doubleArrow(_bot, _function);
    }
    this.waitForRefactoring(xtendEditor);
}
Also used : SWTBot(org.eclipse.swtbot.swt.finder.SWTBot) SWTBotMenu(org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu) SWTBotText(org.eclipse.swtbot.swt.finder.widgets.SWTBotText)

Example 4 with SWTBotText

use of org.eclipse.swtbot.swt.finder.widgets.SWTBotText in project linuxtools by eclipse.

the class TestCreateSystemtapScript method setupGraphGeneral.

private static void setupGraphGeneral(String title, int numItems, String graphID, boolean useRowNum, boolean isTab) {
    int offset = useRowNum ? 0 : 1;
    SWTBotShell firstShell = bot.activeShell();
    openGraphMenu(isTab);
    SWTBotShell shell = bot.shell("Create Graph");
    shell.setFocus();
    deselectDefaultSelection(0);
    bot.radioWithTooltip(GraphFactory.getGraphName(graphID) + "\n\n" + GraphFactory.getGraphDescription(graphID)).click();
    shell.setFocus();
    SWTBotText text = bot.textWithLabel("Title:");
    text.setText(title);
    bot.comboBoxWithLabel("X Series:").setSelection(offset);
    bot.comboBoxWithLabel("Y Series 0:").setSelection(offset);
    for (int i = 1; i < numItems - offset; i++) {
        bot.comboBoxWithLabel(MessageFormat.format("Y Series {0}:", i)).setSelection(i + 1 + offset);
    }
    if (!useRowNum) {
        bot.comboBoxWithLabel(MessageFormat.format("Y Series {0}:", numItems - 1)).setSelection(0);
    }
    bot.button("Finish").click();
    bot.waitUntil(Conditions.shellCloses(shell));
    firstShell.setFocus();
}
Also used : SWTBotText(org.eclipse.swtbot.swt.finder.widgets.SWTBotText) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell) Point(org.eclipse.swt.graphics.Point)

Example 5 with SWTBotText

use of org.eclipse.swtbot.swt.finder.widgets.SWTBotText in project linuxtools by eclipse.

the class TestCreateSystemtapScript method createScript.

public static void createScript(SWTWorkbenchBot bot, String scriptName) {
    clickMainMenu("File", "New", "Other...");
    SWTBotShell shell = bot.shell("New");
    shell.setFocus();
    shell.bot().text().setText("SystemTap");
    bot.waitUntil(new NodeAvailableAndSelect(bot.tree(), "SystemTap", "SystemTap Script"));
    bot.button("Next >").click();
    SWTBotText text = bot.textWithLabel("Script Name:").setText(scriptName);
    assertEquals(scriptName, text.getText());
    text = bot.textWithLabel("Project:").setText(SYSTEMTAP_PROJECT_NAME);
    assertEquals(SYSTEMTAP_PROJECT_NAME, text.getText());
    bot.button("Finish").click();
    bot.waitUntil(Conditions.shellCloses(shell));
    assertEquals(scriptName, bot.activeEditor().getTitle());
}
Also used : SWTBotText(org.eclipse.swtbot.swt.finder.widgets.SWTBotText) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell)

Aggregations

SWTBotText (org.eclipse.swtbot.swt.finder.widgets.SWTBotText)10 SWTBotShell (org.eclipse.swtbot.swt.finder.widgets.SWTBotShell)5 SWTBot (org.eclipse.swtbot.swt.finder.SWTBot)2 WidgetNotFoundException (org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException)2 SWTBotCombo (org.eclipse.swtbot.swt.finder.widgets.SWTBotCombo)2 SWTBotMenu (org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu)2 List (java.util.List)1 Consumer (java.util.function.Consumer)1 ProjectExistsDialog (net.heartsome.cat.ts.test.ui.dialogs.ProjectExistsDialog)1 RenameProblemsDialog (net.heartsome.cat.ts.test.ui.dialogs.RenameProblemsDialog)1 IsSegmentSelected (net.heartsome.cat.ts.test.ui.waits.IsSegmentSelected)1 IResource (org.eclipse.core.resources.IResource)1 Point (org.eclipse.swt.graphics.Point)1 SWTBotEclipseEditor (org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor)1 SWTBotCTabItem (org.eclipse.swtbot.swt.finder.widgets.SWTBotCTabItem)1 SWTBotTable (org.eclipse.swtbot.swt.finder.widgets.SWTBotTable)1 SWTBotTree (org.eclipse.swtbot.swt.finder.widgets.SWTBotTree)1 SWTBotTreeItem (org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem)1 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)1 Test (org.junit.Test)1