Search in sources :

Example 1 with DockerContainersView

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

the class EditDockerConnectionSWTBotTest method shouldRefreshDockerContainersViewWhenConnectionNameChanges.

@Test
public void shouldRefreshDockerContainersViewWhenConnectionNameChanges() {
    // 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 DockerContainersView dockerContainersView = dockerContainers.view();
    final String formTitle = SWTUtils.syncExec(() -> dockerContainersView.getFormTitle());
    assertThat(formTitle).contains("foo");
}
Also used : SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem) DockerContainersView(org.eclipse.linuxtools.internal.docker.ui.views.DockerContainersView) Test(org.junit.Test)

Example 2 with DockerContainersView

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

the class FilterContainersWithLabelsCommandHandler 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 DockerContainersView) {
        final DockerContainersView containersView = (DockerContainersView) activePart;
        containersView.showContainersWithLabels(checked);
    }
    return null;
}
Also used : IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) DockerContainersView(org.eclipse.linuxtools.internal.docker.ui.views.DockerContainersView)

Example 3 with DockerContainersView

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

the class RemoveContainerLogCommandHandler method execute.

@Override
public Object execute(final ExecutionEvent event) {
    final IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
    List<IDockerContainer> selectedContainers = CommandUtils.getSelectedContainers(activePart);
    if (activePart instanceof DockerContainersView) {
        connection = ((DockerContainersView) activePart).getConnection();
    }
    if (selectedContainers.size() != 1 || connection == null)
        return null;
    container = selectedContainers.get(0);
    IDockerContainerInfo info = connection.getContainerInfo(container.id());
    if (info.config().tty()) {
        Map<String, Object> properties = new HashMap<>();
        properties.put(ITerminalsConnectorConstants.PROP_DELEGATE_ID, "org.eclipse.tm.terminal.connector.streams.launcher.streams");
        properties.put(ITerminalsConnectorConstants.PROP_TERMINAL_CONNECTOR_ID, "org.eclipse.tm.terminal.connector.streams.StreamsConnector");
        properties.put(ITerminalsConnectorConstants.PROP_TITLE, info.name());
        ITerminalService service = TerminalServiceFactory.getService();
        service.closeConsole(properties, null);
        return null;
    }
    final RunConsole rc = RunConsole.findConsole(container);
    if (rc != null) {
        RunConsole.removeConsole(rc);
    }
    return null;
}
Also used : IDockerContainer(org.eclipse.linuxtools.docker.core.IDockerContainer) RunConsole(org.eclipse.linuxtools.internal.docker.ui.consoles.RunConsole) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) HashMap(java.util.HashMap) ITerminalService(org.eclipse.tm.terminal.view.core.interfaces.ITerminalService) DockerContainersView(org.eclipse.linuxtools.internal.docker.ui.views.DockerContainersView) IDockerContainerInfo(org.eclipse.linuxtools.docker.core.IDockerContainerInfo)

Example 4 with DockerContainersView

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

the class ShowAllContainersCommandHandler 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 DockerContainersView) {
        final DockerContainersView containersView = (DockerContainersView) activePart;
        containersView.showAllContainers(checked);
    }
    return null;
}
Also used : IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) DockerContainersView(org.eclipse.linuxtools.internal.docker.ui.views.DockerContainersView)

Example 5 with DockerContainersView

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

the class DockerConnectionManagerUtils method configureConnectionManager.

/**
 * Configures the {@link DockerConnectionManager} with the given array of
 * {@link IDockerConnection} (can be mocked) and refreshes the associated
 * {@link DockerExplorerView}.
 *
 * @param connectionStorageManager
 *            the {@link IDockerConnectionStorageManager} to use (can be
 *            mocked)
 */
public static void configureConnectionManager(final IDockerConnectionStorageManager connectionStorageManager) {
    DockerConnectionManager.getInstance().setConnectionStorageManager(connectionStorageManager);
    final SWTWorkbenchBot bot = new SWTWorkbenchBot();
    final SWTBotView dockerExplorerBotView = SWTUtils.getSWTBotView(bot, DockerExplorerView.VIEW_ID);
    final SWTBotView dockerContainersBotView = SWTUtils.getSWTBotView(bot, DockerContainersView.VIEW_ID);
    SWTUtils.syncExec(() -> {
        DockerConnectionManager.getInstance().reloadConnections();
        if (dockerExplorerBotView != null) {
            final DockerExplorerView dockerExplorerView = (DockerExplorerView) dockerExplorerBotView.getViewReference().getView(false);
            if (dockerExplorerView != null) {
                dockerExplorerView.getCommonViewer().refresh();
                dockerExplorerView.showConnectionsOrExplanations();
            }
        }
        if (dockerContainersBotView != null) {
            final DockerContainersView dockerContainersView = (DockerContainersView) dockerContainersBotView.getViewReference().getView(false);
            if (dockerContainersView != null) {
                dockerContainersView.getViewer().refresh();
            }
        }
    });
}
Also used : SWTWorkbenchBot(org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot) DockerExplorerView(org.eclipse.linuxtools.internal.docker.ui.views.DockerExplorerView) SWTBotView(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView) DockerContainersView(org.eclipse.linuxtools.internal.docker.ui.views.DockerContainersView)

Aggregations

DockerContainersView (org.eclipse.linuxtools.internal.docker.ui.views.DockerContainersView)6 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)3 DockerExplorerView (org.eclipse.linuxtools.internal.docker.ui.views.DockerExplorerView)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)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 IDockerContainer (org.eclipse.linuxtools.docker.core.IDockerContainer)1 IDockerContainerInfo (org.eclipse.linuxtools.docker.core.IDockerContainerInfo)1 RunConsole (org.eclipse.linuxtools.internal.docker.ui.consoles.RunConsole)1 DockerContainersCategory (org.eclipse.linuxtools.internal.docker.ui.views.DockerExplorerContentProvider.DockerContainersCategory)1 DockerImagesCategory (org.eclipse.linuxtools.internal.docker.ui.views.DockerExplorerContentProvider.DockerImagesCategory)1 DockerImagesView (org.eclipse.linuxtools.internal.docker.ui.views.DockerImagesView)1 SWTWorkbenchBot (org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot)1 SWTBotView (org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView)1 SWTBotTreeItem (org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem)1 ITerminalService (org.eclipse.tm.terminal.view.core.interfaces.ITerminalService)1 Test (org.junit.Test)1