Search in sources :

Example 6 with XliffUtil

use of net.heartsome.cat.ts.test.ui.utils.XliffUtil in project translationstudio8 by heartsome.

the class XlfEditor method tuidOfSelectedSeg.

/**
	 * @return String 当前选中的文本段的 trans-unit id
	 */
public String tuidOfSelectedSeg() {
    String rowID = rowIdOfSelectedSeg();
    XliffUtil xu = new XliffUtil(rowID);
    return xu.getAttributeOfTU("id");
}
Also used : XliffUtil(net.heartsome.cat.ts.test.ui.utils.XliffUtil)

Example 7 with XliffUtil

use of net.heartsome.cat.ts.test.ui.utils.XliffUtil in project translationstudio8 by heartsome.

the class XlfEditor method tuidOfSegNum.

/**
	 * @param segNum
	 *            文本段序号,合并、分割文本段和排序后应重新获取
	 * @return String 文本段的 trans-unit id
	 */
public String tuidOfSegNum(int segNum) {
    String rowID = rowIdOfSegNum(segNum);
    XliffUtil xu = new XliffUtil(rowID);
    return xu.getAttributeOfTU("id");
}
Also used : XliffUtil(net.heartsome.cat.ts.test.ui.utils.XliffUtil)

Example 8 with XliffUtil

use of net.heartsome.cat.ts.test.ui.utils.XliffUtil in project translationstudio8 by heartsome.

the class TestDemos method TestFile.

@Ignore
@Test
public void TestFile() {
    String fileName = "HSCAT8-83.xlf";
    ProjectTreeItem pTN = ProjectTreeItem.getInstance(prjName);
    pTN.ctxMenuOpenFile(fileName);
    TS ts = TS.getInstance();
    XlfEditor xe = ts.getXlfEditor(fileName);
    int segNum = 2;
    xe.gotoSeg(segNum);
    String rowID = xe.rowIdOfSegNum(segNum);
    XliffUtil xu = new XliffUtil(rowID);
    assertTrue(!xu.tuIsApproved());
    xe.clickContextMenu(xe.ctxMenuApproveStatus(), xe.ctxMenuapproveStatusApproveCurrentSeg());
    xu = new XliffUtil(rowID);
    assertTrue(xu.tuIsApproved());
}
Also used : XliffUtil(net.heartsome.cat.ts.test.ui.utils.XliffUtil) ProjectTreeItem(net.heartsome.cat.ts.test.ui.views.ProjectTreeItem) XlfEditor(net.heartsome.cat.ts.test.ui.editors.XlfEditor) TS(net.heartsome.cat.ts.test.ui.dialogs.TS) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 9 with XliffUtil

use of net.heartsome.cat.ts.test.ui.utils.XliffUtil in project translationstudio8 by heartsome.

the class SplitSegment method splitAt.

/**
	 * 在指定文本段的 index 处分割文本段
	 * @param xe
	 * @param segNum
	 * @param splitIndex
	 */
public static void splitAt(XlfEditor xe, int segNum, int splitIndex) {
    // 判断该文本段是否可编辑
    String rowID = xe.rowIdOfSegNum(segNum);
    XliffUtil xu = new XliffUtil(rowID);
    SegmentAsserts.segIsEditable(xu);
    // 进入编辑模式,方便读取样式文本框中的内容
    xe.enterEditModeSource(segNum);
    // 在实际进行分割文本段之前,得到原文本段的 tuid 和分割后两个文本段的预期内容,
    // 用以在分割后验证得到的文本段内容是否符合预期。
    String tuid = xe.tuidOfSegNum(segNum);
    // 判断给定的分割点是否可分割,然后在两个分支中分别验证结果
    HsSWTBotStyledText st = xe.getStyledText();
    if (SegmentAsserts.indexIsSplitable(st, splitIndex)) {
        String[] expectedText = st.splitTextAt(splitIndex);
        // 将光标移到指定位置,并点击相应的菜单项进行分割
        xe.navigateToIndex(splitIndex);
        ts.menuTranslationSplitSegment().click();
        xe.getNatTable();
        // 确认文本段已按预期分割
        SegmentAsserts.segIsSplit(tuid, expectedText, xe.getSplitXliffUtil(expectedText));
        System.out.println("[Passed] Segment No.\"" + segNum + "\" was successfully split at Index \"" + splitIndex + "\".");
    } else {
        String expectedText = st.getText();
        String position;
        // 将光标移到指定位置,并点击相应的菜单项进行分割
        if (splitIndex <= 0) {
            position = "Beginning.";
            xe.navigateToBegining();
        } else {
            position = "End.";
            xe.navigateToEnd();
        }
        ts.menuTranslationSplitSegment().click();
        // 弹出提示信息
        InformationDialog dialog = new InformationDialog(1, TsUIConstants.getString("msgPlaceCursorToSplit"));
        dialog.lblMessage().isVisible();
        dialog.btnOK().click();
        xe.getNatTable();
        // 确认文本段没有被分割
        SegmentAsserts.segNotSplit(tuid, expectedText, xu);
        System.out.println("[Passed] Segment No.\"" + segNum + "\" was not split at the " + position);
    }
}
Also used : XliffUtil(net.heartsome.cat.ts.test.ui.utils.XliffUtil) InformationDialog(net.heartsome.cat.ts.test.ui.msgdialogs.InformationDialog) HsSWTBotStyledText(net.heartsome.test.swtbot.widgets.HsSWTBotStyledText)

Aggregations

XliffUtil (net.heartsome.cat.ts.test.ui.utils.XliffUtil)9 InformationDialog (net.heartsome.cat.ts.test.ui.msgdialogs.InformationDialog)3 HsSWTBotStyledText (net.heartsome.test.swtbot.widgets.HsSWTBotStyledText)2 TS (net.heartsome.cat.ts.test.ui.dialogs.TS)1 XlfEditor (net.heartsome.cat.ts.test.ui.editors.XlfEditor)1 ProjectTreeItem (net.heartsome.cat.ts.test.ui.views.ProjectTreeItem)1 SWTBotNatTable (net.heartsome.test.swtbot.widgets.SWTBotNatTable)1 Position (org.eclipse.swtbot.swt.finder.utils.Position)1 Ignore (org.junit.Ignore)1 Test (org.junit.Test)1