Search in sources :

Example 1 with DockerImagesView

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

the class EditDockerConnectionSWTBotTest method shouldRefreshDockerImagesViewWhenConnectionNameChanges.

@Test
public void shouldRefreshDockerImagesViewWhenConnectionNameChanges() {
    // given
    configureTCPConnection("Test");
    final SWTBotTreeItem connectionTreeItem = SWTUtils.getTreeItem(dockerExplorer.bot(), "Test");
    assertThat(connectionTreeItem).isNotNull();
    // when
    openConnectionEditionWizard("Test");
    bot.text(0).setText("foo");
    getFinishButton().click();
    SWTUtils.wait(2, TimeUnit.SECONDS);
    // then
    final DockerImagesView dockerImagesView = dockerImages.view();
    final String formTitle = SWTUtils.syncExec(() -> dockerImagesView.getFormTitle());
    assertThat(formTitle).contains("foo");
}
Also used : SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem) DockerImagesView(org.eclipse.linuxtools.internal.docker.ui.views.DockerImagesView) Test(org.junit.Test)

Example 2 with DockerImagesView

use of org.eclipse.linuxtools.internal.docker.ui.views.DockerImagesView 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)

Example 3 with DockerImagesView

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

the class ShowAllImagesCommandHandler method execute.

@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
    final IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
    final boolean checked = !HandlerUtil.toggleCommandState(event.getCommand());
    if (activePart instanceof DockerImagesView) {
        final DockerImagesView imagesView = (DockerImagesView) activePart;
        imagesView.showAllImages(checked);
    }
    return null;
}
Also used : IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) DockerImagesView(org.eclipse.linuxtools.internal.docker.ui.views.DockerImagesView)

Aggregations

DockerImagesView (org.eclipse.linuxtools.internal.docker.ui.views.DockerImagesView)3 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 IDockerConnection (org.eclipse.linuxtools.docker.core.IDockerConnection)1 DockerContainersView (org.eclipse.linuxtools.internal.docker.ui.views.DockerContainersView)1 DockerContainersCategory (org.eclipse.linuxtools.internal.docker.ui.views.DockerExplorerContentProvider.DockerContainersCategory)1 DockerImagesCategory (org.eclipse.linuxtools.internal.docker.ui.views.DockerExplorerContentProvider.DockerImagesCategory)1 DockerExplorerView (org.eclipse.linuxtools.internal.docker.ui.views.DockerExplorerView)1 SWTBotTreeItem (org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem)1 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)1 Test (org.junit.Test)1