/** * Returns the label of the given object. The object must be of type {@link IJavaElement} or adapt to {@link IWorkbenchAdapter}. The empty string is returned * if the element type is not known. * @param obj Object to get the label from. * @param flags The rendering flags * @return Returns the label or the empty string if the object type is not supported. */ public static ColoredString getTextLabel(Object obj, long flags) { if (obj instanceof IJavaElement) { return getElementLabel((IJavaElement) obj, flags); } else if (obj instanceof IResource) { return new ColoredString(((IResource) obj).getName()); } else if (obj instanceof ClassPathContainer) { ClassPathContainer container= (ClassPathContainer) obj; return getContainerEntryLabel(container.getClasspathEntry().getPath(), container.getJavaProject()); } return new ColoredString(JavaElementLabels.getTextLabel(obj, flags)); }