Package jisa.gui
Class ListDisplay<T>
- java.lang.Object
-
- jisa.gui.JFXElement
-
- jisa.gui.ListDisplay<T>
-
- All Implemented Interfaces:
java.lang.Iterable<ListDisplay.Item<T>>
,Element
- Direct Known Subclasses:
VISABrowser
public class ListDisplay<T> extends JFXElement implements java.lang.Iterable<ListDisplay.Item<T>>
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
ListDisplay.Item<T>
static interface
ListDisplay.ItemRunnable<T>
-
Nested classes/interfaces inherited from interface jisa.gui.Element
Element.ElementBorder
-
-
Field Summary
Fields Modifier and Type Field Description protected javafx.scene.control.ListView<jisa.gui.ListDisplay.ListItem>
list
-
Constructor Summary
Constructors Constructor Description ListDisplay(java.lang.String title)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ListDisplay.Item<T>
add(T object, java.lang.String title, java.lang.String subTitle, javafx.scene.image.Image image)
Adds an object to the ListDisplay, displaying it with the given title, sub-title and image, returning a handle in the form of an Item object.void
addDefaultMenuItem(java.lang.String text, ListDisplay.ItemRunnable<T> action)
Add a context menu item to all current and future items in the DisplayList.void
clear()
java.util.List<ListDisplay.Item<T>>
getItems()
ListDisplay.Item<T>
getSelected()
Returns the currently selected item in the list.int
getSelectedIndex()
Returns the index of the currently selected item in the list.boolean
isEmpty()
java.util.Iterator<ListDisplay.Item<T>>
iterator()
void
remove(ListDisplay.Item<T> toRemove)
Removes the specified item from the list (if it contains it in the first place).void
select(int index)
Selects the item with the specified index in the list.void
select(ListDisplay.Item<T> item)
Selects the specified item in the list.void
setOnChange(SRunnable onChange)
Sets what is done when the currently selected item in the list is changed.int
size()
protected void
triggerOnChange()
-
Methods inherited from class jisa.gui.JFXElement
addDialogButton, addDialogMenuButton, addToolbarButton, addToolbarMenuButton, addToolbarSeparator, autoAdjustSize, autoSizeWindow, clearDialogButtons, clearToolbar, close, getIcon, getMaxHeight, getMaxWidth, getMaxWindowHeight, getMaxWindowWidth, getMinHeight, getMinWidth, getNode, getStage, getTitle, getWindowHeight, getWindowWidth, hide, iconProperty, isDecorated, isExitOnClose, isMaximised, isShowing, setCentreNode, setDecorated, setExitOnClose, setIcon, setIcon, setMaxHeight, setMaximised, setMaxWidth, setMaxWindowHeight, setMaxWindowWidth, setMinHeight, setMinWidth, setOnClose, setTitle, setWindowHeight, setWindowSize, setWindowWidth, show, showAsAlert, showAsConfirmation, showAsDialog, titleProperty
-
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface jisa.gui.Element
getBorderedNode, isVisible, setVisible
-
-
-
-
Method Detail
-
add
public ListDisplay.Item<T> add(T object, java.lang.String title, java.lang.String subTitle, javafx.scene.image.Image image)
Adds an object to the ListDisplay, displaying it with the given title, sub-title and image, returning a handle in the form of an Item object.- Parameters:
object
- Object to addtitle
- Title to showsubTitle
- Sub-title to showimage
- Image to show- Returns:
- Item handle
-
remove
public void remove(ListDisplay.Item<T> toRemove)
Removes the specified item from the list (if it contains it in the first place).
-
clear
public void clear()
-
addDefaultMenuItem
public void addDefaultMenuItem(java.lang.String text, ListDisplay.ItemRunnable<T> action)
Add a context menu item to all current and future items in the DisplayList.- Parameters:
text
- Text to show on menu optionaction
- Action to perform when clicked
-
getSelected
public ListDisplay.Item<T> getSelected()
Returns the currently selected item in the list.- Returns:
- Currently selected item
-
getSelectedIndex
public int getSelectedIndex()
Returns the index of the currently selected item in the list.- Returns:
- Index of currently selected item
-
select
public void select(ListDisplay.Item<T> item)
Selects the specified item in the list.- Parameters:
item
- Item to select
-
select
public void select(int index)
Selects the item with the specified index in the list.- Parameters:
index
- Index of item to select
-
setOnChange
public void setOnChange(SRunnable onChange)
Sets what is done when the currently selected item in the list is changed.- Parameters:
onChange
- Action to perform
-
getItems
public java.util.List<ListDisplay.Item<T>> getItems()
-
size
public int size()
-
isEmpty
public boolean isEmpty()
-
triggerOnChange
protected void triggerOnChange()
-
iterator
public java.util.Iterator<ListDisplay.Item<T>> iterator()
- Specified by:
iterator
in interfacejava.lang.Iterable<T>
-
-