Search in sources :

Example 21 with IDockerConnection

use of org.eclipse.linuxtools.docker.core.IDockerConnection in project linuxtools by eclipse.

the class DockerImagesContentProvider method getElements.

@Override
public Object[] getElements(final Object inputElement) {
    if (inputElement instanceof IDockerConnection) {
        final IDockerConnection connection = (IDockerConnection) inputElement;
        if (connection.isImagesLoaded()) {
            final List<IDockerImage> images = connection.getImages();
            if (images == null) {
                return EMPTY;
            }
            return images.toArray();
        }
        loadImages(connection);
        return EMPTY;
    }
    return EMPTY;
}
Also used : IDockerConnection(org.eclipse.linuxtools.docker.core.IDockerConnection) IDockerImage(org.eclipse.linuxtools.docker.core.IDockerImage)

Example 22 with IDockerConnection

use of org.eclipse.linuxtools.docker.core.IDockerConnection in project linuxtools by eclipse.

the class DockerImagesView method selectionChanged.

@Override
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
    final ITreeSelection treeSelection = (ITreeSelection) selection;
    if (treeSelection.isEmpty()) {
        setConnection(null);
        return;
    }
    final Object firstSegment = treeSelection.getPaths()[0].getFirstSegment();
    if (firstSegment instanceof IDockerConnection) {
        final IDockerConnection connection = (IDockerConnection) firstSegment;
        setConnection(connection);
    }
}
Also used : ITreeSelection(org.eclipse.jface.viewers.ITreeSelection) IDockerConnection(org.eclipse.linuxtools.docker.core.IDockerConnection)

Example 23 with IDockerConnection

use of org.eclipse.linuxtools.docker.core.IDockerConnection in project linuxtools by eclipse.

the class ImageInspectPropertySection method setInput.

@Override
public void setInput(final IWorkbenchPart part, final ISelection selection) {
    super.setInput(part, selection);
    final Object input = getSelection(selection);
    final IDockerConnection parentConnection = getConnection(part, selection);
    final IDockerImageInfo imageInfo = getImageInfo(parentConnection, input);
    if (getTreeViewer() != null && imageInfo != null) {
        getTreeViewer().setInput(imageInfo);
        getTreeViewer().expandAll();
    }
}
Also used : IDockerConnection(org.eclipse.linuxtools.docker.core.IDockerConnection) IDockerImageInfo(org.eclipse.linuxtools.docker.core.IDockerImageInfo)

Example 24 with IDockerConnection

use of org.eclipse.linuxtools.docker.core.IDockerConnection in project linuxtools by eclipse.

the class EditDockerConnectionSWTBotTest method shouldUpdateTCPConnectionSettingsWithValidConnectionAvailable.

@Test
public void shouldUpdateTCPConnectionSettingsWithValidConnectionAvailable() {
    // given
    configureTCPConnection();
    openConnectionEditionWizard("Test");
    // when: switch to TCP connection settings and save
    bot.text(0).setText("foo");
    bot.radio(0).click();
    bot.text(1).setText("/var/run/docker.sock");
    getFinishButton().click();
    // then
    final IDockerConnection fooConnection = DockerConnectionManager.getInstance().findConnection("foo");
    assertThat(fooConnection).isNotNull();
    assertThat(fooConnection.getName()).isEqualTo("foo");
    assertThat(fooConnection.getSettings()).isInstanceOf(UnixSocketConnectionSettings.class);
    final UnixSocketConnectionSettings connectionSettings = (UnixSocketConnectionSettings) fooConnection.getSettings();
    assertThat(connectionSettings.getPath()).isEqualTo("unix:///var/run/docker.sock");
}
Also used : UnixSocketConnectionSettings(org.eclipse.linuxtools.internal.docker.core.UnixSocketConnectionSettings) IDockerConnection(org.eclipse.linuxtools.docker.core.IDockerConnection) Test(org.junit.Test)

Example 25 with IDockerConnection

use of org.eclipse.linuxtools.docker.core.IDockerConnection in project linuxtools by eclipse.

the class EditDockerConnectionSWTBotTest method shouldResetConnectionStateWhenTCPConnectionSettingsChanged.

@Test
public void shouldResetConnectionStateWhenTCPConnectionSettingsChanged() {
    // given
    dockerContainers.close();
    dockerImages.close();
    final IDockerConnection connection = configureTCPConnection("Test");
    final IDockerConnectionStorageManager connectionStorageManager = MockDockerConnectionStorageManagerFactory.providing(connection);
    DockerConnectionManagerUtils.configureConnectionManager(connectionStorageManager);
    final SWTBotTreeItem connectionTreeItem = SWTUtils.getTreeItem(dockerExplorer.bot(), "Test");
    assertThat(connectionTreeItem).isNotNull();
    // when
    openConnectionEditionWizard("Test");
    bot.text(2).setText("https://foo.bar:1234");
    getFinishButton().click();
    // then
    final IDockerConnection foundConnection = DockerConnectionManager.getInstance().findConnection("Test");
    assertThat(foundConnection).isNotNull();
    assertThat(foundConnection.getSettings()).isNotNull().isEqualTo(new TCPConnectionSettings("https://foo.bar:1234", PATH_TO_CERTS));
    assertThat(foundConnection.getState()).isEqualTo(EnumDockerConnectionState.UNKNOWN);
}
Also used : IDockerConnectionStorageManager(org.eclipse.linuxtools.docker.core.IDockerConnectionStorageManager) SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem) IDockerConnection(org.eclipse.linuxtools.docker.core.IDockerConnection) TCPConnectionSettings(org.eclipse.linuxtools.internal.docker.core.TCPConnectionSettings) Test(org.junit.Test)

Aggregations

IDockerConnection (org.eclipse.linuxtools.docker.core.IDockerConnection)90 DockerException (org.eclipse.linuxtools.docker.core.DockerException)24 DockerConnection (org.eclipse.linuxtools.internal.docker.core.DockerConnection)20 Job (org.eclipse.core.runtime.jobs.Job)17 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)16 IDockerImage (org.eclipse.linuxtools.docker.core.IDockerImage)15 Test (org.junit.Test)15 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)12 SWTBotTreeItem (org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem)9 File (java.io.File)8 IOException (java.io.IOException)8 ArrayList (java.util.ArrayList)8 IDockerContainer (org.eclipse.linuxtools.docker.core.IDockerContainer)8 IPath (org.eclipse.core.runtime.IPath)7 ITreeSelection (org.eclipse.jface.viewers.ITreeSelection)7 List (java.util.List)5 IDockerConnectionStorageManager (org.eclipse.linuxtools.docker.core.IDockerConnectionStorageManager)5 RunConsole (org.eclipse.linuxtools.internal.docker.ui.consoles.RunConsole)5 DockerClient (com.spotify.docker.client.DockerClient)4 HashMap (java.util.HashMap)4