use of org.eclipse.linuxtools.docker.core.EnumDockerLoggingStatus in project linuxtools by eclipse.
the class DisplayContainerLogCommandHandler 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 || connection == null) {
return null;
}
final IDockerContainer container = selectedContainers.get(0);
final String id = container.id();
final String name = container.name();
if (connection.getContainerInfo(id).config().tty()) {
RunConsole.attachToTerminal(connection, id, null);
return null;
}
try {
final RunConsole rc = RunConsole.findConsole(id);
if (rc != null) {
if (!rc.isAttached()) {
rc.attachToConsole(connection);
}
Display.getDefault().syncExec(() -> rc.setTitle(DVMessages.getFormattedString(CONTAINER_LOG_TITLE, name)));
OutputStream stream = rc.getOutputStream();
// Only bother to ask for a log if
// one isn't currently active
EnumDockerLoggingStatus status = ((DockerConnection) connection).loggingStatus(id);
if (status != EnumDockerLoggingStatus.LOGGING_ACTIVE && !((DockerConnection) connection).getContainerInfo(id).config().tty()) {
rc.clearConsole();
((DockerConnection) connection).logContainer(id, stream);
}
rc.showConsole();
}
} catch (DockerException | InterruptedException e) {
Display.getDefault().syncExec(() -> MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), DVMessages.getFormattedString(ERROR_LOGGING_CONTAINER, id), e.getMessage()));
}
return null;
}
Aggregations