]> git.mxchange.org Git - jfinancials-lib.git/blobdiff - Addressbook/src/org/mxchange/addressbook/application/AddressbookApplication.java
A lot more improvements:
[jfinancials-lib.git] / Addressbook / src / org / mxchange / addressbook / application / AddressbookApplication.java
index 78efb043b54a1454ae310a142c57faeeb83c7c91..0898abe65f0e1963e98a78087f78d392ecfee9a8 100644 (file)
@@ -25,92 +25,49 @@ import org.mxchange.addressbook.exceptions.UnhandledUserChoiceException;
 import org.mxchange.addressbook.manager.application.ApplicationManager;
 
 /**
- * ============================================
- * AddressbookApplication management:
- * ============================================
- * 
+ * ============================================ AddressbookApplication
+ * management: ============================================
+ *
  * Inernet("public" service) and Intranet
- * 
- * Version 1.0+:
- * - Single-user local application
- * - Fields:
- *   + Gender
- *   + Surname
- *   + Family name
- *   + Company name
- *   + Street + number
- *   + ZIP code
- *   + City
- *   + Landline number
- *   + Fax number
- *   + Cell phone number
- *   + Email address
- *   + Birth day
- *   + Comment (?)
- * - Edit own data
- * - Add new contact
- * - Edit contacts
- * - Delete contacts
- * - Categorization of contacts
- * 
- * Version 1.1+:
- * - Permanent storage in database
- * 
- * Version 2.0+:
- * - Multi-user web application
- * - Local user registration / login / resend confirmation link / password
- *   recovery
- * - User groups (aka. teams)
- * - Administration area (user role)
- *   + Create/edit/delete groups
- *   + Edit/delete/lock/unlock user
- *   + Assign user roles/rights
- * - Allow other users / groups to view addressbook
- *   + Full addressbook
- *   + Only some categories
- * - VCard export
- *   + Allow users/guests (not recommended)
- * - XML export of addressbook and compressable (ZIP)
- * - Form to contact other user/group without need of mail program
- *   + User can disabled this
- * - Directory for ussers/groups (who allowed to be listed)
- *   + Simple click to add user to own addressbook
- *   + Search form?
- * 
- * Version 2.1+:
- * - Multi-language support
- * 
- * Version 2.2+:("socialized")
- * - "Social login" (OpenID consumer)
- *   + Connect user account to social account
- *   + Sync own data?
- * - "Social profile"
- *   + OpenID provider
- *   + RSS/activity feed 
- * 
- * ============================================
- * Time esitmation:
- * ============================================
- * 1.0 (console):
- *   + 2 days
- * 
- * 1.1 (database):
- *   + 2 day
- *   + Initial tables: contacts, categories, contact_category
- * 
- * 2.0 (web):
- *   + 3 days
- *   + Additional tables: admins (?), admin_rights, groups,
- *    users, user_contacts, user_user_rights, user_category_rights, 
- * 
- * 2.1 (language)
- *   + 1 day
- *   + Additional tables: languages (disable, enable language "pack" ?)
- * 
- * 2.2 (social):
- *   + 3 days
- *   + Additional tables: ???
- * 
+ *
+ * Version 1.0+: - Single-user local application - Fields: + Gender + Surname +
+ * Family name + Company name + Street + number + ZIP code + City + Landline
+ * number + Fax number + Cell phone number + Email address + Birth day + Comment
+ * (?) - Edit own data - Add new contact - Edit contacts - Delete contacts -
+ * Categorization of contacts
+ *
+ * Version 1.1+: - Permanent storage in database
+ *
+ * Version 2.0+: - Multi-user web application - Local user registration / login
+ * / resend confirmation link / password recovery - User groups (aka. teams) -
+ * Administration area (user role) + Create/edit/delete groups +
+ * Edit/delete/lock/unlock user + Assign user roles/rights - Allow other users /
+ * groups to view addressbook + Full addressbook + Only some categories - VCard
+ * export + Allow users/guests (not recommended) - XML export of addressbook and
+ * compressable (ZIP) - Form to contact other user/group without need of mail
+ * program + User can disabled this - Directory for ussers/groups (who allowed
+ * to be listed) + Simple click to add user to own addressbook + Search form?
+ *
+ * Version 2.1+: - Multi-language support
+ *
+ * Version 2.2+:("socialized") - "Social login" (OpenID consumer) + Connect user
+ * account to social account + Sync own data? - "Social profile" + OpenID
+ * provider + RSS/activity feed
+ *
+ * ============================================ Time esitmation:
+ * ============================================ 1.0 (console): + 2 days
+ *
+ * 1.1 (database): + 2 day + Initial tables: contacts, categories,
+ * contact_category
+ *
+ * 2.0 (web): + 3 days + Additional tables: admins (?), admin_rights, groups,
+ * users, user_contacts, user_user_rights, user_category_rights,
+ *
+ * 2.1 (language) + 1 day + Additional tables: languages (disable, enable
+ * language "pack" ?)
+ *
+ * 2.2 (social): + 3 days + Additional tables: ???
+ *
  * @author Roland Haeder
  * @version 0.0
  * @since 0.0
@@ -120,12 +77,17 @@ public class AddressbookApplication extends BaseFrameworkSystem implements Appli
        /**
         * Application title
         */
