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