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

项目:gw4e.project    文件:GW4EProject.java   
public void removeNature() {
    SWTBotTree tree = setupTreeForMenu(this.projectName);
    SWTBotMenu menu = new SWTBotMenu(
            ContextMenuHelper.contextMenu(tree, new String[] { "GW4E", "Remove GW4E Nature" }));
    menu.click();

    bot.waitUntil(new DefaultCondition() {
        @Override
        public boolean test() throws Exception {
            boolean b = ClasspathManager
                    .hasGW4EClassPathContainer(ResourceManager.getProject(projectName));
            return !b;
        }

        @Override
        public String getFailureMessage() {
            return "GW4E ClassPath Container not removed";
        }
    });
}
项目:gw4e.project    文件:GW4EProject.java   
public void assertMenuEnabled(String[] menus, boolean[] states, String... nodes) {
    SWTBotTree tree = setupTreeForMenu(nodes);

    SWTBotMenu menu = new SWTBotMenu(ContextMenuHelper.contextMenu(tree, menus[0]));
    assertEquals("Invalid state ", states[0], menu.isEnabled());

    String[] submenus = new String[menus.length - 1];
    System.arraycopy(menus, 1, submenus, 0, menus.length - 1);
    boolean[] substates = new boolean[states.length - 1];
    System.arraycopy(states, 1, substates, 0, states.length - 1);
    for (int i = 0; i < submenus.length; i++) {
        String submenu = submenus[i];
        SWTBotMenu sm = menu.contextMenu(submenu);
        assertEquals("Invalid state ", substates[i], sm.isEnabled());
    }
}
项目:gw4e.project    文件:GW4EProject.java   
public void convertExistingProject() throws CoreException {
    SWTBotTree tree = getProjectTree();
    SWTBotTreeItem item = tree.expandNode(this.projectName);
    item.setFocus();
    item.select();
    SWTBotMenu menu = item.contextMenu("Configure").contextMenu("Convert to GW4E");
    menu.click();
    bot.waitUntil(new DefaultCondition() {
        @Override
        public boolean test() throws Exception {
            boolean b = GW4ENature
                    .hasGW4ENature(ResourceManager.getProject(projectName));
            return b;
        }

        @Override
        public String getFailureMessage() {
            return "GraphWalker has not GraphWalker Nature ";
        }
    });
    cleanBuild();
}
项目:gw4e.project    文件:GW4EProject.java   
private ConvertDialog prepareConvertTo(String project, String packageRootFragment, String pkg,
        String targetFilename, String targetFormat, String... nodes) {
    SWTBotTree tree = getProjectTree();
    SWTBotTreeItem item = tree.expandNode(nodes);
    item.select();
    item.setFocus();

    SWTBotMenu menu = item.contextMenu("GW4E").contextMenu("Convert to...");
    menu.click();

    bot.waitUntil(Conditions.shellIsActive("GW4E Conversion File"));
    SWTBotShell shell = bot.shell("GW4E Conversion File");

    ConvertDialog cd = new ConvertDialog(shell);
    return cd;
}
项目:gw4e.project    文件:GW4EPerspective.java   
public static void openNewGraphWalkerModel(SWTWorkbenchBot bot) {

    SWTBotMenu all = bot.menu("File").menu("New");

    /*
    Function<String, String>   f =  new Function<String, String> () {

        @Override
        public String apply(String t) {
            return t;
        }

    };
    all.menuItems().stream().map(f);
    */

    bot.menu("File").menu("New").menu("GW4E Model").click();
    bot.waitUntil(new ShellActiveCondition("GW4E"));
    SWTBotShell shell = bot.shell("GW4E");
    assertTrue(shell.isOpen());
    shell.bot().button("Cancel").click();
    bot.waitUntil(Conditions.shellCloses(shell));
}
项目:gw4e.project    文件:ConsoleView.java   
private void init() {
    ICondition condition = new DefaultCondition () {
        @Override
        public boolean test() throws Exception {
            SWTBotMenu menu = bot.menu("Window");
            menu = menu.menu("Show View");
            menu = menu.menu("Console");
            menu.click();
            try {
                bot.waitUntil(new ViewOpened(ConsoleView.this.bot, "Console"), 3 * 1000);
            } catch (Exception e) {
                return false;
            }
            return true;
        }

        @Override
        public String getFailureMessage() {
            return "Cannot open Console view";
        }
    };
    bot.waitUntil(condition, TIMEOUT);
    botView = getBotView();
}
项目:google-cloud-eclipse    文件:SwtBotWorkbenchActions.java   
/**
 * Opens the preferences dialog from the main Eclipse window.
 * <p>
 * Note: There are some platform-specific intricacies that this abstracts
 * away.
 */
