T
- O
- public abstract class DefaultList<T,O extends OutputManager<?>> extends AbstractWidget<O> implements ScrollableWidget<O>, ScrollPublisher
Modifier and Type | Field and Description |
---|---|
private double |
columns
Number of columns in the list.
|
protected int |
currentRow
Current row in the list.
|
protected ListModel<T> |
listModel
List model.
|
private java.util.ArrayList<ScrollListener> |
scrollListeners
Storage for listeners.
|
protected ListSelectionModel |
selectionModel
List selection model.
|
protected int |
selectionStart
Mark the selection start item.
|
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.
|
protected int |
calculateScrollYPosition()
Calculate the scroll Y position based on the current state.
|
int |
currentRow()
Get current row in the list.
|
protected boolean |
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.
|
boolean |
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()
Get the columns.
|
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.
|
boolean |
isScrollPopupSupported()
Check if this widget that supports scrolling also supports scroll popup.
|
protected boolean |
isSingleSelectionMode()
Test if the selection mode is single selection.
|
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 boolean |
processKey(int key)
Process key event.
|
void |
processKeyEvent(KeyInput event)
Process key event.
|
protected void |
resetView()
Reset this view: set top row to zero, clear selection etc.
|
void |
scroll(java.lang.Integer newXPosition,
java.lang.Integer newYPosition)
Directs the widget to scroll to the specified X and Y positions.
|
protected boolean |
select(int from,
int to)
Add specified range of items to selection.
|
protected boolean |
selectCurrentRow()
If current row is set, set selection to this row only.
|
boolean |
selected(int index)
Check if item with specified index is selected.
|
int[] |
selection()
Get indices of all selected items.
|
boolean |
selectionClear()
Clear selection.
|
int |
selectionMode()
Get access to selection model.
|
int |
selectionSize()
Get the number of selected items.
|
boolean |
set(int index)
Set selection to the specified row.
|
void |
setColumns(double cols)
Set visible list width.
|
protected boolean |
setCurrentRow(int row,
boolean scroll)
Limit the argument by valid row range, and set current row to the specified value.
|
boolean |
setSelectionMode(int mode)
Set list selection mode.
|
void |
setVisibleRows(int rows)
Set number of visible rows.
|
protected boolean |
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, copyColors, copyState, createMouseHoverAction, deactivateDirectManipulation, debug, destroy, disable, disableTooltip, displayPhysicalLocation, draw, drawCaret, enable, enableTooltip, enclosingFrame, findMouseSource, focusTraversable, forceCursorOnFocus, forceVisibility, getActualBounds, getAndResetBitmap, getAndSetBitmap, getBitmapCopy, getCachedScreenLocation, getCachedScreenPhysicalLocation, getCustomMousePointer, getDefaultEvent, getEffectiveMousePointer, getId, getLoadedMousePointer, getMenuMouse, getMouseActions, getMousePosition, getPortableMouseEventCoordinates, getSelectedText, getState, getTextHeight, getTextHeightNative, getTextHeightNative, getTextWidth, getTextWidth, getTextWidthNative, getTextWidthNative, getVisiblePart, getZOrderClass, hasFocus, hidden, hide, highlighted, ignoreAction, initialHeight, initialWidth, insets, isCurrent, isDirectManipulationActive, isDirectManipulationCapable, isDirectManipulationRequired, isDisplayed, isEnabled, isFocusable, isHeader, isMouseDrag, isRealized, isRepaintDisabled, isRMBEntrySupported, isScreenLocationCached, isTabStop, isThreeD, isTotallyObscured, isVisible, isVisible, location, manageSystemActions, mouseActions, mouseClicked, mouseDragged, mouseEntered, mouseExited, mouseMoved, mousePressed, mouseReleased, mouseWheelMoved, moveToBottom, moveToTop, name, navigable, oleDoDrop, oleDrag, oleDragging, oleStartDragging, onOleDragging, onOleDropEnd, parent, parent, parentObject, parentOrSelf, parentOrSelfObject, physicalBounds, physicalDimension, physicalLocation, postprocessConfig, prepParentLocation, preventFocusWhenMouseDownEventDefined, processDirectManipulationEvent, processEvent, processFocusEvent, processKeyEventForSelectableWidget, processKeyListeners, processMnemonic, processMnemonicImpl, processSystemKey, raiseLegacyMouseEvents, reflectAncestorChange, reflectLocationChange, refresh, registerWidgetStateListener, repaint, repaint, repaint, requestFocus, requestSync, resetBitmap, resizeTo, resolveFont, resolvePopupMenuId, resolveTitleFont, screen, screenDimension, screenHeight, screenLocation, screenPhysicalLocation, screenWidth, setBitmap, setCachedScreenLocation, setCachedScreenPhysicalLocation, setEnabled, setHidden, setHighlighted, setLocation, setLocation, setMousePointer, setParent, setPhysicalLocation, setState, setVisible, show, showPopupMenu, supportsCustomMousePointer, sync, topLevelWindow, toString, translate, unrealize, unregisterWidgetStateListener, updateSizeWorker, widgetStateChanged, window
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addFocusListener, addKeyListener, ancestor, ancestorId, bounds, canMovetoTop, clearWidget, config, defaultMousePtr, destroy, displayPhysicalLocation, draw, drawCaret, enclosingFrame, enforceDefaultMousePtr, findMouseSource, focusTraversable, forceCursorOnFocus, forceVisibility, getActualBounds, getCustomMousePointer, getEffectiveMousePointer, getId, getLegacyWidget, getLoadedMousePointer, getMenuMouse, getMouseActions, getMousePosition, getSelectedText, getState, getTriggerWidget, getTriggerWidget, getVisiblePart, getZOrderClass, hasFocus, hasFocus, hidden, hide, highlighted, ignoreEnable, initialHeight, initialWidth, insets, isCurrent, isDirectManipulable, isDirectManipulationActive, isDisplayed, isDroppable, isEnabled, isFocusable, isHeader, isInitialValueLayout, isLegacyFocus, isRealized, isRepaintDisabled, isRMBEntrySupported, isTabStop, isThreeD, isTotallyObscured, isVisible, isVisible, location, maySwitchFocus, moveToBottom, moveToTop, name, navigable, oleDrag, parent, parent, parent, parentObject, parentOrSelf, parentOrSelfObject, physicalBounds, physicalDimension, physicalLocation, postprocessConfig, preventFocusWhenMouseDownEventDefined, processDirectManipulationEvent, processEvent, processFocusEvent, processKeyListeners, processMnemonic, raiseLegacyMouseEvents, refreshWidget, registerWidgetStateListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocus, requestSync, resizeTo, resolvePopupMenuId, screen, screenLocation, screenPhysicalLocation, setEnabled, setHidden, setHighlighted, setLocation, setLocation, setMousePointer, setParent, setPhysicalLocation, setState, setVisible, show, supportsCustomMousePointer, systemFocusGrabbed, topLevelWindow, unrealize, unregisterWidgetStateListener, validateDisplayValue, widgetStateChanged, window
private double columns
protected int currentRow
protected int selectionStart
private final java.util.ArrayList<ScrollListener> scrollListeners
protected final 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 boolean selectionClear()
true
if this list was changed as the result of the callpublic int currentRow()
protected final boolean deselect(int from, int to)
from
- Start index in the range.to
- End index in the range.true
if selection was changed as the result of the callpublic 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 final boolean ensureRowVisible(int row, boolean scroll)
row
- The row to process.scroll
- Scrolling option.true
if the view was changed by this callpublic final 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 boolean processKey(int key)
key
- key to processtrue
if the widget needs repaintingpublic boolean set(int index)
index
- Item index.true
if selection was changed by this callprotected boolean select(int from, int to)
from
- Start index in the range.to
- End index in the range.true
if selection was changed by this callpublic boolean selected(int index)
index
- Item index.true
if item is selected.public final int[] selection()
public int selectionMode()
public int selectionSize()
public double getColumns()
public void setColumns(double cols)
cols
- Width in columns.public boolean setSelectionMode(int mode)
mode
- Selection mode to set.true
if selection mode was changed by this callpublic void setVisibleRows(int rows)
rows
- Number of rows to set.public T value()
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 boolean shiftCurrentRow(int delta, boolean scroll)
delta
- the number of list items to shift current row byscroll
- indicates whether list should be scrolled
to the new current row positiontrue
if widget needs repaintingprotected final boolean setCurrentRow(int row, boolean scroll)
row
- the new rowscroll
- indicates whether list should be scrolled
to the new current row positiontrue
if the current row was changed by the callprotected void resetView()
protected int calculateScrollYPosition()
protected final boolean selectCurrentRow()
true
if selection was changed by this callprotected void postScrollEvent(java.lang.Integer column, java.lang.Integer row)
row
- Scroll row.protected final boolean isSingleSelectionMode()
private final int fixRow(int row)
row
- Row to fix.private boolean focusChange(int key)
key
- Key to check.true
if key was processed.