Search in sources :

Example 1 with IsEditorOpened

use of net.heartsome.test.swtbot.waits.IsEditorOpened in project translationstudio8 by heartsome.

the class OpenFileDialog method openFile.

/**
	 * 在打开文件对话框中输入指定文件名称或路径
	 * @param filePath
	 *            要打开的文件名称或路径
	 * @param isValid
	 *            是否为有效文件名称或路径
	 * @param isFile
	 *            true 表示输入的是文件名称,false 表示文件路径
	 */
public static void openFile(String filePath, boolean isValid, boolean isFile) {
    // typePath 方法处理了多种操作系统的情况
    OsUtil.typePath(filePath);
    // 从路径中取出文件名
    String fileName = new Path(filePath).lastSegment();
    if (isValid) {
        // 确认编辑器成功打开
        HsSWTWorkbenchBot bot = HSBot.bot();
        final SWTBotEditor editor = bot.editorByTitle(fileName);
        bot.waitUntil(new IsEditorOpened(editor));
    } else {
        if (isFile) {
            // 弹出信息对话框
            InfoFileNotFound fnf = new InfoFileNotFound(filePath);
            // 文件未找到
            fnf.msgFileNotFound().isVisible();
            fnf.btnOK().click();
        } else {
            try {
                // 在系统对话框的信息提示框上点确认
                OsUtil.typeEnter();
                // 按 Esc 取消打开文件
                OsUtil.typeEsc();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}
Also used : Path(org.eclipse.core.runtime.Path) SWTBotEditor(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor) InfoFileNotFound(net.heartsome.cat.ts.test.ui.msgdialogs.InfoFileNotFound) IsEditorOpened(net.heartsome.test.swtbot.waits.IsEditorOpened) HsSWTWorkbenchBot(net.heartsome.test.swtbot.finders.HsSWTWorkbenchBot)

Example 2 with IsEditorOpened

use of net.heartsome.test.swtbot.waits.IsEditorOpened in project translationstudio8 by heartsome.

the class ProjectTreeView method doubleClickXlfFile.

/* ****** 鼠标双击功能 ****** */
/**
	 * 双击打开 XLIFF 文件
	 * @param prjName
	 *            XLIFF 文件所在的项目名称
	 * @param xlfFileName
	 *            要打开的 XLIFF 文件名称
	 */
public static void doubleClickXlfFile(String prjName, final String xlfFileName) {
    getTree().expandNode(prjName).expandNode("XLIFF").expandNode(xlfFileName).doubleClick();
    // 确认文件被打开
    SWTBotEditor editor = HSBot.bot().editorByTitle(xlfFileName);
    HSBot.bot().waitUntil(new IsEditorOpened(editor));
}
Also used : SWTBotEditor(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor) IsEditorOpened(net.heartsome.test.swtbot.waits.IsEditorOpened)

Example 3 with IsEditorOpened

use of net.heartsome.test.swtbot.waits.IsEditorOpened in project translationstudio8 by heartsome.

the class ProjectTreeItem method ctxMenuOpenFile.

/**
	 * 打开当前项目中的一个 XLIFF 文件
	 * @param xlfFileName
	 *            要打开的 XLIFF 文件名称
	 */
public void ctxMenuOpenFile(final String xlfFileName) {
    selectFile("XLIFF", xlfFileName);
    SWTBotMenu openFiles = ptv.ctxMenuOpenFile();
    openFiles.isEnabled();
    openFiles.click();
    SWTBotEditor editor = HSBot.bot().editorByTitle(xlfFileName);
    HSBot.bot().waitUntil(new IsEditorOpened(editor));
}
Also used : SWTBotEditor(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor) IsEditorOpened(net.heartsome.test.swtbot.waits.IsEditorOpened) SWTBotMenu(org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu)

Example 4 with IsEditorOpened

use of net.heartsome.test.swtbot.waits.IsEditorOpened in project translationstudio8 by heartsome.

the class ProjectTreeItem method ctxMenuOpenProjectFiles.

/**
	 * 合并打开当前项目中的所有 XLIFF
	 */
public void ctxMenuOpenProjectFiles() {
    ptn.select();
    SWTBotMenu openProjectFiles = ptv.ctxMenuOpenProjectFiles();
    // 确认右键菜单中的打开项目功能可用
    openProjectFiles.isEnabled();
    // 点击该菜单项
    openProjectFiles.click();
    // 确认文件被成功打开
    SWTBotEditor editor = HSBot.bot().editorByTitle(prjName);
    HSBot.bot().waitUntil(new IsEditorOpened(editor));
}
Also used : SWTBotEditor(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor) IsEditorOpened(net.heartsome.test.swtbot.waits.IsEditorOpened) SWTBotMenu(org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu)

Aggregations

IsEditorOpened (net.heartsome.test.swtbot.waits.IsEditorOpened)4 SWTBotEditor (org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor)4 SWTBotMenu (org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu)2 InfoFileNotFound (net.heartsome.cat.ts.test.ui.msgdialogs.InfoFileNotFound)1 HsSWTWorkbenchBot (net.heartsome.test.swtbot.finders.HsSWTWorkbenchBot)1 Path (org.eclipse.core.runtime.Path)1