Search in sources :

Example 41 with SWTBotTreeItem

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

the class SwtBotProjectHelper method expandNode.

public static SWTBotTreeItem expandNode(final AbstractSWTBot<?> bot, final String node) {
    SWTBotTreeItem item = null;
    if ((bot instanceof SWTBotTree)) {
        item = ((SWTBotTree) bot).getTreeItem(node);
    } else {
        if ((bot instanceof SWTBotTreeItem)) {
            item = ((SWTBotTreeItem) bot).getNode(node);
        }
    }
    boolean _isExpanded = item.isExpanded();
    boolean _not = (!_isExpanded);
    if (_not) {
        item.expand();
    }
    return item;
}
Also used : SWTBotTree(org.eclipse.swtbot.swt.finder.widgets.SWTBotTree) SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem)

Example 42 with SWTBotTreeItem

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

the class SwtBotProjectHelper method clearSourceFolderContents.

public static void clearSourceFolderContents(final SWTWorkbenchBot it, final String project) {
    try {
        try {
            SWTBotTree packageExplorerTree = it.tree();
            boolean _hasItems = it.tree().hasItems();
            boolean _not = (!_hasItems);
            if (_not) {
                packageExplorerTree = it.viewByTitle("Package Explorer").bot().tree();
            }
            final SWTBotTreeItem srcNode = SwtBotProjectHelper.expandNode(SwtBotProjectHelper.expandNode(packageExplorerTree, project), "src");
            SWTBotTreeItem[] _items = srcNode.getItems();
            for (final SWTBotTreeItem source : _items) {
                boolean _isDisposed = source.widget.isDisposed();
                boolean _not_1 = (!_isDisposed);
                if (_not_1) {
                    InputOutput.<SWTBotText>println(it.text());
                    srcNode.select(source.getText());
                    source.contextMenu("Delete").click();
                    it.shell("Delete").activate();
                    it.button("OK").click();
                }
            }
        } catch (final Throwable _t) {
            if (_t instanceof WidgetNotFoundException) {
                final Consumer<IResource> _function = (IResource it_1) -> {
                    try {
                        it_1.delete(true, null);
                    } catch (Throwable _e) {
                        throw Exceptions.sneakyThrow(_e);
                    }
                };
                ((List<IResource>) Conversions.doWrapArray(ResourcesPlugin.getWorkspace().getRoot().getProject(project).getFolder("src").members())).forEach(_function);
            } else {
                throw Exceptions.sneakyThrow(_t);
            }
        }
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : WidgetNotFoundException(org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException) Consumer(java.util.function.Consumer) SWTBotTree(org.eclipse.swtbot.swt.finder.widgets.SWTBotTree) SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem) SWTBotText(org.eclipse.swtbot.swt.finder.widgets.SWTBotText) IResource(org.eclipse.core.resources.IResource)

Example 43 with SWTBotTreeItem

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

the class CommandUtilsSWTBotTest method shouldRetrieveConnectionFromSelectedContainerPort.

@Test
public void shouldRetrieveConnectionFromSelectedContainerPort() {
    // given
    final DockerClient client = MockDockerClientFactory.container(MockContainerFactory.name("foo_bar").build(), MockContainerInfoFactory.port("8080/tcp", "0.0.0.0", "8080").build()).build();
    final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).withDefaultTCPConnectionSettings();
    DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
    final SWTBotTreeItem port = SWTUtils.expand(dockerExplorerViewBot.bot().tree(), "Test", "Containers", "foo_bar", "Ports", "0.0.0.0:8080 -> 8080 (tcp)");
    // when selecting the port
    port.select();
    // then current connection should be found
    Assertions.assertThat(CommandUtils.getCurrentConnection(dockerExplorerView)).isEqualTo(dockerConnection);
}
Also used : DockerConnection(org.eclipse.linuxtools.internal.docker.core.DockerConnection) DockerClient(com.spotify.docker.client.DockerClient) SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem) Test(org.junit.Test)

Example 44 with SWTBotTreeItem

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

the class CommandUtilsSWTBotTest method shouldRetrieveConnectionFromSelectedContainerVolume.

@Test
public void shouldRetrieveConnectionFromSelectedContainerVolume() {
    // given
    final DockerClient client = MockDockerClientFactory.container(MockContainerFactory.name("foo_bar").build(), MockContainerInfoFactory.volume("/path/to/host:/path/to/container:Z,ro").build()).build();
    final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).withDefaultTCPConnectionSettings();
    DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
    final SWTBotTreeItem volume = SWTUtils.expand(dockerExplorerViewBot.bot().tree(), "Test", "Containers", "foo_bar", "Volumes", "/path/to/host");
    // when selecting the volume
    volume.select();
    // then current connection should be found
    Assertions.assertThat(CommandUtils.getCurrentConnection(dockerExplorerView)).isEqualTo(dockerConnection);
}
Also used : DockerConnection(org.eclipse.linuxtools.internal.docker.core.DockerConnection) DockerClient(com.spotify.docker.client.DockerClient) SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem) Test(org.junit.Test)

Example 45 with SWTBotTreeItem

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

the class CommandUtilsSWTBotTest method shouldRetrieveConnectionFromSelectedContainerLinksCategory.

@Test
public void shouldRetrieveConnectionFromSelectedContainerLinksCategory() {
    // given
    final DockerClient client = MockDockerClientFactory.container(MockContainerFactory.name("foo_bar").build(), MockContainerInfoFactory.link("/foo:/bar/foo").build()).build();
    final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).withDefaultTCPConnectionSettings();
    DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
    final SWTBotTreeItem links = SWTUtils.expand(dockerExplorerViewBot.bot().tree(), "Test", "Containers", "foo_bar", "Links");
    // when
    links.select();
    // then current connection should be found
    Assertions.assertThat(CommandUtils.getCurrentConnection(dockerExplorerView)).isEqualTo(dockerConnection);
}
Also used : DockerConnection(org.eclipse.linuxtools.internal.docker.core.DockerConnection) DockerClient(com.spotify.docker.client.DockerClient) SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem) Test(org.junit.Test)

Aggregations

SWTBotTreeItem (org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem)63 Test (org.junit.Test)38 DockerConnection (org.eclipse.linuxtools.internal.docker.core.DockerConnection)20 DockerClient (com.spotify.docker.client.DockerClient)19 IDockerConnection (org.eclipse.linuxtools.docker.core.IDockerConnection)9 Path (org.eclipse.core.runtime.Path)7 SWTBotTree (org.eclipse.swtbot.swt.finder.widgets.SWTBotTree)7 IDockerConnectionStorageManager (org.eclipse.linuxtools.docker.core.IDockerConnectionStorageManager)6 SWTBotEclipseEditor (org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor)6 ByteArrayInputStream (java.io.ByteArrayInputStream)5 SWTBotEditor (org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor)5 SWTBotShell (org.eclipse.swtbot.swt.finder.widgets.SWTBotShell)5 IEditorReference (org.eclipse.ui.IEditorReference)5 Ignore (org.junit.Ignore)5 IResource (org.eclipse.core.resources.IResource)4 File (java.io.File)3 IFile (org.eclipse.core.resources.IFile)3 ProjectExplorerTreeItemAppearsCondition (org.eclipse.linuxtools.changelog.ui.tests.utils.ProjectExplorerTreeItemAppearsCondition)3 TCPConnectionSettings (org.eclipse.linuxtools.internal.docker.core.TCPConnectionSettings)3 UnixSocketConnectionSettings (org.eclipse.linuxtools.internal.docker.core.UnixSocketConnectionSettings)2