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