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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations