Commit | Line | Data |
---|---|---|
fae07ea7 NR |
1 | package be.nikiroo.jvcard.tui.panes; |
2 | ||
3 | import java.util.List; | |
4 | ||
5 | import be.nikiroo.jvcard.tui.KeyAction; | |
6 | ||
7 | import com.googlecode.lanterna.gui2.Direction; | |
8 | import com.googlecode.lanterna.gui2.LinearLayout; | |
9 | import com.googlecode.lanterna.gui2.Panel; | |
10 | ||
11 | /** | |
12 | * This class represents the main content that you can see in this application | |
13 | * (i.e., everything but the title and the actions keys is a {@link Panel} | |
14 | * extended from this class). | |
15 | * | |
16 | * @author niki | |
17 | * | |
18 | */ | |
19 | abstract public class MainContent extends Panel { | |
20 | ||
21 | public MainContent() { | |
22 | super(); | |
23 | } | |
24 | ||
25 | public MainContent(Direction dir) { | |
26 | super(); | |
27 | LinearLayout layout = new LinearLayout(dir); | |
28 | layout.setSpacing(0); | |
29 | setLayoutManager(layout); | |
30 | } | |
31 | ||
fae07ea7 NR |
32 | /** |
33 | * The kind of data displayed by this {@link MainContent}. | |
34 | * | |
35 | * @return the kind of data displayed | |
36 | */ | |
37 | abstract public KeyAction.DataType getDataType(); | |
38 | ||
39 | /** | |
40 | * Returns the list of actions and the keys that are bound to it. | |
41 | * | |
42 | * @return the list of actions | |
43 | */ | |
44 | abstract public List<KeyAction> getKeyBindings(); | |
45 | ||
0b0b2b0f | 46 | /** |
bcb54330 | 47 | * The title to display in addition to the application name, or NULL for the |
0b0b2b0f NR |
48 | * default application name. |
49 | * | |
50 | * @return the title or NULL | |
51 | */ | |
bcb54330 NR |
52 | public String getTitle() { |
53 | return null; | |
54 | } | |
0b0b2b0f NR |
55 | |
56 | /** | |
57 | * Returns an error message ready to be displayed if we should ask something | |
58 | * to the user before exiting. | |
59 | * | |
60 | * @return an error message or NULL | |
61 | */ | |
62 | public String getExitWarning() { | |
63 | return null; | |
64 | } | |
65 | ||
fae07ea7 NR |
66 | /** |
67 | * Move the active cursor (not the text cursor, but the currently active | |
68 | * item). | |
69 | * | |
70 | * @param x | |
71 | * the horizontal move (< 0 for left, > 0 for right) | |
72 | * @param y | |
73 | * the vertical move (< 0 for up, > 0 for down) | |
74 | * | |
75 | * @return the error message to display if any | |
76 | */ | |
0b0b2b0f NR |
77 | public String move(int x, int y) { |
78 | return null; | |
79 | } | |
80 | ||
81 | /** | |
82 | * Return the number of items in this {@link MainContent}, or -1 if this | |
83 | * {@link MainContent} is not countable. | |
84 | * | |
85 | * @return -1 or the number of present items | |
86 | */ | |
87 | public int getCount() { | |
88 | return -1; | |
89 | } | |
bcb54330 NR |
90 | |
91 | /** | |
92 | * Refresh the display according to the actual data (this method should be | |
93 | * called when the data changed). | |
94 | */ | |
95 | public void refreshData() { | |
96 | invalidate(); | |
97 | } | |
fae07ea7 | 98 | } |