Search in sources :

Example 11 with IDockerContainer

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

the class CommitContainerCommandHandler method execute.

@Override
public Object execute(final ExecutionEvent event) {
    final IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
    List<IDockerContainer> selectedContainers = CommandUtils.getSelectedContainers(activePart);
    final IDockerConnection connection = CommandUtils.getCurrentConnection(activePart);
    if (selectedContainers.size() != 1 || connection == null)
        return null;
    final IDockerContainer container = selectedContainers.get(0);
    final ContainerCommit wizard = new ContainerCommit(container.id());
    final boolean commitContainer = CommandUtils.openWizard(wizard, HandlerUtil.getActiveShell(event));
    if (commitContainer) {
        performCommitContainer(wizard, connection, container);
    }
    return null;
}
Also used : IDockerContainer(org.eclipse.linuxtools.docker.core.IDockerContainer) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) IDockerConnection(org.eclipse.linuxtools.docker.core.IDockerConnection) ContainerCommit(org.eclipse.linuxtools.internal.docker.ui.wizards.ContainerCommit)

Example 12 with IDockerContainer

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

the class CopyFromContainerCommandHandler method execute.

@Override
public Object execute(final ExecutionEvent event) {
    final IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
    final IDockerConnection connection = CommandUtils.getCurrentConnection(activePart);
    final List<IDockerContainer> selectedContainers = CommandUtils.getSelectedContainers(activePart);
    if (selectedContainers.size() != 1) {
        return null;
    }
    final IDockerContainer container = selectedContainers.get(0);
    if (connection == null) {
        MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), CommandMessages.getString(MISSING_CONNECTION), CommandMessages.getString(ERROR_COPYING_FROM_CONTAINER_NO_CONNECTION));
    } else {
        final ContainerCopyFrom wizard = new ContainerCopyFrom(connection, container);
        final boolean copyFromContainer = CommandUtils.openWizard(wizard, HandlerUtil.getActiveShell(event));
        if (copyFromContainer) {
            performCopyFromContainer(connection, container, wizard.getTarget(), wizard.getSources());
        }
    }
    return null;
}
Also used : IDockerContainer(org.eclipse.linuxtools.docker.core.IDockerContainer) ContainerCopyFrom(org.eclipse.linuxtools.internal.docker.ui.wizards.ContainerCopyFrom) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) IDockerConnection(org.eclipse.linuxtools.docker.core.IDockerConnection)

Example 13 with IDockerContainer

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

the class CopyToContainerCommandHandler method execute.

@Override
public Object execute(final ExecutionEvent event) {
    final IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
    final IDockerConnection connection = CommandUtils.getCurrentConnection(activePart);
    final List<IDockerContainer> selectedContainers = CommandUtils.getSelectedContainers(activePart);
    if (selectedContainers.size() != 1) {
        return null;
    }
    final IDockerContainer container = selectedContainers.get(0);
    if (connection == null) {
        MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), CommandMessages.getString(MISSING_CONNECTION), CommandMessages.getString(ERROR_COPYING_TO_CONTAINER_NO_CONNECTION));
    } else {
        final ContainerCopyTo wizard = new ContainerCopyTo(connection, container);
        final boolean copyToContainer = CommandUtils.openWizard(wizard, HandlerUtil.getActiveShell(event));
        if (copyToContainer) {
            performCopyToContainer(connection, container, wizard.getTarget(), wizard.getSources());
        }
    }
    return null;
}
Also used : IDockerContainer(org.eclipse.linuxtools.docker.core.IDockerContainer) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) ContainerCopyTo(org.eclipse.linuxtools.internal.docker.ui.wizards.ContainerCopyTo) IDockerConnection(org.eclipse.linuxtools.docker.core.IDockerConnection)

Example 14 with IDockerContainer

use of org.eclipse.linuxtools.docker.core.IDockerContainer 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 15 with IDockerContainer

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

the class RemoveContainersCommandHandler method confirmed.

@Override
boolean confirmed(List<IDockerContainer> selectedContainers) {
    // ask for confirmation before deleting images
    List<String> containersToRemove = new ArrayList<>();
    for (IDockerContainer container : selectedContainers) {
        containersToRemove.add(container.name());
    }
    final List<String> names = containersToRemove;
    final DialogResponse response = new DialogResponse();
    Display.getDefault().syncExec(() -> {
        boolean result = MessageDialog.openConfirm(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), DVMessages.getString(CONTAINER_REMOVE_CONFIRM), DVMessages.getFormattedString(CONTAINER_REMOVE_LIST, names.toString()));
        response.setResponse(result);
    });
    return response.getResponse();
}
Also used : IDockerContainer(org.eclipse.linuxtools.docker.core.IDockerContainer) ArrayList(java.util.ArrayList)

Aggregations

IDockerContainer (org.eclipse.linuxtools.docker.core.IDockerContainer)25 IDockerConnection (org.eclipse.linuxtools.docker.core.IDockerConnection)9 IDockerImage (org.eclipse.linuxtools.docker.core.IDockerImage)8 Job (org.eclipse.core.runtime.jobs.Job)7 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)7 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)6 IDockerContainerInfo (org.eclipse.linuxtools.docker.core.IDockerContainerInfo)4 IDockerImageHierarchyNode (org.eclipse.linuxtools.docker.core.IDockerImageHierarchyNode)4 Test (org.junit.Test)4 DockerException (org.eclipse.linuxtools.docker.core.DockerException)3 RunConsole (org.eclipse.linuxtools.internal.docker.ui.consoles.RunConsole)3 DockerClient (com.spotify.docker.client.DockerClient)2 Container (com.spotify.docker.client.messages.Container)2 OutputStream (java.io.OutputStream)2 ArrayList (java.util.ArrayList)2 DockerContainerNotFoundException (org.eclipse.linuxtools.docker.core.DockerContainerNotFoundException)2 EnumDockerLoggingStatus (org.eclipse.linuxtools.docker.core.EnumDockerLoggingStatus)2 EnumDockerStatus (org.eclipse.linuxtools.docker.core.EnumDockerStatus)2 IDockerHostConfig (org.eclipse.linuxtools.docker.core.IDockerHostConfig)2 IDockerPortBinding (org.eclipse.linuxtools.docker.core.IDockerPortBinding)2