Search in sources :

Example 26 with SWTBotMenu

use of org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu in project xtext-xtend by eclipse.

the class AbstractRefactoringSwtBotTest method renameInJavaEditor.

public void renameInJavaEditor(final SWTBotEclipseEditor javaEditor, final String newName, final String dialogName) {
    final SWTBotMenu renameMenuItem = SwtBotProjectHelper.clickableContextMenu(javaEditor, "Refactor", "Rename...");
    renameMenuItem.click();
    boolean _isUseInlineRefactoring = this.testParams.isUseInlineRefactoring();
    if (_isUseInlineRefactoring) {
        javaEditor.typeText(newName);
        boolean _isUsePreview = this.testParams.isUsePreview();
        if (_isUsePreview) {
            javaEditor.pressShortcut(SWT.CTRL, SWT.CR);
            AbstractRefactoringSwtBotTest.bot.shell(dialogName).activate();
            AbstractRefactoringSwtBotTest.bot.button("OK").click();
        } else {
            javaEditor.pressShortcut(KeyStroke.getInstance(SWT.LF));
        }
    } else {
        SWTBot _bot = AbstractRefactoringSwtBotTest.bot.shell(dialogName).activate().bot();
        final Procedure1<SWTBot> _function = (SWTBot it) -> {
            SWTBotText _textWithLabel = it.textWithLabel("New name:");
            _textWithLabel.setText(newName);
            boolean _isUsePreview_1 = this.testParams.isUsePreview();
            if (_isUsePreview_1) {
                it.button("Next").click();
            }
            it.button("Finish").click();
        };
        ObjectExtensions.<SWTBot>operator_doubleArrow(_bot, _function);
    }
    this.waitForRefactoring(javaEditor);
}
Also used : SWTBot(org.eclipse.swtbot.swt.finder.SWTBot) SWTBotMenu(org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu) SWTBotText(org.eclipse.swtbot.swt.finder.widgets.SWTBotText)

Example 27 with SWTBotMenu

use of org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu in project linuxtools by eclipse.

the class DockerComposeSWTBotTest method getRunAsDockerComposeContextMenu.

/**
 * @return the {@link SWTBotMenu} for the "Run as > Docker Image Build"
 *         shortcut
 */
private SWTBotMenu getRunAsDockerComposeContextMenu(final String projectName, final String dockerComposeFileName) {
    final SWTBotView projectExplorerBotView = this.projectExplorerViewRule.getProjectExplorerBotView();
    // make sure the project explorer view is visible, in case it was hidden
    // by another view.
    projectExplorerBotView.setFocus();
    final SWTBotTreeItem fooProjectTreeItem = SWTUtils.getTreeItem(projectExplorerBotView, projectName);
    assertThat(fooProjectTreeItem).isNotNull();
    SWTUtils.syncExec(() -> fooProjectTreeItem.expand());
    final SWTBotTreeItem dockerfileTreeItem = SWTUtils.getTreeItem(fooProjectTreeItem, dockerComposeFileName);
    assertThat(dockerfileTreeItem).isNotNull();
    SWTUtils.select(dockerfileTreeItem);
    final SWTBotMenu runAsDockerComposeMenu = SWTUtils.getContextMenu(projectExplorerBotView.bot().tree(), "Run As", "1 Docker Compose");
    return runAsDockerComposeMenu;
}
Also used : SWTBotMenu(org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu) SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem) SWTBotView(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView)

Example 28 with SWTBotMenu

use of org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu in project linuxtools by eclipse.

the class SWTUtils method getSubMenu.

/**
 * @param menu
 *            the parent menu
 * @param path
 *            the path for the menu
 * @return the child {@link SWTBotMenu} named with the first item in the
 *         given <code>path</code> from the given {@link SWTBotMenu}
 */
