1 package be
.nikiroo
.jvcard
.tui
.panes
;
3 import java
.io
.IOException
;
6 import be
.nikiroo
.jvcard
.tui
.KeyAction
;
8 import com
.googlecode
.lanterna
.gui2
.Direction
;
9 import com
.googlecode
.lanterna
.gui2
.LinearLayout
;
10 import com
.googlecode
.lanterna
.gui2
.Panel
;
13 * This class represents the main content that you can see in this application
14 * (i.e., everything but the title and the actions keys is a {@link Panel}
15 * extended from this class).
20 abstract public class MainContent
extends Panel
{
22 public MainContent() {
26 public MainContent(Direction dir
) {
28 LinearLayout layout
= new LinearLayout(dir
);
30 setLayoutManager(layout
);
34 * The kind of data displayed by this {@link MainContent}.
36 * @return the kind of data displayed
38 abstract public KeyAction
.DataType
getDataType();
41 * Returns the list of actions and the keys that are bound to it.
43 * @return the list of actions
45 abstract public List
<KeyAction
> getKeyBindings();
48 * The title to display in addition to the application name, or NULL for the
49 * default application name.
51 * @return the title or NULL
53 public String
getTitle() {
58 * Returns an error message ready to be displayed if we should ask something
59 * to the user before exiting.
61 * @return an error message or NULL
63 public String
getExitWarning() {
68 * Move the active cursor (not the text cursor, but the currently active
72 * the horizontal move (< 0 for left, > 0 for right)
74 * the vertical move (< 0 for up, > 0 for down)
76 * @return the error message to display if any
78 @SuppressWarnings("unused")
79 public String
move(int x
, int y
) {
84 * Return the number of items in this {@link MainContent}, or -1 if this
85 * {@link MainContent} is not countable.
87 * @return -1 or the number of present items
89 public int getCount() {
94 * Refresh the display according to the actual data (this method should be
95 * called when the data changed).
97 public void refreshData() {
102 * Wake up call when the content is popped-back into view. You should call
103 * this method when you exit a previous content and come back to this one.
106 * By default, it will just refresh the data.
109 * @return a message to display, or NULL
111 * @throws IOException
112 * in case of error (the message of the {@link IOException} will
113 * be displayed to the user)
115 public String
wakeup() throws IOException
{