Java 类org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor 实例源码

项目:mesfavoris    文件:JavaEditorBookmarkPropertiesProviderTest.java   
private SWTBotEclipseEditor textEditor(String fullyQualifiedType) throws JavaModelException, PartInitException {
    IType type = javaProject.findType(fullyQualifiedType);

    IEditorPart editorPart = UIThreadRunnable.syncExec(new Result<IEditorPart>() {

        public IEditorPart run() {
            try {
                return JavaUI.openInEditor(type, true, true);
            } catch (PartInitException | JavaModelException e) {
                throw new RuntimeException(e);
            }
        }

    });

    // IEditorPart editorPart = JavaUI.openInEditor(type, true, true);
    SWTBotEditor editor = bot.editorById(editorPart.getEditorSite().getId());
    return editor.toTextEditor();
}
项目:tlaplus    文件:PDFHandlerThreadingTest.java   
@Test @Ignore("not ready yet")
public void producePDFInNonUIThread() throws InterruptedException {

    // Open specA 
    SWTBotMenu fileMenu = bot.menu("File");
    SWTBotMenu openSpecMenu = fileMenu.menu("Open Spec");
    SWTBotMenu addNewSpecMenu = openSpecMenu.menu("Add New Spec...");
    addNewSpecMenu.click();

    bot.textWithLabel("Root-module file:").setText(specA);
    bot.button("Finish").click();

    // generate PDF
    SWTBotMenu pdfMenu = fileMenu.menu("Produce PDF Version");
    pdfMenu.click();

    // wait for the browser to show up with the generated PDF
    SWTBotEditor swtBotEditor = bot.editorById(OpenSpecHandler.TLA_EDITOR);
    Assert.assertNotNull(swtBotEditor);

    assertNoBackendCodeInUIThread();
}
项目:dsl-devkit    文件:SwtWorkbenchBot.java   
/**
 * Checks if a {@link SWTBotEditor} with the given title exists.
 *
 * @param editorTitle
 *          the title of the editor
 * @return {@code true} if the editor was found open, {@code false} otherwise
 */
public boolean hasEditor(final String editorTitle) {
  for (SWTBotEditor editor : editors()) {
    if (editor.getTitle().equals(editorTitle)) {
      return true;
    }
  }
  return false;
}
项目:dsl-devkit    文件:SwtWorkbenchBot.java   
/**
 * Checks if a {@link SWTBotEditor} is available.
 *
 * @param swtBotEditor
 *          the {@link SWTBotEditor}
 * @return {@code true} if the editor was found open, {@code false} otherwise
 */
public boolean hasEditor(final SWTBotEditor swtBotEditor) {
  for (SWTBotEditor editor : editors()) {
    if (editor.getReference().equals(swtBotEditor.getReference())) {
      return true;
    }
  }
  return false;
}
项目:dsl-devkit    文件:SwtWorkbenchBot.java   
/**
 * Checks if an active {@link SWTBotEditor} is available.
 *
 * @return {@code true} if an active editor was found, {@code false} otherwise
 */
public boolean hasActiveEditor() {
  for (SWTBotEditor editor : editors()) {
    if (editor.isActive()) {
      return true;
    }
  }
  return false;
}
项目:dsl-devkit    文件:FixedDefaultWorkbench.java   
/**
 * Save all editors.
 *
 * @return the fixed default workbench
 */
FixedDefaultWorkbench saveAllEditors() {
  List<? extends SWTBotEditor> editors = bot.editors();
  for (SWTBotEditor editor : editors) {
    editor.save();
  }
  return this;
}
项目:dsl-devkit    文件:FixedDefaultWorkbench.java   
/**
 * Close all editors.
 *
 * @return the fixed default workbench
 */
FixedDefaultWorkbench closeAllEditors() {
  List<? extends SWTBotEditor> editors = bot.editors();
  for (SWTBotEditor editor : editors) {
    editor.close();
  }
  return this;
}
项目:dsl-devkit    文件:AbstractXtextUiTest.java   
@Override
protected void beforeAllTests() {
  super.beforeAllTests();
  initializeSWTBot();
  getBot().closeWelcomePage();
  getBot().resetActivePerspective();
  IEditorPart editor = openEditor(getTestSource().getUri(), true);
  SWTBotEditor swtBotEditor = getBot().editorByTitle(editor.getTitle());
  getTestInformation().putTestObject(SWTBotEclipseEditor.class, new AcfSwtBotEclipseEditor(swtBotEditor.getReference(), getBot()));
}
项目:dsl-devkit    文件:AbstractUiTest.java   
/**
 * @param editorId
 *          the editor id
 * @return true if the editor being tested is open, false otherwise
 */
