2 * Copyright (C) 2015 Roland Haeder
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 package org.mxchange.addressbook.menu;
19 import java.util.List;
20 import org.apache.logging.log4j.Logger;
21 import org.mxchange.addressbook.BaseFrameworkSystem;
22 import org.mxchange.addressbook.client.Client;
23 import org.mxchange.addressbook.menu.item.SelectableMenuItem;
26 * Utility class for menu structure
28 * @author Roland Haeder
30 public class AddressbookMenu extends BaseFrameworkSystem {
33 * Copies entries for given type into the menu list
35 * @param menuList Menu list for later showing
36 * @param menuType Type of menu
37 * @param client Client instance to call back
39 public static void addItemsToList (final List<SelectableMenuItem> menuList, final String menuType, final Client client) {
41 Logger log = new AddressbookMenu().getLogger();
44 int size = menuList.size();
47 log.debug("Adding menu for '" + menuType + "' (old size: '" + size + "') ...");
51 case "main": // Main menu
53 menuList.add(client.getMenuItem('1', "Eigene Adresse anlegen"));
56 menuList.add(client.getMenuItem('2', "Eigene Adresse ändern"));
59 menuList.add(client.getMenuItem('3', "Neue Adresse hinzufügen"));
62 menuList.add(client.getMenuItem('4', "Adressbuch anzeigen"));
65 menuList.add(client.getMenuItem('5', "Adresse suchen"));
67 // Change other address
68 menuList.add(client.getMenuItem('6', "Adresse ändern"));
70 // Delete other address
71 menuList.add(client.getMenuItem('7', "Adresse löschen"));
73 // Always last line: Exit program
74 menuList.add(client.getMenuItem('0', "Programm verlassen"));
77 default: // Not supported
78 log.error("Menu type '" + menuType + "' ont supported");
82 // Size must have changed to more entries than before
83 assert (menuList.size() > size);