public static IPath[] chooseExclusionPattern(
      Shell shell,
      IContainer currentSourceFolder,
      String title,
      String message,
      IPath initialPath,
      boolean multiSelection) {
    Class[] acceptedClasses = new Class[] {IFolder.class, IFile.class};
    ISelectionStatusValidator validator =
        new TypedElementSelectionValidator(acceptedClasses, multiSelection);
    ViewerFilter filter = new TypedViewerFilter(acceptedClasses);

    ILabelProvider lp = new WorkbenchLabelProvider();
    ITreeContentProvider cp = new WorkbenchContentProvider();

    IResource initialElement = null;
    if (initialPath != null) {
      IContainer curr = currentSourceFolder;
      int nSegments = initialPath.segmentCount();
      for (int i = 0; i < nSegments; i++) {
        IResource elem = curr.findMember(initialPath.segment(i));
        if (elem != null) {
          initialElement = elem;
        }
        if (elem instanceof IContainer) {
          curr = (IContainer) elem;
        } else {
          break;
        }
      }
    }

    ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(shell, lp, cp);
    dialog.setTitle(title);
    dialog.setValidator(validator);
    dialog.setMessage(message);
    dialog.addFilter(filter);
    dialog.setInput(currentSourceFolder);
    dialog.setInitialSelection(initialElement);
    dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
    dialog.setHelpAvailable(false);

    if (dialog.open() == Window.OK) {
      Object[] objects = dialog.getResult();
      int existingSegments = currentSourceFolder.getFullPath().segmentCount();

      IPath[] resArr = new IPath[objects.length];
      for (int i = 0; i < objects.length; i++) {
        IResource currRes = (IResource) objects[i];
        IPath path = currRes.getFullPath().removeFirstSegments(existingSegments).makeRelative();
        if (currRes instanceof IContainer) {
          path = path.addTrailingSeparator();
        }
        resArr[i] = path;
      }
      return resArr;
    }
    return null;
  }
  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;
  }
  protected void addNewPathResource() {
    Class<?>[] acceptedClasses =
        new Class[] {ICProject.class, ICContainer.class, ITranslationUnit.class};
    TypedElementSelectionValidator validator =
        new TypedElementSelectionValidator(acceptedClasses, false);
    ViewerFilter filter = new TypedViewerFilter(acceptedClasses);

    String title = CPathEntryMessages.IncludeSymbolEntryPage_newResource_title;
    String message = CPathEntryMessages.IncludeSymbolEntryPage_newResource_description;

    ElementTreeSelectionDialog dialog =
        new ElementTreeSelectionDialog(
            getShell(), new WorkbenchLabelProvider(), new CElementContentProvider());
    dialog.setValidator(validator);
    dialog.setTitle(title);
    dialog.setMessage(message);
    dialog.addFilter(filter);
    dialog.setInput(fCurrCProject);
    dialog.setInitialSelection(fCurrCProject);

    if (dialog.open() == Window.OK) {
      Object[] elements = dialog.getResult();
      IResource resource;
      if (elements[0] instanceof IResource) {
        resource = (IResource) elements[0];
      } else {
        resource = ((ICElement) elements[0]).getResource();
      }
      CPElementGroup newGroup = new CPElementGroup(resource);
      if (!fIncludeSymPathsList.getElements().contains(newGroup)) {
        List<CPElementGroup> groups = fIncludeSymPathsList.getElements();
        for (int i = 0; i < groups.size(); i++) {
          CPElementGroup group = groups.get(i);
          if (group.getPath().isPrefixOf(newGroup.getPath())) {
            CPElement[] cpelements = group.getChildren();
            for (CPElement cpelement : cpelements) {
              if (cpelement.getInherited() == null) {
                switch (cpelement.getEntryKind()) {
                  case IPathEntry.CDT_INCLUDE:
                  case IPathEntry.CDT_INCLUDE_FILE:
                  case IPathEntry.CDT_MACRO:
                  case IPathEntry.CDT_MACRO_FILE:
                    addPathToResourceGroup(cpelement, null, newGroup);
                }
              }
            }
          }
        }
        fIncludeSymPathsList.addElement(newGroup);
      }
      fIncludeSymPathsList.selectElements(new StructuredSelection(newGroup));
      fIncludeSymPathsList.expandElement(newGroup, 1);
    }
  }