public final class GralTable<UserData> extends GralWidget implements GralTable_ifc<UserData>
rootLine
with a unlimited size.
That container references instances of GralTable.TableLineData
.
Each of that table line contains the texts which are displayed in the cells,
the color etc., a key for searching and a reference to any user data. In that kind a table is a container class
with a graphical touch.
GralTable.TableLineData.cellTexts
of the corresponding line.
If the table content will be shifted in the visible area, the text content of the fields are replaced.
GralTable.CellData
as its
'user data'. The CellData refers via CellData#tableItem
the line.
Graphic representation GralTable GralTable.TableLineData
| |<--------------<#>|
|<*------+ | |<>--userData--->User's data
TextField |---rootLine-----*>|
|<>------>CellData |---lineSelected-->|-->cellTexts
| |-->colors
|---tableItem--------------------->|
UML presentation, see Docu_UML_simpleNotation
.
GralTable.TableLineData
refers any aggregated user data, associated with insertLine(String, int, String[], Object)
or GralTable.NodeTableLine.addChildLine(String, String[], Object)
etc. The user data can be gotten with GralTable.TableLineData.getUserData()
.
The user data are not part of the graphical presentation by automatism. They can be used for graphical implementation
by the application, especially to provide the texts or maybe colors for the table line cells.
GralTable.GraphicImplAccess.processKeys(int)
method which is called
from the graphical implementation layer in an key event handler.
This method processes some keys for navigation and selection in the table. If the key is not
used for that, first the action of GralWidget.setActionChange(GralUserAction)
will be invoked with the key. If that method returns false,
the key will be offer the GralMng.userMainKeyAction
for a global key usage.
specifyActionOnLineSelected(GralUserAction)
is called.
GralWidget.setActionFocused(GralUserAction)
is called from the focus action of the presentation graphic layer.
GralWidget.setFocus()
is called from outside, the selected cell is marked with
GraphicImplAccess.CellData#bSetFocus
. The following repaint sets the focus for that cell.
addContextMenuEntry(int, String, String, GralUserAction)
can be invoked for the table only in the graphic thread.
Use any GralGraphicOrder
to do that, use a callback with this time order on the creation of the table.Modifier and Type | Class and Description |
---|---|
static class |
GralTable.CellData
Data for each Text widget of the graphical implementation layer.
|
class |
GralTable.GraphicImplAccess
This is the super class for all implementers.
|
static class |
GralTable.LinePresentation
|
class |
GralTable.NodeTableLine
This class is the super class of
GralTable.TableLineData which presents a line as a node in a tree. |
class |
GralTable.TableLineData
An instance of this class presents a line in a table or a node or leaf in a tree.
|
GralWidget.ActionChangeSelect, GralWidget.ConfigData, GralWidget.DynamicData, GralWidget.ImplAccess
GralWidgetBase.GralWidgComposite, GralWidgetBase.TimeOrderCreateImplWidget
GralWidget_ifc.ActionChange, GralWidget_ifc.ActionChangeWhen
Modifier and Type | Field and Description |
---|---|
protected MarkMask_ifc |
actionMarkOnLine
This action will be called if any line is marked.
|
(package private) GralUserAction |
actionOnLineSelected
This action will be called any time when the selection of the current line is changed.
|
(package private) GralUserAction |
actionOnRefreshChildren
This action will be called any time when children of a tree node line should be refreshed.
|
(package private) boolean |
bChangedLinesForCell |
protected boolean[] |
bColumnEditable |
(package private) long |
bitLinesForCellChanged |
protected boolean |
bPrepareVisibleArea
If true then the graphic implementation fields for cells should be filled newly with the text.
|
protected GralColor |
colorBackFillPending |
protected GralColor |
colorBackMarked
The color of that lines which are marked.
|
protected GralColor |
colorBackMarked2
The color of that lines which are marked.
|
protected GralColor |
colorBackSelect
The color of the current line.
|
protected GralColor |
colorBackSelectMarked
The color of the current, the selected line if it is marked.
|
protected GralColor |
colorBackSelectMarked2
The color of the current, the selected line if it is marked.
|
protected GralColor |
colorBackSelectNew |
protected GralColor |
colorBackSelectNewMarked |
protected GralColor |
colorBackSelectSomeMarked
The color of the current selected line if some children of it are marked.
|
protected GralColor |
colorBackSelectSomeMarked2
The color of the current selected line if some children of it are marked.
|
protected GralColor |
colorBackSomeMarked
The color of that lines which's some children are marked.
|
protected GralColor |
colorBackSomeMarked2
The color of that lines which's some children are marked.
|
protected GralColor |
colorBackVscrollbar
Background of VscrollBar.
|
protected GralColor |
colorSelectChars |
protected GralColor |
colorSelectCharsBack |
protected GralColor[] |
colorSliderVscrollbar
20 nuances of color for the slider of the vertical scrollBar.
|
protected GralColor |
colorTextMarked |
protected GralColor |
colorTextSelect |
protected int |
colSelectedixCellC
The currently selected cell.
|
protected int |
colSelectedNewixCellC |
protected int[] |
columnWidthsGral
Width of each column in GralUnits.
|
protected int[] |
columnWidthsPromille
Set if relative column widths are used.
|
protected GralMenu[] |
contextMenuColumns |
protected boolean |
fillinPending
Set to true if a fillin is pending.
|
(package private) GralTable.GraphicImplAccess |
gi |
protected GralGraphicOrder |
keyActionDone
This callback is need because the paint of a table needs more time if a slow processor is used
and the key repeat rate is higher than the calculation time.
|
protected int |
keyCloseChild |
protected boolean |
keyDone
If set, then a next key will be processed.
|
protected int |
keyMarkDn |
protected int |
keyMarkUp |
protected int |
keyOpenChild |
protected java.lang.String |
keySeparator
The separator for
TreeNodeBase#getNode(String, String) for nested nodes. |
protected int |
lastKeyCode
The last key which was pressed
|
protected long |
lastKeyTime
Check the last time of redrawing.
|
protected GralTable.TableLineData |
lineSelected
The current line.
|
protected int |
lineSelectedixCell
The currently selected cell.
|
protected int |
lineSelectedixCellLast |
protected GralTable.TableLineData |
lineSelectedNew
The line which is selected by mouse pressing, for right mouse menu.
|
protected int |
lineSelectedNewixCell |
protected GralTable.TableLineData[] |
linesForCell
Array of lines which are currently associated to the cells of the implementation layer.
|
protected GralTable.TableLineData[] |
linesForCellPrev
Array of lines which are currently associated to the cells of the implementation layer.
|
private int |
nLineFirst
Number of lines and number of the current line.
|
(package private) GralTable.NodeTableLine |
rootLine
The root for all lines of the table.
|
protected java.lang.StringBuilder |
searchChars |
protected static java.lang.String |
sVersion
Version, history and license.
|
long |
timeLastKeyUpDn |
protected int |
XXXdLineForCells
Difference of changing ixLine for cells. 0: Assignment not changed.
|
protected int |
zColumn
Number of lines and columns of data.
|
protected int |
zLine
Number of lines and columns of data.
|
private int |
zLineCurr
Number of lines and number of the current line.
|
protected int |
zLineVisible
Current number of visible lines in the view.
|
protected int |
zLineVisibleMax |
_wdgImpl, bEditable, bShouldInitialize, cfg, contextMenu, dateUser, dyda, htmlHelp, lastTimeSetVisible, redrawDelayMax, redrawtDelay, sCmd, sFormat, showWidgetInfo, sToolTip, whatIs, XXXbuildMng
_cdata, _wdgPos, bVisibleState, gralMng, name, pixSize
kAllLines, kEmptyArea, version
version
version
Constructor and Description |
---|
GralTable(GralPos currPos,
java.lang.String posName,
int zLineMax,
int[] columnWidths)
Constructs a table which should be positioned on
#setToPanel(GralMngBuild_ifc) |
Modifier and Type | Method and Description |
---|---|
protected void |
actionOnLineSelected(int key,
GralTableLine_ifc<?> line)
It is called whenever another line is selected, if the focus is gotten by mouse click
or a navigation key is pressed.
|
protected void |
actionOnRefreshChildren(GralTableLine_ifc<?> line)
It is called whenever another line is selected, if the focus is gotten by mouse click
or a navigation key is pressed.
|
void |
addContextMenuEntry(int col,
java.lang.String menuname,
java.lang.String sMenuPath,
GralUserAction action)
Adds a context menu entry for the given column.
|
GralTable.TableLineData |
addLine(java.lang.String lineKey,
java.lang.String[] lineTexts,
UserData userData)
Inserts a line in the table with given content.
|
protected void |
checkAndUpdateText(java.lang.String sText,
GralTable.CellData celldata)
Invoked from focus lost of any table cell implementation, checks whether the line is changed.
|
void |
clearTable() |
void |
deleteLine(GralTableLine_ifc<UserData> line)
Deletes a line in the table.
|
boolean |
fillinPending()
Quest whether the table is in a fillin pending state,
see
fillinPending(boolean) . |
boolean |
fillinPending(boolean set)
Sets the table to a fillin pending state or in a not pending state
This is if another thread sets the line data, or create new lines,
which may need a while.
|
protected void |
fillVisibleArea()
Fills the #linesForCell[] with the appropriate lines from the table.
|
protected void |
fillVisibleAreaBehind(GralTable.TableLineData lineStart,
int ixStart)
Fills the
linesForCell starting from the current line down. |
<any> |
getAllLines()
Returns all lines.
|
java.lang.String |
getCellTextFocus()
Gets the text of any cell which is in focus.
|
int |
getColumnInFocus()
Returns the column which is in focus on an action,
|
GralMenu |
getContextMenuColumn(int col)
Returns the same context menu for all cells of the designated column.
|
GralMenu |
getContextMenuColumnCells(int col,
java.lang.String name,
java.lang.String sMenuPath,
GralUserAction action)
Adds a context menu entries to all cells of the designated column.
|
GralTable.TableLineData |
getCurrentLine()
Returns the current selected line.
|
GralTableLine_ifc<UserData> |
getFirstLine() |
GralTableLine_ifc<UserData> |
getFirstMarkedLine(int mask)
Returns the first line from top of the table which is marked or null if no line is marked.
|
int |
getIxLine(GralTableLine_ifc<UserData> line)
Gets the index in the visual presentation of the given line.
|
GralTable.TableLineData |
getLine(java.lang.String key)
Get the line which is designated with the requested key.
|
GralTable.TableLineData |
getLineMousePressed()
Returns the temporary selected line while pressing the mouse button.
|
java.util.List<UserData> |
getListContent()
Returns all content of lines.
|
java.util.List<GralTableLine_ifc<UserData>> |
getMarkedLines(int mask)
Returns all marked lines.
|
GralTable.TableLineData |
insertLine(java.lang.String lineKey,
int row,
java.lang.String[] lineTexts,
UserData userData)
Insert a new line before the current line, or as first line if the table is empty.
|
<any> |
iterLines()
Returns in iterable object for the lines which can used in a for-element expression
or in a
Iterator usage. |
protected void |
mouseDouble(int key,
GralTable.CellData cell)
Invoked in the graphic thread from mouse listener in
GraphicImplAccess#mouseDoubleGral(int, CellData) |
protected void |
mouseDown(int key,
GralTable.CellData cell)
Invoked in the graphic thread from mouse listener in
GraphicImplAccess#mouseDownGral(int, CellData) |
protected void |
mouseUp(int key,
GralTable.CellData cell)
Invoked in the graphic thread from mouse listener in
GraphicImplAccess#mouseUpGral(int, CellData) |
(package private) GralTable.TableLineData |
nextLine(GralTable.TableLineData lineP) |
int |
nrofLinesVisibleMax()
Constructs a table with position
|
(package private) GralTable.TableLineData |
prevLine(GralTable.TableLineData lineP) |
protected boolean |
processKeys(int keyCode)
Handle all standard keys of table.
|
protected void |
resizePostPreparation()
This operation is called after the widget itself was resized but not just redrawn.
|
protected boolean |
searchContent(boolean bUp)
Increments or decrements ixLineNew in [up] or [dn] situation until the
searchChars are found
or one time if searchChars are not given. |
void |
setColorBackSelectedLine(GralColor color)
Sets the color of the currently selected line.
|
(package private) void |
setColors() |
void |
setColumnEditable(int column,
boolean val)
Sets the specified column to edit-able or not.
|
void |
setColumnProportional(int[] widths)
Specify a proportional width for each column.
|
void |
setColumnWidth(int width,
int[] columnWidths) |
void |
setContextMenuColumn(int col,
GralMenu menu) |
void |
setCurrentColumn(int col) |
void |
setCurrentLine(GralTableLine_ifc<UserData> line,
int ixline,
int ixcolumn)
Sets the cell which is the current one in the given line.
|
boolean |
setCurrentLine(java.lang.String key)
Sets the line which is the current one.
|
void |
setFocus(int delay,
int latest)
Sets the focus of the table.
|
protected int |
shiftVisibleArea(int dLine)
Shifts the content in
linesForCell to show the appropriate part of data
(e.g. lines of rootLine )in the table. |
int |
size()
Returns the number of active lines of the table.
|
void |
specifyActionOnLineMarked(MarkMask_ifc action) |
void |
specifyActionOnLineSelected(GralUserAction action)
Sets an action which is called any time when another line is selected.
|
void |
specifyActionOnRefreshChildren(GralUserAction action)
Sets an action which is called any time when another line is selected.
|
void |
specifyKeysMarkUpDn(int up,
int dn)
Specifies the keys to mark lines in the table.
|
GralTable.TableLineData |
XXXaddLine(java.lang.String key,
java.lang.String[] cellTexts,
UserData userData) |
GralTable.TableLineData |
XXXinsertLine(java.lang.String key,
int row,
java.lang.String[] cellTexts,
UserData userData) |
clearShowParam, createImplWidget_Gthread, getActionChange, getActionChangeStrict, getActionDrag, getActionDrop, getActionFocused, getActionShow, getBackColor, getCfgElement, getCmd, getCmd, getContentIdent, getContentInfo, getContextMenu, getData, getDataIx, getDataPath, getDataPath, getFloatValue, getFocusedWidget, getFormat, getGralWidget, getHtmlHelp, getImplAccess, getImplWidget, getItsPanel, getLongValue, getName, getShowMethod, getShowParam, getsToolTip, getText, getValue, getVariable, getVariableFromContentInfo, isChanged, isEditable, isGraphicDisposed, isInFocus, isNotEditableOrShouldInitialize, isVisible, redraw, redraw, redraw, redraw1, redrawOnlyDynamics, refreshFromVariable, refreshFromVariable, removeImplWidget_Gthread, requestNewValueForVariable, setActionChange, setActionFocused, setActionMouse, setActionShow, setBackColor, setBackgroundColor, setBoundsPixel, setCfgElement, setCmd, setContentIdent, setContentInfo, setData, setDataIx, setDataPath, setDragEnable, setDropEnable, setEditable, setFocus, setFocusedWidget, setForegroundColor, setFormat, setHtmlHelp, setLineColor, setLongValue, setMinMax, setPrimaryWidgetOfPanel, setText, setTextColor, setToolTip, setToPanel, setValue, setValue, setValue, setValue, setVariable, setVisible, specifyActionChange, specifyContextMenu, stop, toString, toString, XXXgetWidgetImplementation, XXXremoveWidgetImplementation, XXXrepaintGthread, XXXsetFocusGThread
checkImplWidgetCreation, createImplWidget, gralMng, hasFocus, pos, remove, setFocused
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getBackColor, setBackColor
getActionChange, getCmd, getContentIdent, getContentInfo, getData, getDataPath, getImplWidget, isChanged, isEditable, isGraphicDisposed, isNotEditableOrShouldInitialize, redraw, redraw, refreshFromVariable, refreshFromVariable, setBackgroundColor, setBoundsPixel, setCmd, setContentIdent, setData, setDataPath, setEditable, setForegroundColor, setHtmlHelp, setLineColor, setText, setTextColor
getFocusedWidget, getImplAccess, getName, gralMng, isInFocus, isVisible, pos, setFocus, setFocused, setFocusedWidget, setVisible
protected static final java.lang.String sVersion
mouseDown(int, CellData)
left mouse now selects the line on down.
The version, selection on mouse-up, only mark with mouse down is reserved only for the right mouse for the context menu.
For that it is important: Functionality: right mouse down shows a selection without change, right mouse up then opens the context menu.
The last one is not programmed here, it is feature of the SWT framework (if a context menu was associated to the org.eclipse.swt.widgets.Control
).
fillVisibleArea()
a little bit progress on using bitLinesForCellChanged
but uncomplete. (It should save calculation time).
processKeys(int)
number of key strokes generally reduced to 100 ms min.
bitLinesForCellChanged
: not active, but try to reduce effort for redraw. Has less effect, is not ready.
keyActionDone
should be called immediately in the graphic thread
to update the cell contents and afterwards with 50 ms delay the same because of the focus.
This is not optimized yet. If the second call is not done, an automatic created focusLost and focusGained from Swt
sets the focus in the Text cell before, why it is unclarified.
TODO maybe improve only set the focused cell in the delayed call, dont update the content.
It may also be that updating forces the focus lost/gain behavior. Experience with order of that,
update at last. In the version now it works but needs a little bit too much calculation time.
colorBackMarked2
etc. for selection lines for copy in Fcmd
respectively as common approach as second selection.
processKeys(int)
experience. Now call keyActionDone
not as event,
instead immediately in the key handler. This is possible, because it is the graphic thread, of course!
It is better to save calculation time for enqueu/dequeu the timer and event.
The idea to show the graphic not on any key stroke to save time for fast repetition is not implemented here,
and it may be not necessary. It may be implementable with a time measurement and counter.
addContextMenuEntry(int, String, String, GralUserAction)
instead addContextMenuEntryGthread(...).
It was the faulty name meanwhile, able to add in any thread.
setCurrentColumn(int)
important to focus a column,
if the evaluation of click/enter should depend from the selected column. At long last it works.
getFirstLine()
sometimes necessary, why this was not existing till now?
fillVisibleArea()
has had a problem if the #lineSelected was =null,
occurring on click on a non existing line in the table. now fixed.
fillinPending(boolean)
especially for color to show,
now first time it is really obviously how long or whether a file panel will be filled in another thread.
processKeys(int)
: More detailed association between key and action.
getColumnInFocus()
. why was this not existing till now?
setColumnProportional(int[])
and resizing with this proportional values.
This feature was longer plant but never implemented till now. See also changes in GralTable.GraphicImplAccess.resizeTable(GralRectangle)
.
GralWidget_ifc.ActionChangeWhen#onAnyKey
instead onEnter. It is systematically.
GralTable.NodeTableLine
with prefix tbl_ to distinguish from nd_ variables from node
#GralTable(String, int, int[])
instead constant 50 for number of showed lines.
getCellTextFocus()
mouseDouble(int, CellData)
the getActionChangeStrict(ActionChangeWhen.onMouse1Double, true)
is checked. Therewith the new concept of GralWidget.specifyActionChange(String, GralUserAction, String[], org.vishia.gral.ifc.GralWidget_ifc.ActionChangeWhen...)
for specific actions is used here now. Firstly only for the mouse double click action. TODO: for all specific actions.
getIxLine(GralTableLine_ifc)
to determine the current position of a given table line.
GralTable.GraphicImplAccess.setBoundsCells(int, int)
now gets the zLineVisible.
The SwtTable.setBoundsCells(int, int)
sets the rest of texts invisible. Therewith the phenomena of ghost lines
on resizing are removed.
GralTable.GraphicImplAccess.resizeTable(GralRectangle)
:
The GralWidgetBase.pos()
should not be used because the Composite is resized with it already. Instead the number of lines
is correctly calculated now and GralTable.GraphicImplAccess.setBoundsCells(int, int)
is invoked with that zLineVisible
.
GralTable.TableLineData.bChangedSet
, the content will be written in SwtTable
or another graphic implementation only if the text is changed. Therewith editing a table is possible while the other cells
are updated frequently. That can be used for tables which shows a current state, and a column is editable.
See InspcViewTargetComm
.
processKeys(int)
: Use tab and sh-tab to switch between the columns.
This keys are used as 'traverse key' normally, but they are ignored for that now by a proper TraverseListener
in SwtTable
. The standard traverse listener which is active for traversing between the
text fields of the table does not set the correct colSelectedixCellC
which is necessary for accept the column.
searchContent(boolean)
: If the search string starts with '*' it searches 'contains(...)'.
GralTable.TableLineData.setBackColor(org.vishia.gral.ifc.GralColor, int)
with colorSelect etc. for content-depending table presentation.
TableLineData#setBackColor(GralColor, int
}
now regards the ix-argument as cell index, like defined in comment.
GraphicImplAccess#processKeys(int
} updates the cell text in the line firstly
if it is an editing cell. It helps to get the correct text in the graphic thread.
colorBackSelectSomeMarked
etc.
setColorBackSelectedLine(GralColor)
instead setColorCurrLine():
It is not the current line which is changed but the color setting for all current (= selected) lines.
checkAndUpdateText(String, CellData)
supports update text on edit cells.
GralTable.CellData
is defined now public and as part of GralTable. There were a problem
using the Java7-Compiler with difficult Generic parameter mismatches. The CellData is a simple data class without
generic, but the compiler has interpreted a generic parameter. May the compiler wrong? The structure of a program
should be simple! The only one disadvantage is, GralTable.CellData
has to be public, not protected,
because it is not seen from the implementation class of GralTable.GraphicImplAccess
. Another problem was
GraphicImplAccess#mouseDownGral()
etc. The compiler has a problem it was named 'mouseDown'
and 'super.mouseDown(ev)' was called from the derivated class. Keep it simple. It does not need the same name.
setColumnEditable(int, boolean)
, supports editing in cells.
GralTable.GraphicImplAccess#focusGained()
etc. refactored.
KeyCode#userSelect
etc. for calling actionOnLineSelected(int, GralTableLine_ifc)
setCurrentLine(GralTableLine_ifc, int, int)
can set the given line to any location in the visible area of table.
GralTable.TableLineData
and GralTable.GraphicImplAccess
are non-static yet
because the generic type should be the same without additional effort. This is the reason.
Nevertheless the non-static property was given already, but deployed by the outer aggregation
of the static one.
GralTable.TableLineData
now extends TreeNodeBase
. It is a tree.
GralTable.GraphicImplAccess.cells
, the GraphicImplAccess.CellData
are able to access
elsewhere only in the implementation layer via the text widget.
GralTable.TableLineData
is static now with outer reference, more transparent
GralTable.GraphicImplAccess.resizeTable(GralRectangle)
moved from SWT implementation,
preparing tree view. GralTable.NodeTableLine.tbl_treeDepth
, GralTable.TableLineData#childLines
for tree view.
GralTable.TableLineData
is static now with outer reference, more transparent
actionOnLineSelected(int, GralTableLine_ifc)
only if the line is changed,
not on focus without changed line.
GralWidget.setBackColor(GralColor, int)
with special comments for usage of the int parameter.
See GralTable_ifc.setBackColor(GralColor, int)
, Adequate GralWidget.getBackColor(int)
.
GralTable.GraphicImplAccess
implements now GralWidgImplAccess_ifc
without any other
changes (was proper) and sets GralWidget._wdgImpl
. Therefore all routines which works from the
GralWidget calls the methods of the implement of the GralTable immediately without special overridden methods
in this class. It is the concept.
GralWidget.DynamicData.backColor
etc.
#getMarkedLines()
now checkes the TableLineData#userData
whether that is instanceof MarkMask_ifc
. If true then uses its selection state
instead the selection state of the GralTable.TableLineData
.
GralTable.GraphicImplAccess
is provided as super class for the graphic implementation class,
for example SwtTable
.
GralTable
, the GralTable.TableLineData
and this
interface are marked with the generic type UserData.
TableLineData#lineInGraphic
not used yet, but for further usage.
Maybe for refresh data only if they are in the visible range. 2013-10-03 removed, too many effort on tree view.
To detect visible lines iterate over GralTable.GraphicImplAccess.cells
deleteLine(GralTableLine_ifc)
was not ready, now tested
GralTable.TableLineData
instead TableItemWidget.
specifyKeysMarkUpDn(int, int)
specifyActionOnLineMarked(MarkMask_ifc)
actionOnLineSelected(int, GralTableLine_ifc)
processKeys(int)
: input of a text key starts searching for a line with this key
immediately, better handling for usage.
#setCurrentLine(int)
with int, it isn't new because it was able to set with
#setCurrentCell(int, int)
with -1 as second parameter.
#ixColumn
starts with the search string.
#idxLine
was not cleared if the table was cleared.
#setColorCurrLine(GralColor)
setCurrentLine(String)
, insertLine(String, int, String[], Object)
:
the key is supported now.
#procStandardKeys(int, GralTableLine_ifc, int)
returns true if standard keys are used.
actionOnLineSelected(int, GralTableLine_ifc)
: The user action is called
anytime if a line is selected by user operation. It can be show any associated content anywhere
additionally. It is used for example in "The.file.Commander" to show date, time and maybe content
while the user selects any files. The graphical implementation should be call actionOnLineSelected(int, GralTableLine_ifc)
in its Selection listener.
GralSelectList
to this class. It means any table has the capability
of selection of multiple lines. This capability is supported with a extension of the
GralTableLine_ifc
with org.vishia.util.MarkMask_ifc
. The selection of a line
is notificated in the users data which are associated with the table line, not in the graphic
representation of the table. This is differenced to SWT Table implementation. The capability
of selection in an SWT table isn't used. The selection is done by default with shift-key up/down
or with mouse selection ctrl-click, shift-click like usual.
The selection is not missed if the up/down keys are pressed furthermore. More as that,
more as one ranges of lines can be selected. That is a better capability than in SWT.
protected int keyMarkUp
protected int keyMarkDn
protected int keyOpenChild
protected int keyCloseChild
protected java.lang.String keySeparator
TreeNodeBase#getNode(String, String)
for nested nodes.
This can be set for special tables. Default is null because no tree-table.GralUserAction actionOnLineSelected
GralUserAction.exec(int, GralWidget_ifc, Object...)
will be called
with the line as Object.GralUserAction actionOnRefreshChildren
GralUserAction.exec(int, GralWidget_ifc, Object...)
will be called
with the line as Object.public long timeLastKeyUpDn
protected int[] columnWidthsGral
protected int[] columnWidthsPromille
protected boolean[] bColumnEditable
protected GralMenu[] contextMenuColumns
protected int lineSelectedixCell
protected int colSelectedixCellC
protected int lineSelectedixCellLast
protected int lineSelectedNewixCell
protected int colSelectedNewixCellC
protected GralTable.TableLineData[] linesForCell
rootLine
are all of the lines of the table. They are not associated to any graphic widget any time.
Whether they are associated to a graphic widget or not is able to evaluate with this array.
The cellLines[0] is the TableLineData of the first visible line in any case etc.protected GralTable.TableLineData[] linesForCellPrev
rootLine
are all of the lines of the table. They are not associated to any graphic widget any time.
Whether they are associated to a graphic widget or not is able to evaluate with this array.
The cellLines[0] is the TableLineData of the first visible line in any case etc.long bitLinesForCellChanged
boolean bChangedLinesForCell
protected GralTable.TableLineData lineSelected
protected GralTable.TableLineData lineSelectedNew
protected boolean fillinPending
protected int zLine
protected int zColumn
protected int zLineVisible
protected int zLineVisibleMax
private int zLineCurr
rootLine
private int nLineFirst
rootLine
protected final java.lang.StringBuilder searchChars
GralTable.NodeTableLine rootLine
protected boolean bPrepareVisibleArea
protected int XXXdLineForCells
#redrawTableWithFocusedCell(CellData)
protected long lastKeyTime
protected int lastKeyCode
protected boolean keyDone
keyActionDone
.protected GralColor colorBackSelect
protected GralColor colorBackMarked
protected GralColor colorBackSelectMarked
protected GralColor colorBackSomeMarked
protected GralColor colorBackSelectSomeMarked
protected GralColor colorBackMarked2
protected GralColor colorBackSelectMarked2
protected GralColor colorBackSomeMarked2
protected GralColor colorBackSelectSomeMarked2
protected GralColor colorBackSelectNew
protected GralColor colorBackSelectNewMarked
protected GralColor colorBackFillPending
protected GralColor colorTextSelect
protected GralColor colorTextMarked
protected GralColor colorSelectCharsBack
protected GralColor colorSelectChars
protected GralColor colorBackVscrollbar
protected final GralColor[] colorSliderVscrollbar
protected MarkMask_ifc actionMarkOnLine
protected final GralGraphicOrder keyActionDone
keyDone
= true, then the next key
is processed immediately. Elsewhere, if the graphic thread is busy in the graphic os dispatching
and a new key event is received there, the key action won't be executed.
public GralTable(GralPos currPos, java.lang.String posName, int zLineMax, int[] columnWidths)
#setToPanel(GralMngBuild_ifc)
currPos
- Position used for current, maybe nullposName
- String given position in GralPos units and name, see GralWidget.GralWidget(GralPos, String, char)
zLineMax
- maximal number of lines managed for content. It should be related to the size of viewing. 10..50 is proper.columnWidths
- positive value from left: width, negative value from right: width.
The last column with a positive width is used for sizeable.public int nrofLinesVisibleMax()
pos
- String given position in GralPos units.name
- to registratecolumnWidths
- positive value from left: width, negative value from right: width.
The last column with a positive width is used for sizeable.public void specifyActionOnLineSelected(GralUserAction action)
GralUserAction.userActionGui(int, GralWidget, Object...)
will be called
with the line as Object and the following keys:
KeyCode#removed
if the table was cleard.
KeyCode#defaultSelect
if the table was filled and firstly the lineSelected
is set.
KeyCode#userSelect
if the user acts with keyboard or mouse
actionOnLineSelected
- The action, null to switch off this functionality.public void specifyActionOnLineMarked(MarkMask_ifc action)
public void specifyActionOnRefreshChildren(GralUserAction action)
GralUserAction.userActionGui(int, GralWidget, Object...)
will be called
with the line as Object.actionOnLineSelected
- The action, null to switch off this functionality.public void specifyKeysMarkUpDn(int up, int dn)
KeyCode#shift
+ KeyCode#up
respectively shift+dn are specified.up
- Any code defined in KeyCode
which marks a line and selects the next line after them.dn
- Any code defined in KeyCode
which marks a line and selects the previous line after them.public void addContextMenuEntry(int col, java.lang.String menuname, java.lang.String sMenuPath, GralUserAction action)
getContextMenuColumn(int)
and GralMenu.addMenuItem(String, String, GralUserAction)
.
The context menu is valid for the column of the whole table independent of the line. In the
GralUserAction.exec(int, GralWidget_ifc, Object...)
method (param action) the given widget
is the whole table. To get the line where the mouse was pressed:
getLineMousePressed()
returns the line where the mouse was pressed to open the context menu
getCurrentLine()
returns the line which was selected before. It is possible especially to work with both lines.
The mouse button for the context menu does not change the current line of the table.
col
- The column, see getContextMenuColumn(int)
identArgJbat
- The name of the entry, see GralMenu.addMenuItem(String, String, GralUserAction)
sMenuPath
- same like GralMenu.addMenuItem(String, String, GralUserAction)
action
- the action invoked on menu entered.public GralMenu getContextMenuColumn(int col)
#getContextMenuColumnCells(int)
is: Some resources are saved, because there is only one menu item instance in the implementation layer
of the graphic for all cells.#getContextMenuColumnCells(int)
. Note that the GralWidget_ifc
-parameter of the
GralUserAction.exec(int, GralWidget_ifc, Object...)
methods of all added menu entries
are given with the whole table, instance of this GralTable
.col
- The column of the table, count from 0,1,...GralMenu.addMenuItem(String, String, GralUserAction)
.public void setContextMenuColumn(int col, GralMenu menu)
public GralMenu getContextMenuColumnCells(int col, java.lang.String name, java.lang.String sMenuPath, GralUserAction action)
getContextMenuColumn(int)
or addContextMenuEntry(int, String, String, GralUserAction)
are called before. That is because either only one context menu can be added to all cells of a column
(saves resources) or internal an extra context menu with the same appearance can be addes to all cells
of the column. Using this method creates a context menu and its entry for all cells of the column
with an extra menu instance. The reason of the extra instance is: The menu instance associates the cell,
and the cell associates the table line via GralTableLine_ifc
. Because that the
GralWidget_ifc
-parameter of the GralUserAction.exec(int, GralWidget_ifc, Object...)
of the action parameter refers the cell. Use the following template for the action:
col
- The column of the table, count from 0,1,...GralMenu.addMenuItem(String, String, GralUserAction)
.public void setColumnWidth(int width, int[] columnWidths)
public void setColumnProportional(int[] widths)
setColumnWidth(int, int[])
are used as minimal values.
Hence a value of 0 for width means, the given absolute width should be used anytime.
widths
- public void setColumnEditable(int column, boolean val)
#setToPanel(GralMngBuild_ifc)
or after them in running mode.column
- the number, starting by 0.val
- true then edit-able, false then read only.java.lang.IndexOutOfBoundsException
- on faulty column.public boolean setCurrentLine(java.lang.String key)
GralTable_ifc
setCurrentLine
in interface GralTable_ifc<UserData>
key
- The key of the line, given by GralTable_ifc.insertLine(String, int, String[], Object)
.void setColors()
public void setFocus(int delay, int latest)
GraphicImplAccess.CellData#bSetFocus
).
Than it invokes the overridden super.GralWidget.setFocus(int, int)
.
That method asserts the visibility of the table and calls GralWidgImplAccess_ifc.setFocusGThread()
That method is implemented in the implementation widget layer and causes a redraw which focused
the correct cell.setFocus
in interface GralWidget_ifc
setFocus
in interface GralWidgetBase_ifc
setFocus
in class GralWidget
delay
- Delay in ms for invoking the focus requestGralWidget.setFocus(int, int)
public void setCurrentLine(GralTableLine_ifc<UserData> line, int ixline, int ixcolumn)
GralTable_ifc
setCurrentLine
in interface GralTable_ifc<UserData>
line
- The line which should be selected.ixline
- the index in the visible are of table where the line should be present.
If the index is negative, it is the index from end of visible area. -1 means the last line.
if the index is outside of the area, it will be set inside.ixcolumn
- from 0 for the left column, if -1 then let the current row of table unchanged.public void setCurrentColumn(int col)
public void setColorBackSelectedLine(GralColor color)
color
- public boolean fillinPending()
fillinPending(boolean)
.public boolean fillinPending(boolean set)
set
- true: set to pending, false: set to ready.public GralTable.TableLineData getCurrentLine()
getCurrentLine
in interface GralTable_ifc<UserData>
public GralTable.TableLineData getLineMousePressed()
#lineSelected()
is unchanged in this moment.public GralTable.TableLineData getLine(java.lang.String key)
GralTable_ifc
getLine
in interface GralTable_ifc<UserData>
key
- The key to find out the row.public GralTableLine_ifc<UserData> getFirstLine()
public java.lang.String getCellTextFocus()
public int getColumnInFocus()
public int getIxLine(GralTableLine_ifc<UserData> line)
line
- any line of this table, maybe null, maybe a line from any other tablepublic GralTable.TableLineData insertLine(java.lang.String lineKey, int row, java.lang.String[] lineTexts, UserData userData)
insertLine
in interface GralTable_ifc<UserData>
lineKey
- The key to get it.row
- The row where the line should be inserted before. 0 - insert on top.
negative or Integer.MAXINT or number greater as number of rows: append on end.lineTexts
- texts of the cells. May be null.userData
- data assigned to the line, able to get with GralTableLine_ifc.getUserData()
.GralTableLine_ifc} to add content.
public GralTable.TableLineData XXXinsertLine(java.lang.String key, int row, java.lang.String[] cellTexts, UserData userData)
public GralTable.TableLineData addLine(java.lang.String lineKey, java.lang.String[] lineTexts, UserData userData)
GralTable_ifc
addLine
in interface GralTable_ifc<UserData>
lineKey
- The key to get it.lineTexts
- texts of the cells. May be null.userData
- data assigned to the line, maybe null, able to get with GralTableLine_ifc.getUserData()
.GralTable_ifc.addLine(String, String[], Object)
public GralTable.TableLineData XXXaddLine(java.lang.String key, java.lang.String[] cellTexts, UserData userData)
public void deleteLine(GralTableLine_ifc<UserData> line)
GralTable_ifc
deleteLine
in interface GralTable_ifc<UserData>
public <any> iterLines()
Iterator
usage.
Because the class GralTable.TableLineData
implements the GralTableLine_ifc
the user can write for example: for(GralTableLine_ifcline: widgTableVariables.iterLines()) { MyData data = line.getUserData(); line.setBackColor(colorXY, 0); }
public int size()
GralTable_ifc
size
in interface GralTable_ifc<UserData>
public void clearTable()
clearTable
in interface GralTable_ifc<UserData>
public java.util.List<GralTableLine_ifc<UserData>> getMarkedLines(int mask)
GralTable_ifc
getMarkedLines
in interface GralTable_ifc<UserData>
public <any> getAllLines()
GralTable_ifc
GralTable_ifc.insertLine(String, int, String[], Object)
or GralTable_ifc.deleteLine(GralTableLine_ifc)
will be called. Do not call any modification of this list
for example List.add(Object)
or List.remove(int)
, use the methods
of this interface to change the content of the table. Elsewhere the graphical presentation of the data
may be corrupted.
See GralTable_ifc.getListContent()
.getAllLines
in interface GralTable_ifc<UserData>
public java.util.List<UserData> getListContent()
GralTable_ifc
ConcurrentModificationException
will be thrown. But after them the list is able to use independently.getListContent
in interface GralTable_ifc<UserData>
public GralTableLine_ifc<UserData> getFirstMarkedLine(int mask)
GralTable_ifc
getFirstMarkedLine
in interface GralTable_ifc<UserData>
protected void fillVisibleArea()
lineSelectedixCell
with the line number where the lineSelected
is presented.protected void fillVisibleAreaBehind(GralTable.TableLineData lineStart, int ixStart)
linesForCell
starting from the current line down.
This is called in fillVisibleArea()
but also if a line is folded/unfolded.
Then only the following lines are influenced.lineStart
- from this line in the whole #rootline
container.ixStart
- index in the graphical rows in the table.protected int shiftVisibleArea(int dLine)
linesForCell
to show the appropriate part of data
(e.g. lines of rootLine
)in the table.dLine
- >0 shift up to get next lines, <0 shift down to get previous linesGralTable.TableLineData nextLine(GralTable.TableLineData lineP)
GralTable.TableLineData prevLine(GralTable.TableLineData lineP)
protected void mouseDown(int key, GralTable.CellData cell)
GraphicImplAccess#mouseDownGral(int, CellData)
key
- cell
- protected void mouseUp(int key, GralTable.CellData cell)
GraphicImplAccess#mouseUpGral(int, CellData)
key
- cell
- protected void mouseDouble(int key, GralTable.CellData cell)
GraphicImplAccess#mouseDoubleGral(int, CellData)
key
- cell
- protected boolean searchContent(boolean bUp)
searchChars
are found
or one time if searchChars are not given.
If the searchChars are not found, either the first or last line will be selected. It is because
any key operation should have an effect for the user. Paradigm: Not the search and found is prior,
the response of operation is prior. The user may see whether anything is found.bUp
- directionprotected void checkAndUpdateText(java.lang.String sText, GralTable.CellData celldata)
sText
- The text in the cell from the implementation widget.celldata
- The cell, the line is gotten from linesForCell
[GralTable.CellData.ixCellLine
].protected boolean processKeys(int keyCode)
keyMarkUp
keyMarkDn
GralMng.getRegisteredUserAction(String what)
with what="KeyAction"
and invokes the returned action method. With them all standard key actions of this application
may be done if a GralUserAction
is registered for that.
keyCode
- Encoding see KeyCode
.protected void resizePostPreparation()
GralWidgetBase
GralWidgetBase.GralWidgComposite.resizeWidgets(GralRectangle, int)
If some specific resize operations should be done for redraw (for example calculate which implementation widgets are visible)
Then this operation should be overridden.
It is done for example in resizePostPreparation()
.resizePostPreparation
in class GralWidgetBase
protected void actionOnLineSelected(int key, GralTableLine_ifc<?> line)
GralUserAction.userActionGui(int, GralWidget, Object...)
.
The specifyActionOnLineSelected(GralUserAction)
can be set with any user instantiation
of that interface. The params[0] of that routine are filled with the GralTableLine_ifc
of the selected line.line
- protected void actionOnRefreshChildren(GralTableLine_ifc<?> line)
GralUserAction.userActionGui(int, GralWidget, Object...)
.
The specifyActionOnLineSelected(GralUserAction)
can be set with any user instantiation
of that interface. The params[0] of that routine are filled with the GralTableLine_ifc
of the selected line.line
-