Improve UI, take "dirty" check into account, move launcher to Main.java
[jvcard.git] / src / be / nikiroo / jvcard / tui / MainContent.java
1 package be.nikiroo.jvcard.tui;
2
3 import java.util.List;
4
5 import com.googlecode.lanterna.gui2.Direction;
6 import com.googlecode.lanterna.gui2.Interactable;
7 import com.googlecode.lanterna.gui2.LinearLayout;
8 import com.googlecode.lanterna.gui2.Panel;
9
10 /**
11 * This class represents the main content that you can see in this application
12 * (i.e., everything but the title and the actions keys is a {@link Panel}
13 * extended from this class).
14 *
15 * @author niki
16 *
17 */
18 abstract public class MainContent extends Panel {
19
20 public MainContent() {
21 super();
22 }
23
24 public MainContent(Direction dir) {
25 super();
26 LinearLayout layout = new LinearLayout(dir);
27 layout.setSpacing(0);
28 setLayoutManager(layout);
29 }
30
31 /**
32 * The title to display instead of the application name, or NULL for the
33 * default application name.
34 *
35 * @return the title or NULL
36 */
37 abstract public String getTitle();
38
39 /**
40 * Returns an error message ready to be displayed if we should ask something
41 * to the user before exiting.
42 *
43 * @return an error message or NULL
44 */
45 abstract public String getExitWarning();
46
47 /**
48 * The {@link KeyAction#Mode} that links to this {@link MainContent}.
49 *
50 * @return the linked mode
51 */
52 abstract public KeyAction.Mode getMode();
53
54 /**
55 * The kind of data displayed by this {@link MainContent}.
56 *
57 * @return the kind of data displayed
58 */
59 abstract public KeyAction.DataType getDataType();
60
61 /**
62 * Returns the list of actions and the keys that are bound to it.
63 *
64 * @return the list of actions
65 */
66 abstract public List<KeyAction> getKeyBindings();
67
68 /**
69 * Move the active cursor (not the text cursor, but the currently active
70 * item).
71 *
72 * @param x
73 * the horizontal move (&lt; 0 for left, &gt; 0 for right)
74 * @param y
75 * the vertical move (&lt; 0 for up, &gt; 0 for down)
76 *
77 * @return the error message to display if any
78 */
79 abstract public String move(int x, int y);
80 }