Module MaterialFX

Class AbstractMFXTreeCell<T>

Type Parameters:
T - The type of the data within TreeItem.
All Implemented Interfaces:
Styleable, EventTarget
Direct Known Subclasses:
MFXSimpleTreeCell

public abstract class AbstractMFXTreeCell<T> extends HBox
Base class for every cell used by MFXTreeItems. Specifies properties and methods that should be common to all cells.

It's common for TreeViews to display the data in an horizontal container and that's why this class extends HBox rather than Control and define its skin.

To build a cell the item data should be sufficient however the constructors have been refactored to pass th AbstractMFXTreeItem as parameter because to implement cell selection it is needed to bound the selected property of the cell to the item selected property. It's kinda tricky because one needs to select the item but if you select the item and update its background accordingly you set the background color of the entire container not the item's cell. So we select the item in the model but in the view the cell appears selected. The same concept applies to MFXCheckTreeCells.

Also, note that to build a cell the height must be fixed for layout reasons, by default it's 27. When the cell is created the render(Object) method is called.

  • Property Details

  • Field Details

  • Constructor Details

  • Method Details

    • getFixedCellSize

      public double getFixedCellSize()
      Gets the value of the property fixedCellSize.
      Property description:
    • fixedCellSizeProperty

      public DoubleProperty fixedCellSizeProperty()
      See Also:
    • setFixedCellSize

      public void setFixedCellSize(double fixedCellSize)
      Sets the value of the property fixedCellSize.
      Property description:
    • isSelected

      public boolean isSelected()
      Gets the value of the property selected.
      Property description:
    • selectedProperty

      public BooleanProperty selectedProperty()
      See Also:
    • defaultDisclosureNode

      protected abstract void defaultDisclosureNode()
      Each cell must have a disclosure node (the node to expand/collapse the item), therefore it needs to specify how to create it.
    • getDisclosureNode

      public abstract Node getDisclosureNode()
      Returns:
      the cell's disclosure node instance
    • setDisclosureNode

      public abstract <N extends Node> void setDisclosureNode(N node)
      Sets the cell's disclosure node to the specified node.
      Type Parameters:
      N - the specified parameter N should be a subclass of Node
    • render

      protected abstract void render(T data)
      Specifies how the cell should represent the item's data, whether it is a node, a primitive type or something else.
      Parameters:
      data - the item's data
    • updateCell

      public abstract void updateCell(MFXTreeItem<T> item)
      This methods is needed for updating the cell when the item state changes. For example the disclosure node is added to all cells and should have the same size in each cell for layout reasons (think at how the HBox works and what would happen if you don't have the disclosure node) but by default it has not the icon because it is added only when the items list is not empty, when it changes from empty to full or vice versa the icon is added/removed.