Package snap.view
Class ListArea<T>
java.lang.Object
snap.props.PropObject
snap.view.View
snap.view.ParentView
snap.view.ListArea<T>
- All Implemented Interfaces:
PropChange.DoChange
,Selectable<T>
,XMLArchiver.Archivable
A View to show a list of items and act as basis of ListView.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final Insets
static final String
static final String
static final String
static final String
static final String
static final String
Fields inherited from class snap.view.ParentView
_children, Child_Prop, NeedsLayout_Prop
Fields inherited from class snap.view.View
_align, _borderRadius, _effect, _font, _margin, _padding, _repaintRect, _showing, _spacing, _vertical, Action, Align_Prop, Border_Prop, BorderRadius_Prop, Clip_Prop, Cursor_Prop, DEFAULT_ALIGN, DEFAULT_MARGIN, DEFAULT_PADDING, DEFAULT_SPACING, Disabled_Prop, DragEvents, Effect_Prop, Fill_Prop, Focusable_Prop, Focused_Prop, FocusWhenPressed_Prop, Font_Prop, GrowHeight_Prop, GrowWidth_Prop, Height_Prop, KeyEvents, KeyPress, KeyRelease, KeyType, LeanX_Prop, LeanY_Prop, Managed_Prop, Margin_Prop, MaxHeight_Prop, MaxWidth_Prop, MinHeight_Prop, MinWidth_Prop, MouseDrag, MouseEnter, MouseEvents, MouseExit, MouseMove, MousePress, MouseRelease, Name_Prop, Opacity_Prop, Padding_Prop, Paintable_Prop, Parent_Prop, Pickable_Prop, PrefHeight_Prop, PrefWidth_Prop, Rotate_Prop, ScaleX_Prop, ScaleY_Prop, Scroll, Showing_Prop, Spacing_Prop, Text_Prop, ToolTip_Prop, TransX_Prop, TransY_Prop, Vertical_Prop, Visible_Prop, Width_Prop, X_Prop, Y_Prop
Fields inherited from class snap.props.PropObject
_pcs, EMPTY_OBJECT
Fields inherited from interface snap.util.Selectable
Items_Prop, SelIndex_Prop, SelItem_Prop
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
Calculates sample width and height from items.void
cellConfigureBasic
(ListCell<T> aCell) Called to do standard cell configure.protected void
cellEditingChanged
(ListCell<T> aCell) Called when cell editing starts.void
clearSel()
Clears the selection.protected void
configureCell
(ListCell<T> aCell) Called to configure a cell.protected void
configureCellFills
(ListCell<T> aCell) Called to configure a cell fill and text fill.protected void
configureCellText
(ListCell<T> aCell) Called to configure a cell text.createCell
(int anIndex) Creates a cell for item at index.void
Edit cell.protected boolean
equalsItems
(List<T> theItems) Returns whether given items are equal to set items.void
fromXMLView
(XMLArchiver anArchiver, XMLElement anElement) XML unarchival.Returns the paint for alternating cells.getCell
(int anIndex) Returns the cell at given index.Returns method to configure list cells.getCellForRow
(int anIndex) Returns the cell at given index.getCellForY
(double aY) Returns the cell for given Y.Returns the cell padding.Returns the default cell padding.protected int
Returns the column index.Override to return white.Returns the cell currently editing.getItem
(int anIndex) Returns the individual item at index.getItemBounds
(int anIndex) Returns the bounds for item at index.int
Returns the number of items.getItemForText
(String aString) Return list item that matches string.Returns the ItemKey (a simple alternate way to set ListArea item text using KeyChain).Returns the items.Returns function for determining text for an item.protected double
getPrefHeightImpl
(double aW) Returns the preferred height.protected double
getPrefWidthImpl
(double aH) Returns the preferred width.double
Returns the row height.int
getRowIndexForY
(double aY) Returns the row index at given Y location.getSel()
Returns the List selection.Returns the cell for selected index/item.int
Returns the selected index.int[]
Returns the selected indexes.Returns the selected item.Object[]
Returns the selected itemes.<T> T[]
getSelItems
(Class<T> aClass) Returns the selected itemes.int
Returns the index of the currently targeted cell.getText()
Override to return text for currently selected item.Returns text for item.Returns a mapped property name.protected ColViewProxy<?>
Returns the ViewProxy to do layout.boolean
Returns whether list cells are editable.boolean
Returns whether list allows multiple selections.boolean
Returns whether row height has been explicitly set.boolean
isSelIndex
(int anIndex) Returns whether given index is selected index.boolean
Returns whether list shows visual cue for item under the mouse.protected void
Override to layout children with VBox layout.void
Override to see if paint exposes missing cells.protected void
Called when PickList changes selection.void
processEnterAction
(ViewEvent anEvent) Handle enter action.protected void
processEvent
(ViewEvent anEvent) Process events.protected void
Scrolls Selection to visible.void
Selects up in the list.void
selectUp()
Selects up in the list.void
setAltPaint
(Paint aPaint) Sets the paint for alternating cells.void
setCellConfigure
(Consumer<ListCell<T>> aCC) Sets method to configure list cells.void
setCellPadding
(Insets aPad) Sets the cell padding.void
setEditable
(boolean aValue) Sets whether list cells are editable.protected void
setEditingCell
(ListCell<T> aCell) Sets the cell currently editing.void
setHeight
(double aValue) Override to reset cells.void
setItemKey
(String aKey) Sets the ItemKey (a simple alternate way to set ListArea item text using KeyChain).void
Sets the items.void
setItemsList
(List<T> theItems) Sets the items.void
setItemTextFunction
(Function<T, String> aFunc) Sets function for determining text for an item.void
setMultiSel
(boolean aValue) Sets whether list allows multiple selections.protected void
setPickList
(PickList<T> aPL) Sets the underlying picklist.void
setRowHeight
(double aValue) Sets the row height.void
Sets the List selection.void
setSelIndex
(int anIndex) Sets the selected index.void
setSelIndexes
(int[] theIndexes) Sets the selected index.void
setSelItem
(T anItem) Sets the selected index.void
setSelItems
(T[] theItems) Sets the selected items.protected void
setShowing
(boolean aValue) Override to maybe scroll sel to visible.protected void
setTargetedIndex
(int anIndex) Sets the index of the currently targeted cell.void
setTargeting
(boolean aValue) Sets whether list shows visual cue for item under the mouse.void
Override to set the given text in this ListArea by matching it to existing item text.void
setY
(double aValue) Override to reset cells.toXMLView
(XMLArchiver anArchiver) XML archival.protected void
updateCellAt
(int anIndex) Updates item at index (required to be in visible range).void
updateIndex
(int anIndex) Called to update items in the list that have changed, by index.void
updateItem
(T anItem) Called to update item in list that has changed.void
Called to update all visible items in list.void
updateItems
(T[] theItems) Called to update items in list that have changed.Methods inherited from class snap.view.ParentView
addChild, addChild, addDeepChangeListener, childDidDeepChange, childDidPropChange, fromXML, fromXMLChildren, getChild, getChildAt, getChildAt, getChildCount, getChildCountManaged, getChildForClass, getChildForName, getChildLast, getChildren, getChildrenForClass, getChildrenInPaintOrder, getChildrenManaged, getFocusNext, getFocusPrev, getPropValue, getViewList, indexOfChild, initProps, intersectsShape, isInLayout, isNeedsLayout, isNeedsLayoutDeep, isNeedsRepaintDeep, layout, layoutDeep, layoutDeepImpl, layoutFloatingViews, paintAbove, paintChildren, parentFontChanged, processPropChange, relayout, removeChild, removeChild, removeChildren, removeDeepChangeListener, setChildren, setFont, setNeedsLayout, setNeedsLayoutDeep, setNeedsRepaintDeep, setOwner, setOwnerChildren, setPropValue, themeChanged, toXML, toXMLChildren
Methods inherited from class snap.view.View
addBinding, addEventFilter, addEventHandler, clone, contains, contains, containsShape, createActionEvent, disableEvents, enableEvents, fireActionEvent, getAlign, getAlignX, getAlignY, getAnim, getAnimCleared, getAnimTimeDeep, getBestHeight, getBestSize, getBestWidth, getBinding, getBinding, getBindingCount, getBindings, getBorder, getBorderRadius, getBounds, getBoundsLocal, getBoundsParent, getBoundsShape, getBoundsShapeParent, getClip, getClipAll, getClipAllBounds, getClipBounds, getClippedRect, getCursor, getDefaultBorder, getDefaultFont, getEffect, getEnv, getEventAdapter, getFill, getFillColor, getFocusNext, getFocusPrev, getFont, getHeight, getHost, getInsetsAll, getLean, getLeanX, getLeanY, getLocalToParent, getLocalToParent, getMargin, getMaxHeight, getMaxSize, getMaxWidth, getMaxX, getMaxY, getMidX, getMidY, getMinHeight, getMinHeightImpl, getMinSize, getMinWidth, getMinWidthImpl, getName, getOpacity, getOpacityAll, getOwner, getOwner, getPadding, getParent, getParent, getParentCount, getParentToLocal, getParentToLocal, getPhysics, getPhysics, getPrefHeight, getPrefHeight, getPrefSize, getPrefWidth, getPrefWidth, getProp, getPropDefault, getProps, getRealClassName, getRepaintRect, getRepaintRectExpanded, getRootView, getRotate, getScale, getScaleX, getScaleY, getSize, getSpacing, getToolTip, getToolTip, getTransX, getTransY, getUpdater, getVisRect, getWidth, getWindow, getX, getXY, getY, indexInHost, indexInParent, isActionable, isAncestor, isClipToBounds, isDisabled, isEnabled, isFocusable, isFocused, isFocusKeysEnabled, isFocusPainted, isFocusWhenPressed, isFontSet, isGrowHeight, isGrowWidth, isGuest, isHorizontal, isLocalToParentSimple, isManaged, isManagedVisible, isMaxHeightSet, isMaxWidthSet, isMinHeightSet, isMinWidthSet, isMouseDown, isMouseOver, isNeedsRepaint, isPaintable, isPickable, isPickableVisible, isPrefHeightSet, isPrefWidthSet, isShowing, isToolTipEnabled, isVertical, isVisible, localToParent, localToParent, localToParent, localToParent, localToScreen, paintBack, paintFront, parentToLocal, parentToLocal, parentToLocal, parentToLocal, playAnimDeep, processEventAll, processEventFilters, processEventHandlers, relayoutParent, removeBinding, removeBinding, removeEventFilter, removeEventHandler, repaint, repaint, repaint, repaintInParent, requestFocus, runDelayed, runIntervals, runLater, scrollToVisible, setActionable, setAlign, setAlignX, setAlignY, setAnimProps, setAnimString, setAnimTimeDeep, setBorder, setBorder, setBorderRadius, setBounds, setBounds, setBoundsLocal, setClip, setClipToBounds, setCursor, setDisabled, setEffect, setEnabled, setFill, setFocusable, setFocused, setFocusKeysEnabled, setFocusPainted, setFocusWhenPressed, setGrowHeight, setGrowWidth, setLean, setLeanX, setLeanY, setManaged, setMargin, setMargin, setMaxHeight, setMaxSize, setMaxSize, setMaxWidth, setMinHeight, setMinSize, setMinSize, setMinWidth, setName, setOpacity, setPadding, setPadding, setPaintable, setParent, setPickable, setPrefHeight, setPrefSize, setPrefSize, setPrefWidth, setProp, setRealClassName, setRotate, setScale, setScaleX, setScaleY, setSize, setSize, setSizeLocal, setSizeToBestSize, setSizeToPrefSize, setSpacing, setToolTip, setToolTipEnabled, setTransX, setTransY, setVertical, setVisible, setWidth, setX, setXY, setXYLocal, stopAnimDeep, stopIntervals, toStringProps
Methods inherited from class snap.props.PropObject
addPropChangeListener, addPropChangeListener, firePropChange, firePropChange, firePropChange, getPropForName, getPropParent, getPropSet, getPropsForArchival, getPropsForArchivalExtra, getPropsString, isPropDefault, removePropChangeListener, removePropChangeListener, setPropsString, setPropValues, toString
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface snap.util.Selectable
removeItem, removeItemAndUpdateSel
-
Field Details
-
_items
-
CELL_PAD_DEFAULT
-
CellPadding_Prop
- See Also:
-
Editable_Prop
- See Also:
-
EditingCell_Prop
- See Also:
-
ItemKey_Prop
- See Also:
-
RowHeight_Prop
- See Also:
-
Sel_Prop
- See Also:
-
-
Constructor Details
-
ListArea
public ListArea()Creates a new ListArea.
-
-
Method Details
-
getItemCount
public int getItemCount()Returns the number of items. -
getItem
Returns the individual item at index. -
getItemsList
Returns the items.- Specified by:
getItemsList
in interfaceSelectable<T>
-
setItemsList
Sets the items.- Specified by:
setItemsList
in interfaceSelectable<T>
-
setItems
Sets the items.- Specified by:
setItems
in interfaceSelectable<T>
-
setPickList
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
Returns the List selection. -
setSel
Sets the List selection. -
getSelIndex
public int getSelIndex()Returns the selected index.- Specified by:
getSelIndex
in interfaceSelectable<T>
-
setSelIndex
public void setSelIndex(int anIndex) Sets the selected index.- Specified by:
setSelIndex
in interfaceSelectable<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
Returns the selected item.- Specified by:
getSelItem
in interfaceSelectable<T>
-
setSelItem
Sets the selected index.- Specified by:
setSelItem
in interfaceSelectable<T>
-
getSelItems
Returns the selected itemes. -
getSelItems
Returns the selected itemes. -
setSelItems
Sets the selected items. -
selectUp
public void selectUp()Selects up in the list. -
selectDown
public void selectDown()Selects up in the list. -
processEnterAction
Handle enter action. -
pickListPropChange
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
Returns the cell padding. -
setCellPadding
Sets the cell padding. -
getCellPaddingDefault
Returns the default cell padding. -
getRowIndexForY
public int getRowIndexForY(double aY) Returns the row index at given Y location. -
getItemTextFunction
Returns function for determining text for an item. -
setItemTextFunction
Sets function for determining text for an item. -
getCellConfigure
Returns method to configure list cells. -
setCellConfigure
Sets method to configure list cells. -
getItemKey
Returns the ItemKey (a simple alternate way to set ListArea item text using KeyChain). -
setItemKey
Sets the ItemKey (a simple alternate way to set ListArea item text using KeyChain). -
getAltPaint
Returns the paint for alternating cells. -
setAltPaint
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
Called to update item in list that has changed. -
updateItems
public void updateItems()Called to update all visible items in list. -
updateItems
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
Returns the cell at given index. -
getCellForY
Returns the cell for given Y. -
getCellForRow
Returns the cell at given index. -
getSelCell
Returns the cell for selected index/item. -
getItemBounds
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 classView
-
getPrefHeightImpl
protected double getPrefHeightImpl(double aW) Returns the preferred height.- Overrides:
getPrefHeightImpl
in classView
-
layoutImpl
protected void layoutImpl()Override to layout children with VBox layout.- Overrides:
layoutImpl
in classParentView
-
getViewProxy
Returns the ViewProxy to do layout.- Overrides:
getViewProxy
in classParentView
-
createCell
Creates a cell for item at index. -
configureCell
Called to configure a cell. -
cellConfigureBasic
Called to do standard cell configure. -
configureCellText
Called to configure a cell text. -
configureCellFills
Called to configure a cell fill and text fill. -
getText
Returns text for item. -
getColIndex
protected int getColIndex()Returns the column index. -
setY
public void setY(double aValue) Override to reset cells. -
setHeight
public void setHeight(double aValue) Override to reset cells. -
paintAll
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 classParentView
-
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
Returns the cell currently editing. -
setEditingCell
Sets the cell currently editing. -
editCell
Edit cell. -
cellEditingChanged
Called when cell editing starts. -
processEvent
Process events.- Overrides:
processEvent
in classView
-
getDefaultFill
Override to return white.- Overrides:
getDefaultFill
in classView
-
getText
Override to return text for currently selected item. -
setText
Override to set the given text in this ListArea by matching it to existing item text. -
getItemForText
Return list item that matches string. -
getValuePropName
Returns a mapped property name.- Overrides:
getValuePropName
in classView
-
setShowing
protected void setShowing(boolean aValue) Override to maybe scroll sel to visible.- Overrides:
setShowing
in classParentView
-
equalsItems
Returns whether given items are equal to set items. -
toXMLView
XML archival.- Overrides:
toXMLView
in classParentView
-
fromXMLView
XML unarchival.- Overrides:
fromXMLView
in classParentView
-