Search in sources :

Example 41 with IDockerConnection

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

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

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

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

the class EditDockerConnectionCommandHandler method execute.

@Override
public Object execute(ExecutionEvent event) {
    final IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
    final IDockerConnection currentConnection = CommandUtils.getCurrentConnection(activePart);
    final String oldConnectionName = currentConnection.getName();
    final EditDockerConnection wizard = new EditDockerConnection(currentConnection);
    if (CommandUtils.openWizard(wizard, HandlerUtil.getActiveShell(event))) {
        // apply the changes to all launch configurations if needed
        final String newConnectionName = currentConnection.getName();
        if (!newConnectionName.equals(oldConnectionName)) {
            LaunchConfigurationUtils.updateLaunchConfigurations(IBuildDockerImageLaunchConfigurationConstants.CONFIG_TYPE_ID, IDockerImageBuildOptions.DOCKER_CONNECTION, oldConnectionName, newConnectionName);
            LaunchConfigurationUtils.updateLaunchConfigurations(IRunDockerImageLaunchConfigurationConstants.CONFIG_TYPE_ID, IRunDockerImageLaunchConfigurationConstants.CONNECTION_NAME, oldConnectionName, newConnectionName);
        }
    }
    return null;
}
Also used : EditDockerConnection(org.eclipse.linuxtools.internal.docker.ui.wizards.EditDockerConnection) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) IDockerConnection(org.eclipse.linuxtools.docker.core.IDockerConnection)

Example 45 with IDockerConnection

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

the class OpenInHierarchyViewCommandHandler method execute.

@Override
public Object execute(ExecutionEvent event) {
    // retrieve the selected image
    final IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
    final IDockerConnection2 currentConnection = (IDockerConnection2) CommandUtils.getCurrentConnection(activePart);
    // run a job to retrieve the image hierarchy
    final RetrieveImageHierarchyJob retrieveImageHierarchyJob = new RetrieveImageHierarchyJob(currentConnection, CommandUtils.getSelectedElement(activePart));
    retrieveImageHierarchyJob.addJobChangeListener(new JobChangeAdapter() {

        @Override
        public void done(IJobChangeEvent event) {
            // input
            if (retrieveImageHierarchyJob.getImageHierarchy() == null) {
                Activator.logWarningMessage(CommandMessages.getString(// $NON-NLS-1$
                "command.showIn.imageHierarchyView.failure.missingHierarchy"));
            }
            Display.getDefault().asyncExec(() -> {
                try {
                    final DockerImageHierarchyView dockerImageHierarchyView = (DockerImageHierarchyView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(DockerImageHierarchyView.VIEW_ID, null, IWorkbenchPage.VIEW_VISIBLE);
                    dockerImageHierarchyView.setConnection((IDockerConnection) currentConnection);
                    dockerImageHierarchyView.show(retrieveImageHierarchyJob.getImageHierarchy());
                } catch (PartInitException e) {
                    Activator.logErrorMessage(CommandMessages.getString(// $NON-NLS-1$
                    "command.showIn.imageHierarchyView.failure"), e);
                }
            });
        }
    });
    retrieveImageHierarchyJob.schedule();
    // 
    return null;
}
Also used : RetrieveImageHierarchyJob(org.eclipse.linuxtools.internal.docker.ui.jobs.RetrieveImageHierarchyJob) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) JobChangeAdapter(org.eclipse.core.runtime.jobs.JobChangeAdapter) IDockerConnection(org.eclipse.linuxtools.docker.core.IDockerConnection) IJobChangeEvent(org.eclipse.core.runtime.jobs.IJobChangeEvent) PartInitException(org.eclipse.ui.PartInitException) IDockerConnection2(org.eclipse.linuxtools.docker.core.IDockerConnection2) DockerImageHierarchyView(org.eclipse.linuxtools.internal.docker.ui.views.DockerImageHierarchyView)

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