T
- public abstract class DefaultList<T,O extends OutputManager<?>> extends AbstractWidget<O> implements ScrollableWidget<O>, ScrollPublisher
Widget.ZOrderClass
Modifier and Type | Field and Description |
---|---|
private boolean |
allowDeselect
Enable item deselection flag.
|
private double |
columns
Number of columns in the list.
|
private int |
currentRow
Current row in the list.
|
private ListModel<T> |
listModel
List model.
|
private java.util.ArrayList<ScrollListener> |
scrollListeners
Storage for listeners.
|
private ListSelectionModel |
selectionModel
List selection model.
|
private int |
visibleRows
Number of visible rows in the list.
|
insets, location, LOG, mousePtr, nativeInsets, physicalLocation
Constructor and Description |
---|
DefaultList(ListModel<T> model)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addScrollListener(ScrollListener listener)
Add scroll listener.
|
void |
addSelectionListener(SelectionListener listener)
Add selection listener.
|
void |
allowDeselect(boolean allow)
Control removing of selection from current item.
|
protected int |
calculateScrollYPosition()
Calculate the scroll Y position based on the current state.
|
void |
clear()
Clear list.
|
int |
currentRow()
Get current row in the list.
|
void |
deselect(int from,
int to)
Deselect specified range of items.
|
Dimension |
dimension()
Get widget dimension.
|
void |
ensureRowVisible(int row)
Ensure that specified row is visible.
|
void |
ensureRowVisible(int row,
boolean scroll)
Ensure that specified row is visible.
|
int |
first()
Get first selected row index.
|
private int |
fixRow(int row)
Fix row to make sure it fits into model bounds.
|
private boolean |
focusChange(int key)
Handle keys which may trigger focus change.
|
double |
getColumns() |
NativeDimension |
getScrollDimension()
Returns the scroll dimension of this widget.
|
NativeDimension |
getScrollStep()
Returns the dimension of the base scroll step desired by the widget
in the X and Y directions.
|
NativeDimension |
getVisibleDimension()
Returns the visible dimension of this widget.
|
double |
height()
Get widget height.
|
int |
index()
Get index of first selected item.
|
boolean |
isScrollPopupSupported()
Check if this widget that supports scrolling also supports scroll popup.
|
Dimension |
minimumSize()
Get widget minimum size.
|
ListModel<T> |
model()
Get underlying list model.
|
protected void |
postScrollEvent(java.lang.Integer column,
java.lang.Integer row)
Post scroll event with the specified row.
|
protected void |
processKey(int key)
Process key event.
|
void |
processKeyEvent(KeyInput event)
Process key event.
|
protected void |
redraw()
Redrawing worker.
|
void |
scroll(java.lang.Integer newXPosition,
java.lang.Integer newYPosition)
Directs the widget to scroll to the specified X and Y positions.
|
void |
select(int index)
Select row with specified index.
|
void |
select(int from,
int to)
Select specified range of items.
|
boolean |
selected(int index)
Check if item with specified index is selected.
|
int[] |
selection()
Get indices of all selected items.
|
int |
selectionMode()
Get access to selection model.
|
protected void |
selectItem()
Handle selection/deselection of current item.
|
void |
setColumns(double cols)
Set visible list width.
|
void |
setSelectionMode(int mode)
Set list selection mode.
|
void |
setVisibleRows(int rows)
Set number of visible rows.
|
protected void |
shiftCurrentRow(int delta,
boolean scroll)
Shifts current row by specified delta.
|
T |
value()
Get value of first selected item.
|
int |
visibleRows()
Get number of visible rows.
|
double |
width()
Get widget width.
|
_setHidden, _setVisible, activateDirectManipulation, addFocusListener, addKeyListener, afterConfigUpdateBase, ancestor, ancestorId, autoResize, bounds, clear, clearWidget, clipRectangle, clipRectangle, clipWith, config, createMouseHoverAction, deactivateDirectManipulation, debug, destroy, disable, displayPhysicalLocation, draw, drawCaret, enable, enclosingFrame, findMouseSource, focusTraversable, forceCursorOnFocus, forceVisibility, getActualBounds, getAndResetBitmap, getAndSetBitmap, getBitmapCopy, getCustomMousePointer, getDefaultEvent, getEffectiveMousePointer, getId, getLoadedMousePointer, getMenuMouse, getMouseActions, getPortableMouseEventCoordinates, getSelectedText, getState, getTextHeight, getTextHeightNative, getTextWidth, getTextWidthNative, getVisiblePart, getZOrderClass, hasFocus, hidden, hide, highlighted, ignoreAction, insets, isDirectManipulationCapable, isDirectManipulationRequired, isDisplayed, isEnabled, isFocusable, isHeader, isRealized, isRMBEntrySupported, isTabStop, isThreeD, isTotallyObscured, isVisible, location, manageSystemActions, mouseActions, mouseClicked, mouseDragged, mouseEntered, mouseExited, mouseMoved, mousePressed, mouseReleased, mouseWheelMoved, moveToBottom, moveToTop, name, navigable, parent, parent, parentOrSelf, physicalBounds, physicalDimension, physicalLocation, postprocessConfig, prepParentLocation, processDirectManipulationEvent, processEvent, processFocusEvent, processKeyListeners, processMnemonic, processMnemonicImpl, processSystemKey, raiseLegacyMouseEvents, refresh, registerWidgetStateListener, repaint, repaint, requestFocus, requestSync, resetBitmap, resizeTo, resolveFont, resolveTitleFont, screen, screenDimension, screenHeight, screenLocation, screenPhysicalLocation, screenWidth, setBitmap, setEnabled, setHidden, setHighlighted, setLocation, setLocation, setMousePointer, setParent, setPhysicalLocation, setState, setVisible, show, supportsCustomMousePointer, sync, topLevelWindow, toString, translate, unrealize, updateSizeWorker, window
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addFocusListener, addKeyListener, ancestor, ancestorId, bounds, clearWidget, config, defaultMousePtr, destroy, displayPhysicalLocation, draw, drawCaret, enclosingFrame, enforceDefaultMousePtr, findMouseSource, focusTraversable, forceCursorOnFocus, forceVisibility, getActualBounds, getCustomMousePointer, getEffectiveMousePointer, getId, getLegacyWidget, getLoadedMousePointer, getMenuMouse, getMouseActions, getSelectedText, getState, getVisiblePart, getZOrderClass, hasFocus, hidden, hide, highlighted, insets, isDirectManipulable, isDisplayed, isEnabled, isFocusable, isHeader, isRealized, isRMBEntrySupported, isTabStop, isThreeD, isTotallyObscured, isVisible, location, moveToBottom, moveToTop, name, navigable, parent, parent, parentOrSelf, physicalBounds, physicalDimension, physicalLocation, postprocessConfig, processDirectManipulationEvent, processEvent, processFocusEvent, processKeyListeners, processMnemonic, raiseLegacyMouseEvents, repaint, repaint, requestFocus, requestSync, resizeTo, screen, screenLocation, screenPhysicalLocation, setEnabled, setHidden, setHighlighted, setLocation, setLocation, setMousePointer, setParent, setPhysicalLocation, setState, setVisible, show, supportsCustomMousePointer, topLevelWindow, unrealize, window
private boolean allowDeselect
private double columns
private int currentRow
private java.util.ArrayList<ScrollListener> scrollListeners
private ListSelectionModel selectionModel
private int visibleRows
public void addScrollListener(ScrollListener listener)
addScrollListener
in interface ScrollPublisher
listener
- Listener to add.public void addSelectionListener(SelectionListener listener)
listener
- Listener to add.public void allowDeselect(boolean allow)
allow
- true
allow deselection of current item.public void clear()
public int currentRow()
public void deselect(int from, int to)
from
- Start index in the range.to
- End index in the range.public Dimension dimension()
dimension
in interface Widget<O extends OutputManager<?>>
dimension
in class AbstractWidget<O extends OutputManager<?>>
public void ensureRowVisible(int row)
row
- The row to process.public void ensureRowVisible(int row, boolean scroll)
row
- The row to process.scroll
- Scrolling option.public int first()
public double height()
height
in interface Widget<O extends OutputManager<?>>
height
in class AbstractWidget<O extends OutputManager<?>>
public Dimension minimumSize()
minimumSize
in interface Widget<O extends OutputManager<?>>
minimumSize
in class AbstractWidget<O extends OutputManager<?>>
public void processKeyEvent(KeyInput event)
processKeyEvent
in interface Widget<O extends OutputManager<?>>
processKeyEvent
in class AbstractWidget<O extends OutputManager<?>>
event
- Key event to process.protected void processKey(int key)
key
- key to processpublic void select(int index)
index
- Item index.public void select(int from, int to)
from
- Start index in the range.to
- End index in the range.public boolean selected(int index)
index
- Item index.true
if item is selected.public int[] selection()
public int selectionMode()
public double getColumns()
public void setColumns(double cols)
cols
- Width in columns.public void setSelectionMode(int mode)
mode
- Selection mode to set.public void setVisibleRows(int rows)
rows
- Number of rows to set.public T value()
public int index()
public int visibleRows()
public double width()
width
in interface Widget<O extends OutputManager<?>>
width
in class AbstractWidget<O extends OutputManager<?>>
public NativeDimension getScrollDimension()
The returned dimension doesn't need to be in the same units as the
widget's physical size but it must be compatible with the result
of getVisibleDimension()
and getScrollStep()
.
getScrollDimension
in interface ScrollableWidget<O extends OutputManager<?>>
public NativeDimension getVisibleDimension()
The returned dimension doesn't need to be in the same units as the
widget's physical size but it must be compatible with the result
of getScrollDimension()
and getScrollStep()
.
getVisibleDimension
in interface ScrollableWidget<O extends OutputManager<?>>
public NativeDimension getScrollStep()
The scroll step must be in the same units as the dimensions returned
by getScrollDimension()
and getVisibleDimension()
.
getScrollStep
in interface ScrollableWidget<O extends OutputManager<?>>
public void scroll(java.lang.Integer newXPosition, java.lang.Integer newYPosition)
getScrollDimension()
, getVisibleDimension()
and getScrollStep()
.scroll
in interface ScrollableWidget<O extends OutputManager<?>>
newXPosition
- New X scroll position.newYPosition
- New Y scroll position.public boolean isScrollPopupSupported()
isScrollPopupSupported
in interface ScrollableWidget<O extends OutputManager<?>>
true
if this widget supports scroll popup.protected void shiftCurrentRow(int delta, boolean scroll)
delta
- the number of list items to shift current row byscroll
- indicates whether list should be scrolled
to the shift rowprotected int calculateScrollYPosition()
protected void selectItem()
protected void redraw()
protected void postScrollEvent(java.lang.Integer column, java.lang.Integer row)
row
- Scroll row.private int fixRow(int row)
row
- Row to fix.private boolean focusChange(int key)
key
- Key to check.true
if key was processed.