-       public static final String APP_TITLE = "Adressbuch";
+       public static final String APP_TITLE = "Adressbuch"; //NOI18N
 
        /**
         * Application version
         */
-       public static final String APP_VERSION = "0.0";
+       public static final String APP_VERSION = "0.0"; //NOI18N
+
+       /**
+        * Self instance
+        */
+       private static Application selfInstance;
 
        /**
         * Console client is enabled by default
@@ -137,13 +99,21 @@ public class AddressbookApplication extends BaseFrameworkSystem implements Appli
         */
        private boolean guiClient = false;
 
+       /**
+        * Protected constructor
+        */
+       protected AddressbookApplication () {
+               // Set own instance
+               selfInstance = this;
+       }
+
        /**
         * Getter for printable application name
         *
         * @return A printable name
         */
        public static String printableTitle () {
-               return MessageFormat.format("{0} v{1}", APP_TITLE, APP_VERSION);
+               return MessageFormat.format("{0} v{1}", APP_TITLE, APP_VERSION); //NOI18N
        }
 
        /**
@@ -151,7 +121,7 @@ public class AddressbookApplication extends BaseFrameworkSystem implements Appli
         */
        @Override
        public void doBootstrap () {
-               this.getLogger().debug("Initializing application ...");
+               this.getLogger().debug("Initializing application ..."); //NOI18N
 
                // Init client variable
                Client client = null;
@@ -159,19 +129,19 @@ public class AddressbookApplication extends BaseFrameworkSystem implements Appli
                // Is console or Swing choosen?
                if (this.isConsole()) {
                        // Debug message
-                       this.getLogger().debug("Initializing console client ...");
+                       this.getLogger().debug("Initializing console client ..."); //NOI18N
 
                        // Init console client instance
                        client = new ConsoleClient(this);
                } else if (this.isGui()) {
                        // Debug message
-                       this.getLogger().debug("Initializing GUI (Swing) client ...");
+                       this.getLogger().debug("Initializing GUI (Swing) client ..."); //NOI18N
 
                        // Init console instance
                        client = new SwingClient(this);
                } else {
                        // Not client choosen
-                       this.getLogger().error("No client choosen. Cannot launch.");
+                       this.getLogger().error("No client choosen. Cannot launch."); //NOI18N
                        System.exit(1);
                }
 
@@ -183,6 +153,9 @@ public class AddressbookApplication extends BaseFrameworkSystem implements Appli
 
                // The application is running at this point
                this.getClient().enableIsRunning();
+
+               // Trace message
+               this.getLogger().trace("EXIT!"); //NOI18N
        }
 
        /**
@@ -191,14 +164,14 @@ public class AddressbookApplication extends BaseFrameworkSystem implements Appli
        @Override
        public void doMainLoop () {
                // Debug message
-               this.getLogger().trace("CALLED!");
+               this.getLogger().trace("CALLED!"); //NOI18N
 
-       // @TODO The application should be running now
+               // @TODO The application should be running now
                // Output introduction
                this.showIntro();
 
                // Set current menu to main
-               this.getClient().setCurrentMenu("main");
+               this.getClient().setCurrentMenu("main"); //NOI18N
 
                // --- Main loop starts here ---
                while (this.getClient().isRunning()) {
@@ -219,17 +192,17 @@ public class AddressbookApplication extends BaseFrameworkSystem implements Appli
                                // Ignore it
                        }
                }
-       // --- Main loop ends here ---
+               // --- Main loop ends here ---
 
                // Debug message
-               this.getLogger().debug("Main loop exit - shutting down ...");
+               this.getLogger().debug("Main loop exit - shutting down ..."); //NOI18N
        }
 
        /**
         * Enables console client by setting propper flag
         */
        private void enableConsoleClient () {
-               this.getLogger().debug("Enabling console client (may become optional client) ...");
+               this.getLogger().debug("Enabling console client (may become optional client) ..."); //NOI18N
                this.consoleClient = true;
                this.guiClient = false;
        }
