package be.nikiroo.jvcard.tui.panes;
+import java.io.IOException;
import java.util.List;
import be.nikiroo.jvcard.tui.KeyAction;
}
/**
- * The title to display instead of the application name, or NULL for the
+ * The kind of data displayed by this {@link MainContent}.
+ *
+ * @return the kind of data displayed
+ */
+ abstract public KeyAction.DataType getDataType();
+
+ /**
+ * Returns the list of actions and the keys that are bound to it.
+ *
+ * @return the list of actions
+ */
+ abstract public List<KeyAction> getKeyBindings();
+
+ /**
+ * The title to display in addition to the application name, or NULL for the
* default application name.
*
* @return the title or NULL
*/
- abstract public String getTitle();
+ public String getTitle() {
+ return null;
+ }
/**
* Returns an error message ready to be displayed if we should ask something
*
* @return an error message or NULL
*/
- abstract public String getExitWarning();
+ public String getExitWarning() {
+ return null;
+ }
/**
- * The {@link KeyAction#Mode} that links to this {@link MainContent}.
+ * Move the active cursor (not the text cursor, but the currently active
+ * item).
*
- * @return the linked mode
+ * @param x
+ * the horizontal move (< 0 for left, > 0 for right)
+ * @param y
+ * the vertical move (< 0 for up, > 0 for down)
+ *
+ * @return the error message to display if any
*/
- abstract public KeyAction.Mode getMode();
+ public String move(int x, int y) {
+ return null;
+ }
/**
- * The kind of data displayed by this {@link MainContent}.
+ * Return the number of items in this {@link MainContent}, or -1 if this
+ * {@link MainContent} is not countable.
*
- * @return the kind of data displayed
+ * @return -1 or the number of present items
*/
- abstract public KeyAction.DataType getDataType();
+ public int getCount() {
+ return -1;
+ }
/**
- * Returns the list of actions and the keys that are bound to it.
- *
- * @return the list of actions
+ * Refresh the display according to the actual data (this method should be
+ * called when the data changed).
*/
- abstract public List<KeyAction> getKeyBindings();
+ public void refreshData() {
+ invalidate();
+ }
/**
- * Move the active cursor (not the text cursor, but the currently active
- * item).
+ * Wake up call when the content is popped-back into view. You should call
+ * this method when you exit a previous content and come back to this one.
*
- * @param x
- * the horizontal move (< 0 for left, > 0 for right)
- * @param y
- * the vertical move (< 0 for up, > 0 for down)
+ * <p>
+ * By default, it will just refresh the data.
+ * </p>
*
- * @return the error message to display if any
+ * @return a message to display, or NULL
+ *
+ * @throws IOException
+ * in case of error (the message of the {@link IOException} will
+ * be displayed to the user)
*/
- abstract public String move(int x, int y);
+ public String wakeup() throws IOException {
+ refreshData();
+ return null;
+ }
}