Package snap.view

Class ListView<T>

All Implemented Interfaces:
PropChange.DoChange, Selectable<T>, XMLArchiver.Archivable
Direct Known Subclasses:
BrowserCol, PopupList

public class ListView<T> extends ParentView implements Selectable<T>
A View to manage a list of items (ListArea) in a ScrollView.
  • Field Details

  • Constructor Details

    • ListView

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

    • getListArea

      public ListArea<T> getListArea()
      Returns the ListArea.
    • createListArea

      protected ListArea<T> createListArea()
      Creates the ListArea.
    • getScrollView

      public ScrollView getScrollView()
      Returns the ScrollView.
    • createScrollView

      protected ScrollView createScrollView()
      Creates the ScrollView.
    • 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.
    • getItemCount

      public int getItemCount()
      Returns the number of items.
    • getItem

      public T getItem(int anIndex)
      Returns the individual item at index.
    • 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>
    • 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>
    • selectUp

      public void selectUp()
      Selects up in the list.
    • selectDown

      public void selectDown()
      Selects up in the list.
    • getRowHeight

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

      public void setRowHeight(double aValue)
      Sets the row height.
    • setItemTextFunction

      public void setItemTextFunction(Function<T,String> aFunc)
      Sets function for deteriming text for an item.
    • getCellConfigure

      public Consumer<ListCell<T>> getCellConfigure()
      Returns method to configure list cells.
    • setCellConfigure

      public void setCellConfigure(Consumer<ListCell<T>> aCC)
      Sets method to configure list cells.
    • getItemKey

      public String getItemKey()
      Returns the ItemKey (a simple alternate way to set ListArea item text using KeyChain).
    • setItemKey

      public void setItemKey(String aKey)
      Sets the ItemKey (a simple alternate way to set ListArea item text using KeyChain).
    • getAltPaint

      public Paint getAltPaint()
      Returns the paint for alternating cells.
    • setAltPaint

      public void setAltPaint(Paint aPaint)
      Sets the paint for alternating cells.
    • isTargeting

      public boolean isTargeting()
      Returns whether list shows visual cue for item under the mouse.
    • setTargeting

      public void setTargeting(boolean aValue)
      Sets whether list shows visual cue for item under the mouse.
    • updateItem

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

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

      public ListCell<T> getCell(int anIndex)
      Returns the cell at given index.
    • 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
    • getText

      public String getText(T anItem)
      Returns text for item.
    • getText

      public String getText()
      Override to return text for currently selected item.
      Overrides:
      getText in class View
    • setText

      public void setText(String aString)
      Override to forward to ListArea.
      Overrides:
      setText in class View
    • configureCell

      protected void configureCell(ListCell<T> aCell)
      Called to configure a cell.
    • processEvent

      protected void processEvent(ViewEvent anEvent)
      Process events.
      Overrides:
      processEvent in class View
    • getValuePropName

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

      public void setBorderRadius(double aValue)
      Override to sync ScrollView and ListArea.
      Overrides:
      setBorderRadius in class View
    • 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