X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2Forg%2Fmxchange%2Faddressbook%2Fmenu%2FMenuTools.java;h=87f8c114733b6ef686d8f7a6d35638c0fc5d092e;hb=d320d13f3f26ab01c36a7d6857918b141977454a;hp=ee03267c4299383778f9cd6cb8d29611ae3d9b5e;hpb=8eae125e777194074b19ed1b7fb5ad2be4c3a461;p=addressbook-swing.git diff --git a/src/org/mxchange/addressbook/menu/MenuTools.java b/src/org/mxchange/addressbook/menu/MenuTools.java index ee03267..87f8c11 100644 --- a/src/org/mxchange/addressbook/menu/MenuTools.java +++ b/src/org/mxchange/addressbook/menu/MenuTools.java @@ -18,37 +18,34 @@ package org.mxchange.addressbook.menu; import java.util.Iterator; import java.util.Map; -import org.apache.logging.log4j.Logger; +import org.mxchange.addressbook.BaseAddressbookSystem; import org.mxchange.addressbook.menu.item.SelectableMenuItem; -import org.mxchange.jcore.BaseFrameworkSystem; +import org.mxchange.jcore.exceptions.MenuInitializationException; /** - * + * Menu utilities + *

* @author Roland Haeder */ -public class MenuTools extends BaseFrameworkSystem { +public class MenuTools extends BaseAddressbookSystem { /** * Gets an array with all available access keys back from given menu map. * This can later be handle to the client's enterChar() method. - * + *

* @param menus A Map with all menus and their entries * @param menuType Menu type * @return An array with available access chars + * @throws org.mxchange.jcore.exceptions.MenuInitializationException If the menu cannot be initialized */ - public static char[] getAccessKeysFromMenuMap (final Map menus, final String menuType) { - // Get logger - Logger logger = new MenuTools().getLogger(); - + public static char[] getAccessKeysFromMenuMap (final Map menus, final String menuType) throws MenuInitializationException { // First search for the proper menu class Menu menu = menus.get(menuType); // Is it there? if (!(menu instanceof Menu)) { // Not found - // TODO Rewrite to exception - logger.error("Menu '" + menuType + "' not found."); - System.exit(1); + throw new MenuInitializationException(menu, menuType); } // Get iterator @@ -62,11 +59,11 @@ public class MenuTools extends BaseFrameworkSystem { while (iterator.hasNext()) { // Get item SelectableMenuItem item = iterator.next(); - //* NOISY-DEBUG: */ logger.debug("item=" + item); + //* NOISY-DEBUG: */ logger.logDebug("item=" + item); // Get access key from item and add it to the array accessKeys[i] = item.getAccessKey(); - //* NOISY-DEBUG: */ logger.debug("accessKeys[" + i + "]=" + accessKeys[i]); + //* NOISY-DEBUG: */ logger.logDebug("accessKeys[" + i + "]=" + accessKeys[i]); // Increment counter i++;