public static void openPreferencesDialog(final SWTWorkbenchBot bot) {
  SwtBotTestingUtilities.performAndWaitForWindowChange(bot, new Runnable() {
    @Override
    public void run() {
      if (SwtBotTestingUtilities.isMac()) {
        // TODO: Mac has "Preferences..." under the "Eclipse" menu item.
        // However,
        // the "Eclipse" menu item is a system menu item (like the Apple menu
        // item), and can't be reached via SWTBot.
        openPreferencesDialogViaEvents(bot);
      } else {
        SWTBotMenu windowMenu = bot.menu("Window");
        windowMenu.menu("Preferences").click();
      }
    }
  });
}
项目:google-cloud-eclipse    文件:SwtBotProjectActions.java   
/**
 * Creates a Java class with the specified name.
 *
 * @param projectName the name of the project the class should be created in
 * @param sourceFolder the name of the source folder in which the class should be created.
 *        Typically "src" for normal Java projects, or "src/main/java" for Maven projects
 * @param packageName the name of the package the class should be created in
 * @param className the name of the class to be created
 */
public static void createJavaClass(final SWTWorkbenchBot bot, String sourceFolder,
    String projectName,
    String packageName, final String className) {
  SWTBotTreeItem project = SwtBotProjectActions.selectProject(bot, projectName);
  selectProjectItem(project, sourceFolder, packageName).select();
  SwtBotTestingUtilities.performAndWaitForWindowChange(bot, new Runnable() {
    @Override
    public void run() {
      MenuItem menuItem = ContextMenuHelper.contextMenu(getProjectRootTree(bot), "New", "Class");
      new SWTBotMenu(menuItem).click();
    }
  });

  SwtBotTestingUtilities.performAndWaitForWindowChange(bot, new Runnable() {
    @Override
    public void run() {
      bot.activeShell();
      bot.textWithLabel("Name:").setText(className);
      SwtBotTestingUtilities.clickButtonAndWaitForWindowClose(bot, bot.button("Finish"));
    }
  });
}
项目: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();
}
项目:gwt-eclipse-plugin    文件:SwtBotWorkbenchActions.java   
/**
 * Opens the preferences dialog from the main Eclipse window.
 * <p>
 * Note: There are some platform-specific intricacies that this abstracts
 * away.
 */
public static void openPreferencesDialog(final SWTWorkbenchBot bot) {
  SwtBotUtils.performAndWaitForWindowChange(bot, new Runnable() {
    @Override
    public void run() {
      if (SwtBotUtils.isMac()) {
        // TODO: Mac has "Preferences..." under the "Eclipse" menu item.
        // However,
        // the "Eclipse" menu item is a system menu item (like the Apple menu
        // item), and can't be reached via SWTBot.
        openPreferencesDialogViaEvents(bot);
      } else {
        SWTBotMenu windowMenu = bot.menu("Window");
        windowMenu.menu("Preferences").click();
      }
    }
  });
}
项目:gwt-eclipse-plugin    文件:SwtBotProjectActions.java   
/**
 * Creates a java class with the specified name.
 *
 * @param bot The SWTWorkbenchBot.
 * @param projectName The name of the project the class should be created in.
 * @param packageName The name of the package the class should be created in.
 * @param className The name of the java class to be created.
 */
