]> git.mxchange.org Git - addressbook-swing.git/blob - Addressbook/src/org/mxchange/addressbook/menu/AddressbookMenu.java
Global commit: Changed spaces to tabs, because all Java files have tabs for indenting
[addressbook-swing.git] / Addressbook / src / org / mxchange / addressbook / menu / AddressbookMenu.java
1 /*
2  * Copyright (C) 2015 Roland Haeder
3  *
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.
8  *
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.
13  *
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/>.
16  */
17 package org.mxchange.addressbook.menu;
18
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;
24
25 /**
26  * Utility class for menu structure
27  *
28  * @author Roland Haeder
29  */
30 public class AddressbookMenu extends BaseFrameworkSystem {
31
32         /**
33          * Copies entries for given type into the menu list
34          *
35          * @param menuList Menu list for later showing
36          * @param menuType Type of menu
37          * @param client Client instance to call back
38          */
39         public static void addItemsToList (final List<SelectableMenuItem> menuList, final String menuType, final Client client) {
40                 // Get logger
41                 Logger log = new AddressbookMenu().getLogger();
42
43                 // Get list size
44                 int size = menuList.size();
45
46                 // Debug message
47                 log.debug("Adding menu for '" + menuType + "' (old size: '" + size + "') ...");
48
49                 // Depends on type
50                 switch (menuType) {
51                         case "main": // Main menu
52                                 // Enter own data
53                                 menuList.add(client.getMenuItem('1', "Eigene Adresse anlegen"));
54
55                                 // Change own data
56                                 menuList.add(client.getMenuItem('2', "Eigene Adresse ändern"));
57
58                                 // Add new addess
59                                 menuList.add(client.getMenuItem('3', "Neue Adresse hinzufügen"));
60
61                                 // List entries
62                                 menuList.add(client.getMenuItem('4', "Adressbuch anzeigen"));
63
64                                 // Address search
65                                 menuList.add(client.getMenuItem('5', "Adresse suchen"));
66
67                                 // Change other address
68                                 menuList.add(client.getMenuItem('6', "Adresse ändern"));
69
70                                 // Delete other address
71                                 menuList.add(client.getMenuItem('7', "Adresse löschen"));
72
73                                 // Always last line: Exit program
74                                 menuList.add(client.getMenuItem('0', "Programm verlassen"));
75                                 break;
76
77                         default: // Not supported
78                                 log.error("Menu type '" + menuType + "' ont supported");
79                                 System.exit(1);
80                 }
81
82                 // Size must have changed to more entries than before
83                 assert (menuList.size() > size);
84         }
85
86 }