/*
   * @see ViewerSorter#category(Object)
   */
  public int category(Object obj) {
    if (obj instanceof CPListElement) {
      CPListElement element = (CPListElement) obj;
      if (element.getParentContainer() != null) {
        return CONTAINER_ENTRY;
      }

      if (element.isJRE()) {
        return JRE_ENTRY;
      }

      if (element.isInNonModifiableContainer()) {
        return REQUIRED_ENTRY;
      }

      switch (element.getEntryKind()) {
        case IIncludePathEntry.CPE_LIBRARY:
          return LIBRARY;
        case IIncludePathEntry.CPE_PROJECT:
          return PROJECT;
        case IIncludePathEntry.CPE_SOURCE:
          return SOURCE;
        case IIncludePathEntry.CPE_CONTAINER:
          return CONTAINER;
      }
    } else if (obj instanceof CPListElementAttribute) {
      return ATTRIBUTE;
    } else if (obj instanceof IAccessRule) {
      return ATTRIBUTE;
    }
    return OTHER;
  }
  private void updateProjectsList(IJavaScriptProject currJProject) {
    // add the projects-cpentries that are already on the class path
    List cpelements = fClassPathList.getElements();

    final List checkedProjects = new ArrayList(cpelements.size());

    for (int i = cpelements.size() - 1; i >= 0; i--) {
      CPListElement cpelem = (CPListElement) cpelements.get(i);
      if (isEntryKind(cpelem.getEntryKind())) {
        checkedProjects.add(cpelem);
      }
    }
    fProjectsList.setElements(checkedProjects);
  }
  private void updateClasspathList() {
    List projelements = fProjectsList.getElements();

    boolean remove = false;
    List cpelements = fClassPathList.getElements();
    // backwards, as entries will be deleted
    for (int i = cpelements.size() - 1; i >= 0; i--) {
      CPListElement cpe = (CPListElement) cpelements.get(i);
      if (isEntryKind(cpe.getEntryKind())) {
        if (!projelements.remove(cpe)) {
          cpelements.remove(i);
          remove = true;
        }
      }
    }
    for (int i = 0; i < projelements.size(); i++) {
      cpelements.add(projelements.get(i));
    }
    if (remove || (projelements.size() > 0)) {
      fClassPathList.setElements(cpelements);
    }
  }