public static void createJavaClass(final SWTWorkbenchBot bot, String projectName,
    String packageName, final String className) {
  SWTBotTreeItem project = SwtBotProjectActions.selectProject(bot, projectName);
  selectProjectItem(project, SOURCE_FOLDER, packageName).select();
  SwtBotUtils.performAndWaitForWindowChange(bot, new Runnable() {
    @Override
    public void run() {
      MenuItem menuItem = ContextMenuHelper.contextMenu(getProjectRootTree(bot), "New", "Class");
      new SWTBotMenu(menuItem).click();
    }
  });

  SwtBotUtils.performAndWaitForWindowChange(bot, new Runnable() {
    @Override
    public void run() {
      bot.activeShell();
      bot.textWithLabel("Name:").setText(className);
      SwtBotUtils.clickButtonAndWaitForWindowChange(bot, bot.button("Finish"));
    }
  });
}
项目:gw4e.project    文件:GW4EProject.java   
public GraphModelProperties getGraphmlProperties(String folder, String pkg, String filename) {
    SWTBotTreeItem pti = getProjectTreeItem(this.projectName);
    pti.expand();

    SWTBotTreeItem fileItem = null;
    if (pkg == null) {
        fileItem = pti.expandNode(folder, filename);
    } else {
        fileItem = pti.expandNode(folder, pkg, filename);
    }

    bot.waitUntil(new isItemExpandedInTree(pti.getNode(folder)));

    fileItem.setFocus();
    fileItem.select();
    bot.waitUntil(new isItemSelectedInTree(fileItem));

    fileItem.click();

    bot.waitUntil(new isItemSelected(fileItem));

    SWTBotMenu fileMenu = bot.menu("File");
    fileMenu.menu("Properties").click();

    bot.waitUntil(Conditions.shellIsActive("Properties for " + filename));
    SWTBotShell shell = bot.shell("Properties for " + filename);
    GraphModelProperties gp = new GraphModelProperties(shell.bot(), this.projectName, folder, pkg, filename);

    return gp;
}
项目:gw4e.project    文件:GW4EProject.java   
public SWTBotMenu canGenerateSource(boolean enabled, String... nodes) {
    SWTBotTree tree = getProjectTree();
    SWTBotTreeItem item = tree.expandNode(nodes);
    item.setFocus();
    item.select();
    SWTBotMenu menu = item.contextMenu("GW4E").contextMenu("Generate Test and Interface");
    assertEquals("Invalid state ", enabled, menu.isEnabled());
    return menu;
}
项目:gw4e.project    文件:GW4EProject.java   
public void generateSource(String... nodes) {
    SWTBotTree tree = getProjectTree();
    SWTBotTreeItem item = tree.expandNode(nodes);
    item.setFocus();
    item.select();
    SWTBotMenu menu = item.contextMenu("GW4E").contextMenu("Generate Test and Interface");
    assertEquals("Invalid state ", true, menu.isEnabled());
    Display.getDefault().asyncExec(new Runnable() {
        @Override
        public void run() {
            menu.click();
        }
    });

}
项目:gw4e.project    文件:ModelRefactoring.java   
public void refactorModelName (String newName,String [] nodes) {
    SWTBotTree tree = getProjectTree();
    SWTBotTreeItem item = tree.expandNode(nodes);
    item.select();
    item.setFocus();

    SWTBotMenu menu = item.contextMenu("Refactor").contextMenu("Rename...");
    menu.click();

    bot.waitUntil(Conditions.shellIsActive("Rename Resource"));
    SWTBotShell shell = bot.shell("Rename Resource");

    SWTBotText text = shell.bot().textWithLabel("New name:");
    text.setText(newName);

    ICondition condition = new DefaultCondition () {
        @Override
        public boolean test() throws Exception {
            return shell.bot().button("OK").isEnabled();
        }

        @Override
        public String getFailureMessage() {
            return "OK button not enabled";
        }
    };

    bot.waitUntil(condition);

    shell.bot().button("OK").click();

    bot.waitUntil(Conditions.shellCloses(shell));
}
项目:gw4e.project    文件:ModelRefactoring.java   
public void refactorRenameFolder (String [] nodes, String name) {
    SWTBotTree tree = getProjectTree();
    SWTBotTreeItem item = tree.expandNode(nodes);
    item.select();
    item.setFocus();

    SWTBotMenu menu = item.contextMenu("Refactor").contextMenu("Rename...");
    menu.click();

    bot.waitUntil(Conditions.shellIsActive("Rename Package"));
    SWTBotShell shell = bot.shell("Rename Package");


    SWTBotText text = shell.bot().textWithLabel("New name:");
    text.setText(name);

    ICondition condition = new DefaultCondition () {
        @Override
        public boolean test() throws Exception {
            return shell.bot().button("OK").isEnabled();
        }

        @Override
        public String getFailureMessage() {
            return "OK button not enabled";
        }
    };

    bot.waitUntil(condition);

    shell.bot().button("OK").click();

    bot.waitUntil(Conditions.shellCloses(shell), 30 * 1000);
}
项目:gw4e.project    文件:ModelRefactoring.java   
public void refactorMoveModel (String [] nodes,String [] destination, String name) {
    SWTBotTree tree = getProjectTree();
    SWTBotTreeItem item = tree.expandNode(nodes);
    item.select();
    item.setFocus();

    SWTBotMenu menu = item.contextMenu("Refactor").contextMenu("Move...");
    menu.click();

    bot.waitUntil(Conditions.shellIsActive("Move"));
    SWTBotShell shell = bot.shell("Move");

    SWTBotTree packageTree = shell.bot().treeWithLabel("Choose destination for '"+ name + "':");
    SWTBotTreeItem target = packageTree.expandNode(destination);
    target.select();
    target.setFocus();

    ICondition condition = new DefaultCondition () {
        @Override
        public boolean test() throws Exception {
            return shell.bot().button("OK").isEnabled();
        }

        @Override
        public String getFailureMessage() {
            return "OK button not enabled";
        }
    };

    bot.waitUntil(condition);

    shell.bot().button("OK").click();

    bot.waitUntil(Conditions.shellCloses(shell));
}
项目:google-cloud-eclipse    文件:SwtBotProjectActions.java   
/**
 * Opens the Properties dialog for a given project.
 *
 * This method assumes that either the Package Explorer or Project Explorer view is visible.
 */
