Add more warnings source to 1.6) and fix warnings
[jvcard.git] / src / be / nikiroo / jvcard / tui / panes / MainContent.java
CommitLineData
fae07ea7
NR
1package be.nikiroo.jvcard.tui.panes;
2
5ad0e17e 3import java.io.IOException;
fae07ea7
NR
4import java.util.List;
5
6import be.nikiroo.jvcard.tui.KeyAction;
7
8import com.googlecode.lanterna.gui2.Direction;
9import com.googlecode.lanterna.gui2.LinearLayout;
10import com.googlecode.lanterna.gui2.Panel;
11
12/**
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).
16 *
17 * @author niki
18 *
19 */
20abstract public class MainContent extends Panel {
21
22 public MainContent() {
23 super();
24 }
25
26 public MainContent(Direction dir) {
27 super();
28 LinearLayout layout = new LinearLayout(dir);
29 layout.setSpacing(0);
30 setLayoutManager(layout);
31 }
32
fae07ea7
NR
33 /**
34 * The kind of data displayed by this {@link MainContent}.
35 *
36 * @return the kind of data displayed
37 */
38 abstract public KeyAction.DataType getDataType();
39
40 /**
41 * Returns the list of actions and the keys that are bound to it.
42 *
43 * @return the list of actions
44 */
45 abstract public List<KeyAction> getKeyBindings();
46
0b0b2b0f 47 /**
bcb54330 48 * The title to display in addition to the application name, or NULL for the
0b0b2b0f
NR
49 * default application name.
50 *
51 * @return the title or NULL
52 */
bcb54330
NR
53 public String getTitle() {
54 return null;
55 }
0b0b2b0f
NR
56
57 /**
58 * Returns an error message ready to be displayed if we should ask something
59 * to the user before exiting.
60 *
61 * @return an error message or NULL
62 */
63 public String getExitWarning() {
64 return null;
65 }
66
fae07ea7
NR
67 /**
68 * Move the active cursor (not the text cursor, but the currently active
69 * item).
70 *
71 * @param x
72 * the horizontal move (&lt; 0 for left, &gt; 0 for right)
73 * @param y
74 * the vertical move (&lt; 0 for up, &gt; 0 for down)
75 *
76 * @return the error message to display if any
77 */
d5260eeb 78 @SuppressWarnings("unused")
0b0b2b0f
NR
79 public String move(int x, int y) {
80 return null;
81 }
82
83 /**
84 * Return the number of items in this {@link MainContent}, or -1 if this
85 * {@link MainContent} is not countable.
86 *
87 * @return -1 or the number of present items
88 */
89 public int getCount() {
90 return -1;
91 }
bcb54330
NR
92
93 /**
94 * Refresh the display according to the actual data (this method should be
95 * called when the data changed).
96 */
97 public void refreshData() {
98 invalidate();
99 }
5ad0e17e
NR
100
101 /**
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.
104 *
3634193b
NR
105 * <p>
106 * By default, it will just refresh the data.
107 * </p>
108 *
5ad0e17e
NR
109 * @return a message to display, or NULL
110 *
111 * @throws IOException
112 * in case of error (the message of the {@link IOException} will
113 * be displayed to the user)
114 */
115 public String wakeup() throws IOException {
3634193b 116 refreshData();
5ad0e17e
NR
117 return null;
118 }
fae07ea7 119}