Search in sources :

Example 1 with DockerImagesCategory

use of org.eclipse.linuxtools.internal.docker.ui.views.DockerExplorerContentProvider.DockerImagesCategory 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 2 with DockerImagesCategory

use of org.eclipse.linuxtools.internal.docker.ui.views.DockerExplorerContentProvider.DockerImagesCategory in project linuxtools by eclipse.

the class RefreshCommandHandler method getRefreshJobs.

private List<Job> getRefreshJobs(final IWorkbenchPart activePart) {
    final IDockerConnection connection = getCurrentConnection(activePart);
    final ArrayList<Job> jobs = new ArrayList<>();
    if (activePart instanceof DockerImagesView) {
        jobs.add(getRefreshImagesJob(connection));
    } else if (activePart instanceof DockerContainersView) {
        jobs.add(getRefreshContainersJob(connection));
    } else if (activePart instanceof DockerExplorerView) {
        DockerExplorerView dockerExplorerView = (DockerExplorerView) activePart;
        final ITreeSelection selection = dockerExplorerView.getCommonViewer().getStructuredSelection();
        if (selection.getFirstElement() instanceof DockerContainersCategory) {
            jobs.add(getRefreshContainersJob(connection));
        } else if (selection.getFirstElement() instanceof DockerImagesCategory) {
            jobs.add(getRefreshImagesJob(connection));
        } else {
            final IDockerConnection[] connections = DockerConnectionManager.getInstance().getConnections();
            for (IDockerConnection selectedConnection : connections) {
                if (!selectedConnection.isOpen()) {
                    try {
                        selectedConnection.open(true);
                    } catch (DockerException e) {
                    // do nothing
                    }
                }
                if (selectedConnection.isOpen()) {
                    jobs.add(getRefreshContainersJob(selectedConnection));
                    jobs.add(getRefreshImagesJob(selectedConnection));
                }
            }
        }
    }
    return jobs;
}
Also used : DockerException(org.eclipse.linuxtools.docker.core.DockerException) DockerExplorerView(org.eclipse.linuxtools.internal.docker.ui.views.DockerExplorerView) ITreeSelection(org.eclipse.jface.viewers.ITreeSelection) IDockerConnection(org.eclipse.linuxtools.docker.core.IDockerConnection) ArrayList(java.util.ArrayList) DockerImagesView(org.eclipse.linuxtools.internal.docker.ui.views.DockerImagesView) DockerContainersView(org.eclipse.linuxtools.internal.docker.ui.views.DockerContainersView) Job(org.eclipse.core.runtime.jobs.Job) DockerContainersCategory(org.eclipse.linuxtools.internal.docker.ui.views.DockerExplorerContentProvider.DockerContainersCategory) DockerImagesCategory(org.eclipse.linuxtools.internal.docker.ui.views.DockerExplorerContentProvider.DockerImagesCategory)

Aggregations

IDockerConnection (org.eclipse.linuxtools.docker.core.IDockerConnection)2 DockerContainersCategory (org.eclipse.linuxtools.internal.docker.ui.views.DockerExplorerContentProvider.DockerContainersCategory)2 DockerImagesCategory (org.eclipse.linuxtools.internal.docker.ui.views.DockerExplorerContentProvider.DockerImagesCategory)2 ArrayList (java.util.ArrayList)1 Job (org.eclipse.core.runtime.jobs.Job)1 ITreeSelection (org.eclipse.jface.viewers.ITreeSelection)1 DockerException (org.eclipse.linuxtools.docker.core.DockerException)1 EnumDockerStatus (org.eclipse.linuxtools.docker.core.EnumDockerStatus)1 IDockerContainer (org.eclipse.linuxtools.docker.core.IDockerContainer)1 IDockerImage (org.eclipse.linuxtools.docker.core.IDockerImage)1 IDockerPortMapping (org.eclipse.linuxtools.docker.core.IDockerPortMapping)1 DockerContainersView (org.eclipse.linuxtools.internal.docker.ui.views.DockerContainersView)1 DockerContainerLink (org.eclipse.linuxtools.internal.docker.ui.views.DockerExplorerContentProvider.DockerContainerLink)1 DockerContainerLinksCategory (org.eclipse.linuxtools.internal.docker.ui.views.DockerExplorerContentProvider.DockerContainerLinksCategory)1 DockerContainerPortMappingsCategory (org.eclipse.linuxtools.internal.docker.ui.views.DockerExplorerContentProvider.DockerContainerPortMappingsCategory)1 DockerContainerVolume (org.eclipse.linuxtools.internal.docker.ui.views.DockerExplorerContentProvider.DockerContainerVolume)1 DockerContainerVolumesCategory (org.eclipse.linuxtools.internal.docker.ui.views.DockerExplorerContentProvider.DockerContainerVolumesCategory)1 LoadingStub (org.eclipse.linuxtools.internal.docker.ui.views.DockerExplorerContentProvider.LoadingStub)1 DockerExplorerView (org.eclipse.linuxtools.internal.docker.ui.views.DockerExplorerView)1 DockerImagesView (org.eclipse.linuxtools.internal.docker.ui.views.DockerImagesView)1