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);
}
}
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));
}
}
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);
}
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();
}
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());
}
Aggregations