Package org.luwrain.controls
Class ListArea<E>
java.lang.Object
org.luwrain.controls.ListArea<E>
- All Implemented Interfaces:
ClipboardTranslator.Provider
,RegionTextQueryTranslator.Provider
,Area
,HotPoint
,Lines
- Direct Known Subclasses:
CommanderArea
,EditableListArea
,ListPopup2
,ListPopupBase
,MainMenu
,MarkableListArea
,TreeListArea
public class ListArea<E>
extends Object
implements Area, ClipboardTranslator.Provider, RegionTextQueryTranslator.Provider
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
static interface
static interface
static enum
protected static class
static interface
static class
static interface
-
Field Summary
Modifier and TypeFieldDescriptionprotected String
protected static final Set<ListArea.Appearance.Flags>
protected final ClipboardTranslator
protected final ControlContext
protected int
protected int
protected final ListArea.Appearance<E>
protected ListArea.ClickHandler<E>
protected final ListArea.ClipboardSaver<E>
protected final Set<ListArea.Flags>
protected final ListArea.Model<E>
protected final ListArea.Transition
protected static final Set<ListArea.Appearance.Flags>
protected final RegionPoint
protected final RegionTextQueryTranslator
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
announceChar
(String line, int pos, int rightBound) void
Action[]
int
getExistingItemIndexOnLine
(int lineIndex) int
int
int
getItemIndexOnLine
(int index) getItemOnLine
(int lineIndex) getLine
(int index) int
int
getLineIndexByItemIndex
(int index) int
protected String
getObservableSubstr
(E item) boolean
isEmpty()
protected boolean
protected String
protected boolean
onAltEnd
(InputEvent event) protected boolean
onAltHome
(InputEvent event) protected boolean
onAltLeft
(InputEvent event) protected boolean
onAltRight
(InputEvent event) protected boolean
Announces the list area.protected boolean
boolean
onAreaQuery
(AreaQuery query) protected boolean
protected boolean
onChar
(InputEvent event) boolean
onClipboardCopy
(int fromX, int fromY, int toX, int toY, boolean withDeleting) boolean
boolean
onDeleteRegion
(int fromX, int fromY, int toX, int toY) protected boolean
onEnd
(InputEvent event) protected boolean
onEnter
(InputEvent event) protected boolean
onHome
(InputEvent event) boolean
onInputEvent
(InputEvent event) protected boolean
protected boolean
onMoveDown
(InputEvent event, boolean briefAnnouncement) protected boolean
onMoveHotPoint
(MoveHotPointEvent event) protected boolean
onMoveLeft
(InputEvent event) protected boolean
onMoveRight
(InputEvent event) protected boolean
onMoveUp
(InputEvent event, boolean briefAnnouncement) protected void
onNewHotPointY
(boolean briefAnnouncement) protected boolean
onOk
(SystemEvent event) protected boolean
onPageDown
(InputEvent event, boolean briefAnnouncement) protected boolean
onPageUp
(InputEvent event, boolean briefAnnouncement) onRegionTextQuery
(int fromX, int fromY, int toX, int toY) boolean
onSystemEvent
(SystemEvent event) protected boolean
onTransition
(ListArea.Transition.Type type, Hint hint, boolean briefAnnouncement) void
redraw()
void
refresh()
Refreshes the content of the list.void
reset
(boolean announce) void
void
resetHotPoint
(boolean introduce) boolean
select
(int index, boolean announce) Selects the item by its index.boolean
Searches for the item in the model and sets hot point on it.final E
selected()
Returns the object in the model corresponding to current hot point position.final int
The index of the item in the model which is under the hot point in this list.boolean
selectEmptyLineBottom
(boolean announce) void
setAreaName
(String areaName) void
setListClickHandler
(ListArea.ClickHandler<E> clickHandler)
-
Field Details
-
NONE_APPEARANCE_FLAGS
-
BRIEF_ANNOUNCEMENT_ONLY
-
context
-
regionPoint
-
clipboardTranslator
-
regionTextQueryTranslator
-
areaName
-
listModel
-
listAppearance
-
listTransition
-
listClipboardSaver
-
listFlags
-
listClickHandler
-
hotPointX
protected int hotPointX -
hotPointY
protected int hotPointY
-
-
Constructor Details
-
ListArea
-
-
Method Details
-
setListClickHandler
-
getListModel
-
getListAppearance
-
selected
Returns the object in the model corresponding to current hot point position. If the model is empty or hot point is on an empty line, this method always returnsnull
.- Returns:
- The object in the model associated with the currently selected line or
null
if there is no any
-
selectedIndex
public final int selectedIndex()The index of the item in the model which is under the hot point in this list. This method returns the index in the model, not on the screen. It means that the value returned by this method may be different than the value returned bygetHotPointY()
(but may be equal as well). If the list is empty or an empty line is selected, this method returns -1.- Returns:
- The index of the selected line in the model or -1 if there is no any
-
select
Searches for the item in the model and sets hot point on it. Given an arbitrary object, this method looks through all items in the model and does a couple of checks: literal pointers equality and a check withequals()
method. If at least one of these checks succeeds, the item is considered equal to the given one, and hot points is set on it.- Parameters:
obj
- The object to search forannounce
- Must be true if it is necessary to introduce the object, once it's found- Returns:
- True if the request object is found, false otherwise
-
select
public boolean select(int index, boolean announce) Selects the item by its index. Given the non-negative integer value as an index, this method sets the hot point on the item addressed with this index, checking only that index is in appropriate bounds. Index must address the object as a number in the model, ignoring any empty lines.- Parameters:
index
- The item index to selectannounce
- Must be true, if it is necessary to announce the item , once it has been selected- Returns:
- True if the index is valid and the item gets hot point on it
-
selectEmptyLineBottom
public boolean selectEmptyLineBottom(boolean announce) -
getExistingItemIndexOnLine
public int getExistingItemIndexOnLine(int lineIndex) -
getItemIndexOnLine
public int getItemIndexOnLine(int index) -
getLineIndexByItemIndex
public int getLineIndexByItemIndex(int index) -
getItemOnLine
-
getListItemCount
public int getListItemCount() -
reset
public void reset(boolean announce) -
resetHotPoint
public void resetHotPoint() -
resetHotPoint
public void resetHotPoint(boolean introduce) -
announceSelected
public void announceSelected() -
refresh
public void refresh()Refreshes the content of the list. This method callsrefresh()
method of the model and displays new items. It does not produce any speech announcement of the change. HotPointY is preserved if it is possible (meaning, the new number of lines not less than old value of hotPointY), but hotPointX is moved to the beginning of the line. -
redraw
public void redraw() -
isEmpty
public boolean isEmpty() -
onInputEvent
- Specified by:
onInputEvent
in interfaceArea
-
onSystemEvent
- Specified by:
onSystemEvent
in interfaceArea
-
onAreaQuery
- Specified by:
onAreaQuery
in interfaceArea
-
getAreaActions
- Specified by:
getAreaActions
in interfaceArea
-
getLineCount
public int getLineCount()- Specified by:
getLineCount
in interfaceLines
-
getLine
-
getHotPointX
public int getHotPointX()- Specified by:
getHotPointX
in interfaceArea
- Specified by:
getHotPointX
in interfaceHotPoint
-
getHotPointY
public int getHotPointY()- Specified by:
getHotPointY
in interfaceArea
- Specified by:
getHotPointY
in interfaceHotPoint
-
getAreaName
- Specified by:
getAreaName
in interfaceArea
-
setAreaName
-
onAnnounce
protected boolean onAnnounce()Announces the list area. If the area is created withAREA_ANNOUNCE_SELECTED
flag, this method speaks the screen text of the currently selected item or the area name otherwise (without the flag or if there is no selected item). -
onAnnounceLine
protected boolean onAnnounceLine() -
onMoveHotPoint
-
onBeginListeningQuery
-
onListeningFinishedEvent
-
onChar
-
onMoveDown
-
onMoveUp
-
onPageDown
-
onPageUp
-
onEnd
-
onHome
-
onTransition
-
onMoveRight
-
onMoveLeft
-
onAltRight
-
onAltLeft
-
onAltEnd
-
onAltHome
-
onEnter
-
onOk
-
onRegionTextQuery
- Specified by:
onRegionTextQuery
in interfaceRegionTextQueryTranslator.Provider
-
onClipboardCopyAll
public boolean onClipboardCopyAll()- Specified by:
onClipboardCopyAll
in interfaceClipboardTranslator.Provider
-
onClipboardCopy
public boolean onClipboardCopy(int fromX, int fromY, int toX, int toY, boolean withDeleting) - Specified by:
onClipboardCopy
in interfaceClipboardTranslator.Provider
-
onDeleteRegion
public boolean onDeleteRegion(int fromX, int fromY, int toX, int toY) - Specified by:
onDeleteRegion
in interfaceClipboardTranslator.Provider
-
onNewHotPointY
protected void onNewHotPointY(boolean briefAnnouncement) -
getObservableSubstr
-
noContentStr
-
announceChar
-
noContent
protected boolean noContent()
-