/** * Returns the styled label of the given object. The object must be of type {@link IJavaElement} or adapt to {@link IWorkbenchAdapter}. * If the element type is not known, the empty string is returned. * The returned label is BiDi-processed with {@link TextProcessor#process(String, String)}. * * @param obj object to get the label for * @param flags the rendering flags * @return the label or the empty string if the object type is not supported * * @since 3.4 */ public static StyledString getStyledTextLabel(Object obj, long flags) { if (obj instanceof IJavaElement) { return getStyledElementLabel((IJavaElement) obj, flags); } else if (obj instanceof IResource) { return getStyledResourceLabel((IResource) obj); } else if (obj instanceof ClassPathContainer) { ClassPathContainer container= (ClassPathContainer) obj; return getStyledContainerEntryLabel(container.getClasspathEntry().getPath(), container.getJavaProject()); } else if (obj instanceof IStorage) { return getStyledStorageLabel((IStorage) obj); } else if (obj instanceof IAdaptable) { IWorkbenchAdapter wbadapter= ((IAdaptable)obj).getAdapter(IWorkbenchAdapter.class); if (wbadapter != null) { return Strings.markLTR(new StyledString(wbadapter.getLabel(obj))); } } return new StyledString(); }
/** * Returns the styled label of the given object. The object must be of type {@link IJavaElement} or adapt to {@link IWorkbenchAdapter}. * If the element type is not known, the empty string is returned. * The returned label is BiDi-processed with {@link TextProcessor#process(String, String)}. * * @param obj object to get the label for * @param flags the rendering flags * @return the label or the empty string if the object type is not supported * * @since 3.4 */ public static StyledString getStyledTextLabel(Object obj, long flags) { if (obj instanceof IJavaElement) { return getStyledElementLabel((IJavaElement) obj, flags); } else if (obj instanceof IResource) { return getStyledResourceLabel((IResource) obj); } else if (obj instanceof ClassPathContainer) { ClassPathContainer container= (ClassPathContainer) obj; return getStyledContainerEntryLabel(container.getClasspathEntry().getPath(), container.getJavaProject()); } else if (obj instanceof IStorage) { return getStyledStorageLabel((IStorage) obj); } else if (obj instanceof IAdaptable) { IWorkbenchAdapter wbadapter= ((IAdaptable)obj).getAdapter(IWorkbenchAdapter.class); if (wbadapter != null) { return Strings.markLTR(new StyledString(wbadapter.getLabel(obj))); } } return new StyledString(); }