1 package be
.nikiroo
.jvcard
.tui
.windows
;
6 import jexer
.TApplication
;
8 import jexer
.event
.TResizeEvent
;
9 import be
.nikiroo
.jvcard
.tui
.panes
.MainContent
;
11 public abstract class TuiBrowserWindow
extends TuiBasicWindow
{
13 private boolean showHeader
;
15 public TuiBrowserWindow(TApplication app
, String title
, boolean showHeaders
) {
18 this.showHeader
= showHeaders
;
20 table
= new TTable(this, 0, 0, getWidth() - 2, getHeight() - 2,
24 onAction(table
.getSelectedLine(),
25 table
.getSelectedColumn());
31 * Change the currently displayed data.
34 * the table headers (mandatory)
38 public void setData(List
<String
> headers
, List
<List
<String
>> lines
) {
39 int prevLine
= table
.getSelectedLine();
40 int prevColumn
= table
.getSelectedColumn();
43 table
.setHeaders(headers
, showHeader
);
44 for (List
<String
> line
: lines
) {
50 table
.setSelectedLine(Math
.min(prevLine
, table
.getNumberOfLines() - 1));
51 table
.setSelectedColumn(Math
.min(prevColumn
,
52 table
.getNumberOfColumns() - 1));
56 * Return the number of items in this {@link MainContent}, or -1 if this
57 * {@link MainContent} is not countable.
59 * @return -1 or the number of present items
62 return table
.getNumberOfLines();
66 * An item has been selected.
69 * the currently selected line
70 * @param selectedColumn
71 * the currently selected column
73 @SuppressWarnings("unused")
74 public void onAction(int selectedLine
, int selectedColumn
) {
78 public void onResize(TResizeEvent resize
) {
79 super.onResize(resize
);
80 // Will be NULL at creation time in super()
82 table
.setWidth(getWidth() - 2);
83 table
.setHeight(getHeight() - 2);