Package snap.view

Class TreeView<T>

All Implemented Interfaces:
PropChange.DoChange, Selectable<T>, XMLArchiver.Archivable

public class TreeView<T> extends ParentView implements Selectable<T>
A View subclass to show a list of hierarchical items.
  • Constructor Details

    • TreeView

      public TreeView()
      Creates a new TreeView.
  • Method Details

    • getScrollView

      public ScrollView getScrollView()
      Returns the ScrollView.
    • getRowHeight

      public int getRowHeight()
      Returns the row height.
    • setRowHeight

      public void setRowHeight(int aValue)
      Sets the row height.
    • getPrefRowCount

      public int getPrefRowCount()
      Returns the preferred number of rows.
    • setPrefRowCount

      public void setPrefRowCount(int aValue)
      Sets the preferred number of rows.
    • getMaxRowCount

      public int getMaxRowCount()
      Returns the maximum number of rows.
    • setMaxRowCount

      public void setMaxRowCount(int aValue)
      Sets the maximum number of rows.
    • getCellConfigure

      public Consumer<ListCell<T>> getCellConfigure()
      Called to set method for rendering.
    • setCellConfigure

      public void setCellConfigure(Consumer<ListCell<T>> aCC)
      Called to set method for rendering.
    • getColCount

      public int getColCount()
      Returns the number of columns.
    • getCol

      public TreeCol<T> getCol(int anIndex)
      Returns the column at given index.
    • getCols

      public TreeCol<T>[] getCols()
      Returns the column at given index.
    • addCol

      public void addCol(TreeCol<T> aCol)
      Adds a column.
    • addCol

      public void addCol(TreeCol<T> aCol, int anIndex)
      Adds a column at index.
    • getRowCount

      public int getRowCount()
      Returns the number of rows.
    • getItemsList

      public List<T> getItemsList()
      Returns the items.
      Specified by:
      getItemsList in interface Selectable<T>
    • setItemsList

      public void setItemsList(List<T> theItems)
      Sets the items.
      Specified by:
      setItemsList in interface Selectable<T>
    • setItemsImpl

      protected void setItemsImpl(List<T> theItems)
      Sets the items.
    • setItems

      public void setItems(T[] theItems)
      Sets the items.
      Specified by:
      setItems in interface Selectable<T>
    • getSelIndex

      public int getSelIndex()
      Returns the selected index.
      Specified by:
      getSelIndex in interface Selectable<T>
    • setSelIndex

      public void setSelIndex(int anIndex)
      Sets the selected index.
      Specified by:
      setSelIndex in interface Selectable<T>
    • getSelItem

      public T getSelItem()
      Returns the selected item.
      Specified by:
      getSelItem in interface Selectable<T>
    • setSelItem

      public void setSelItem(T anItem)
      Sets the selected index.
      Specified by:
      setSelItem in interface Selectable<T>
    • pickListSelChange

      protected void pickListSelChange(PropChange aPC)
      Called when PickList changes selection.
    • getExpandedItems

      public List<T> getExpandedItems(List<T> theItems)
      Returns the list of expanded items for given items.
    • updateItem

      public void updateItem(T anItem)
      Called to update item that has changed.
    • updateItems

      public void updateItems()
      Called to update all visible items.
    • updateItems

      public void updateItems(T[] theItems)
      Called to update items that have changed.
    • getSelRow

      public int getSelRow()
      Returns the selected row.
    • getSelCol

      public int getSelCol()
      Returns the selected column.
    • setSelCol

      public void setSelCol(int anIndex)
      Sets the selected column.
    • getRowIndexForY

      public int getRowIndexForY(double aY)
      Returns the row index at given point.
    • expandAll

      public void expandAll()
      Expands all tree nodes.
    • expandItem

      public void expandItem(T anItem)
      Expands the given item.
    • collapseItem

      public void collapseItem(T anItem)
      Expands the given item.
    • toggleItem

      public void toggleItem(T anItem)
      Expands the given item.
    • getResolver

      public TreeResolver<T> getResolver()
      Returns the resolver.
    • setResolver

      public void setResolver(TreeResolver<T> aResolver)
      Sets the resolver.
    • getParent

      public T getParent(T anItem)
      Returns the parent of given item.
    • getParentCount

      public int getParentCount(T anItem)
      Returns the parent of given item.
    • isAncestor

      public boolean isAncestor(T anItem, T aPar)
      Returns whether given item has given object as any of it's ancestors.
    • isParent

      public boolean isParent(T anItem)
      Whether given object is a parent (has children).
    • getChildren

      public T[] getChildren(T aParent)
      Returns the children.
    • getText

      public String getText(T anItem, int aCol)
      Returns the text to be used for given item.
    • getImage

      public Image getImage(T anItem)
      Return the image to be used for given item.
    • getGraphic

      public View getGraphic(T anItem)
      Return the graphic to be used for given item.
    • isExpanded

      public boolean isExpanded(T anItem)
      Returns whether an item is expanded.
    • setExpanded

      public void setExpanded(T anItem, boolean aValue)
      Sets whether an item is expaned.
    • findParent

      public T findParent(T anItem)
      Searches for parent of given item (only works if given item is visible).
    • setY

      public void setY(double aValue)
      Override to reset cells.
      Overrides:
      setY in class View
    • setHeight

      public void setHeight(double aValue)
      Override to reset cells.
      Overrides:
      setHeight in class View
    • getPrefWidthImpl

      protected double getPrefWidthImpl(double aH)
      Returns the preferred width.
      Overrides:
      getPrefWidthImpl in class View
    • getPrefHeightImpl

      protected double getPrefHeightImpl(double aW)
      Returns the preferred height.
      Overrides:
      getPrefHeightImpl in class View
    • layoutImpl

      protected void layoutImpl()
      Override to layout ScrollView.
      Overrides:
      layoutImpl in class ParentView
    • getMaxHeight

      public double getMaxHeight()
      Returns the maximum height.
      Overrides:
      getMaxHeight in class View
    • processEvent

      protected void processEvent(ViewEvent anEvent)
      Override to ensure that DragGesture events.
      Overrides:
      processEvent in class View
    • getValuePropName

      public String getValuePropName()
      Returns a mapped property name.
      Overrides:
      getValuePropName in class View
    • getExpandedImage

      public Image getExpandedImage()
      Returns an Icon of a down arrow.
    • getCollapsedImage

      public Image getCollapsedImage()
      Returns an image of a down arrow.
    • getDefaultBorder

      public Border getDefaultBorder()
      Returns the default border.
      Overrides:
      getDefaultBorder in class View
    • equalsItems

      protected boolean equalsItems(List<T> theItems)
      Returns whether given items are equal to set items.
    • toXMLView

      public XMLElement toXMLView(XMLArchiver anArchiver)
      XML archival.
      Overrides:
      toXMLView in class ParentView
    • fromXMLView

      public void fromXMLView(XMLArchiver anArchiver, XMLElement anElement)
      XML unarchival.
      Overrides:
      fromXMLView in class ParentView