private IStatus handleResponse(Collection<IResource> resources) { int severity = IStatus.OK; for (IResource resource : resources) { if (resource.getKind() == ResourceKind.STATUS) { severity = IStatus.WARNING; break; } } return new Status( severity, OpenShiftUIActivator.PLUGIN_ID, OK, "Resources created from template.", null); }
@Override public String getText(Object arg) { if (arg instanceof IResource) { IResource resource = (IResource) arg; if (isFailedStatus(resource)) { return org.apache.commons.lang.StringUtils.capitalize(((IStatus) resource).getMessage()); } return NLS.bind("{0} - {1}", resource.getKind(), resource.getName()); } return arg.toString(); }
@Override public StyledString getStyledText(Object arg) { if (arg instanceof IResource) { IResource resource = (IResource) arg; StyledString text = new StyledString(); if (isFailedStatus(resource)) { text.append(((IStatus) resource).getMessage()); } else { text.append(StringUtils.humanize(resource.getKind().toString())); text.append(resource.getName(), StyledString.QUALIFIER_STYLER); } return text; } return null; }
private boolean isFailedStatus(IResource resource) { return ResourceKind.STATUS.equals(resource.getKind()) && ((IStatus) resource).isFailure(); }
@Before public void setUp() { capability = new TemplateTraceability(resource); when(resource.getNamespace()).thenReturn("mynamespace"); when(resource.getKind()).thenReturn(ResourceKind.TEMPLATE); }