/*
   * (non-Javadoc)
   * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
   */
  public boolean hasChildren(Object element) {
    if (element instanceof ClassGroupElement) {
      ClassGroupElement classGroup = (ClassGroupElement) element;

      return classGroup.hasChildren();
    } else {
      return getChildren(element).length > 0;
    }
  }
  /*
   * (non-Javadoc)
   * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
   */
  public Object[] getChildren(Object parentElement) {
    List<? extends Object> result = Collections.emptyList();

    if (parentElement instanceof JSElement) {
      JSElement root = (JSElement) parentElement;

      // @formatter:off
      result =
          CollectionsUtil.newList(
              new ClassGroupElement(
                  Messages.JSIndexViewContentProvider_WorkspaceGroupLabel,
                  JSIndexQueryHelper.getJSCoreIndex()),
              new ClassGroupElement(
                  Messages.JSIndexViewContentProvider_ProjectGroupLabel, root.getIndex()));
      // @formatter:on
    } else if (parentElement instanceof ClassGroupElement) {
      ClassGroupElement group = (ClassGroupElement) parentElement;

      result = group.getClasses();
    } else if (parentElement instanceof ClassElement) {
      TypeElement type = (ClassElement) parentElement;
      // NOTE: have to do this "temp" acrobatics to make the compiler happy, due to use of generics
      // and differing
      // return types when grabbing properties vs events
      List<Object> temp = new ArrayList<Object>();

      temp.addAll(type.getProperties());
      temp.addAll(type.getEvents());

      result = temp;
    } else if (parentElement instanceof EventElement) {
      EventElement event = (EventElement) parentElement;

      result = event.getProperties();
    }

    return result.toArray(new Object[result.size()]);
  }