use of org.eclipse.swtbot.swt.finder.utils.Position in project translationstudio8 by heartsome.
the class SplitSegment method splitAfter.
/**
* @param xe 要操作的 XlfEditor 对象
* @param segNum 要分割的文本段序号
* @param afterText 在此文本之后分割
*/
public static void splitAfter(XlfEditor xe, int segNum, String afterText) {
SWTBotNatTable nt = xe.getNatTable();
xe.selectSourceCell(segNum);
Position pos = nt.positionOfSelectedCell();
String expectedText = nt.getTextByPosition(pos.line, pos.column);
int splitIndex = StringUtil.indexAfterWithAssert(expectedText, afterText);
splitAt(xe, segNum, splitIndex);
}
use of org.eclipse.swtbot.swt.finder.utils.Position in project translationstudio8 by heartsome.
the class SplitSegment method splitWithoutCursor.
/**
* 尝试不将光标置于源文本中直接分割
* @param xe 要操作的 XlfEditor 对象
* @param segNum 尝试分割的文本段序号
*/
public static void splitWithoutCursor(XlfEditor xe, int segNum) {
// 判断该文本段是否可编辑
String rowID = xe.rowIdOfSegNum(segNum);
XliffUtil xu = new XliffUtil(rowID);
SegmentAsserts.segIsEditable(xu);
// 选中文本段的源文本单元格,而不进入编辑状态
xe.selectSourceCell(segNum);
// 在实际进行分割文本段之前,得到原文本段的 tuid,用以验证得到的文本段内容是否符合预期。
String tuid = xe.tuidOfSegNum(segNum);
// 判断给定的分割点是否可分割
SWTBotNatTable nt = xe.getNatTable();
Position pos = nt.positionOfSelectedCell();
String expectedText = nt.getTextByPosition(pos.line, pos.column);
// 点击相应的菜单项进行分割
ts.menuTranslationSplitSegment().click();
// 弹出提示信息
InformationDialog dialog = new InformationDialog(1, TsUIConstants.getString("msgPlaceCursorToSplit"));
dialog.lblMessage().isVisible();
dialog.btnOK().click();
xe.getNatTable();
// 确认文本段没有被分割
SegmentAsserts.segNotSplit(tuid, expectedText, xu);
}
use of org.eclipse.swtbot.swt.finder.utils.Position in project translationstudio8 by heartsome.
the class XlfEditor method typeTextAfter.
/**
* 在指定字符串之后输入内容
* @param afterText
* 指定的字符串,输入的内容将在其最后一个字符之后
* @param text
* 要输入的内容
*/
public void typeTextAfter(String afterText, String text) {
HsSWTBotStyledText styledText = getStyledText();
Position targetPos = styledText.positionOfFollowing(afterText);
Assert.isTrue(!targetPos.equals(new Position(-1, -1)), "Text \"" + afterText + "\" not found.");
styledText.typeText(targetPos.line, targetPos.column, text);
}
use of org.eclipse.swtbot.swt.finder.utils.Position in project translationstudio8 by heartsome.
the class XlfEditor method navigateBetween.
/**
* 将光标定位到指定的两个字符串之间 指定的两个字符串必须相邻
* @param afterText
* 指定的字符串,光标将置于其最后一个字符之后
* @param beforeText
* 指定的字符串,光标将置于其第一个字符之前
*/
public void navigateBetween(String afterText, String beforeText) {
HsSWTBotStyledText styledText = getStyledText();
Position targetPosA = styledText.positionOfFollowing(afterText);
Assert.isTrue(!targetPosA.equals(new Position(-1, -1)), "Text \"" + afterText + "\" not found.");
Position targetPosB = styledText.positionOf(beforeText);
Assert.isTrue(!targetPosB.equals(new Position(-1, -1)), "Text \"" + beforeText + "\" not found.");
Assert.isTrue(targetPosB.equals(targetPosA), "Text \"" + afterText + beforeText + "\" not found.");
styledText.navigateTo(targetPosA);
}
use of org.eclipse.swtbot.swt.finder.utils.Position in project translationstudio8 by heartsome.
the class XlfEditor method typeTextBetween.
/**
* 在指定的两个字符串之间输入内容
* @param afterText
* 指定的字符串,输入的内容将在其最后一个字符之后
* @param beforeText
* 指定的字符串,输入的内容将在其第一个字符之前
* @param text
* 要输入的内容
*/
public void typeTextBetween(String afterText, String beforeText, String text) {
HsSWTBotStyledText styledText = getStyledText();
Position targetPosA = styledText.positionOfFollowing(afterText);
Assert.isTrue(!targetPosA.equals(new Position(-1, -1)), "Text \"" + afterText + "\" not found.");
Position targetPosB = styledText.positionOf(beforeText);
Assert.isTrue(!targetPosB.equals(new Position(-1, -1)), "Text \"" + beforeText + "\" not found.");
Assert.isTrue(targetPosB.equals(targetPosA), "Text \"" + afterText + beforeText + "\" not found.");
styledText.typeText(targetPosA.line, targetPosA.column, text);
}
Aggregations