]> git.mxchange.org Git - addressbook-swing.git/blob - Addressbook/src/org/mxchange/addressbook/application/AddressbookApplication.java
Introduced own exception + added first sub menu for changing address data
[addressbook-swing.git] / Addressbook / src / org / mxchange / addressbook / application / AddressbookApplication.java
1 /*\r
2  * Copyright (C) 2015 Roland Haeder\r
3  *\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
8  *\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
13  *\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
16  */\r
17 package org.mxchange.addressbook.application;\r
18 \r
19 import org.mxchange.addressbook.BaseFrameworkSystem;\r
20 import org.mxchange.addressbook.client.Client;\r
21 import org.mxchange.addressbook.client.console.ConsoleClient;\r
22 import org.mxchange.addressbook.manager.application.ApplicationManager;\r
23 \r
24 /**\r
25  * ============================================\r
26  * AddressbookApplication management:\r
27  * ============================================\r
28  * \r
29  * Inernet("public" service) and Intranet\r
30  * \r
31  * Version 1.0+:\r
32  * - Single-user local application\r
33  * - Fields:\r
34  *   + Gender\r
35  *   + Surname\r
36  *   + Family name\r
37  *   + Company name\r
38  *   + Street + number\r
39  *   + ZIP code\r
40  *   + City\r
41  *   + Landline number\r
42  *   + Fax number\r
43  *   + Cell phone number\r
44  *   + Email address\r
45  *   + Birth day\r
46  *   + Comment (?)\r
47  * - Edit own data\r
48  * - Add new contact\r
49  * - Edit contacts\r
50  * - Delete contacts\r
51  * - Categorization of contacts\r
52  * \r
53  * Version 1.1+:\r
54  * - Permanent storage in database\r
55  * \r
56  * Version 2.0+:\r
57  * - Multi-user web application\r
58  * - Local user registration / login / resend confirmation link / password\r
59  *   recovery\r
60  * - User groups (aka. teams)\r
61  * - Administration area (user role)\r
62  *   + Create/edit/delete groups\r
63  *   + Edit/delete/lock/unlock user\r
64  *   + Assign user roles/rights\r
65  * - Allow other users / groups to view addressbook\r
66  *   + Full addressbook\r
67  *   + Only some categories\r
68  * - VCard export\r
69  *   + Allow users/guests (not recommended)\r
70  * - XML export of addressbook and compressable (ZIP)\r
71  * - Form to contact other user/group without need of mail program\r
72  *   + User can disabled this\r
73  * - Directory for ussers/groups (who allowed to be listed)\r
74  *   + Simple click to add user to own addressbook\r
75  *   + Search form?\r
76  * \r
77  * Version 2.1+:\r
78  * - Multi-language support\r
79  * \r
80  * Version 2.2+:("socialized")\r
81  * - "Social login" (OpenID consumer)\r
82  *   + Connect user account to social account\r
83  *   + Sync own data?\r
84  * - "Social profile"\r
85  *   + OpenID provider\r
86  *   + RSS/activity feed \r
87  * \r
88  * ============================================\r
89  * Time esitmation:\r
90  * ============================================\r
91  * 1.0 (console):\r
92  *   + 2 days\r
93  * \r
94  * 1.1 (database):\r
95  *   + 2 day\r
96  *   + Initial tables: contacts, categories, contact_category\r
97  * \r
98  * 2.0 (web):\r
99  *   + 3 days\r
100  *   + Additional tables: admins (?), admin_rights, groups,\r
101  *    users, user_contacts, user_user_rights, user_category_rights, \r
102  * \r
103  * 2.1 (language)\r
104  *   + 1 day\r
105  *   + Additional tables: languages (disable, enable language "pack" ?)\r
106  * \r
107  * 2.2 (social):\r
108  *   + 3 days\r
109  *   + Additional tables: ???\r
110  * \r
111  * @author Roland Haeder\r
112  * @version 0.0\r
113  * @since 0.0\r
114  */\r
115 public class AddressbookApplication extends BaseFrameworkSystem implements Application {\r
116     /**\r
117      * Application title\r
118      */\r
119     public static final String APP_TITLE = "Addressbuch";\r
120 \r
121     /**\r
122      * Application version\r
123      */\r
124     public static final String APP_VERSION = "0.0";\r
125 \r
126     /**\r
127      * Main method (entry point)\r
128      *\r
129      * @param args the command line arguments\r
130      */\r
131     public static void main (String[] args) {\r
132         // Start application\r
133         new AddressbookApplication().start ();\r
134     }\r
135 \r
136     /**\r
137      * Bootstraps application\r
138      */\r
139     @Override\r
140     public void doBootstrap () {\r
141         this.getLogger().debug("Initializing application ...");\r
142         \r
143         // Init client instance\r
144         Client client = new ConsoleClient(this);\r
145 \r
146                 // Init client instance\r
147         this.setClient(client);\r
148         \r
149         // The application is running at this point\r
150         this.getClient().enableIsRunning();\r
151     }\r
152 \r
153     /**\r
154      * Main loop of the application\r
155      */\r
156     @Override\r
157     public void doMainLoop () {\r
158         // @TODO The application should be running now\r
159         \r
160         // Output introduction\r
161         this.showIntro();\r
162 \r
163         // Set current menu to main\r
164         this.getClient().setCurrentMenu("main");\r
165 \r
166         // --- Main loop starts here ---\r
167         while (this.getClient().isApplicationRunning()) {\r
168             // The application is still active, show menu selection\r
169             this.getClient().showCurrentMenu();\r
170 \r
171             try {\r
172                 // Ask for user input and run proper method\r
173                 this.getClient().doUserMenuChoice();\r
174             } catch (final Exception ex) {\r
175                 this.getLogger().catching(ex);\r
176             }\r
177         }\r
178         // --- Main loop ends here ---\r
179 \r
180         // Debug message\r
181         this.getLogger().debug("Main loop exit - shutting down ...");\r
182     }\r
183 \r
184     /**\r
185      * Show introduction which depends on client\r
186      */\r
187     private void showIntro () {\r
188         // Let the client show it\r
189         this.getClient().showWelcome();\r
190     }\r
191 \r
192     /**\r
193      * Launches the application\r
194      */\r
195     private void start () {\r
196         this.getLogger().info("Program is started.");\r
197 \r
198         // Launch application\r
199         ApplicationManager.getManager(this).start ();\r
200 \r
201         this.getLogger().info("End of program (last line)");\r
202     }\r
203 \r
204 }\r