public static void openProjectProperties(final SWTWorkbenchBot bot, String projectName) {
  selectProject(bot, projectName);

  SwtBotTestingUtilities.performAndWaitForWindowChange(bot, new Runnable() {
    @Override
    public void run() {
      // Open the Project Properties menu via the File menu
      SWTBotMenu fileMenu = bot.menu("File");
      fileMenu.menu("Properties").click();
    }
  });
}
项目:dsl-devkit    文件:ContextActionUiTestUtil.java   
/**
 * Returns the {@link SWTBotMenu}s available on the given widget bot.
 *
 * @param widgetBot
 *          the bot representing the widget, whose {@link SWTBotMenu}s should be returned
 * @return the {@link SWTBotMenu}s on the given widget bot
 */
public static List<SWTBotMenu> getContextMenuItems(final AbstractSWTBot<? extends Control> widgetBot) {
  return UIThreadRunnable.syncExec(new Result<List<SWTBotMenu>>() {
    @Override
    public List<SWTBotMenu> run() {
      List<SWTBotMenu> menuItems = Lists.newArrayList();
      for (MenuItem menuItem : new ContextMenuFinder(widgetBot.widget).findMenus(widgetBot.widget.getShell(), WidgetMatcherFactory.widgetOfType(MenuItem.class), true)) {
        menuItems.add(new SWTBotMenu(menuItem));
      }
      return menuItems;
    }
  });
}
项目:dsl-devkit    文件:ContextActionUiTestUtil.java   
/**
 * Returns the disabled {@link SWTBotMenu}s on the given widget bot.
 *
 * @param widgetBot
 *          the bot representing the widget, whose disabled {@link SWTBotMenu}s should be returned
 * @return the disabled {@link SWTBotMenu}s on the given widget bot
 */
public static List<SWTBotMenu> getDisabledContextMenuItems(final AbstractSWTBot<? extends Control> widgetBot) {
  return UIThreadRunnable.syncExec(new Result<List<SWTBotMenu>>() {
    @Override
    public List<SWTBotMenu> run() {
      List<SWTBotMenu> disabledMenuItems = Lists.newArrayList();
      for (MenuItem menuItem : new ContextMenuFinder(widgetBot.widget).findMenus(widgetBot.widget.getShell(), WidgetMatcherFactory.widgetOfType(MenuItem.class), true)) {
        if (!menuItem.isEnabled()) {
          disabledMenuItems.add(new SWTBotMenu(menuItem));
        }
      }
      return disabledMenuItems;
    }
  });
}
项目:tlaplus    文件:HandlerThreadingTest.java   
/**
 * Adds a new spec to the toolbox, opens it and tests if parsing is done on
 * a non-UI thread
 * 
 * @see Bug #103 in general/bugzilla/index.html
 */
