Package snap.view

Class ListArea<T>

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

public class ListArea<T> extends ParentView implements Selectable<T>
A View to show a list of items and act as basis of ListView.
  • Field Details

  • Constructor Details

    • ListArea

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

    • 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>
    • setPickList

      protected void setPickList(PickList<T> aPL)
      Sets the underlying picklist.
    • isMultiSel

      public boolean isMultiSel()
      Returns whether list allows multiple selections.
    • setMultiSel

      public void setMultiSel(boolean aValue)
      Sets whether list allows multiple selections.
    • getSel

      public ListSel getSel()
      Returns the List selection.
    • setSel

      public void setSel(ListSel aSel)
      Sets the List selection.
    • 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>
    • getSelIndexes

      public int[] getSelIndexes()
      Returns the selected indexes.
    • setSelIndexes

      public void setSelIndexes(int[] theIndexes)
      Sets the selected index.
    • clearSel

      public void clearSel()
      Clears the selection.
    • isSelIndex

      public boolean isSelIndex(int anIndex)
      Returns whether given index is selected index.
    • 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>
    • getSelItems

      public Object[] getSelItems()
      Returns the selected itemes.
    • getSelItems

      public <T> T[] getSelItems(Class<T> aClass)
      Returns the selected itemes.
    • setSelItems

      public void setSelItems(T[] theItems)
      Sets the selected items.
    • selectUp

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

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

      public void processEnterAction(ViewEvent anEvent)
      Handle enter action.
    • pickListPropChange

      protected void pickListPropChange(PropChange aPC)
      Called when PickList changes selection.
    • isRowHeightSet

      public boolean isRowHeightSet()
      Returns whether row height has been explicitly set.
    • getRowHeight

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

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

      public Insets getCellPadding()
      Returns the cell padding.
    • setCellPadding

      public void setCellPadding(Insets aPad)
      Sets the cell padding.
    • getCellPaddingDefault

      public Insets getCellPaddingDefault()
      Returns the default cell padding.
    • getRowIndexForY

      public int getRowIndexForY(double aY)
      Returns the row index at given Y location.
    • getItemTextFunction

      public Function<T,String> getItemTextFunction()
      Returns function for determining text for an item.
    • setItemTextFunction

      public void setItemTextFunction(Function<T,String> aFunc)
      Sets function for determining 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.
    • getTargetedIndex

      public int getTargetedIndex()
      Returns the index of the currently targeted cell.
    • setTargetedIndex

      protected void setTargetedIndex(int anIndex)
      Sets the index of the currently targeted cell.
    • updateItem

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

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

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

      public void updateIndex(int anIndex)
      Called to update items in the list that have changed, by index.
    • updateCellAt

      protected void updateCellAt(int anIndex)
      Updates item at index (required to be in visible range).
    • getCell

      public ListCell<T> getCell(int anIndex)
      Returns the cell at given index.
    • getCellForY

      public ListCell<T> getCellForY(double aY)
      Returns the cell for given Y.
    • getCellForRow

      public ListCell<T> getCellForRow(int anIndex)
      Returns the cell at given index.
    • getSelCell

      public ListCell<T> getSelCell()
      Returns the cell for selected index/item.
    • getItemBounds

      public Rect getItemBounds(int anIndex)
      Returns the bounds for item at index.
    • scrollSelToVisible

      protected void scrollSelToVisible()
      Scrolls Selection to visible.
    • 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 children with VBox layout.
      Overrides:
      layoutImpl in class ParentView
    • getViewProxy

      protected ColViewProxy<?> getViewProxy()
      Returns the ViewProxy to do layout.
      Overrides:
      getViewProxy in class ParentView
    • createCell

      protected ListCell<T> createCell(int anIndex)
      Creates a cell for item at index.
    • configureCell

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

      public void cellConfigureBasic(ListCell<T> aCell)
      Called to do standard cell configure.
    • configureCellText

      protected void configureCellText(ListCell<T> aCell)
      Called to configure a cell text.
    • configureCellFills

      protected void configureCellFills(ListCell<T> aCell)
      Called to configure a cell fill and text fill.
    • getText

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

      protected int getColIndex()
      Returns the column index.
    • 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
    • paintAll

      public void paintAll(Painter aPntr)
      Override to see if paint exposes missing cells. If so, request layout. Should only happen under rare circumstances, like when a Scroller containing ListArea grows.
      Overrides:
      paintAll in class ParentView
    • calcSampleSize

      protected void calcSampleSize()
      Calculates sample width and height from items.
    • isEditable

      public boolean isEditable()
      Returns whether list cells are editable.
    • setEditable

      public void setEditable(boolean aValue)
      Sets whether list cells are editable.
    • getEditingCell

      public ListCell<T> getEditingCell()
      Returns the cell currently editing.
    • setEditingCell

      protected void setEditingCell(ListCell<T> aCell)
      Sets the cell currently editing.
    • editCell

      public void editCell(ListCell<T> aCell)
      Edit cell.
    • cellEditingChanged

      protected void cellEditingChanged(ListCell<T> aCell)
      Called when cell editing starts.
    • processEvent

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

      public Paint getDefaultFill()
      Override to return white.
      Overrides:
      getDefaultFill in class View
    • 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 set the given text in this ListArea by matching it to existing item text.
      Overrides:
      setText in class View
    • getItemForText

      public T getItemForText(String aString)
      Return list item that matches string.
    • getValuePropName

      public String getValuePropName()
      Returns a mapped property name.
      Overrides:
      getValuePropName 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