X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=Addressbook%2Fsrc%2Forg%2Fmxchange%2Faddressbook%2Fmenu%2FAddressbookMenu.java;h=12257eb08d96aa8d80fbfba4cf5b53d00281e134;hb=a67280d037eb9f783695157780cbbc676e84b26f;hp=02d00b65808179e9c8231d88b7ffbb7671da1bfe;hpb=5bacd2cdd7a323b9047addcdd1b921c4ae8983a1;p=addressbook-swing.git
diff --git a/Addressbook/src/org/mxchange/addressbook/menu/AddressbookMenu.java b/Addressbook/src/org/mxchange/addressbook/menu/AddressbookMenu.java
index 02d00b6..12257eb 100644
--- a/Addressbook/src/org/mxchange/addressbook/menu/AddressbookMenu.java
+++ b/Addressbook/src/org/mxchange/addressbook/menu/AddressbookMenu.java
@@ -1,85 +1,106 @@
-/*
- * Copyright (C) 2015 Roland Haeder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-package org.mxchange.addressbook.menu;
-
-import java.util.List;
-import org.apache.logging.log4j.Logger;
-import org.mxchange.addressbook.BaseFrameworkSystem;
-import org.mxchange.addressbook.client.Client;
-import org.mxchange.addressbook.menu.item.SelectableMenuItem;
-
-/**
- * Utility class for menu structure
- *
- * @author Roland Haeder
- */
-public class AddressbookMenu extends BaseFrameworkSystem {
- /**
- * Copies entries for given type into the menu list
- *
- * @param menuList Menu list for later showing
- * @param menuType Type of menu
- * @param client Client instance to call back
- */
- public static void addItemsToList (final List menuList, final String menuType, final Client client) {
- // Get logger
- Logger log = new AddressbookMenu().getLogger();
-
- // Get list size
- int size = menuList.size();
-
- // Debug message
- log.debug("Adding menu for '" + menuType + "' (old size: '" + size + "') ...");
-
- // Depends on type
- switch (menuType) {
- case "main": // Main menu
- // Enter own data
- menuList.add(client.getMenuItem('1', "Eigene Adresse anlegen"));
-
- // Change own data
- menuList.add(client.getMenuItem('2', "Eigene Adresse ändern"));
-
- // Add new addess
- menuList.add(client.getMenuItem('3', "Neue Adresse hinzufügen"));
-
- // List entries
- menuList.add(client.getMenuItem('4', "Adressbuch anzeigen"));
-
- // Address search
- menuList.add(client.getMenuItem('5', "Adresse suchen"));
-
- // Change other address
- menuList.add(client.getMenuItem('6', "Adresse ändern"));
-
- // Delete other address
- menuList.add(client.getMenuItem('7', "Adresse löschen"));
-
- // Always last line: Exit program
- menuList.add(client.getMenuItem('0', "Programm verlassen"));
- break;
-
- default: // Not supported
- log.error("Menu type '" + menuType + "' ont supported");
- System.exit(1);
- }
-
- // Size must have changed to more entries than before
- assert(menuList.size() > size);
- }
-
-}
+/*
+ * Copyright (C) 2015 Roland Haeder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+package org.mxchange.addressbook.menu;
+
+import java.text.MessageFormat;
+import java.util.List;
+import org.apache.logging.log4j.Logger;
+import org.mxchange.addressbook.BaseAddressbookSystem;
+import org.mxchange.addressbook.client.AddressbookClient;
+import org.mxchange.addressbook.menu.item.SelectableMenuItem;
+import org.mxchange.jcore.client.Client;
+
+/**
+ * Utility class for menu structure
+ *
+ * @author Roland Haeder
+ */
+public class AddressbookMenu extends BaseAddressbookSystem {
+
+ /**
+ * Copies entries for given type into the menu list
+ *
+ * @param menuList Menu list for later showing
+ * @param menuType Type of menu
+ * @param client Client instance to call back
+ */
+ public static void addItemsToList (final List menuList, final String menuType, final Client client) {
+ // Get logger
+ Logger log = new AddressbookMenu().getLogger();
+
+ // Trace call
+ log.trace(MessageFormat.format("menuList={0},menuType={1},client={2} - CALLED!", menuList, menuType, client)); //NOI18N
+
+ // Some instances must be set
+ if (menuList == null) {
+ // Abort here
+ throw new NullPointerException("menuList is null"); //NOI18N
+ } else if (client == null) {
+ // Abort here
+ throw new NullPointerException("contact is null"); //NOI18N
+ } else if (!(client instanceof AddressbookClient)) {
+ // Not correct instance
+ throw new IllegalArgumentException(MessageFormat.format("client{0} must implement AddressbookClient", client));
+ }
+
+ // Cast client to proper interface
+ AddressbookClient c = (AddressbookClient) client;
+
+ // Get list size
+ int size = menuList.size();
+
+ // Debug message
+ log.debug(MessageFormat.format("Adding menu for '{0}' (old size: '{1}') ...", menuType, size)); //NOI18N
+
+ // Depends on type
+ switch (menuType) {
+ case "main": // Main menu //NOI18N
+ // Enter own data
+ menuList.add(c.getMenuItem('1', "Eigene Adresse anlegen"));
+
+ // Change own data
+ menuList.add(c.getMenuItem('2', "Eigene Adresse ändern"));
+
+ // Add new addess
+ menuList.add(c.getMenuItem('3', "Neue Adresse hinzufügen"));
+
+ // List entries
+ menuList.add(c.getMenuItem('4', "Adressbuch anzeigen"));
+
+ // Address search
+ menuList.add(c.getMenuItem('5', "Adresse suchen"));
+
+ // Change other address
+ menuList.add(c.getMenuItem('6', "Adresse ändern"));
+
+ // Delete other address
+ menuList.add(c.getMenuItem('7', "Adresse löschen"));
+
+ // Always last line: Exit program
+ menuList.add(c.getMenuItem('0', "Programm verlassen"));
+ break;
+
+ default: // Not supported
+ log.error(MessageFormat.format("Menu type '{0}' ont supported", menuType)); //NOI18N
+ System.exit(1);
+ }
+
+ // Size must have changed to more entries than before
+ assert (menuList.size() > size);
+ }
+
+}