org.eclipse.swtbot.swt.finder.utils.Position Java Examples

The following examples show how to use org.eclipse.swtbot.swt.finder.utils.Position. 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: XlfEditor.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 在指定的两个字符串之间输入内容
 * @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);
}
 
Example #2
Source File: XlfEditor.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 在指定的两个字符串之间输入内容
 * @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);
}
 
Example #3
Source File: XlfEditor.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 将光标定位到指定的两个字符串之间 指定的两个字符串必须相邻
 * @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);
}
 
Example #4
Source File: XlfEditor.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 将光标定位到指定字符串之后
 * @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);
}
 
Example #5
Source File: XlfEditor.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 将光标定位到指定字符串之前
 * @param beforeText
 *            指定的字符串,光标将置于其第一个字符之前
 */
public void navigateBefore(String beforeText) {
	HsSWTBotStyledText styledText = getStyledText();
	Position targetPos = styledText.positionOf(beforeText);
	Assert.isTrue(!targetPos.equals(new Position(-1, -1)), "Text \"" + beforeText + "\" not found.");
	styledText.navigateTo(targetPos);
}
 
Example #6
Source File: SplitSegment.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 尝试不将光标置于源文本中直接分割
 * @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);
}
 
Example #7
Source File: SplitSegment.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 尝试从段末分割文本段
 * @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);
}
 
Example #8
Source File: SplitSegment.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @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);
}
 
Example #9
Source File: SplitSegment.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @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);
}
 
Example #10
Source File: SplitSegment.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @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);
}
 
Example #11
Source File: XlfEditor.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 将光标定位到指定的两个字符串之间 指定的两个字符串必须相邻
 * @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);
}
 
Example #12
Source File: XlfEditor.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 将光标定位到指定字符串之后
 * @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);
}
 
Example #13
Source File: XlfEditor.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 将光标定位到指定字符串之前
 * @param beforeText
 *            指定的字符串,光标将置于其第一个字符之前
 */
public void navigateBefore(String beforeText) {
	HsSWTBotStyledText styledText = getStyledText();
	Position targetPos = styledText.positionOf(beforeText);
	Assert.isTrue(!targetPos.equals(new Position(-1, -1)), "Text \"" + beforeText + "\" not found.");
	styledText.navigateTo(targetPos);
}
 
Example #14
Source File: SplitSegment.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 尝试不将光标置于源文本中直接分割
 * @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);
}
 
Example #15
Source File: SplitSegment.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 尝试从段末分割文本段
 * @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);
}
 
Example #16
Source File: SplitSegment.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @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);
}
 
Example #17
Source File: SplitSegment.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @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);
}
 
Example #18
Source File: SplitSegment.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @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);
}
 
Example #19
Source File: AcfSwtBotEclipseEditor.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Synchronously wait until the cursor is on the given position.
 * 
 * @param line
 *          line number
 * @param column
 *          column number
 */
private void waitUntilCursorIsOnPosition(final int line, final int column) {
  bot.waitUntil(new DefaultCondition() {

    public boolean test() {
      Position position = cursorPosition();
      return isActive() && position.line == line && position.column == column;
    }

    public String getFailureMessage() {
      return NLS.bind("The cursor should be on the position ({0}, {1}) and the editor should have focus.", line, column);
    }

  });
}
 
Example #20
Source File: AcfSwtBotEclipseEditor.java    From dsl-devkit with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void navigateTo(final Position position) {
  super.navigateTo(position);
  waitUntilCursorIsOnPosition(position.line, position.column);
}
 
Example #21
Source File: XlfEditor.java    From translationstudio8 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * 在指定字符串之前输入内容
 * @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);
}
 
Example #22
Source File: XlfEditor.java    From translationstudio8 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * 在指定字符串之后输入内容
 * @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);
}
 
Example #23
Source File: XlfEditor.java    From tmxeditor8 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * 在指定字符串之前输入内容
 * @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);
}
 
Example #24
Source File: XlfEditor.java    From tmxeditor8 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * 在指定字符串之后输入内容
 * @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);
}