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