+
+ /**
+ * Used to callback a function from the menu when the user has to introduce
+ * some text.
+ *
+ * @param answer
+ * the user answer
+ *
+ * @return an error message if any
+ */
+ @SuppressWarnings("unused")
+ public String callback(String answer) {
+ return null;
+ }
+
+ /**
+ * When asking a question to the user, return the question.
+ *
+ * @return the question
+ */
+ public String getQuestion() {
+ return null;
+ }
+
+ /**
+ * When asking a question to the user (not for one-key mode), return the
+ * default answer.
+ *
+ * @return the default answer
+ */
+ public String getDefaultAnswer() {
+ return null;
+ }
+
+ /**
+ * Translate the given {@link KeyStroke} into a user text {@link String} of
+ * size 3.
+ *
+ * @param key
+ * the key to translate
+ *
+ * @return the translated text
+ */
+ static public String trans(KeyStroke key) {
+ String keyTrans = "";
+
+ switch (key.getKeyType()) {
+ case Enter:
+ if (Main.isUnicode())
+ keyTrans = " ⤶ ";
+ else
+ keyTrans = Main.trans(StringId.KEY_ENTER);
+ break;
+ case Tab:
+ if (Main.isUnicode())
+ keyTrans = " ↹ ";
+ else
+ keyTrans = Main.trans(StringId.KEY_TAB);
+
+ break;
+ case Character:
+ keyTrans = " " + key.getCharacter() + " ";
+ break;
+ default:
+ keyTrans = "" + key.getKeyType();
+ int width = 3;
+ if (keyTrans.length() > width) {
+ keyTrans = keyTrans.substring(0, width);
+ } else if (keyTrans.length() < width) {
+ keyTrans = keyTrans
+ + new String(new char[width - keyTrans.length()])
+ .replace('\0', ' ');
+ }
+ break;
+ }
+
+ return keyTrans;
+ }