@Test
public void parseSpecInNonUIThread() {

    // 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(specB);
    bot.button("Finish").click();

    assertNoBackendCodeInUIThread();

    // Open specB
    addNewSpecMenu.click();

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

    assertNoBackendCodeInUIThread();

    final String specName = getSpecName(new File(specB));

    // increase timeout since farsite spec takes a long time to parse
    final long timeout = SWTBotPreferences.TIMEOUT * 4;

    // specs are created in non-UI thread asynchronously which causes a
    // delay before the menu entry becomes available
    bot.waitUntil(Conditions.waitForMenu(waitForToolboxShell(), WithText.<MenuItem> withText(specName)), timeout);

    // Go back to previous spec
    openSpecMenu.menu(specName);

    assertNoBackendCodeInUIThread();
}
项目: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    文件:CloneModelTest.java   
@Test
public void cloneModelMainMenu() {
    final SWTBotMenu modelMenu = bot.menu("TLC Model Checker");
    final SWTBotMenu cloneModelMenu = modelMenu.menu("Clone Model");
    final SWTBotMenu cloneModelSubMenu = cloneModelMenu.click();
    cloneModelSubMenu.menu(TEST_MODEL).click();

    bot.button("OK").click();
    bot.waitUntil(new ModelEditorOpenCondition(TEST_MODEL_RENAME));
}
项目: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);
}
项目:tlaplus    文件:RenameSpecHandlerTest.java   
private void openSpecExplorer() {
    SWTBotMenu windowMenu = bot.menu("Window");
    SWTBotMenu specExplorerMenu = windowMenu.menu(SPEC_EXPLORER);
    specExplorerMenu.click();

    // spec context menu
    SWTBotView packageExplorerView = bot.viewByTitle(SPEC_EXPLORER);
    packageExplorerView.setFocus();
}
项目:tlaplus    文件:AddSpecWizardTest.java   
/**
 * Test to make sure the "Add Spec" wizard does not accept invalid spec names
 */
@Test
public void doNotAcceptInvalidSpecNames() {

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

    // get a handle for the button before invoking the UI (widget not found exception otherwise)
    SWTBotButton button = bot.button("Finish");

    // create a valid path
    String path = System.getProperty("java.io.tmpdir");
    path += File.separator + "Invalid-Name.tla";

    // set an invalid spec name
    bot.textWithLabel("Root-module file:").setText(path);

    // check if the wizard can finish
    Assert.assertTrue(
            "Finish button must not be enabled with invalid spec name",
            !button.isEnabled());

    //TODO could change the wizard marker/error area for the correct string too
}
项目:scenarioo-example-swtbot-e4    文件:OrderOverviewContextMenuHandler.java   
private void clickContextMenuActionForTreeItem(final SWTBotTreeItem treeItem,
        final ContextMenuAction contextMenuAction) {
    SWTBotMenu botMenuAction = treeItem.contextMenu(contextMenuAction.getActionName());
    botMenuAction.click();
    closeContextMenu(botMenuAction);
    bot.sleep(500);
    LOGGER.info("menu action clicked and context menu closed for: " + treeItem.getText());
}
项目:scenarioo-example-swtbot-e4    文件:OrderOverviewContextMenuHandler.java   
private void closeContextMenu(final SWTBotMenu menu) {
    Display.getDefault().syncExec(new Runnable() {
        @Override
        public void run() {
            menu.widget.getParent().setVisible(false);
        }
    });
}
项目:scenarioo-example-swtbot-e4    文件:ScenariooTestWrapper.java   
protected void clickContextMenuActionForTreeItem(final SWTBotTree tree, final SWTBotTreeItem treeItem,
        final String actionName) {
    SWTBotMenu contextMenuAction = treeItem.contextMenu(actionName);
    contextMenuAction.click();
    closeContextMenu(contextMenuAction);
    bot.sleep(500);
}
项目:scenarioo-example-swtbot-e4    文件:ScenariooTestWrapper.java   
@Deprecated
protected void clickMenuEntryAndGenerateDocu(final SWTBotMenu menu, final PageName pageName) {
    menu.click();
    closeContextMenu(menu);
    bot.sleep(500);
    scenariooWriterHelper.writeStep(menu.getText() + "_menu_entry_clicked", pageName, screenshot());
}
项目:scenarioo-example-swtbot-e4    文件:ScenariooTestWrapper.java   
private void closeContextMenu(final SWTBotMenu menu) {
    Display.getDefault().syncExec(new Runnable() {
        @Override
        public void run() {
            menu.widget.getParent().setVisible(false);
        }
    });
}
项目:scenarioo-example-swtbot-e4    文件:ScenariooTestWrapper.java   
/**
 * 
 * @param tree
 * @param orderNumber
 * @param actionName
 * @return SWTBotMenu
 */
