Search in sources :

Example 6 with InformationDialog

use of net.heartsome.cat.ts.test.ui.msgdialogs.InformationDialog 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)

Example 7 with InformationDialog

use of net.heartsome.cat.ts.test.ui.msgdialogs.InformationDialog in project translationstudio8 by heartsome.

the class MemoryDBManagement method checkMsg.

/**
	 * 判断返回结果,并进行处理,
	 * @param isSave true 表示是保存连接操作,不需要考虑连接错误的; false 表示是查询连接操作。
	 * @param isFromImportDb true 表示是从导入记忆库界面打开的,数据库已经确保是对的,不用检查expectedConnect。
	 * @return true 表示需要保存连接   false 表示不需要保存连接,只对保存连接调用时起作用,查询连接调用此方法无需理会此返回值
	 */
public boolean checkMsg(boolean isSave) {
    if (isFromImportDb) {
        return true;
    }
    if (expectedConnect.equals(TsUIConstants.ExpectedResult.SUCCESS)) {
        assertTrue(HSBot.bot().activeShell().getText().equals(dialog.getText()));
        return true;
    } else {
        InformationDialog msgDlg = null;
        // 如果是保存操作,且返回值是连接错误,此时不用弹出提示框,直接返回true
        if (isSave && expectedConnect == TsUIConstants.ExpectedResult.CONNECTION_ERROR) {
            return true;
        } else {
            assertTrue(HSBot.bot().shells().length == 3);
        }
        switch(expectedConnect) {
            case SUCCESS:
                {
                    break;
                }
            case NO_SERVER:
                {
                    msgDlg = new InformationDialog(InformationDialog.dlgTitleErrorInfo, InformationDialog.msgServerIsRequired);
                    break;
                }
            case NO_PORT:
                {
                    msgDlg = new InformationDialog(InformationDialog.dlgTitleErrorInfo, InformationDialog.msgPortIsRequired);
                    break;
                }
            case NO_INSTANCE:
                {
                    msgDlg = new InformationDialog(InformationDialog.dlgTitleErrorInfo, InformationDialog.msgInstanceIsRequired);
                    break;
                }
            case NO_PATH:
                {
                    msgDlg = new InformationDialog(InformationDialog.dlgTitleErrorInfo, InformationDialog.msgPathIsRequired);
                    break;
                }
            case NO_USERNAME:
                {
                    msgDlg = new InformationDialog(InformationDialog.dlgTitleErrorInfo, InformationDialog.msgUsernameIsRequired);
                    break;
                }
            case CONNECTION_ERROR:
                {
                    msgDlg = new InformationDialog(InformationDialog.dlgTitleTips, InformationDialog.msgServerConnectionError);
                    break;
                }
            default:
                {
                    assertTrue("参数错误,无此预期结果:" + expectedConnect, false);
                }
        }
        assertTrue(msgDlg.lblMessage().isVisible());
        msgDlg.btnOK().click();
        Waits.shellClosed(msgDlg);
        return false;
    }
}
Also used : InformationDialog(net.heartsome.cat.ts.test.ui.msgdialogs.InformationDialog)

Example 8 with InformationDialog

use of net.heartsome.cat.ts.test.ui.msgdialogs.InformationDialog in project translationstudio8 by heartsome.

the class ProjectSetting method setTBDB.

/**
	 * 设置术语库
	 * @param from
	 *            功能入口,请使用 TSUIConstants 类提供的常量;
	 * @param nextAction
	 *            下一步操作,请使用本类提供的常量;
	 */
public void setTBDB(Entry from, NextAction nextAction) {
    if (dlgPrjSetting == null) {
        openPrjSettingDlg(from);
    }
    dlgPrjSetting.treiTbSetting().select();
    if (!dlgPrjSetting.table().containsTextInColumn(tBDBName, dlgPrjSetting.tblColName())) {
        if (isTBDBExist) {
            dlgPrjSetting.btnAdd().click();
            DBManagement dbMgmt = new DBManagement(row);
            dbMgmt.selectDB(tBDBName);
        } else {
            dlgPrjSetting.btnCreate().click();
        // TODO 同上
        }
        try {
            InformationDialog dlgInfo = new InformationDialog(InformationDialog.dlgTitleTips, InformationDialog.msgNoMatchInDB);
            dlgInfo.btnOK().click();
            Waits.shellClosed(dlgInfo);
        } catch (WidgetNotFoundException e) {
            e.printStackTrace();
        }
        assertTrue("未正确选择术语库:" + tBDBName, dlgPrjSetting.table().containsTextInColumn(tBDBName, dlgPrjSetting.tblColName()));
    }
    nextAction(nextAction);
}
Also used : WidgetNotFoundException(org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException) InformationDialog(net.heartsome.cat.ts.test.ui.msgdialogs.InformationDialog) DBManagement(net.heartsome.cat.ts.test.basecase.menu.db.DBManagement)

Aggregations

InformationDialog (net.heartsome.cat.ts.test.ui.msgdialogs.InformationDialog)8 XliffUtil (net.heartsome.cat.ts.test.ui.utils.XliffUtil)3 DBManagement (net.heartsome.cat.ts.test.basecase.menu.db.DBManagement)2 HsSWTBotStyledText (net.heartsome.test.swtbot.widgets.HsSWTBotStyledText)2 WidgetNotFoundException (org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException)2 SWTBotNatTable (net.heartsome.test.swtbot.widgets.SWTBotNatTable)1 Position (org.eclipse.swtbot.swt.finder.utils.Position)1