Search in sources :

Example 16 with IDockerConnection

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

the class ContainerInspectPropertySection 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 IDockerContainerInfo containerInfo = getContainerInfo(parentConnection, input);
    if (getTreeViewer() != null && containerInfo != null) {
        getTreeViewer().setInput(containerInfo);
        getTreeViewer().expandAll();
    }
}
Also used : IDockerConnection(org.eclipse.linuxtools.docker.core.IDockerConnection) IDockerContainerInfo(org.eclipse.linuxtools.docker.core.IDockerContainerInfo)

Example 17 with IDockerConnection

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

the class DockerContainersContentProvider method getElements.

@Override
public Object[] getElements(final Object inputElement) {
    if (inputElement instanceof IDockerConnection) {
        final IDockerConnection connection = (IDockerConnection) inputElement;
        if (connection.isContainersLoaded()) {
            return connection.getContainers().toArray();
        }
        loadContainers(connection);
        return EMPTY;
    }
    return EMPTY;
}
Also used : IDockerConnection(org.eclipse.linuxtools.docker.core.IDockerConnection)

Example 18 with IDockerConnection

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

the class DockerContainersView 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);
        setLabelFilterIds();
    }
}
Also used : ITreeSelection(org.eclipse.jface.viewers.ITreeSelection) IDockerConnection(org.eclipse.linuxtools.docker.core.IDockerConnection)

Example 19 with IDockerConnection

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

the class DockerExplorerLabelProvider method getImage.

@Override
public Image getImage(final Object element) {
    if (element instanceof IDockerConnection) {
        if (((IDockerConnection) element).isOpen()) {
            return OPEN_CONNECTION_IMAGE;
        } else {
            return UNOPEN_CONNECTION_IMAGE;
        }
    } else if (element instanceof DockerImagesCategory) {
        return CATEGORY_IMAGE;
    } else if (element instanceof DockerContainersCategory) {
        return CATEGORY_IMAGE;
    } else if (element instanceof IDockerImage) {
        return IMAGE_IMAGE;
    } else if (element instanceof IDockerContainer) {
        final IDockerContainer container = (IDockerContainer) element;
        final EnumDockerStatus containerStatus = EnumDockerStatus.fromStatusMessage(container.status());
        if (containerStatus == EnumDockerStatus.RUNNING) {
            return STARTED_CONTAINER_IMAGE;
        } else if (containerStatus == EnumDockerStatus.PAUSED) {
            return PAUSED_CONTAINER_IMAGE;
        } else {
            return STOPPED_CONTAINER_IMAGE;
        }
    } else if (element instanceof DockerContainerLinksCategory || element instanceof DockerContainerLink) {
        return CONTAINER_LINK_IMAGE;
    } else if (element instanceof DockerContainerVolumesCategory || element instanceof DockerContainerVolume) {
        return CONTAINER_VOLUME_IMAGE;
    } else if (element instanceof DockerContainerPortMappingsCategory || element instanceof IDockerPortMapping) {
        return CONTAINER_PORT_IMAGE;
    } else if (element instanceof LoadingStub) {
        return LOADING_IMAGE;
    }
    return null;
}
Also used : IDockerContainer(org.eclipse.linuxtools.docker.core.IDockerContainer) DockerContainerLinksCategory(org.eclipse.linuxtools.internal.docker.ui.views.DockerExplorerContentProvider.DockerContainerLinksCategory) DockerContainerLink(org.eclipse.linuxtools.internal.docker.ui.views.DockerExplorerContentProvider.DockerContainerLink) DockerContainerVolumesCategory(org.eclipse.linuxtools.internal.docker.ui.views.DockerExplorerContentProvider.DockerContainerVolumesCategory) IDockerPortMapping(org.eclipse.linuxtools.docker.core.IDockerPortMapping) DockerImagesCategory(org.eclipse.linuxtools.internal.docker.ui.views.DockerExplorerContentProvider.DockerImagesCategory) DockerContainersCategory(org.eclipse.linuxtools.internal.docker.ui.views.DockerExplorerContentProvider.DockerContainersCategory) DockerContainerPortMappingsCategory(org.eclipse.linuxtools.internal.docker.ui.views.DockerExplorerContentProvider.DockerContainerPortMappingsCategory) IDockerConnection(org.eclipse.linuxtools.docker.core.IDockerConnection) DockerContainerVolume(org.eclipse.linuxtools.internal.docker.ui.views.DockerExplorerContentProvider.DockerContainerVolume) EnumDockerStatus(org.eclipse.linuxtools.docker.core.EnumDockerStatus) IDockerImage(org.eclipse.linuxtools.docker.core.IDockerImage) LoadingStub(org.eclipse.linuxtools.internal.docker.ui.views.DockerExplorerContentProvider.LoadingStub)

Example 20 with IDockerConnection

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

the class DockerExplorerView method createPartControl.

@Override
public void createPartControl(final Composite parent) {
    final FormToolkit toolkit = new FormToolkit(parent.getDisplay());
    this.pageBook = new PageBook(parent, SWT.NONE);
    this.connectionsPane = createConnectionsPane(pageBook, toolkit);
    this.explanationsPane = createExplanationPane(pageBook, toolkit);
    showConnectionsOrExplanations();
    this.containersAndImagesSearchFilter = getContainersAndImagesSearchFilter();
    getCommonViewer().addFilter(containersAndImagesSearchFilter);
    DockerConnectionManager.getInstance().addConnectionManagerListener(this);
    if (DockerConnectionManager.getInstance().getConnections().length > 0) {
        IDockerConnection conn = DockerConnectionManager.getInstance().getConnections()[0];
        getCommonViewer().setSelection(new StructuredSelection(conn));
    }
}
Also used : FormToolkit(org.eclipse.ui.forms.widgets.FormToolkit) PageBook(org.eclipse.ui.part.PageBook) IDockerConnection(org.eclipse.linuxtools.docker.core.IDockerConnection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection)

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