Ejemplo n.º 1
0
  public String getStyledText(Object element) {
    if (element instanceof LineElement) return getLineElementLabel((LineElement) element);

    if (!(element instanceof IResource)) return new String();

    IResource resource = (IResource) element;
    if (!resource.exists()) new String(SearchMessages.FileLabelProvider_removed_resource_label);

    String name = BasicElementLabels.getResourceName(resource);
    if (fOrder == SHOW_LABEL) {
      return getColoredLabelWithCounts(resource, new String(name));
    }

    String pathString = BasicElementLabels.getPathLabel(resource.getParent().getFullPath(), false);
    if (fOrder == SHOW_LABEL_PATH) {
      String str = new String(name);
      String decorated = Messages.format(fgSeparatorFormat, new String[] {str, pathString});

      //			decorateColoredString(str, decorated, String.QUALIFIER_STYLER);
      return getColoredLabelWithCounts(resource, str);
    }

    String str = new String(Messages.format(fgSeparatorFormat, new String[] {pathString, name}));
    return getColoredLabelWithCounts(resource, str);
  }
  @Override
  public StyledString getStyledText(Object element) {
    if (element instanceof TreeNode) {
      element = ((TreeNode<?>) element).data;
    }

    if (element instanceof ICustomLineElement) {
      return getLineElementLabel((ICustomLineElement) element);
    }

    if (!(element instanceof IResource)) {
      IResource resource = null;
      if (element instanceof IAdaptable) {
        IAdaptable iAdaptable = (IAdaptable) element;
        resource = iAdaptable.getAdapter(IResource.class);
        if (resource != null) {
          if (element instanceof ICustomModule) {
            return getColoredLabelWithCounts(resource, new StyledString(element.toString()));
          }
          element = resource;
        }
      }
      if (!(element instanceof IResource)) {
        return new StyledString(element.toString());
      }
    }

    IResource resource = (IResource) element;
    if (!resource.exists()) {
      new StyledString("<removed resource>");
    }

    String name = BasicElementLabels.getResourceName(resource);
    return getColoredLabelWithCounts(resource, new StyledString(name));
  }