/**
  * @param cpentry
  * @param str
  */
 private void addParentInfo(CPElement cpentry, StringBuffer str) {
   if (bShowParentInfo) {
     CPElement parent = cpentry.getParentContainer();
     if (parent != null) {
       str.append(" ["); // $NON-NLS-1$
       try {
         IPathEntryContainer container =
             CoreModel.getPathEntryContainer(cpentry.getPath(), cpentry.getCProject());
         if (container != null) {
           str.append(container.getDescription());
         }
       } catch (CModelException e) {
         str.append(parent.getPath());
       }
       str.append(']');
     }
   }
 }
 private void addBaseString(IPath endPath, CPElement cpentry, StringBuffer str) {
   IPath baseRef = (IPath) cpentry.getAttribute(CPElement.BASE_REF);
   if (!baseRef.isEmpty()) {
     if (baseRef.isAbsolute()) {
       //				str.append("From project ");
       IPath path = baseRef;
       if (endPath != null) {
         path = path.append(endPath);
       }
       str.append(path.makeRelative().toPortableString());
     } else {
       //				str.append("From contribution ");
       IPathEntryContainer container;
       if (endPath != null) {
         str.append(endPath.toPortableString());
       }
       str.append(" - ("); // $NON-NLS-1$
       try {
         container = CoreModel.getPathEntryContainer(baseRef, cpentry.getCProject());
         if (container != null) {
           str.append(container.getDescription());
         }
       } catch (CModelException e1) {
       }
       str.append(')');
     }
   } else {
     IPath path = (IPath) cpentry.getAttribute(CPElement.BASE);
     if (!path.isEmpty()) {
       if (endPath != null) {
         path = path.append(endPath);
       }
       str.insert(0, path.toPortableString());
     } else if (endPath != null) {
       str.insert(0, endPath.toPortableString());
     }
   }
 }
 public String getCPElementText(CPElement cpentry) {
   IPath path = cpentry.getPath();
   switch (cpentry.getEntryKind()) {
     case IPathEntry.CDT_LIBRARY:
       {
         IPath libPath = (IPath) cpentry.getAttribute(CPElement.LIBRARY);
         StringBuffer str = new StringBuffer();
         addBaseString(libPath, cpentry, str);
         addExport(cpentry, str);
         addParentInfo(cpentry, str);
         return str.toString();
       }
     case IPathEntry.CDT_PROJECT:
       return path.lastSegment();
     case IPathEntry.CDT_INCLUDE:
       {
         IPath incPath = ((IPath) cpentry.getAttribute(CPElement.INCLUDE));
         StringBuffer str = new StringBuffer();
         addBaseString(incPath, cpentry, str);
         addExport(cpentry, str);
         addParentInfo(cpentry, str);
         return str.toString();
       }
     case IPathEntry.CDT_INCLUDE_FILE:
       {
         IPath incFilePath = ((IPath) cpentry.getAttribute(CPElement.INCLUDE_FILE));
         StringBuffer str = new StringBuffer();
         addBaseString(incFilePath, cpentry, str);
         addExport(cpentry, str);
         addParentInfo(cpentry, str);
         return str.toString();
       }
     case IPathEntry.CDT_MACRO:
       {
         StringBuffer str =
             new StringBuffer(
                 (String) cpentry.getAttribute(CPElement.MACRO_NAME)
                     + "=" //$NON-NLS-1$
                     + (String) cpentry.getAttribute(CPElement.MACRO_VALUE));
         addBaseString(null, cpentry, str);
         addExport(cpentry, str);
         addParentInfo(cpentry, str);
         return str.toString();
       }
     case IPathEntry.CDT_MACRO_FILE:
       {
         IPath macroFilePath = ((IPath) cpentry.getAttribute(CPElement.MACROS_FILE));
         StringBuffer str = new StringBuffer();
         addBaseString(macroFilePath, cpentry, str);
         addExport(cpentry, str);
         addParentInfo(cpentry, str);
         return str.toString();
       }
     case IPathEntry.CDT_CONTAINER:
       {
         StringBuffer str = new StringBuffer(path.toString());
         try {
           IPathEntryContainer container =
               CoreModel.getPathEntryContainer(cpentry.getPath(), cpentry.getCProject());
           if (container != null) {
             str.setLength(0);
             str.append(container.getDescription());
           }
         } catch (CModelException e) {
         }
         addExport(cpentry, str);
         return str.toString();
       }
     case IPathEntry.CDT_SOURCE:
     case IPathEntry.CDT_OUTPUT:
       {
         StringBuffer buf = new StringBuffer(path.makeRelative().toString());
         IResource resource = cpentry.getResource();
         if (resource != null && !resource.exists()) {
           buf.append(' ');
           if (cpentry.getStatus().getSeverity()
               != IStatus.OK) { // only valid error for src/output would missing path...
             buf.append(fCreateLabel);
           } else {
             buf.append(fNewLabel);
           }
         }
         return buf.toString();
       }
     default:
       // pass
   }
   return CPathEntryMessages.CPElementLabelProvider_unknown_element_label;
 }