@@ -238,7 +211,7 @@ public class AddressbookApplication extends BaseFrameworkSystem implements Appli
         * Enables GUI client by setting propper flag
         */
        private void enableGuiClient () {
-               this.getLogger().debug("Enabling GUI client (may become new default client) ...");
+               this.getLogger().debug("Enabling GUI client (may become new default client) ..."); //NOI18N
                this.consoleClient = false;
                this.guiClient = true;
        }
@@ -269,17 +242,20 @@ public class AddressbookApplication extends BaseFrameworkSystem implements Appli
         * @param args Arguments from program launch
         */
        private void parseArguments (final String[] args) {
+               // Trace message
+               this.getLogger().trace(MessageFormat.format("args()={0} - CALLED!", args.length)); //NOI18N
+
                // Debug message
-               this.getLogger().debug(MessageFormat.format("Parsing {0} arguments ...", args.length));
+               this.getLogger().debug(MessageFormat.format("Parsing {0} arguments ...", args.length)); //NOI18N
 
                for (final String arg : args) {
                        // Switch on it
                        switch (arg) {
-                               case "-console":
+                               case "-console": //NOI18N
                                        enableConsoleClient();
                                        break;
 
-                               case "-gui":
+                               case "-gui": //NOI18N
                                        enableGuiClient();
                                        break;
                        }
@@ -290,8 +266,14 @@ public class AddressbookApplication extends BaseFrameworkSystem implements Appli
         * Show introduction which depends on client
         */
        private void showIntro () {
+               // Trace message
+               this.getLogger().trace("CALLED!"); //NOI18N
+
                // Let the client show it
                this.getClient().showWelcome();
+
+               // Trace message
+               this.getLogger().trace("EXIT!"); //NOI18N
        }
 
        /**
@@ -300,7 +282,7 @@ public class AddressbookApplication extends BaseFrameworkSystem implements Appli
         * @param args Arguments handled to program
         */
        private void start (final String args[]) {
-               this.getLogger().info("Program is started.");
+               this.getLogger().info("Program is started."); //NOI18N
 
                // Parse arguments
                this.parseArguments(args);
@@ -309,7 +291,7 @@ public class AddressbookApplication extends BaseFrameworkSystem implements Appli
                ApplicationManager.getManager(this).start();
 
                // Good bye, but this should not be reached ...
-               this.getLogger().warn("Unusual exit reached.");
+               this.getLogger().warn("Unusual exit reached."); //NOI18N
                this.doShutdown();
        }
 
@@ -328,10 +310,23 @@ public class AddressbookApplication extends BaseFrameworkSystem implements Appli
         */
        @Override
        public void doShutdown () {
+               // Trace message
+               this.getLogger().trace("CALLED!"); //NOI18N
+
                // Shutdown client
                this.getClient().doShutdown();
 
-               this.getLogger().info("End of program (last line)");
+               this.getLogger().info("End of program (last line)"); //NOI18N
                System.exit(0);
        }
+
+       /**
+        * Getter for this application
+        *
+        * @return Instance from this application
+        */
+       public static final Application getInstance () {
+               // Return it
+               return selfInstance;
+       }
 }