Search in sources :

Example 6 with Position

use of org.eclipse.swtbot.swt.finder.utils.Position in project translationstudio8 by heartsome.

the class SplitSegment method splitAtEnd.

/**
	 * 尝试从段末分割文本段
	 * @param xe 要操作的 XlfEditor 对象
	 * @param segNum 尝试分割的文本段序号
	 */
public static void splitAtEnd(XlfEditor xe, int segNum) {
    SWTBotNatTable nt = xe.getNatTable();
    xe.selectSourceCell(segNum);
    Position pos = nt.positionOfSelectedCell();
    String expectedText = nt.getTextByPosition(pos.line, pos.column);
    int splitIndex = expectedText.length();
    splitAt(xe, segNum, splitIndex);
}
Also used : SWTBotNatTable(net.heartsome.test.swtbot.widgets.SWTBotNatTable) Position(org.eclipse.swtbot.swt.finder.utils.Position)

Example 7 with Position

use of org.eclipse.swtbot.swt.finder.utils.Position in project translationstudio8 by heartsome.

the class SplitSegment method splitBefore.

/**
	 * @param xe 要操作的 XlfEditor 对象
	 * @param segNum 要分割的文本段序号
	 * @param beforeText 在此文本之前分割
	 */
public static void splitBefore(XlfEditor xe, int segNum, String beforeText) {
    SWTBotNatTable nt = xe.getNatTable();
    xe.selectSourceCell(segNum);
    Position pos = nt.positionOfSelectedCell();
    String expectedText = nt.getTextByPosition(pos.line, pos.column);
    int splitIndex = StringUtil.indexBeforeWithAssert(expectedText, beforeText);
    splitAt(xe, segNum, splitIndex);
}
Also used : SWTBotNatTable(net.heartsome.test.swtbot.widgets.SWTBotNatTable) Position(org.eclipse.swtbot.swt.finder.utils.Position)

Example 8 with Position

use of org.eclipse.swtbot.swt.finder.utils.Position in project translationstudio8 by heartsome.

the class SplitSegment method splitBetween.

/**
	 * @param xe 要操作的 XlfEditor 对象
	 * @param segNum 要分割的文本段序号
	 * @param afterText 在此文本之后分割,此内容在文本段中必须与下一个参数相邻
	 * @param beforeText 在此文本之前分割,此内容在文本段中必须与上一个参数相邻
	 */
public static void splitBetween(XlfEditor xe, int segNum, String afterText, String beforeText) {
    SWTBotNatTable nt = xe.getNatTable();
    xe.selectSourceCell(segNum);
    Position pos = nt.positionOfSelectedCell();
    String expectedText = nt.getTextByPosition(pos.line, pos.column);
    int splitIndex = StringUtil.indexBetweenWithAssert(expectedText, afterText, beforeText);
    splitAt(xe, segNum, splitIndex);
}
Also used : SWTBotNatTable(net.heartsome.test.swtbot.widgets.SWTBotNatTable) Position(org.eclipse.swtbot.swt.finder.utils.Position)

Example 9 with Position

use of org.eclipse.swtbot.swt.finder.utils.Position in project translationstudio8 by heartsome.

the class XlfEditor method navigateAfter.

/**
	 * 将光标定位到指定字符串之后
	 * @param afterText
	 *            指定的字符串,光标将置于其最后一个字符之后
	 */
public void navigateAfter(String afterText) {
    HsSWTBotStyledText styledText = getStyledText();
    Position targetPos = styledText.positionOfFollowing(afterText);
    Assert.isTrue(!targetPos.equals(new Position(-1, -1)), "Text \"" + afterText + "\" not found.");
    styledText.navigateTo(targetPos);
}
Also used : Position(org.eclipse.swtbot.swt.finder.utils.Position) HsSWTBotStyledText(net.heartsome.test.swtbot.widgets.HsSWTBotStyledText)

Example 10 with Position

use of org.eclipse.swtbot.swt.finder.utils.Position in project translationstudio8 by heartsome.

the class XlfEditor method typeTextBefore.

/**
	 * 在指定字符串之前输入内容
	 * @param beforeText
	 *            指定的字符串,输入的内容将在其第一个字符之前
	 * @param text
	 *            要输入的内容
	 */
public void typeTextBefore(String beforeText, String text) {
    HsSWTBotStyledText styledText = getStyledText();
    Position targetPos = styledText.positionOf(beforeText);
    Assert.isTrue(!targetPos.equals(new Position(-1, -1)), "Text \"" + beforeText + "\" not found.");
    styledText.typeText(targetPos.line, targetPos.column, text);
}
Also used : Position(org.eclipse.swtbot.swt.finder.utils.Position) HsSWTBotStyledText(net.heartsome.test.swtbot.widgets.HsSWTBotStyledText)

Aggregations

Position (org.eclipse.swtbot.swt.finder.utils.Position)11 HsSWTBotStyledText (net.heartsome.test.swtbot.widgets.HsSWTBotStyledText)6 SWTBotNatTable (net.heartsome.test.swtbot.widgets.SWTBotNatTable)5 InformationDialog (net.heartsome.cat.ts.test.ui.msgdialogs.InformationDialog)1 XliffUtil (net.heartsome.cat.ts.test.ui.utils.XliffUtil)1