protected CPElement[] openWorkspacePathEntryDialog(CPElement existing) {
    Class<?>[] acceptedClasses =
        new Class[] {ICProject.class, IProject.class, IContainer.class, ICContainer.class};
    TypedElementSelectionValidator validator =
        new TypedElementSelectionValidator(acceptedClasses, existing == null);
    ViewerFilter filter = new TypedViewerFilter(acceptedClasses);

    String title =
        (existing == null)
            ? CPathEntryMessages.IncludeSymbolEntryPage_fromWorkspaceDialog_new_title
            : CPathEntryMessages.IncludeSymbolEntryPage_fromWorkspaceDialog_edit_title;
    String message =
        (existing == null)
            ? CPathEntryMessages.IncludeSymbolEntryPage_fromWorkspaceDialog_new_description
            : CPathEntryMessages.IncludeSymbolEntryPage_fromWorkspaceDialog_edit_description;

    ElementTreeSelectionDialog dialog =
        new ElementTreeSelectionDialog(
            getShell(), new WorkbenchLabelProvider(), new CElementContentProvider());
    dialog.setValidator(validator);
    dialog.setTitle(title);
    dialog.setMessage(message);
    dialog.addFilter(filter);
    dialog.setInput(CoreModel.getDefault().getCModel());
    if (existing == null) {
      dialog.setInitialSelection(fCurrCProject);
    } else {
      dialog.setInitialSelection(existing.getCProject());
    }

    if (dialog.open() == Window.OK) {
      Object[] elements = dialog.getResult();
      CPElement[] res = new CPElement[elements.length];
      for (int i = 0; i < res.length; i++) {
        IProject project;
        IPath includePath;
        if (elements[i] instanceof IResource) {
          project = ((IResource) elements[i]).getProject();
          includePath = ((IResource) elements[i]).getProjectRelativePath();
        } else {
          project = ((ICElement) elements[i]).getCProject().getProject();
          includePath = ((ICElement) elements[i]).getResource().getProjectRelativePath();
        }
        CPElementGroup group = getSelectedGroup();
        res[i] =
            new CPElement(
                fCurrCProject,
                IPathEntry.CDT_INCLUDE,
                group.getResource().getFullPath(),
                group.getResource());
        res[i].setAttribute(CPElement.BASE, project.getFullPath().makeRelative());
        res[i].setAttribute(CPElement.INCLUDE, includePath);
      }
      return res;
    }
    return null;
  }
 /**
  * @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;
 }