Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 5f03fc57c64b7d426a42bb8f16e80acaf0677658 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*******************************************************************************
 * Copyright (c) 2014, 2015 Red Hat.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Red Hat - Initial Contribution
 *******************************************************************************/

package org.eclipse.linuxtools.internal.docker.ui.commands;

import static org.eclipse.linuxtools.internal.docker.ui.commands.CommandUtils.getRunConsole;

import java.util.List;

import org.eclipse.linuxtools.docker.core.DockerException;
import org.eclipse.linuxtools.docker.core.IDockerConnection;
import org.eclipse.linuxtools.docker.core.IDockerContainer;
import org.eclipse.linuxtools.internal.docker.ui.RunConsole;
import org.eclipse.linuxtools.internal.docker.ui.views.DVMessages;

/**
 * Command handler to unpause all the selected {@link IDockerContainer}
 * @author xcoulon
 *
 */
public class UnpauseContainersCommandHandler extends BaseContainersCommandHandler {

	private static final String CONTAINERS_UNPAUSE_MSG = "ContainersPause.msg"; //$NON-NLS-1$
	private static final String CONTAINER_UNPAUSE_MSG = "ContainerPause.msg"; //$NON-NLS-1$
	private static final String CONTAINER_UNPAUSE_ERROR_MSG = "ContainerPauseError.msg"; //$NON-NLS-1$

	@Override
	void executeInJob(final IDockerContainer container, final IDockerConnection connection) {
		try {
			final RunConsole console = getRunConsole(connection, container);
			if (console != null) {
				// if we are auto-logging, show the console
				console.showConsole();
				// Start the container
				connection.unpauseContainer(container.id(), console.getOutputStream());
			} else {
				connection.unpauseContainer(container.id(), null);
			}
			connection.getContainers(true);
		} catch (DockerException | InterruptedException e) {
			final String errorMessage = DVMessages.getFormattedString(CONTAINER_UNPAUSE_ERROR_MSG, container.id());
			openError(errorMessage, e);
		} 
	}

	@Override
	String getJobName(final List<IDockerContainer> selectedContainers) {
		return DVMessages.getString(CONTAINERS_UNPAUSE_MSG);
	}

	@Override
	String getTaskName(final IDockerContainer container) {
		return DVMessages.getFormattedString(CONTAINER_UNPAUSE_MSG, container.name());
	}

}

Back to the top