Interface TreeItem

All Superinterfaces:
Serializable
All Known Implementing Classes:
TreeItemImpl

public interface TreeItem extends Serializable
Author:
Bogdan Stefanescu
  • Field Details

  • Method Details

    • getPath

      Path getPath()
      Gets the item path.

      The path is uniquely identifying the item in its tree and is consistent with the tree structure so the parent item will have the same path as the child minus the last segment. The root item path will always be "/". (The root item should not be displayed in the tree - it has no label or other properties.)

      Paths are useful to locate items in the tree using find methods.

      Returns:
      the item path
      See Also:
    • getObject

      Object getObject()
      Gets the object attached to this item.

      The nature of the object depends on the registered content provider which will populate the tree branches when ContentProvider.getChildren(Object) is called. The root item is specified by using TreeModel.setInput(Object)

      Returns:
      the attached object or null if none
    • getParent

      TreeItem getParent()
      Gets the parent item or null if this is the root item.
      Returns:
      the parent item
    • getName

      String getName()
      Gets this node name.

      This is the same as the last segment on the item path

    • getLabel

      String getLabel()
      Gets the label to be displayed for this item.
    • isExpanded

      boolean isExpanded()
      Tests whether or not the item is expanded.
      Returns:
      true of expanded, false otherwise
    • isContainer

      boolean isContainer()
      Tests whether or not the item may have children.
      Returns:
      true if a container, false otherwise
    • getChildren

      TreeItem[] getChildren()
      Gets the cached children.

      The children items are created using the content provider the first time you call expand()

    • getChild

      TreeItem getChild(String name)
      Gets the child item given its name.

      This method will force loading children using the provider if not already loaded or if invalidated.

      Parameters:
      name - the name of the child item
      Returns:
      the child item or null if none
    • hasChildren

      boolean hasChildren()
      Tests whether this item has any children.

      This method will not load children if not already loaded.

      Returns:
      true if the children item has children, false otherwise
    • find

      TreeItem find(Path path)
      Finds the item given its relative path to that item.

      This method will search only the loaded items - it will not make additional calls to provider to get new items.

      Parameters:
      path - the item path to find
      Returns:
      the item or null if none.
    • findAndReveal

      TreeItem findAndReveal(Path path)
      Finds the item given its relative path to that item and expand all its parents so that the item will be visible in the tree.

      The item itself will not be expanded. Use expand() on the returned item if you want so.

      This method is loading any parent if not already loaded by using the registered provider.

      Parameters:
      path - the item path to find
      Returns:
      the item or null if none
    • expand

      TreeItem[] expand()
      Expands the item.

      This will load children items from the provider if they are not already loaded or if invalidated.

    • collapse

      void collapse()
      Collapses this item. This will hide any loaded children.
    • refresh

      void refresh(int type)
      Reloads item information like label, properties and children depending on the specified refresh type.

      The argument is used to specify the type of refresh and can have one of the following values:

      • DATA - to refresh only item data like labels
      • CHILDREN - to refresh only item children
      • BOTH - to refresh both data and children
      Parameters:
      type - of refresh
    • invalidate

      void invalidate(int type)
      Invalidates the item.

      This will force reloading item data and/or children next time item and/or children are accessed. The argument is used to specify the type of invalidation and can have one of the following values:

      • DATA - to invalidate only item data like labels
      • CHILDREN - to invalidate only item children
      • BOTH - to invalidate both data and children
      Parameters:
      type - of invalidation
    • validate

      void validate()
      Validates the item.

      If the item was not invalidated do nothing.

    • getValidationState

      int getValidationState()
      Returns the validation state.

      Can be one of:

      • DATA - the item data is invalid (not loaded or invalidated)
      • CHILDREN - the item children are invalid
      • BOTH - both data and children are invalid
      Returns:
      the validation state.
    • getContentProvider

      ContentProvider getContentProvider()
      Gets the current content provider.
      Returns:
      the content provider. never return null
    • accept

      Object accept(TreeItemVisitor visitor)
      Accepts a visitor. This is to support visitor pattern.
      Parameters:
      visitor - the visitor to accept
      Returns:
      the result of the visit