Search in sources :

Example 46 with IDockerConnection

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

the class PullImageCommandHandler method execute.

@Override
public Object execute(final ExecutionEvent event) {
    final IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
    final IDockerConnection connection = CommandUtils.getCurrentConnection(activePart);
    if (connection == null) {
        MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), CommandMessages.getString(MISSING_CONNECTION), CommandMessages.getString(ERROR_PULLING_IMAGE_NO_CONNECTION));
    } else {
        final ImagePull wizard = new ImagePull(connection);
        final boolean pullImage = CommandUtils.openWizard(wizard, HandlerUtil.getActiveShell(event));
        if (pullImage) {
            performPullImage(connection, wizard.getSelectedImageName(), // part of the IRegistry interface
            (AbstractRegistry) wizard.getSelectedRegistryAccount());
        }
    }
    return null;
}
Also used : IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) IDockerConnection(org.eclipse.linuxtools.docker.core.IDockerConnection) ImagePull(org.eclipse.linuxtools.internal.docker.ui.wizards.ImagePull)

Example 47 with IDockerConnection

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

the class PushImageCommandHandler method execute.

@Override
public Object execute(final ExecutionEvent event) {
    final IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
    final IDockerImage selectedImage = CommandUtils.getSelectedImage(activePart);
    final ImagePush wizard = new ImagePush(selectedImage, selectedImage.repo() + ":" + selectedImage.tags().get(0));
    final boolean pushImage = CommandUtils.openWizard(wizard, HandlerUtil.getActiveShell(event));
    if (pushImage) {
        final IDockerConnection connection = CommandUtils.getCurrentConnection(activePart);
        performPushImage(wizard, connection);
    }
    return null;
}
Also used : IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) IDockerConnection(org.eclipse.linuxtools.docker.core.IDockerConnection) IDockerImage(org.eclipse.linuxtools.docker.core.IDockerImage) ImagePush(org.eclipse.linuxtools.internal.docker.ui.wizards.ImagePush)

Example 48 with IDockerConnection

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

the class RemoveConnectionCommandHandler method execute.

@Override
public Object execute(ExecutionEvent event) {
    final IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
    if (activePart instanceof CommonNavigator) {
        final CommonViewer viewer = ((CommonNavigator) activePart).getCommonViewer();
        final ITreeSelection selection = (ITreeSelection) viewer.getSelection();
        Stream.of(selection.getPaths()).forEach(p -> DockerConnectionManager.getInstance().removeConnection((IDockerConnection) p.getLastSegment()));
    }
    return null;
}
Also used : CommonNavigator(org.eclipse.ui.navigator.CommonNavigator) ITreeSelection(org.eclipse.jface.viewers.ITreeSelection) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) CommonViewer(org.eclipse.ui.navigator.CommonViewer) IDockerConnection(org.eclipse.linuxtools.docker.core.IDockerConnection)

Example 49 with IDockerConnection

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

the class RemoveTagCommandHandler method execute.

@Override
public Object execute(final ExecutionEvent event) {
    final IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
    final List<IDockerImage> selectedImages = CommandUtils.getSelectedImages(activePart);
    final IDockerConnection connection = CommandUtils.getCurrentConnection(activePart);
    if (selectedImages.size() != 1 || connection == null) {
        Activator.log(new DockerException(CommandMessages.getString(// $NON-NLS-1$
        "Command.missing.selection.failure")));
        return null;
    }
    final IDockerImage image = selectedImages.get(0);
    final ImageRemoveTag wizard = new ImageRemoveTag(image);
    final boolean removeTag = CommandUtils.openWizard(wizard, HandlerUtil.getActiveShell(event));
    if (removeTag) {
        performRemoveTagImage(connection, wizard.getTag());
    }
    return null;
}
Also used : DockerException(org.eclipse.linuxtools.docker.core.DockerException) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) IDockerConnection(org.eclipse.linuxtools.docker.core.IDockerConnection) IDockerImage(org.eclipse.linuxtools.docker.core.IDockerImage) ImageRemoveTag(org.eclipse.linuxtools.internal.docker.ui.wizards.ImageRemoveTag)

Example 50 with IDockerConnection

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

the class RestartContainersCommandHandler method executeInJob.

@Override
void executeInJob(final IDockerContainer container, final IDockerConnection connection) {
    try {
        final RunConsole console = getRunConsole(connection, container);
        long waitTime = Platform.getPreferencesService().getLong(// $NON-NLS-1$
        "org.eclipse.linuxtools.docker.ui", PreferenceConstants.RESTART_WAIT_TIME, DEFAULT_WAIT_TIME, null);
        if (console != null) {
            // if we are auto-logging, show the console
            console.showConsole();
            // Start the container
            ((DockerConnection) connection).restartContainer(container.id(), (int) waitTime, console.getOutputStream());
        } else {
            ((DockerConnection) connection).restartContainer(container.id(), (int) waitTime, null);
        }
        connection.getContainers(true);
    } catch (DockerException | InterruptedException e) {
        final String errorMessage = DVMessages.getFormattedString(CONTAINER_RESTART_ERROR_MSG, container.id());
        openError(errorMessage, e);
    }
}
Also used : IDockerConnection(org.eclipse.linuxtools.docker.core.IDockerConnection) DockerConnection(org.eclipse.linuxtools.internal.docker.core.DockerConnection) DockerException(org.eclipse.linuxtools.docker.core.DockerException) CommandUtils.getRunConsole(org.eclipse.linuxtools.internal.docker.ui.commands.CommandUtils.getRunConsole) RunConsole(org.eclipse.linuxtools.internal.docker.ui.consoles.RunConsole)

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