Search in sources :

Example 21 with SWTBotView

use of org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView in project eclipse-integration-commons by spring-projects.

the class SWTBotUtils method getView.

/**
 * Gets a view by name. It assumes the view MUST be opened, although not
 * necessarily active. Open the view first if necessary.
 *
 * @return Active, focused explorer view
 */
public static SWTBotView getView(SWTWorkbenchBot bot, String name) {
    SWTBotView explorer = bot.viewByTitle(name);
    explorer.setFocus();
    return explorer;
}
Also used : SWTBotView(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView)

Example 22 with SWTBotView

use of org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView 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 23 with SWTBotView

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

the class DockerConnectionManagerUtils method configureConnectionManager.

/**
 * Configures the {@link DockerConnectionManager} with the given array of
 * {@link IDockerConnection} (can be mocked) and refreshes the associated
 * {@link DockerExplorerView}.
 *
 * @param connectionStorageManager
 *            the {@link IDockerConnectionStorageManager} to use (can be
 *            mocked)
 */
public static void configureConnectionManager(final IDockerConnectionStorageManager connectionStorageManager) {
    DockerConnectionManager.getInstance().setConnectionStorageManager(connectionStorageManager);
    final SWTWorkbenchBot bot = new SWTWorkbenchBot();
    final SWTBotView dockerExplorerBotView = SWTUtils.getSWTBotView(bot, DockerExplorerView.VIEW_ID);
    final SWTBotView dockerContainersBotView = SWTUtils.getSWTBotView(bot, DockerContainersView.VIEW_ID);
    SWTUtils.syncExec(() -> {
        DockerConnectionManager.getInstance().reloadConnections();
        if (dockerExplorerBotView != null) {
            final DockerExplorerView dockerExplorerView = (DockerExplorerView) dockerExplorerBotView.getViewReference().getView(false);
            if (dockerExplorerView != null) {
                dockerExplorerView.getCommonViewer().refresh();
                dockerExplorerView.showConnectionsOrExplanations();
            }
        }
        if (dockerContainersBotView != null) {
            final DockerContainersView dockerContainersView = (DockerContainersView) dockerContainersBotView.getViewReference().getView(false);
            if (dockerContainersView != null) {
                dockerContainersView.getViewer().refresh();
            }
        }
    });
}
Also used : SWTWorkbenchBot(org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot) DockerExplorerView(org.eclipse.linuxtools.internal.docker.ui.views.DockerExplorerView) SWTBotView(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView) DockerContainersView(org.eclipse.linuxtools.internal.docker.ui.views.DockerContainersView)

Example 24 with SWTBotView

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

the class SWTUtils method getView.

@SuppressWarnings("unchecked")
public static <T> T getView(final SWTWorkbenchBot bot, final String viewId, final boolean restore) {
    final SWTBotView viewBot = bot.viewById(viewId);
    viewBot.setFocus();
    return (T) viewBot.getReference().getView(restore);
}
Also used : SWT(org.eclipse.swt.SWT) SWTBotView(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView)

Example 25 with SWTBotView

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

the class DockerExplorerViewSWTBotTest method shouldShowSelectedConnectionInPropertiesView.

@Test
public void shouldShowSelectedConnectionInPropertiesView() {
    // given
    final DockerClient client = MockDockerClientFactory.build();
    final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).withDefaultTCPConnectionSettings();
    DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
    // open the context menu on one the container
    selectConnectionInTreeView("Test");
    // show container info in Properties view
    SWTUtils.getContextMenu(dockerExplorerViewBot.bot().tree(), "Show In", "Properties").click();
    // the properties view should be visible
    assertThat(this.bot.viewById("org.eclipse.ui.views.PropertySheet").isActive()).isEqualTo(true);
    SWTBotView propertiesViewBot = bot.viewById("org.eclipse.ui.views.PropertySheet");
    SWTUtils.getContextMenu(propertiesViewBot.bot().tree().select(1), "Copy").click();
    this.dockerExplorerView = (DockerExplorerView) (dockerExplorerViewBot.getViewReference().getView(true));
}
Also used : DockerConnection(org.eclipse.linuxtools.internal.docker.core.DockerConnection) DockerClient(com.spotify.docker.client.DockerClient) SWTBotView(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView) Test(org.junit.Test)

Aggregations

SWTBotView (org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView)41 SWTBotTree (org.eclipse.swtbot.swt.finder.widgets.SWTBotTree)14 Test (org.junit.Test)12 SWTBotTreeItem (org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem)10 SWTBotShell (org.eclipse.swtbot.swt.finder.widgets.SWTBotShell)7 Repository (org.eclipse.jgit.lib.Repository)3 SWTWorkbenchBot (org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot)3 Git (org.eclipse.jgit.api.Git)2 Composite (org.eclipse.swt.widgets.Composite)2 Tree (org.eclipse.swt.widgets.Tree)2 WidgetNotFoundException (org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException)2 SWTBotStyledText (org.eclipse.swtbot.swt.finder.widgets.SWTBotStyledText)2 SWTBotToolbarToggleButton (org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarToggleButton)2 DockerClient (com.spotify.docker.client.DockerClient)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 IResource (org.eclipse.core.resources.IResource)1 CoreException (org.eclipse.core.runtime.CoreException)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 IDynamicVariable (org.eclipse.core.variables.IDynamicVariable)1 GitScopeOperation (org.eclipse.egit.ui.internal.operations.GitScopeOperation)1