use of org.jboss.tools.openshift.internal.ui.job.PodLogsJob in project jbosstools-openshift by jbosstools.
the class PodLogsHandler method showLogs.
protected void showLogs(IPod pod, ExecutionEvent event) {
if (pod == null) {
showDialog(event, "No pod selected", "No pod was selected to retrieve a log.");
return;
}
if (!ArrayUtils.contains(STATES, pod.getStatus())) {
showDialog(event, "Logs Unavailable", NLS.bind(INVALID_POD_STATUS_MESSAGE, pod.getStatus()));
return;
}
Collection<IContainer> containers = pod.getContainers();
if (containers.isEmpty()) {
showDialog(event, "Logs Unavailable", "There are no containers from which to retrieve logs");
return;
}
String containerName = null;
if (containers.size() > 1) {
List<String> names = containers.stream().map(c -> c.getName()).collect(Collectors.toList());
Collections.sort(names);
ElementListSelectionDialog dialog = new ElementListSelectionDialog(HandlerUtil.getActiveShell(event), new LabelProvider());
dialog.setElements(names.toArray());
dialog.setTitle("Pod Containers");
dialog.setMessage("Select a pod container");
dialog.setMultipleSelection(false);
int result = dialog.open();
if (Window.CANCEL == result) {
return;
}
containerName = (String) dialog.getFirstResult();
} else if (containers.size() == 1) {
containerName = containers.iterator().next().getName();
}
new PodLogsJob(pod, containerName).schedule();
}
Aggregations