Add more warnings source to 1.6) and fix warnings
[jvcard.git] / src / be / nikiroo / jvcard / tui / panes / MainContent.java
index df8731366b37d788e2ab5ff86258e018221fb4da..c63afd9b47ef2da4dd919f1fac5ab6791d917e61 100644 (file)
@@ -1,5 +1,6 @@
 package be.nikiroo.jvcard.tui.panes;
 
+import java.io.IOException;
 import java.util.List;
 
 import be.nikiroo.jvcard.tui.KeyAction;
@@ -30,12 +31,28 @@ abstract public class MainContent extends Panel {
        }
 
        /**
-        * 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
@@ -43,39 +60,60 @@ abstract public class MainContent extends Panel {
         * 
         * @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 (&lt; 0 for left, &gt; 0 for right)
+        * @param y
+        *            the vertical move (&lt; 0 for up, &gt; 0 for down)
+        * 
+        * @return the error message to display if any
         */
-       abstract public KeyAction.Mode getMode();
+       @SuppressWarnings("unused")
+       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 (&lt; 0 for left, &gt; 0 for right)
-        * @param y
-        *            the vertical move (&lt; 0 for up, &gt; 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;
+       }
 }