@Deprecated
protected SWTBotMenu getContextMenuAndGenerateDocu(final SWTBotTree tree, final String orderNumber,
        final String actionName) {

    final SWTBotTreeItem treeItem = tree.getTreeItem(orderNumber);
    return getContextMenuAndGenerateDocu(tree, treeItem, actionName);
}
项目:scenarioo-example-swtbot-e4    文件:ScenariooTestWrapper.java   
/**
 * 
 * @param tree
 * @param treeItem
 * @param actionName
 * @return SWTBotMenu
 */
protected SWTBotMenu getContextMenuAndGenerateDocu(final SWTBotTree tree, final SWTBotTreeItem treeItem,
        final String actionName) {

    openContextMenuForTreeItem(tree, treeItem);
    final SWTBotMenu menuAction = treeItem.contextMenu(actionName);

    scenariooWriterHelper.writeStep("context_menu_opened", PageName.ORDER_OVERVIEW, screenshot());
    return menuAction;
}
项目:scenarioo-example-swtbot-e4    文件:DeleteOrderRule.java   
private void deleteOrderWithGivenNumber() {
    LOGGER.info("\n\nDelete order rule started.\n\n");
    SWTBotMenu deleteOrder = bot.tree().getTreeItem(orderNumber).contextMenu("Delete Order");
    deleteOrder.click();
    LOGGER.info("\n"
            + "-----------------------------------------------------------------\n"
            + "Delete order rule finished: order " + orderNumber + " deleted.\n"
            + "-----------------------------------------------------------------\n\n");
}
项目:scenarioo-example-swtbot-e4    文件:ExitHandlerTest.java   
@Test
public void executeExit() {
    // testing on hard-coded String just to have
    // a simple example

    SWTBotMenu fileMenu = bot.menu("File");
    Assert.assertNotNull(fileMenu);
    SWTBotMenu exitMenu = fileMenu.menu("Exit");
    Assert.assertNotNull(exitMenu);
    exitMenu.click();
}
项目:scenarioo-example-swtbot-e4    文件:ChangeArticleUpdatesTheOrderOverviewTest.java   
@Test
public void execute() {

    SWTBotTree tree = bot.tree();
    final SWTBotTreeItem orderTreeItem = tree.getTreeItem(CreateTempOrderRule.ORDER_NUMBER_TEMP);
    expandTreeItem(orderTreeItem);

    generateInitialViewDocuForOrderOverview();

    SWTBotTreeItem firstPositionNode = orderTreeItem.getItems()[0];
    SWTBotMenu menu = getContextMenuAndGenerateDocu(tree, firstPositionNode, "Edit Position");
    LOGGER.info(menu.toString());

    clickMenuEntryAndGenerateDocu(menu, PageName.POSITION_DETAIL);

    String articleName = firstPositionNode.getText();
    String editorTitle = CreateTempOrderRule.ORDER_NUMBER_TEMP + " - " + articleName + " - " + POSITION_STATE;
    LOGGER.info("select Position Editor: " + editorTitle);
    SWTBotView partByTitle = wbBot.partByTitle(editorTitle);
    Assert.assertNotNull(partByTitle);

    LOGGER.info("part: " + partByTitle.getPart().toString());
    selectArticleAndGenerateDocu(articleName);

    saveAllAndGenerateDocu();

    // close order details
    partByTitle.close();

    generateDocu("check if part was closed", PageName.POSITION_DETAIL);
    LOGGER.info(getClass().getSimpleName() + " successful!");
}
项目:gwt-eclipse-plugin    文件:SwtBotProjectActions.java   
/**
 * Opens the Properties dialog for a given project.
 *
 * This method assumes that either the Package Explorer or Project Explorer view is visible.
 */
public static void openProjectProperties(final SWTWorkbenchBot bot, String projectName) {
  selectProject(bot, projectName);

  SwtBotUtils.performAndWaitForWindowChange(bot, new Runnable() {
    @Override
    public void run() {
      // Open the Project Properties menu via the File menu
      SWTBotMenu fileMenu = bot.menu("File");
      fileMenu.menu("Properties").click();
    }
  });
}
项目: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    文件:ProjectTreeItem.java   
/**
 * 转换当前项目中的一个源文件为 XLIFF
 * @param srcFileName
 *            要转换的源文件名称
 */
public void ctxMenuConvertFile(String srcFileName) {
    selectFile("Source", srcFileName);
    SWTBotMenu convertFiles = ptv.ctxMenuConvertSrcFile2Xliff();
    convertFiles.isEnabled();
    convertFiles.click();
    // TODO:确认转换对话框正确打开
}