public static SWTBotMenu getSubMenu(final SWTBotMenu menu, String... path) {
    final SWTBotMenu subMenu = menu.menu(path[0]);
    if (subMenu == null) {
        Assert.fail("Failed to find submenu '" + path[0] + "'.");
    }
    if (path.length == 1) {
        return subMenu;
    }
    final String[] remainingPath = new String[path.length - 1];
    System.arraycopy(path, 1, remainingPath, 0, remainingPath.length);
    return getSubMenu(subMenu, remainingPath);
}
Also used : SWTBotMenu(org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu)

Example 29 with SWTBotMenu

use of org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu in project linuxtools by eclipse.

the class SWTUtils method getContextMenu.

/**
 * @param tree
 *            the root {@link SWTBotTree}
 * @param path
 *            the path for the menu
 * @return the child {@link SWTBotMenu} named with the first item in the
 *         given <code>path</code> from the given {@link SWTBotTree}
 */
public static SWTBotMenu getContextMenu(final SWTBotTree tree, String... path) {
    final SWTBotMenu contextMenu = tree.contextMenu(path[0]);
    if (contextMenu == null) {
        Assert.fail("Failed to find context menu '" + path[0] + "'.");
    }
    if (path.length == 1) {
        return contextMenu;
    }
    final String[] remainingPath = new String[path.length - 1];
    System.arraycopy(path, 1, remainingPath, 0, remainingPath.length);
    return getSubMenu(contextMenu, remainingPath);
}
Also used : SWTBotMenu(org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu)

Example 30 with SWTBotMenu

use of org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu in project linuxtools by eclipse.

the class DockerExplorerViewSWTBotTest method shouldProvideEnabledUnpauseCommandOnMultipleContainersAtOnce.

@Test
public void shouldProvideEnabledUnpauseCommandOnMultipleContainersAtOnce() {
    // given
    final DockerClient client = MockDockerClientFactory.container(MockContainerFactory.name("gentle_foo").status("Up (Paused)").build()).container(MockContainerFactory.name("angry_bar").status("Up (Paused)").build()).build();
    final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).withDefaultTCPConnectionSettings();
    DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
    // open the context menu on one of the containers
    selectContainersInTreeView("Test", "gentle_foo", "angry_bar");
    final SWTBotMenu menuCommand = dockerExplorerViewBot.bot().tree().contextMenu("Unpause");
    // then
    MenuAssertion.assertThat(menuCommand).isVisible().isEnabled();
}
Also used : DockerConnection(org.eclipse.linuxtools.internal.docker.core.DockerConnection) DockerClient(com.spotify.docker.client.DockerClient) SWTBotMenu(org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu) Test(org.junit.Test)

Aggregations

SWTBotMenu (org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu)44 Test (org.junit.Test)27 DockerClient (com.spotify.docker.client.DockerClient)14 DockerConnection (org.eclipse.linuxtools.internal.docker.core.DockerConnection)14 SWTBotEditor (org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor)3 WidgetNotFoundException (org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException)3 SWTBotShell (org.eclipse.swtbot.swt.finder.widgets.SWTBotShell)3 SWTBotTreeItem (org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem)3 IsEditorOpened (net.heartsome.test.swtbot.waits.IsEditorOpened)2 SWTWorkbenchBot (org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot)2 SWTBot (org.eclipse.swtbot.swt.finder.SWTBot)2 SWTBotRadio (org.eclipse.swtbot.swt.finder.widgets.SWTBotRadio)2 SWTBotText (org.eclipse.swtbot.swt.finder.widgets.SWTBotText)2 ArrayList (java.util.ArrayList)1 ContributionItem (org.eclipse.jface.action.ContributionItem)1 IContributionItem (org.eclipse.jface.action.IContributionItem)1 IMenuManager (org.eclipse.jface.action.IMenuManager)1 MenuManager (org.eclipse.jface.action.MenuManager)1 AbstractTest (org.eclipse.linuxtools.profiling.tests.AbstractTest)1 AbstractChartBuilder (org.eclipse.linuxtools.systemtap.graphing.ui.charts.AbstractChartBuilder)1