protected boolean isEditorOpen(final String editorId) {
  for (SWTBotEditor e : getBot().editors()) {
    if (e.getReference().getId().equals(editorId)) {
      return true;
    }
  }
  return false;
}
项目:tlaplus    文件:CloneModelTest.java   
@Before
public void setUp() throws Exception {
    super.setUp();

    // create a dummy spec "ToBeRenamedSpec"
    SWTBotMenu fileMenu = bot.menu("File");
    SWTBotMenu openSpecMenu = fileMenu.menu("Open Spec");
    SWTBotMenu addNewSpecMenu = openSpecMenu.menu("Add New Spec...");
    addNewSpecMenu.click();

    String path = System.getProperty("java.io.tmpdir") + File.separator + "RSHTest"
            + System.currentTimeMillis();
    path += File.separator + TEST_SPEC + TLA_SUFFIX;

    bot.textWithLabel("Root-module file:").setText(path);
    bot.button("Finish").click();

    final String specName = getSpecName(new File(path));
    bot.waitUntil(Conditions.waitForMenu(bot.activeShell(), WithText.<MenuItem> withText(specName)));

    // create a new dummy model
    final SWTBotMenu modelMenu = bot.menu("TLC Model Checker");
    final SWTBotMenu newModelMenu = modelMenu.menu("New Model...");
    newModelMenu.click();
    bot.button("OK").click();
    bot.waitUntil(new ModelEditorOpenCondition(TEST_MODEL));

    // save and close model editor
    SWTBotEditor activeEditor = bot.activeEditor();
    activeEditor.saveAndClose();

    checkSpecAndModelExistenceAPI(TEST_SPEC);
}
项目:tlaplus    文件:RenameSpecHandlerTest.java   
@Before
public void setUp() throws Exception {
    super.setUp();

    // create a dummy spec "ToBeRenamedSpec"
    SWTBotMenu fileMenu = bot.menu("File");
    SWTBotMenu openSpecMenu = fileMenu.menu("Open Spec");
    SWTBotMenu addNewSpecMenu = openSpecMenu.menu("Add New Spec...");
    addNewSpecMenu.click();

    String path = System.getProperty("java.io.tmpdir") + File.separator + "RSHTest"
            + System.currentTimeMillis();
    path += File.separator + TEST_SPEC + TLA_SUFFIX;

    bot.textWithLabel("Root-module file:").setText(path);
    bot.button("Finish").click();

    final String specName = getSpecName(new File(path));
    bot.waitUntil(Conditions.waitForMenu(bot.activeShell(), WithText.<MenuItem> withText(specName)));

    // create a new dummy model
    final SWTBotMenu modelMenu = bot.menu("TLC Model Checker");
    final SWTBotMenu newModelMenu = modelMenu.menu("New Model...");
    newModelMenu.click();
    bot.button("OK").click();
    bot.waitUntil(new ModelEditorOpenCondition(TEST_MODEL));

    // save and close model editor
    SWTBotEditor activeEditor = bot.activeEditor();
    activeEditor.saveAndClose();

    checkSpecAndModelExistenceAPI(TEST_SPEC);
}
项目:translationstudio8    文件:ProjectTreeItem.java   
/**
 * 合并打开当前项目中的所有 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));
}
项目:translationstudio8    文件:ProjectTreeItem.java   
/**
 * 打开当前项目中的一个 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));
}
项目:translationstudio8    文件:OpenFileDialog.java   
/**
 * 在打开文件对话框中输入指定文件名称或路径
 * @param filePath
 *            要打开的文件名称或路径
 * @param isValid
 *            是否为有效文件名称或路径
 * @param isFile
 *            true 表示输入的是文件名称,false 表示文件路径
 */
public static void openFile(String filePath, boolean isValid, boolean isFile) {
    OsUtil.typePath(filePath); // typePath 方法处理了多种操作系统的情况

    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(); // 在系统对话框的信息提示框上点确认
                OsUtil.typeEsc(); // 按 Esc 取消打开文件
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}
项目:translationstudio8    文件:TS.java   
/**
 * 激活或打开编辑器,仅限合并打开的指定项目中的 XLIFF 文件
 * 
 * @param prjName
 *            要打开的项目名称
 */
public void setCurrentFile(String prjName) {
    SWTBotEditor editor = bot.editorByTitle(prjName);
    if (editor != null) {
        editor.show();
    } else {
        ProjectTreeItem.getInstance(prjName).ctxMenuOpenProjectFiles();
    }
    // TODO: 需要完善对同名编辑器的判断和处理
}
项目:translationstudio8    文件:TS.java   
/**
 * 激活或打开编辑器,仅限项目 XLIFF 目录中的 XLIFF 文件
 * 
 * @param prjName
 *            XLIFF 文件所在的项目名称
 * @param xlfFileName
 *            要打开的 XLIFF 文件名称
 */
public void setCurrentFile(String prjName, String xlfFileName) {
    SWTBotEditor editor = bot.editorByTitle(xlfFileName);
    if (editor != null) {
        editor.show();
    } else {
        ProjectTreeView.doubleClickXlfFile(prjName, xlfFileName);
    }
    // TODO: 需要完善对同名编辑器的判断和处理
}
项目:DevStudioUITestAutomation    文件:DashBoardCreation.java   
/**
 * @param bot
 * @return
 */
