Class ExpandableNode

java.lang.Object
org.eclipse.jface.viewers.internal.ExpandableNode

@NoExtend public class ExpandableNode extends Object
The expandable placeholder element to be used for viewer items that represent an expandable tree or table element.

The idea of ExpandableNode is to allow viewers to show only some subset of children that would otherwise all appear below parent element. The main purpose of this is to prevent UI freezes with viewers that can offer lot of elements but can't efficiently handle such amount using SWT.

The node consists of a parent element, list of all children of this parent and the offset to which child elements are supposed to be created and shown in the viewer.

  • Constructor Details

    • ExpandableNode

      public ExpandableNode(Object[] children, int startOffSet, int limit, StructuredViewer viewer)
      Parameters:
      children - non null list of children
      startOffSet - first not shown item index
      limit - current child limit of the viewer
      viewer - owner of the node
  • Method Details

    • getOffset

      public int getOffset()
      The viewer is supposed to show subset of original elements as children of this node up to this offset (but not including it). In other worlds, this is the index of first invisible element under this node.
      Returns:
      current offset in the original list of elements
    • getLimit

      public int getLimit()
      Returns:
      limit value
    • getRemainingElements

      public Object[] getRemainingElements()
      This method returns those children of the current node which are supposed to be not created / shown yet in the viewer.
      Returns:
      all remaining elements from original array starting with the element at offset index
    • getAllElements

      public Object[] getAllElements()
      Returns original list of elements of the parent.
      Returns:
      original list of elements of the parent
    • getLabel

      public String getLabel()
      Returns label shown for the node in the viewer.
      Returns:
      label shown for the node in the viewer
    • addElement

      public void addElement(Object element)
      Client can use AbstractTableViewer.add(Object[]) to add an element beyond visible range. It must be tracked to render when ExpandableNode node is clicked.
    • contains

      public boolean contains(Object element)
      Returns true if the given element is present in the all elements.
      Returns:
      returns if it finds in all the elements.