public static boolean openDashBoard(SWTWorkbenchBot bot) {
    bot.menu(Properties.MENU_ITEM_DEVELOPER_STUDIO)
            .menu(Properties.MENU_ITEM_OPEN_DASHBOARD).click();
    bot.cTabItem(Properties.CTAB_ITEM_DEVELOPER_STUDIO_DASHBOARD)
            .activate();
    SWTBotEditor dashBoardEditor = bot.activeEditor();
    dashBoardEditor.setFocus();

    if (dashBoardEditor.getTitle().contentEquals(Properties.VIEW_DASHBOARD)) {
        return true;
    }

    return false;
}
项目:tmxeditor8    文件:ProjectTreeItem.java   
/**
 * 合并打开当前项目中的所有 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));
}
项目:tmxeditor8    文件:ProjectTreeItem.java   
/**
 * 打开当前项目中的一个 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));
}
项目:tmxeditor8    文件:OpenFileDialog.java   
/**
 * 在打开文件对话框中输入指定文件名称或路径
 * @param filePath
 *            要打开的文件名称或路径
 * @param isValid
 *            是否为有效文件名称或路径
 * @param isFile
 *            true 表示输入的是文件名称,false 表示文件路径
 */
public static void openFile(String filePath, boolean isValid, boolean isFile) {
    OsUtil.typePath(filePath); // typePath 方法处理了多种操作系统的情况

    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(); // 在系统对话框的信息提示框上点确认
                OsUtil.typeEsc(); // 按 Esc 取消打开文件
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}
项目:tmxeditor8    文件:TS.java   
/**
 * 激活或打开编辑器,仅限合并打开的指定项目中的 XLIFF 文件
 * 
 * @param prjName
 *            要打开的项目名称
 */
public void setCurrentFile(String prjName) {
    SWTBotEditor editor = bot.editorByTitle(prjName);
    if (editor != null) {
        editor.show();
    } else {
        ProjectTreeItem.getInstance(prjName).ctxMenuOpenProjectFiles();
    }
    // TODO: 需要完善对同名编辑器的判断和处理
}
项目:tmxeditor8    文件:TS.java   
/**
 * 激活或打开编辑器,仅限项目 XLIFF 目录中的 XLIFF 文件
 * 
 * @param prjName
 *            XLIFF 文件所在的项目名称
 * @param xlfFileName
 *            要打开的 XLIFF 文件名称
 */
public void setCurrentFile(String prjName, String xlfFileName) {
    SWTBotEditor editor = bot.editorByTitle(xlfFileName);
    if (editor != null) {
        editor.show();
    } else {
        ProjectTreeView.doubleClickXlfFile(prjName, xlfFileName);
    }
    // TODO: 需要完善对同名编辑器的判断和处理
}
项目:packtpub-xtext-book-examples    文件:SmallJavaProjectWizardTests.java   
@Test
public void testDuplicateClassError() throws CoreException {
    createProjectAndAssertNoErrorMarker("SmallJava Project", TEST_PROJECT);
    SWTBotEditor editor = bot.editorByTitle("example.smalljava");
    editor.toTextEditor().setText(
            "package smalljava.lang;\nclass Object {}"
    );
    editor.save();
    waitForAutoBuild();
    assertErrorsInProject(1);
}
项目:translationstudio8    文件:XlfEditor.java   
/**
 * 按指定的编辑器对象创建
 * @param editor
 */
public XlfEditor(SWTBotEditor editor) {
    super(editor.getReference(), bot);
    getNatTable();
}
项目:tmxeditor8    文件:XlfEditor.java   
/**
 * 按指定的编辑器对象创建
 * @param editor
 */
public XlfEditor(SWTBotEditor editor) {
    super(editor.getReference(), bot);
    getNatTable();
}
项目:xsemantics    文件:XsemanticsWorkbenchBase.java   
protected SWTBotEditor setEditorContents(CharSequence text) {
    testEditor().toTextEditor().setText(text.toString());
    testEditor().save();
    return testEditor();
}
项目:xsemantics    文件:XsemanticsWorkbenchBase.java   
protected SWTBotEditor testEditor() {
    return bot.editorByTitle(TEST_FILE);
}
项目:translationstudio8    文件:ProjectTreeView.java   
/**
 * 双击打开 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));
}
项目:tmxeditor8    文件:ProjectTreeView.java   
/**
 * 双击打开 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));
}
项目:translationstudio8    文件:TS.java   
/**
 * 得到指定文件名所在的编辑器
 * 
 * @param fileName
 *            指定的文件名
 * @return XlfEditor 得到的编辑器
 */
public XlfEditor getXlfEditor(String fileName) {
    SWTBotEditor editor = bot.editorByTitle(fileName);
    editor.show();
    return new XlfEditor(editor);
}
项目:tmxeditor8    文件:TS.java   
/**
 * 得到指定文件名所在的编辑器
 * 
 * @param fileName
 *            指定的文件名
 * @return XlfEditor 得到的编辑器
 */
public XlfEditor getXlfEditor(String fileName) {
    SWTBotEditor editor = bot.editorByTitle(fileName);
    editor.show();
    return new XlfEditor(editor);
}