]> git.mxchange.org Git - jaddressbook-lib.git/commitdiff
Continued with re-implementation of Swing frame
authorRoland Haeder <roland@mxchange.org>
Thu, 23 Jul 2015 13:16:01 +0000 (15:16 +0200)
committerRoland Haeder <roland@mxchange.org>
Thu, 23 Jul 2015 13:16:01 +0000 (15:16 +0200)
Signed-off-by:Roland Häder <roland@mxchange.org>

Addressbook/src/org/mxchange/addressbook/application/AddressbookApplication.java
Addressbook/src/org/mxchange/addressbook/client/BaseClient.java
Addressbook/src/org/mxchange/addressbook/client/gui/AddressbookFrame.java
Addressbook/src/org/mxchange/addressbook/client/gui/ClientFrame.java
Addressbook/src/org/mxchange/addressbook/client/gui/SwingClient.java
Addressbook/src/org/mxchange/addressbook/localization/bundle_de_DE.properties
Addressbook/src/org/mxchange/addressbook/localization/bundle_en_US.properties
Addressbook/src/org/mxchange/addressbook/manager/contact/ContactManager.java
Addressbook/src/org/mxchange/addressbook/menu/item/console/ConsoleMenuItem.java

index 788c940ed3c41eb082ab699fcda3f03383381a24..3759d978f87e6706ef8522990f0983109badb81f 100644 (file)
-/*\r
- * Copyright (C) 2015 Roland Haeder\r
- *\r
- * This program is free software: you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation, either version 3 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.\r
- */\r
-package org.mxchange.addressbook.application;\r
-\r
-import java.text.MessageFormat;\r
-import org.mxchange.addressbook.BaseFrameworkSystem;\r
-import org.mxchange.addressbook.UnhandledUserChoiceException;\r
-import org.mxchange.addressbook.client.Client;\r
-import org.mxchange.addressbook.client.console.ConsoleClient;\r
-import org.mxchange.addressbook.client.gui.SwingClient;\r
-import org.mxchange.addressbook.manager.application.ApplicationManager;\r
-\r
-/**\r
- * ============================================\r
- * AddressbookApplication management:\r
- * ============================================\r
- * \r
- * Inernet("public" service) and Intranet\r
- * \r
- * Version 1.0+:\r
- * - Single-user local application\r
- * - Fields:\r
- *   + Gender\r
- *   + Surname\r
- *   + Family name\r
- *   + Company name\r
- *   + Street + number\r
- *   + ZIP code\r
- *   + City\r
- *   + Landline number\r
- *   + Fax number\r
- *   + Cell phone number\r
- *   + Email address\r
- *   + Birth day\r
- *   + Comment (?)\r
- * - Edit own data\r
- * - Add new contact\r
- * - Edit contacts\r
- * - Delete contacts\r
- * - Categorization of contacts\r
- * \r
- * Version 1.1+:\r
- * - Permanent storage in database\r
- * \r
- * Version 2.0+:\r
- * - Multi-user web application\r
- * - Local user registration / login / resend confirmation link / password\r
- *   recovery\r
- * - User groups (aka. teams)\r
- * - Administration area (user role)\r
- *   + Create/edit/delete groups\r
- *   + Edit/delete/lock/unlock user\r
- *   + Assign user roles/rights\r
- * - Allow other users / groups to view addressbook\r
- *   + Full addressbook\r
- *   + Only some categories\r
- * - VCard export\r
- *   + Allow users/guests (not recommended)\r
- * - XML export of addressbook and compressable (ZIP)\r
- * - Form to contact other user/group without need of mail program\r
- *   + User can disabled this\r
- * - Directory for ussers/groups (who allowed to be listed)\r
- *   + Simple click to add user to own addressbook\r
- *   + Search form?\r
- * \r
- * Version 2.1+:\r
- * - Multi-language support\r
- * \r
- * Version 2.2+:("socialized")\r
- * - "Social login" (OpenID consumer)\r
- *   + Connect user account to social account\r
- *   + Sync own data?\r
- * - "Social profile"\r
- *   + OpenID provider\r
- *   + RSS/activity feed \r
- * \r
- * ============================================\r
- * Time esitmation:\r
- * ============================================\r
- * 1.0 (console):\r
- *   + 2 days\r
- * \r
- * 1.1 (database):\r
- *   + 2 day\r
- *   + Initial tables: contacts, categories, contact_category\r
- * \r
- * 2.0 (web):\r
- *   + 3 days\r
- *   + Additional tables: admins (?), admin_rights, groups,\r
- *    users, user_contacts, user_user_rights, user_category_rights, \r
- * \r
- * 2.1 (language)\r
- *   + 1 day\r
- *   + Additional tables: languages (disable, enable language "pack" ?)\r
- * \r
- * 2.2 (social):\r
- *   + 3 days\r
- *   + Additional tables: ???\r
- * \r
- * @author Roland Haeder\r
- * @version 0.0\r
- * @since 0.0\r
- */\r
-public class AddressbookApplication extends BaseFrameworkSystem implements Application {\r
-    /**\r
-     * Application title\r
-     */\r
-    public static final String APP_TITLE = "Adressbuch";\r
-\r
-    /**\r
-     * Application version\r
-     */\r
-    public static final String APP_VERSION = "0.0";\r
-\r
-    /**\r
-     * Console client is enabled by default\r
-     */\r
-    private boolean consoleClient = true;\r
-\r
-    /**\r
-     * GUI client is disabled by default\r
-     */\r
-    private boolean guiClient = false;\r
-\r
-    /**\r
-     * Getter for printable application name\r
-     * \r
-     * @return A printable name\r
-     */\r
-    public static String printableTitle () {\r
-       return MessageFormat.format("{0} v{1}", APP_TITLE, APP_VERSION);\r
-    }\r
-\r
-    /**\r
-     * Bootstraps application\r
-     */\r
-    @Override\r
-    public void doBootstrap () {\r
-       this.getLogger().debug("Initializing application ...");\r
-\r
-       // Init client variable\r
-       Client client = null;\r
-\r
-       // Is console or Swing choosen?\r
-       if (this.isConsole()) {\r
-           // Debug message\r
-           this.getLogger().debug("Initializing console client ...");\r
-\r
-           // Init console client instance\r
-           client = new ConsoleClient(this);\r
-       } else if (this.isGui()) {\r
-           // Debug message\r
-           this.getLogger().debug("Initializing GUI (Swing) client ...");\r
-\r
-           // Init console instance\r
-           client = new SwingClient(this);\r
-       } else {\r
-           // Not client choosen\r
-           this.getLogger().error("No client choosen. Cannot launch.");\r
-           System.exit(1);\r
-       }\r
-\r
-       // Init client\r
-       client.initClient();\r
-\r
-       // Set client instance\r
-       this.setClient(client);\r
-       \r
-       // The application is running at this point\r
-       this.getClient().enableIsRunning();\r
-    }\r
-\r
-    /**\r
-     * Main loop of the application\r
-     */\r
-    @Override\r
-    public void doMainLoop () {\r
-       // @TODO The application should be running now\r
-       \r
-       // Output introduction\r
-       this.showIntro();\r
-\r
-       // Set current menu to main\r
-       this.getClient().setCurrentMenu("main");\r
-\r
-       // --- Main loop starts here ---\r
-       while (this.getClient().isRunning()) {\r
-           // The application is still active, show menu selection\r
-           this.getClient().showCurrentMenu();\r
-\r
-           try {\r
-               // Ask for user input and run proper method\r
-               this.getClient().doUserMenuChoice();\r
-           } catch (final UnhandledUserChoiceException ex) {\r
-               this.getLogger().catching(ex);\r
-           }\r
-       }\r
-       // --- Main loop ends here ---\r
-\r
-       // Debug message\r
-       this.getLogger().debug("Main loop exit - shutting down ...");\r
-    }\r
-\r
-    /**\r
-     * Enables console client by setting propper flag\r
-     */\r
-    private void enableConsoleClient () {\r
-       this.getLogger().debug("Enabling console client (may become optional client) ...");\r
-       this.consoleClient = true;\r
-       this.guiClient = false;\r
-    }\r
-\r
-    /**\r
-     * Enables GUI client by setting propper flag\r
-     */\r
-    private void enableGuiClient () {\r
-       this.getLogger().debug("Enabling GUI client (may become new default client) ...");\r
-       this.consoleClient = false;\r
-       this.guiClient = true;\r
-    }\r
-\r
-    /**\r
-     * Checks whether the client shoule be console client should be launched by\r
-     * checking if -console is set.\r
-     * \r
-     * @return Whether console client should be taken\r
-     */\r
-    private boolean isConsole () {\r
-       return this.consoleClient;\r
-    }\r
-\r
-    /**\r
-     * Checks whether the client shoule be GUI client should be launched by\r
-     * checking if -gui is set.\r
-     * \r
-     * @return Whether GUI client should be taken\r
-     */\r
-    private boolean isGui () {\r
-       return this.guiClient;\r
-    }\r
-\r
-    /**\r
-     * Parses all given arguments\r
-     *\r
-     * @param args Arguments from program launch\r
-     */\r
-    private void parseArguments (final String[] args) {\r
-       // Debug message\r
-       this.getLogger().debug(MessageFormat.format("Parsing {0} arguments ...", args.length));\r
-       \r
-       for (final String arg : args) {\r
-           // Switch on it\r
-           switch (arg) {\r
-               case "-console":\r
-                   enableConsoleClient();\r
-                   break;\r
-                   \r
-               case "-gui":\r
-                   enableGuiClient();\r
-                   break;\r
-}\r
-       }\r
-    }\r
-\r
-    /**\r
-     * Show introduction which depends on client\r
-     */\r
-    private void showIntro () {\r
-       // Let the client show it\r
-       this.getClient().showWelcome();\r
-    }\r
-\r
-    /**\r
-     * Launches the application\r
-     * \r
-     * @param args Arguments handled to program\r
-     */\r
-    private void start (final String args[]) {\r
-       this.getLogger().info("Program is started.");\r
-\r
-       // Parse arguments\r
-       this.parseArguments(args);\r
-\r
-       // Launch application\r
-       ApplicationManager.getManager(this).start();\r
-\r
-       // Good bye, but this should not be reached ...\r
-       this.getLogger().warn("Unusual exit reached.");\r
-       this.doShutdown();\r
-    }\r
-\r
-    /**\r
-     * Main method (entry point)\r
-     *\r
-     * @param args the command line arguments\r
-     */\r
-    public static void main (String[] args) {\r
-       // Start application\r
-       new AddressbookApplication().start(args);\r
-    }\r
-\r
-    /**\r
-     * Shuts down the application.\r
-     */\r
-    @Override\r
-    public void doShutdown () {\r
-       // Shutdown client\r
-       this.getClient().doShutdown();\r
-\r
-       this.getLogger().info("End of program (last line)");\r
-       System.exit(0);\r
-    }\r
-}\r
+/*
+ * Copyright (C) 2015 Roland Haeder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.addressbook.application;
+
+import java.text.MessageFormat;
+import org.mxchange.addressbook.BaseFrameworkSystem;
+import org.mxchange.addressbook.UnhandledUserChoiceException;
+import org.mxchange.addressbook.client.Client;
+import org.mxchange.addressbook.client.console.ConsoleClient;
+import org.mxchange.addressbook.client.gui.SwingClient;
+import org.mxchange.addressbook.manager.application.ApplicationManager;
+
+/**
+ * ============================================
+ * 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: ???
+ * 
+ * @author Roland Haeder
+ * @version 0.0
+ * @since 0.0
+ */
+public class AddressbookApplication extends BaseFrameworkSystem implements Application {
+    /**
+     * Application title
+     */
+    public static final String APP_TITLE = "Adressbuch";
+
+    /**
+     * Application version
+     */
+    public static final String APP_VERSION = "0.0";
+
+    /**
+     * Console client is enabled by default
+     */
+    private boolean consoleClient = true;
+
+    /**
+     * GUI client is disabled by default
+     */
+    private boolean guiClient = false;
+
+    /**
+     * Getter for printable application name
+     * 
+     * @return A printable name
+     */
+    public static String printableTitle () {
+       return MessageFormat.format("{0} v{1}", APP_TITLE, APP_VERSION);
+    }
+
+    /**
+     * Bootstraps application
+     */
+    @Override
+    public void doBootstrap () {
+       this.getLogger().debug("Initializing application ...");
+
+       // Init client variable
+       Client client = null;
+
+       // Is console or Swing choosen?
+       if (this.isConsole()) {
+           // Debug message
+           this.getLogger().debug("Initializing console client ...");
+
+           // Init console client instance
+           client = new ConsoleClient(this);
+       } else if (this.isGui()) {
+           // Debug message
+           this.getLogger().debug("Initializing GUI (Swing) client ...");
+
+           // Init console instance
+           client = new SwingClient(this);
+       } else {
+           // Not client choosen
+           this.getLogger().error("No client choosen. Cannot launch.");
+           System.exit(1);
+       }
+
+       // Init client
+       client.initClient();
+
+       // Set client instance
+       this.setClient(client);
+       
+       // The application is running at this point
+       this.getClient().enableIsRunning();
+    }
+
+    /**
+     * Main loop of the application
+     */
+    @Override
+    public void doMainLoop () {
+       // Debug message
+       this.getLogger().trace("CALLED!");
+
+       // @TODO The application should be running now
+       
+       // Output introduction
+       this.showIntro();
+
+       // Set current menu to main
+       this.getClient().setCurrentMenu("main");
+
+       // --- Main loop starts here ---
+       while (this.getClient().isRunning()) {
+           // The application is still active, show menu selection
+           this.getClient().showCurrentMenu();
+
+           try {
+               // Ask for user input and run proper method
+               this.getClient().doUserMenuChoice();
+           } catch (final UnhandledUserChoiceException ex) {
+               this.getLogger().catching(ex);
+           }
+
+           try {
+               // Sleep a little to reduce system load
+               Thread.sleep(100);
+           } catch (final InterruptedException ex) {
+               // Ignore it
+           }
+       }
+       // --- Main loop ends here ---
+
+       // Debug message
+       this.getLogger().debug("Main loop exit - shutting down ...");
+    }
+
+    /**
+     * Enables console client by setting propper flag
+     */
+    private void enableConsoleClient () {
+       this.getLogger().debug("Enabling console client (may become optional client) ...");
+       this.consoleClient = true;
+       this.guiClient = false;
+    }
+
+    /**
+     * Enables GUI client by setting propper flag
+     */
+    private void enableGuiClient () {
+       this.getLogger().debug("Enabling GUI client (may become new default client) ...");
+       this.consoleClient = false;
+       this.guiClient = true;
+    }
+
+    /**
+     * Checks whether the client shoule be console client should be launched by
+     * checking if -console is set.
+     * 
+     * @return Whether console client should be taken
+     */
+    private boolean isConsole () {
+       return this.consoleClient;
+    }
+
+    /**
+     * Checks whether the client shoule be GUI client should be launched by
+     * checking if -gui is set.
+     * 
+     * @return Whether GUI client should be taken
+     */
+    private boolean isGui () {
+       return this.guiClient;
+    }
+
+    /**
+     * Parses all given arguments
+     *
+     * @param args Arguments from program launch
+     */
+    private void parseArguments (final String[] args) {
+       // Debug message
+       this.getLogger().debug(MessageFormat.format("Parsing {0} arguments ...", args.length));
+       
+       for (final String arg : args) {
+           // Switch on it
+           switch (arg) {
+               case "-console":
+                   enableConsoleClient();
+                   break;
+                   
+               case "-gui":
+                   enableGuiClient();
+                   break;
+}
+       }
+    }
+
+    /**
+     * Show introduction which depends on client
+     */
+    private void showIntro () {
+       // Let the client show it
+       this.getClient().showWelcome();
+    }
+
+    /**
+     * Launches the application
+     * 
+     * @param args Arguments handled to program
+     */
+    private void start (final String args[]) {
+       this.getLogger().info("Program is started.");
+
+       // Parse arguments
+       this.parseArguments(args);
+
+       // Launch application
+       ApplicationManager.getManager(this).start();
+
+       // Good bye, but this should not be reached ...
+       this.getLogger().warn("Unusual exit reached.");
+       this.doShutdown();
+    }
+
+    /**
+     * Main method (entry point)
+     *
+     * @param args the command line arguments
+     */
+    public static void main (String[] args) {
+       // Start application
+       new AddressbookApplication().start(args);
+    }
+
+    /**
+     * Shuts down the application.
+     */
+    @Override
+    public void doShutdown () {
+       // Shutdown client
+       this.getClient().doShutdown();
+
+       this.getLogger().info("End of program (last line)");
+       System.exit(0);
+    }
+}
index 399a6c1b9bedb891adc79f848e9ce61269ab9777..0c8bba50c4b12c8f373ca36acb97b7c9d74e22e5 100644 (file)
-/*\r
- * Copyright (C) 2015 Roland Haeder\r
- *\r
- * This program is free software: you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation, either version 3 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.\r
- */\r
-package org.mxchange.addressbook.client;\r
-\r
-import java.util.HashMap;\r
-import java.util.Map;\r
-import org.mxchange.addressbook.BaseFrameworkSystem;\r
-import org.mxchange.addressbook.manager.contact.ContactManager;\r
-import org.mxchange.addressbook.manager.contact.ManageableContact;\r
-import org.mxchange.addressbook.menu.Menu;\r
-\r
-/**\r
- * A general client\r
- *\r
- * @author Roland Haeder\r
- */\r
-public abstract class BaseClient extends BaseFrameworkSystem {\r
-\r
-    /**\r
-     * Current menu choice\r
-     */\r
-    private String currentMenu;\r
-\r
-    /**\r
-     * Application is not running by default\r
-     */\r
-    private boolean isRunning;\r
-\r
-    /**\r
-     * Menu system\r
-     */\r
-    private final Map<String, Menu> menus;\r
-\r
-    /**\r
-     * No instances can be created of this class\r
-     */\r
-    protected BaseClient () {\r
-       super();\r
-\r
-       // Init menu map\r
-       this.menus = new HashMap<>(10);\r
-    }\r
-\r
-    /**\r
-     * Shutdown method for all clients\r
-     */\r
-    public void doShutdown () {\r
-       // Disable client\r
-       this.disableIsRunning();\r
-\r
-       // Shuts down contact manager\r
-       this.getContactManager().doShutdown();\r
-    }\r
-\r
-    /**\r
-     * Enables the client\r
-     */\r
-    public final void enableIsRunning () {\r
-       this.isRunning = true;\r
-    }\r
-\r
-    /**\r
-     * Current menu choice\r
-     * \r
-     * @return the currentMenu\r
-     */\r
-    public final String getCurrentMenu () {\r
-       return this.currentMenu;\r
-    }\r
-\r
-    /**\r
-     * Current menu choice\r
-     * @param currentMenu the currentMenu to set\r
-     */\r
-    public final void setCurrentMenu (final String currentMenu) {\r
-       this.currentMenu = currentMenu;\r
-    }\r
-\r
-    /**\r
-     * "Getter" for given menu type\r
-     *\r
-     * @param menuType Menu type instance to return\r
-     * @return Menu or null if not found\r
-     */\r
-    public Menu getMenu (final String menuType) {\r
-       // Default is not found\r
-       Menu menu = null;\r
-       \r
-       // Check array\r
-       if (this.getMenus().containsKey(menuType)) {\r
-           // Found!\r
-           menu = this.getMenus().get(menuType);\r
-       }\r
-       \r
-       // Return it\r
-       return menu;\r
-    }\r
-\r
-    /**\r
-     * Determines whether the application is still active by checking some\r
-     * conditions\r
-     * \r
-     * @return Whether the application is still active\r
-     */\r
-    public final boolean isRunning () {\r
-       // In console client, 0 may have been used\r
-       return this.isRunning;\r
-    }\r
-\r
-    /**\r
-     * Disables running state, so the main loop can abort.\r
-     */\r
-    protected final void disableIsRunning () {\r
-       this.isRunning = false;\r
-    }\r
-\r
-    /**\r
-     * Fills menu map with swing menus\r
-     */\r
-    protected abstract void fillMenuMap ();\r
-\r
-    /**\r
-     * Getter for menus map\r
-     * @return Map of all menus\r
-     */\r
-    protected final Map<String, Menu> getMenus () {\r
-       return this.menus;\r
-    }\r
-\r
-    /**\r
-     * Initializes contact manager\r
-     */\r
-    protected void initContactManager () {\r
-       // Debug message\r
-       this.getLogger().debug("Initializing contact manager ...");\r
-       \r
-       // Init contact manager with console client\r
-       // @TODO Static initial amount of contacts\r
-       ManageableContact manager = new ContactManager (100, (Client) this);\r
-       \r
-       // Set it here\r
-       this.setContactManager(manager);\r
-       \r
-       // Debug message\r
-       this.getLogger().debug("Contact manager has been initialized.");\r
-    }\r
-\r
-    /**\r
-     * Shows given menu\r
-     *\r
-     * @param menuType Given menu to show\r
-     */\r
-    protected void showMenu (final String menuType) {\r
-       Menu menu = this.getMenu(menuType);\r
-       \r
-       // Is the menu set?\r
-       if (!(menu instanceof Menu)) {\r
-           // Not found\r
-           // @todo Own exception?\r
-           throw new NullPointerException("Menu '" + menuType + "' not found.");\r
-       }\r
-       \r
-       // Show menu\r
-       menu.show((Client) this);\r
-    }\r
-}\r
+/*
+ * Copyright (C) 2015 Roland Haeder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.addressbook.client;
+
+import java.util.HashMap;
+import java.util.Map;
+import org.mxchange.addressbook.BaseFrameworkSystem;
+import org.mxchange.addressbook.manager.contact.ContactManager;
+import org.mxchange.addressbook.manager.contact.ManageableContact;
+import org.mxchange.addressbook.menu.Menu;
+
+/**
+ * A general client
+ *
+ * @author Roland Haeder
+ */
+public abstract class BaseClient extends BaseFrameworkSystem {
+
+    /**
+     * Current menu choice
+     */
+    private String currentMenu;
+
+    /**
+     * Application is not running by default
+     */
+    private boolean isRunning;
+
+    /**
+     * Menu system
+     */
+    private final Map<String, Menu> menus;
+
+    /**
+     * No instances can be created of this class
+     */
+    protected BaseClient () {
+       super();
+
+       // Init menu map
+       this.menus = new HashMap<>(10);
+    }
+
+    /**
+     * Shutdown method for all clients
+     */
+    public void doShutdown () {
+       // Disable client
+       this.disableIsRunning();
+
+       // Shuts down contact manager
+       this.getContactManager().doShutdown();
+    }
+
+    /**
+     * Enables the client
+     */
+    public final void enableIsRunning () {
+       this.isRunning = true;
+    }
+
+    /**
+     * Current menu choice
+     * 
+     * @return the currentMenu
+     */
+    public final String getCurrentMenu () {
+       return this.currentMenu;
+    }
+
+    /**
+     * Current menu choice
+     * @param currentMenu the currentMenu to set
+     */
+    public final void setCurrentMenu (final String currentMenu) {
+       this.currentMenu = currentMenu;
+    }
+
+    /**
+     * "Getter" for given menu type
+     *
+     * @param menuType Menu type instance to return
+     * @return Menu or null if not found
+     */
+    public Menu getMenu (final String menuType) {
+       // Default is not found
+       Menu menu = null;
+       
+       // Check array
+       if (this.getMenus().containsKey(menuType)) {
+           // Found!
+           menu = this.getMenus().get(menuType);
+       }
+       
+       // Return it
+       return menu;
+    }
+
+    /**
+     * Determines whether the application is still active by checking some
+     * conditions
+     * 
+     * @return Whether the application is still active
+     */
+    public final boolean isRunning () {
+       // In console client, 0 may have been used
+       return this.isRunning;
+    }
+
+    /**
+     * Disables the client
+     */
+    protected final void disableIsRunning () {
+       this.isRunning = false;
+    }
+
+    /**
+     * Fills menu map with swing menus
+     */
+    protected abstract void fillMenuMap ();
+
+    /**
+     * Getter for menus map
+     * @return Map of all menus
+     */
+    protected final Map<String, Menu> getMenus () {
+       return this.menus;
+    }
+
+    /**
+     * Initializes contact manager
+     */
+    protected void initContactManager () {
+       // Debug message
+       this.getLogger().debug("Initializing contact manager ...");
+       
+       // Init contact manager with console client
+       // @TODO Static initial amount of contacts
+       ManageableContact manager = new ContactManager (100, (Client) this);
+       
+       // Set it here
+       this.setContactManager(manager);
+       
+       // Debug message
+       this.getLogger().debug("Contact manager has been initialized.");
+    }
+
+    /**
+     * Shows given menu
+     *
+     * @param menuType Given menu to show
+     */
+    protected void showMenu (final String menuType) {
+       Menu menu = this.getMenu(menuType);
+       
+       // Is the menu set?
+       if (!(menu instanceof Menu)) {
+           // Not found
+           // @todo Own exception?
+           throw new NullPointerException("Menu '" + menuType + "' not found.");
+       }
+       
+       // Show menu
+       menu.show((Client) this);
+    }
+}
index fe9d47b09ad23b721d4a1717c8bb3a2fc4669f12..73101004f821c5b3d374aa70bcb080e9a1f3e32b 100644 (file)
-/*\r
- * Copyright (C) 2015 Roland Haeder\r
- *\r
- * This program is free software: you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation, either version 3 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.\r
- */\r
-package org.mxchange.addressbook.client.gui;\r
-\r
-import java.text.MessageFormat;\r
-import javax.swing.JFrame;\r
-import org.mxchange.addressbook.BaseFrameworkSystem;\r
-import org.mxchange.addressbook.FrameAlreadyInitializedException;\r
-import org.mxchange.addressbook.application.AddressbookApplication;\r
-import org.mxchange.addressbook.client.Client;\r
-\r
-/**\r
- *\r
- * @author Roland Haeder\r
- */\r
-public class AddressbookFrame extends BaseFrameworkSystem implements ClientFrame {\r
-\r
-    /**\r
-     * Own instance\r
-     */\r
-    private static ClientFrame self;\r
-\r
-    /**\r
-     * Singelton getter for this frame instance.\r
-     *\r
-     * @param client Client instance\r
-     * @return Returns a singelton instance of this frame\r
-     */\r
-    public static final ClientFrame getSelfInstance (final Client client) {\r
-       // Is it set?\r
-       if (!(self instanceof ClientFrame)) {\r
-           // Create new instance\r
-           self = new AddressbookFrame(client);\r
-       }\r
-       \r
-       // Return instance\r
-       return self;\r
-    }\r
-\r
-    /**\r
-     * Frame instance\r
-     */\r
-    private final JFrame frame;\r
-\r
-    /**\r
-     * Whether this frame has been initialized\r
-     */\r
-    private boolean isInitialized;\r
-\r
-    /**\r
-     * Creates an instance of this frame with a client instance\r
-     * \r
-     * @param client\r
-     */\r
-    private AddressbookFrame (final Client client) {\r
-       // Debug line\r
-       this.getLogger().trace(MessageFormat.format("client={0}: CALLED!", client));\r
-\r
-       // Set frame instance\r
-       this.frame = new JFrame(AddressbookApplication.printableTitle());\r
-\r
-       // Set client here\r
-       this.setClient(client);\r
-    }\r
-\r
-    /**\r
-     * Setups the frame, do not set isInitialized here\r
-     * \r
-     * @param client Client instance\r
-     */\r
-    @Override\r
-    public void setupFrame (final Client client) {\r
-       // Debug line\r
-       this.getLogger().trace(MessageFormat.format("client={0}: CALLED!", client));\r
-\r
-       // Has the user entered own data?\r
-       if (this.getClient().getContactManager().isOwnContactAdded()) {\r
-           // Debug message\r
-           this.getLogger().debug("Disabling menus: isOwnContactAdded()=false");\r
-\r
-           // Not entered yet, so enable menu\r
-           //addOwnData.setEnabled(false);\r
-       }\r
-\r
-       // All done here\r
-       //statusLabel.setText(bundle.getString("AddressbookFrame.status.done.text"));\r
-    }\r
-\r
-    /**\r
-     * Initalizes this frame. Having initComponents() exposed (publicly\r
-     * accessible) means that any other object can initialize components which\r
-     * you may not want.\r
-     * \r
-     * @throws org.mxchange.addressbook.FrameAlreadyInitializedException If this method has been called twice\r
-     */\r
-    @Override\r
-    public void initFrame () throws FrameAlreadyInitializedException {\r
-       // Debug line\r
-       this.getLogger().trace("CALLED!");\r
-\r
-       // Has this frame been initialized?\r
-       if (this.isInitialized()) {\r
-           // Throw exception\r
-           throw new FrameAlreadyInitializedException();\r
-       }\r
-\r
-       // Init components\r
-       this.initComponents();\r
-\r
-       // Set flag\r
-       this.isInitialized = true;\r
-    }\r
-\r
-    /**\r
-     * Returns field isInitialized. This flag indicates whether this frame has been initialized or not.\r
-     * \r
-     * @return Field isInitialized\r
-     */\r
-    @Override\r
-    public final boolean isInitialized () {\r
-       return this.isInitialized;\r
-    }\r
-\r
-    /**\r
-     * Initialize components\r
-     */\r
-    private void initComponents () {\r
-       // Debug line\r
-       this.getLogger().trace("CALLED!");\r
-    }\r
-\r
-}\r
+/*
+ * Copyright (C) 2015 Roland Haeder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.addressbook.client.gui;
+
+import java.awt.BorderLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.text.MessageFormat;
+import javax.swing.BorderFactory;
+import javax.swing.BoxLayout;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JMenu;
+import javax.swing.JMenuBar;
+import javax.swing.JMenuItem;
+import javax.swing.JPanel;
+import org.mxchange.addressbook.BaseFrameworkSystem;
+import org.mxchange.addressbook.FrameAlreadyInitializedException;
+import org.mxchange.addressbook.application.AddressbookApplication;
+import org.mxchange.addressbook.client.Client;
+
+/**
+ *
+ * @author Roland Haeder
+ */
+public class AddressbookFrame extends BaseFrameworkSystem implements ClientFrame {
+
+    /**
+     * Own instance
+     */
+    private static ClientFrame self;
+
+    /**
+     * Singelton getter for this frame instance.
+     *
+     * @param client Client instance
+     * @return Returns a singelton instance of this frame
+     */
+    public static final ClientFrame getSelfInstance (final Client client) {
+       // Is it set?
+       if (!(self instanceof ClientFrame)) {
+           // Create new instance
+           self = new AddressbookFrame(client);
+       }
+       
+       // Return instance
+       return self;
+    }
+
+    /**
+     * Frame instance
+     */
+    private final JFrame frame;
+
+    /**
+     * Whether this frame has been initialized
+     */
+    private boolean isInitialized;
+
+    /**
+     * Status label needs to be updated
+     */
+    private JLabel statusLabel;
+
+    /**
+     * Creates an instance of this frame with a client instance
+     * 
+     * @param client
+     */
+    private AddressbookFrame (final Client client) {
+       // Debug line
+       this.getLogger().trace(MessageFormat.format("client={0}: CALLED!", client));
+
+       // Set frame instance
+       this.frame = new JFrame(AddressbookApplication.printableTitle());
+
+       // Set default close operation
+       this.frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+
+       // Set client here
+       this.setClient(client);
+    }
+
+    /**
+     * Shutdown this frame
+     */
+    @Override
+    public void doShutdown () {
+       // First only show shutdown status
+       this.statusLabel.setText(this.getBundle().getString("AddressbookFrame.statusLabel.shutdown.text"));
+    }
+
+    /**
+     * Setups the frame, do not set isInitialized here
+     * 
+     * @param client Client instance
+     */
+    @Override
+    public void setupFrame (final Client client) {
+       // Debug line
+       this.getLogger().trace(MessageFormat.format("client={0}: CALLED!", client));
+
+       // Has the user entered own data?
+       if (this.getClient().getContactManager().isOwnContactAdded()) {
+           // Debug message
+           this.getLogger().debug("Disabling menus: isOwnContactAdded()=false");
+
+           // Not entered yet, so enable menu
+           //addOwnData.setEnabled(false);
+       }
+
+       // Make the frame visible
+       this.frame.setVisible(true);
+
+       // All done here
+       this.statusLabel.setText(this.getBundle().getString("AddressbookFrame.statusLabel.done.text"));
+    }
+
+    /**
+     * Initalizes this frame. Having initComponents() exposed (publicly
+     * accessible) means that any other object can initialize components which
+     * you may not want.
+     * 
+     * @throws org.mxchange.addressbook.FrameAlreadyInitializedException If this method has been called twice
+     */
+    @Override
+    public void initFrame () throws FrameAlreadyInitializedException {
+       // Debug line
+       this.getLogger().trace("CALLED!");
+
+       // Has this frame been initialized?
+       if (this.isInitialized()) {
+           // Throw exception
+           throw new FrameAlreadyInitializedException();
+       }
+
+       // Init components
+       this.initComponents();
+
+       // Set flag
+       this.isInitialized = true;
+    }
+
+    /**
+     * Returns field isInitialized. This flag indicates whether this frame has been initialized or not.
+     * 
+     * @return Field isInitialized
+     */
+    @Override
+    public final boolean isInitialized () {
+       return this.isInitialized;
+    }
+
+    /**
+     * Initialize components
+     */
+    private void initComponents () {
+       // Debug line
+       this.getLogger().trace("CALLED!");
+
+       // Register shutdown listener
+       this.frame.addWindowListener(new WindowAdapter() {
+           /**
+            * Invoked when a window has been closed.
+            */
+           @Override
+           public void windowClosed(final WindowEvent e) {
+               // Shutdown application cleanly
+               self.getClient().getApplication().doShutdown();
+           }
+
+           /**
+            * Invoked when a window is in the process of being closed.
+            * The close operation can be overridden at this point.
+            */
+           @Override
+           public void windowClosing(final WindowEvent e) {
+               // Also shutdown cleanly here
+               self.getClient().getApplication().doShutdown();
+           }
+       });
+
+       // Setup layout manager
+       this.frame.setLayout(new BorderLayout(2, 2));
+
+       // Set window size
+       this.frame.setSize(700, 400);
+
+       // Center window in middle of screen, instead of top-left corner
+       this.frame.setLocationRelativeTo(null);
+
+       // Init menu bar in north
+       JMenuBar menuBar = new JMenuBar();
+
+       // Init some menus:
+       // 1) File menu
+       JMenu menu = new JMenu(this.getBundle().getString("AddressbookFrame.menu.file.text"));
+
+       // Add menu items:
+       // 1.x) Exit program (should be last)
+       JMenuItem item = new JMenuItem(this.getBundle().getString("AddressbookFrame.menuItem.exitProgram.text"));
+       item.setToolTipText(this.getBundle().getString("AddressbookFrame.menuItem.exitProgram.toolTipText"));
+
+       // Add listener to exit menu
+       item.addActionListener(new ActionListener() {
+           /**
+            * If the user has performed this action
+            *
+            * @param e An instance of an ActionEvent class
+            */
+           @Override
+           public void actionPerformed (final ActionEvent e) {
+               self.getClient().getApplication().doShutdown();
+           }
+       });
+
+       // Add item -> menu
+       menu.add(item);
+
+       // Add menu -> menu bar
+       menuBar.add(menu);
+
+       // Add menu bar -> frame
+       this.frame.add(menuBar, BorderLayout.NORTH);
+
+       // Init status label (which needs to be updated
+       this.statusLabel = new JLabel(this.getBundle().getString("AddressbookFrame.statusLabel.initializing.text"));
+
+       // Init status bar in south
+       JPanel statusPanel = new JPanel();
+       statusPanel.setLayout(new BoxLayout(statusPanel, BoxLayout.X_AXIS));
+       statusPanel.add(this.statusLabel);
+       statusPanel.setBorder(BorderFactory.createEtchedBorder());
+
+       // Add panel to frame
+       this.frame.add(statusPanel, BorderLayout.SOUTH);
+    }
+
+}
index 0c5ab4dfa365d580cd7d769f253f5aec4880c671..f0cc531062d875e8d920b7c0f660703d1e88f726 100644 (file)
@@ -1,50 +1,56 @@
-/*\r
- * Copyright (C) 2015 Roland Haeder\r
- *\r
- * This program is free software: you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation, either version 3 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.\r
- */\r
-package org.mxchange.addressbook.client.gui;\r
-\r
-import org.mxchange.addressbook.FrameAlreadyInitializedException;\r
-import org.mxchange.addressbook.FrameworkInterface;\r
-import org.mxchange.addressbook.client.Client;\r
-\r
-/**\r
- * An interface for applications with a frame\r
- *\r
- * @author Roland Haeder\r
- */\r
-public interface ClientFrame extends FrameworkInterface {\r
-    /**\r
-     * Setups the frame (and starts it). You have to call initFrame() before you\r
-     * can call this method.\r
-     * \r
-     * @param client Client instance\r
-     */\r
-    public void setupFrame (final Client client);\r
-\r
-    /**\r
-     * Initializes frame\r
-     * \r
-     * @throws org.mxchange.addressbook.FrameAlreadyInitializedException If this method has been called twice\r
-     */\r
-    public void initFrame () throws FrameAlreadyInitializedException;\r
-\r
-    /**\r
-     * Returns field isInitialized. This flag indicates whether this frame has been initialized or not.\r
-     * \r
-     * @return Field isInitialized\r
-     */\r
-    public boolean isInitialized ();\r
-}\r
+/*
+ * Copyright (C) 2015 Roland Haeder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.addressbook.client.gui;
+
+import org.mxchange.addressbook.FrameAlreadyInitializedException;
+import org.mxchange.addressbook.FrameworkInterface;
+import org.mxchange.addressbook.client.Client;
+
+/**
+ * An interface for applications with a frame
+ *
+ * @author Roland Haeder
+ */
+public interface ClientFrame extends FrameworkInterface {
+
+    /**
+     * Shutdown this frame
+     */
+    public void doShutdown ();
+
+    /**
+     * Setups the frame (and starts it). You have to call initFrame() before you
+     * can call this method.
+     * 
+     * @param client Client instance
+     */
+    public void setupFrame (final Client client);
+
+    /**
+     * Initializes frame
+     * 
+     * @throws org.mxchange.addressbook.FrameAlreadyInitializedException If this method has been called twice
+     */
+    public void initFrame () throws FrameAlreadyInitializedException;
+
+    /**
+     * Returns field isInitialized. This flag indicates whether this frame has been initialized or not.
+     * 
+     * @return Field isInitialized
+     */
+    public boolean isInitialized ();
+}
index 8992b3a1ebb621a54afb9499d6f829e79033fe25..c616ae9ac90186e6a75fecca6e3b7d8f538a3a06 100644 (file)
-/*\r
- * Copyright (C) 2015 Roland Haeder\r
- *\r
- * This program is free software: you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation, either version 3 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.\r
- */\r
-package org.mxchange.addressbook.client.gui;\r
-\r
-import org.mxchange.addressbook.FrameAlreadyInitializedException;\r
-import org.mxchange.addressbook.UnhandledUserChoiceException;\r
-import org.mxchange.addressbook.application.Application;\r
-import org.mxchange.addressbook.client.BaseClient;\r
-import org.mxchange.addressbook.client.Client;\r
-import org.mxchange.addressbook.contact.Contact;\r
-import org.mxchange.addressbook.menu.Menu;\r
-import org.mxchange.addressbook.menu.item.SelectableMenuItem;\r
-\r
-/**\r
- *\r
- * @author Roland Haeder\r
- */\r
-public class SwingClient extends BaseClient implements Client {\r
-    /**\r
-     * Swing frame instance\r
-     */\r
-    private final ClientFrame frame;\r
-\r
-    /**\r
-     * Constructor with an Application instance.\r
-     * \r
-     * @param application Application instance\r
-     */\r
-    public SwingClient (final Application application) {\r
-       super();\r
-\r
-       // Set application instance\r
-       this.setApplication(application);\r
-\r
-       // Init frame instance\r
-       this.frame = AddressbookFrame.getSelfInstance(this);\r
-    }\r
-\r
-    @Override\r
-    public void displayAddressBox (final Contact contact) {\r
-       throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.\r
-    }\r
-\r
-    @Override\r
-    public void displayNameBox (final Contact contact) {\r
-       throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.\r
-    }\r
-\r
-    @Override\r
-    public void displayOtherDataBox (final Contact contact) {\r
-       throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.\r
-    }\r
-\r
-    @Override\r
-    public void doChangeOwnAddressData (Contact contact) {\r
-       throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.\r
-    }\r
-\r
-    @Override\r
-    public void doChangeOwnNameData (Contact contact) {\r
-       throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.\r
-    }\r
-\r
-    @Override\r
-    public void doChangeOwnOtherData (Contact contact) {\r
-       throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.\r
-    }\r
-\r
-    @Override\r
-    public Contact doEnterOwnData () {\r
-       throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.\r
-    }\r
-\r
-    @Override\r
-    public void doShutdown () {\r
-       // Parent call\r
-       super.doShutdown();\r
-\r
-       // @TODO Add other shutdown stuff\r
-    }\r
-\r
-    @Override\r
-    public void doUserMenuChoice () throws UnhandledUserChoiceException {\r
-       // Not implemented here\r
-    }\r
-\r
-    @Override\r
-    public char enterChar (final char[] validChars, String message) {\r
-       throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.\r
-    }\r
-\r
-    @Override\r
-    public int enterInt (final int minimum, final int maximum, final String message) {\r
-       throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.\r
-    }\r
-\r
-    @Override\r
-    public String enterString (final int minLength, final int maxLength, final String message, final boolean allowEmpty) {\r
-       throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.\r
-    }\r
-\r
-    @Override\r
-    public Menu getMenu (final String menuType) {\r
-       throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.\r
-    }\r
-\r
-    /**\r
-     * Returns a Swing menu item\r
-     * \r
-     * @param accessKey Key to access the menu\r
-     * @param text Text to show to user\r
-     * @return A SelectableMenuItem\r
-     */\r
-    @Override\r
-    public SelectableMenuItem getMenuItem (final char accessKey, final String text) {\r
-       // Returns null as the menu is now no longer controlled here.\r
-       return null;\r
-    }\r
-\r
-    /**\r
-     * Inizializes this client\r
-     */\r
-    @Override\r
-    public void initClient () {\r
-       // Init contact manager here\r
-       this.initContactManager();\r
-\r
-       try {\r
-           // Init frame\r
-           this.frame.initFrame();\r
-       } catch (final FrameAlreadyInitializedException ex) {\r
-           this.getLogger().catching(ex);\r
-           System.exit(1);\r
-       }\r
-\r
-       // Now start the frame\r
-       this.frame.setupFrame(this);\r
-    }\r
-\r
-    @Override\r
-    public void outputMessage (final String message) {\r
-       throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.\r
-    }\r
-\r
-    @Override\r
-    public void showCurrentMenu () {\r
-       // Not implemented here\r
-    }\r
-\r
-    @Override\r
-    public void showEntry (final SelectableMenuItem item) {\r
-       throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.\r
-    }\r
-\r
-    @Override\r
-    public void showWelcome () {\r
-       // Not implemented here\r
-    }\r
-\r
-    @Override\r
-    public void userChooseChangeContactData (final Contact contact) throws UnhandledUserChoiceException {\r
-       throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.\r
-    }\r
-\r
-    /**\r
-     * Fills menu map with swing menus\r
-     */\r
-    @Override\r
-    protected final void fillMenuMap () {\r
-       // Nothing to fill here as the Swing frame is handling this all\r
-       throw new UnsupportedOperationException("Not implemented.");\r
-    }\r
-}\r
+/*
+ * Copyright (C) 2015 Roland Haeder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.addressbook.client.gui;
+
+import org.mxchange.addressbook.FrameAlreadyInitializedException;
+import org.mxchange.addressbook.UnhandledUserChoiceException;
+import org.mxchange.addressbook.application.Application;
+import org.mxchange.addressbook.client.BaseClient;
+import org.mxchange.addressbook.client.Client;
+import org.mxchange.addressbook.contact.Contact;
+import org.mxchange.addressbook.menu.Menu;
+import org.mxchange.addressbook.menu.item.SelectableMenuItem;
+
+/**
+ *
+ * @author Roland Haeder
+ */
+public class SwingClient extends BaseClient implements Client {
+    /**
+     * Swing frame instance
+     */
+    private final ClientFrame frame;
+
+    /**
+     * Constructor with an Application instance.
+     * 
+     * @param application Application instance
+     */
+    public SwingClient (final Application application) {
+       super();
+
+       // Debug message
+       this.getLogger().trace("CALLED!");
+
+       // Set application instance
+       this.setApplication(application);
+
+       // Init frame instance
+       this.frame = AddressbookFrame.getSelfInstance(this);
+    }
+
+    @Override
+    public void displayAddressBox (final Contact contact) {
+       throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+    }
+
+    @Override
+    public void displayNameBox (final Contact contact) {
+       throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+    }
+
+    @Override
+    public void displayOtherDataBox (final Contact contact) {
+       throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+    }
+
+    @Override
+    public void doChangeOwnAddressData (Contact contact) {
+       throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+    }
+
+    @Override
+    public void doChangeOwnNameData (Contact contact) {
+       throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+    }
+
+    @Override
+    public void doChangeOwnOtherData (Contact contact) {
+       throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+    }
+
+    @Override
+    public Contact doEnterOwnData () {
+       throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+    }
+
+    @Override
+    public void doShutdown () {
+       // Debug message
+       this.getLogger().trace("CALLED!");
+
+       // Parent call
+       super.doShutdown();
+
+       // Shutdown frame
+       this.frame.doShutdown();
+
+       // @TODO Add other shutdown stuff
+
+       // Debug message
+       this.getLogger().trace("EXIT!");
+    }
+
+    @Override
+    public void doUserMenuChoice () throws UnhandledUserChoiceException {
+       // Debug message
+       //* NOISY-DEBUG: */ this.getLogger().trace("CALLED!");
+
+       // Not implemented here
+    }
+
+    @Override
+    public char enterChar (final char[] validChars, String message) {
+       throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+    }
+
+    @Override
+    public int enterInt (final int minimum, final int maximum, final String message) {
+       throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+    }
+
+    @Override
+    public String enterString (final int minLength, final int maxLength, final String message, final boolean allowEmpty) {
+       throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+    }
+
+    @Override
+    public Menu getMenu (final String menuType) {
+       throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+    }
+
+    /**
+     * Returns a Swing menu item
+     * 
+     * @param accessKey Key to access the menu
+     * @param text Text to show to user
+     * @return A SelectableMenuItem
+     */
+    @Override
+    public SelectableMenuItem getMenuItem (final char accessKey, final String text) {
+       // Debug message
+       this.getLogger().trace("CALLED!");
+
+       // Returns null as the menu is now no longer controlled here.
+       return null;
+    }
+
+    /**
+     * Inizializes this client
+     */
+    @Override
+    public void initClient () {
+       // Debug message
+       this.getLogger().trace("CALLED!");
+
+       // Init contact manager here
+       this.initContactManager();
+
+       try {
+           // Init frame
+           this.frame.initFrame();
+       } catch (final FrameAlreadyInitializedException ex) {
+           this.getLogger().catching(ex);
+           System.exit(1);
+       }
+
+       // Now start the frame
+       this.frame.setupFrame(this);
+
+       // Debug message
+       this.getLogger().trace("EXIT!");
+    }
+
+    @Override
+    public void outputMessage (final String message) {
+       throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+    }
+
+    @Override
+    public void showCurrentMenu () {
+       // Debug message
+       //* NOISY-DEBUG: */ this.getLogger().trace("CALLED!");
+
+       // Not implemented here
+    }
+
+    @Override
+    public void showEntry (final SelectableMenuItem item) {
+       throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+    }
+
+    @Override
+    public void showWelcome () {
+       // Debug message
+       this.getLogger().trace("CALLED!");
+
+       // Not implemented here
+    }
+
+    @Override
+    public void userChooseChangeContactData (final Contact contact) throws UnhandledUserChoiceException {
+       throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+    }
+
+    /**
+     * Fills menu map with swing menus
+     */
+    @Override
+    protected final void fillMenuMap () {
+       // Nothing to fill here as the Swing frame is handling this all
+       throw new UnsupportedOperationException("Not implemented.");
+    }
+}
index bbc3dbb89c45a9797f45b9dd9573e7a8a2e8a4c2..1a68562c97e7e8434cb2623483b9bd058d8ccd3d 100644 (file)
@@ -1,28 +1,24 @@
-# Copyright (C) 2015 Roland Haeder\r
-#\r
-# This program is free software: you can redistribute it and/or modify\r
-# it under the terms of the GNU General Public License as published by\r
-# the Free Software Foundation, either version 3 of the License, or\r
-# (at your option) any later version.\r
-#\r
-# This program is distributed in the hope that it will be useful,\r
-# but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
-# GNU General Public License for more details.\r
-#\r
-# You should have received a copy of the GNU General Public License\r
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.\r
-\r
-AddressbookFrame.addOwn.text=Eigene Adresse hinzuf\u00fcgen\r
-AddressbookFrame.text=Datei\r
-AddressbookFrame.statusLabel.text=Initialisiere ...\r
-AddressbookFrame.status.text=Willkommen ...\r
-AddressbookFrame.status.AccessibleContext.accessibleName=\r
-AddressbookFrame.status.AccessibleContext.accessibleDescription=\r
-AddressbookFrame.exitProgram.toolTipText=Beendet das Programm sauber\r
-AddressbookFrame.exitProgram.text=Programm beenden\r
-AddressbookFrame.addressbookMenu.text=Adressbuch\r
-AddressbookFrame.addOwnData.toolTipText=Erlaubt das Hinzuf\u00fcgen eigener Daten\r
-AddressbookFrame.addOwnData.AccessibleContext.accessibleName=addOwn\r
-AddressbookFrame.addOwnData.AccessibleContext.accessibleDescription=\r
-AddressbookFrame.status.done.text=Fertig.\r
+# Copyright (C) 2015 Roland Haeder
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+AddressbookFrame.addOwn.text=Eigene Adresse hinzuf\u00fcgen
+AddressbookFrame.menu.file.text=Datei
+AddressbookFrame.statusLabel.initializing.text=Initialisiere ...
+AddressbookFrame.statusLabel.done.text=Fertig.
+AddressbookFrame.statusLabel.shutdown.text=Shuttting down ...
+AddressbookFrame.menuItem.exitProgram.toolTipText=Beendet das Programm und speichert alle Einstellungen ab.
+AddressbookFrame.menuItem.exitProgram.text=Programm beenden
+AddressbookFrame.menu.addressbook.text=Adressbuch
+AddressbookFrame.addOwnData.toolTipText=Erlaubt das Hinzuf\u00fcgen eigener Daten.
index 8d314b98a6d74120d48bf2fee1fe294ee944745b..b3853fb19041ae4cc0b039741ad4ce4cf283e469 100644 (file)
@@ -1,28 +1,24 @@
-# Copyright (C) 2015 Roland Haeder\r
-#\r
-# This program is free software: you can redistribute it and/or modify\r
-# it under the terms of the GNU General Public License as published by\r
-# the Free Software Foundation, either version 3 of the License, or\r
-# (at your option) any later version.\r
-#\r
-# This program is distributed in the hope that it will be useful,\r
-# but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
-# GNU General Public License for more details.\r
-#\r
-# You should have received a copy of the GNU General Public License\r
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.\r
-\r
-AddressbookFrame.addOwn.text=Add own address\r
-AddressbookFrame.text=File\r
-AddressbookFrame.statusLabel.text=Initializing ...\r
-AddressbookFrame.status.text=Welcome ...\r
-AddressbookFrame.status.AccessibleContext.accessibleName=\r
-AddressbookFrame.status.AccessibleContext.accessibleDescription=\r
-AddressbookFrame.exitProgram.toolTipText=Exits the program cleanly.\r
-AddressbookFrame.exitProgram.text=Exit program\r
-AddressbookFrame.addressbookMenu.text=Addressbook\r
-AddressbookFrame.addOwnData.toolTipText=Allows the user to add own address data\r
-AddressbookFrame.addOwnData.AccessibleContext.accessibleName=addOwn\r
-AddressbookFrame.addOwnData.AccessibleContext.accessibleDescription=\r
-AddressbookFrame.status.done.text=Done.\r
+# Copyright (C) 2015 Roland Haeder
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+AddressbookFrame.addOwn.text=Add own address
+AddressbookFrame.menu.file.text=File
+AddressbookFrame.statusLabel.initializing.text=Initializing ...
+AddressbookFrame.statusLabel.done.text=Done.
+AddressbookFrame.statusLabel.shutdown.text=Shuttting down ...
+AddressbookFrame.menuItem.exitProgram.toolTipText=Exits the program and saves all data.
+AddressbookFrame.menuItem.exitProgram.text=Exit program
+AddressbookFrame.addressbookMenu.text=Addressbook
+AddressbookFrame.addOwnData.toolTipText=Allows the user to add own address data
index 709f6f9369bd8d9f4e140a15382896086ce5c7b8..5c4f54e65b0c053b03d7479a4c649e21219adaa7 100644 (file)
-/*\r
- * Copyright (C) 2015 Roland Haeder\r
- *\r
- * This program is free software: you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation, either version 3 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.\r
- */\r
-package org.mxchange.addressbook.manager.contact;\r
-\r
-import java.text.MessageFormat;\r
-import java.util.ArrayList;\r
-import java.util.Collections;\r
-import java.util.Iterator;\r
-import java.util.List;\r
-import org.mxchange.addressbook.UnhandledUserChoiceException;\r
-import org.mxchange.addressbook.client.Client;\r
-import org.mxchange.addressbook.contact.Contact;\r
-import org.mxchange.addressbook.database.frontend.contact.ContactDatabaseFrontend;\r
-import org.mxchange.addressbook.database.frontend.contact.ContactWrapper;\r
-import org.mxchange.addressbook.manager.BaseManager;\r
-\r
-/**\r
- * A manager for contacts, please note that this implementation loads the whole\r
- * list into RAM.\r
- *\r
- * @author Roland Haeder\r
- * @version 0.0\r
- */\r
-public class ContactManager extends BaseManager implements ManageableContact {\r
-    /**\r
-     * Column name list\r
-     */\r
-    private final List<String> columnNames;\r
-\r
-    /**\r
-     * A ContactWrapper instance\r
-     */\r
-    private final ContactWrapper contactDatabase;\r
-\r
-    /**\r
-     * A list of all contacts\r
-     */\r
-    private final List<Contact> contacts;\r
-\r
-\r
-    /**\r
-     * @param maxContacts Maximum allowed contacts\r
-     * @param client Client instance to use\r
-     */\r
-    public ContactManager (final int maxContacts, final Client client) {\r
-       // Always call super constructor first\r
-       super();\r
-\r
-       // Set client instance\r
-       this.setClient(client);\r
-\r
-       // Init contacts\r
-       this.contacts = new ArrayList<>(maxContacts);\r
-\r
-       // Init database connection\r
-       this.contactDatabase = new ContactDatabaseFrontend(this);\r
-\r
-       // Initialize list\r
-       this.columnNames = new ArrayList<>(15);\r
-\r
-       // And fill it\r
-       this.fillColumnNamesFromBundle();\r
-\r
-       // Read all entries\r
-       this.contactDatabase.readAllContacts();\r
-\r
-       // Debug message\r
-       //* NOISY-DEBUG: */ this.getLogger().debug("client=" + client);\r
-    }\r
-\r
-    /**\r
-     * Adds given Contact instance to list\r
-     *\r
-     * @param contact Contact instance to add\r
-     */\r
-    @Override\r
-    public void addContact (final Contact contact) {\r
-       this.contacts.add(contact);\r
-    }\r
-\r
-    /**\r
-     * Let the user add a new other address\r
-     */\r
-    @Override\r
-    public void addOtherAddress () {\r
-       throw new UnsupportedOperationException("Not supported yet.");\r
-    }\r
-\r
-    /**\r
-     * Let the user change other address\r
-     */\r
-    @Override\r
-    public void changeOtherAddress () {\r
-       throw new UnsupportedOperationException("Not supported yet.");\r
-    }\r
-\r
-    /**\r
-     * Allows the user to change his/her own data\r
-     */\r
-    @Override\r
-    public void changeOwnData () {\r
-       /*\r
-        * First check if the user has registered own contact, before that\r
-        * nothing can be changed.\r
-        */\r
-       if (!this.isOwnContactAdded()) {\r
-           // Not added\r
-           this.getClient().outputMessage("Sie haben noch nicht Ihre Daten eingegeben.");\r
-           \r
-           // Skip any below code\r
-           return;\r
-       }\r
-       \r
-       // Instance\r
-       Contact contact = this.getOwnContact();\r
-       \r
-       // It must be found\r
-       assert(contact instanceof Contact);\r
-       \r
-       // Display contact\r
-       contact.show(this.getClient());\r
-       \r
-       try {\r
-           // Ask user what to change\r
-           this.getClient().userChooseChangeContactData(contact);\r
-       } catch (final UnhandledUserChoiceException ex) {\r
-           this.getLogger().catching(ex);\r
-       }\r
-    }\r
-\r
-    /**\r
-     * Let the user delete other address\r
-     */\r
-    @Override\r
-    public void deleteOtherAddress () {\r
-       throw new UnsupportedOperationException("Not supported yet.");\r
-    }\r
-\r
-    /**\r
-     * Let the user change address data\r
-     * \r
-     * @param contact Instance to change data\r
-     * @param client Client instance to call back\r
-     */\r
-    @Override\r
-    public void doChangeAddressData (final Contact contact, final Client client) {\r
-       // First display it again\r
-       client.displayAddressBox(contact);\r
-\r
-       // Is it own data?\r
-       if (contact.isOwnContact()) {\r
-           // Deligate to client\r
-           this.getClient().doChangeOwnAddressData(contact);\r
-       } else {\r
-           // Other contact's address data to change\r
-           throw new UnsupportedOperationException("Changing contact entries not finished.");\r
-       }\r
-\r
-       // Flush whole list\r
-       this.flush();\r
-    }\r
-\r
-    /**\r
-     * Let the user change "name data"\r
-     * \r
-     * @param contact Instance to change data\r
-     * @param client Client instance to call back\r
-     */\r
-    @Override\r
-    public void doChangeNameData (final Contact contact, final Client client) {\r
-       // First display them again\r
-       client.displayNameBox(contact);\r
-\r
-       // Is this own data?\r
-       if (contact.isOwnContact()) {\r
-           // Re-ask own data\r
-           this.getClient().doChangeOwnNameData(contact);\r
-       } else {\r
-           // Then re-ask them ...\r
-           throw new UnsupportedOperationException("Changing contact entries not finished.");\r
-       }\r
-\r
-       // Flush whole list\r
-       this.flush();\r
-    }\r
-\r
-    /**\r
-     * Let the user change other data\r
-     *\r
-     * @param contact Instance to change data\r
-     * @param client Client instance to call back\r
-     * @todo Didn't handle birthday\r
-     */\r
-    @Override\r
-    public void doChangeOtherData (final Contact contact, final Client client) {\r
-       // First display them again\r
-       this.getClient().displayOtherDataBox(contact);\r
-\r
-       // Is this own data?\r
-       if (contact.isOwnContact()) {\r
-           // Re-ask own data\r
-           this.getClient().doChangeOwnOtherData(contact);\r
-       } else {\r
-           // Then re-ask them ...\r
-           throw new UnsupportedOperationException("Changing contact entries not finished.");\r
-       }\r
-\r
-       // Flush whole list\r
-       this.flush();\r
-    }\r
-\r
-    /**\r
-     * Asks user for own data\r
-     */\r
-    @Override\r
-    public void doEnterOwnData () {\r
-       // Deligate this call to the client\r
-       Contact contact = this.getClient().doEnterOwnData();\r
-\r
-       // Add it to contact "book"\r
-       this.registerContact(contact);\r
-    }\r
-\r
-    /**\r
-     * Shuts down this contact manager\r
-     */\r
-    @Override\r
-    public void doShutdown () {\r
-       // Shut down the database layer\r
-       this.getContactDatabase().doShutdown();\r
-    }\r
-\r
-    /**\r
-     * Asks the user for his/her cellphone number\r
-     * \r
-     * @return User's cellphone number\r
-     */\r
-    @Override\r
-    public String enterOwnCellNumber () {\r
-       return this.getClient().enterString(5, 30, "Bitte geben Sie Ihre Handynummer an: ", true);\r
-    }\r
-\r
-    /**\r
-     * Asks the user for his/her city's name\r
-     *\r
-     * @return City's name of the user\r
-     */\r
-    @Override\r
-    public String enterOwnCity () {\r
-       return this.getClient().enterString(3, 50, "Bitte geben Sie Ihre Wohnort ein: ", false);\r
-    }\r
-\r
-    /**\r
-     * Asks the user for his/her city's name\r
-     *\r
-     * @return City's name of the user\r
-     */\r
-    @Override\r
-    public String enterOwnComment () {\r
-       return this.getClient().enterString(0, 100, "Kommentar zu Ihrem Eintrag: ", true);\r
-    }\r
-\r
-    /**\r
-     * Asks the user for his/her company name\r
-     * \r
-     * @return User's company name\r
-     */\r
-    @Override\r
-    public String enterOwnCompanyName () {\r
-       return this.getClient().enterString(5, 50, "Bitte geben Sie Ihre Firmenbezeichnung ein: ", true);\r
-    }\r
-\r
-    /**\r
-     * Asks user for his/her own country code\r
-     * \r
-     * @return User's own country code\r
-     */\r
-    @Override\r
-    public String enterOwnCountryCode () {\r
-       return this.getClient().enterString(2, 2, "Bitte geben Sie den zweistelligen Ländercode von Ihrem Land ein: ", false).toUpperCase();\r
-    }\r
-\r
-    /**\r
-     * Asks user for his/her own country code\r
-     * \r
-     * @return User's own country code\r
-     */\r
-    @Override\r
-    public String enterOwnEmailAddress () {\r
-       return this.getClient().enterString(10, 50, "Bitte geben Sie Ihre Email-Adresse ein: ", true);\r
-    }\r
-\r
-    /**\r
-     * Asks the user for family name\r
-     * \r
-     * @return Family name of the user\r
-     */\r
-    @Override\r
-    public String enterOwnFamilyName () {\r
-       return this.getClient().enterString(2, 50, "Bitte geben Sie Ihren Nachnamen ein: ", false);\r
-    }\r
-\r
-    /**\r
-     * Asks the user for family name\r
-     * \r
-     * @return Family name of the user\r
-     */\r
-    @Override\r
-    public String enterOwnFaxNumber () {\r
-       return this.getClient().enterString(5, 30, "Bitte geben Sie Ihre Faxnummer an: ", true);\r
-    }\r
-\r
-    /**\r
-     * Asks the user for gender, until a valid has been entered\r
-     * \r
-     * @return Gender of the user\r
-     */\r
-    @Override\r
-    public char enterOwnGender () {\r
-       return this.getClient().enterChar(new char[] {'M', 'F', 'C'}, "Bitte geben Sie die Anrede ein: (M=Herr, F=Frau, C=Firma): ");\r
-    }\r
-\r
-    /**\r
-     * Asks the user for phone number\r
-     * \r
-     * @return Phone number of the user\r
-     */\r
-    @Override\r
-    public String enterOwnPhoneNumber () {\r
-       return this.getClient().enterString(5, 30, "Bitte geben Sie Ihre Telefonnummer an: ", true);\r
-    }\r
-\r
-    /**\r
-     * Asks the user for own street (including number)\r
-     * @return Own street an number\r
-     */\r
-    @Override\r
-    public String enterOwnStreet () {\r
-       return this.getClient().enterString(5, 50, "Bitte geben Sie Ihre Strasse und Hausnummer ein: ", false);\r
-    }\r
-\r
-    /**\r
-     * Asks the user for surname\r
-     * @return Surname of the user\r
-     */\r
-    @Override\r
-    public String enterOwnSurname () {\r
-       return this.getClient().enterString(2, 50, "Bitte geben Sie Ihren Vornamen ein: ", false);\r
-    }\r
-\r
-    /**\r
-     * Asks the user for own ZIP code\r
-     * \r
-     * @return ZIP code\r
-     */\r
-    @Override\r
-    public int enterOwnZipCode () {\r
-       return this.getClient().enterInt(0, 99_999, "Bitte geben Sie Ihre Postleitzahl ein: ");\r
-    }\r
-\r
-    @Override\r
-    public final int getColumnCount () {\r
-       return this.columnNames.size();\r
-    }\r
-\r
-    /**\r
-     * Getter for whole contact list\r
-     *\r
-     * @return List of all contacts\r
-     */\r
-    @Override\r
-    public List<Contact> getList () {\r
-       return Collections.unmodifiableList(this.contacts);\r
-    }\r
-\r
-    /**\r
-     * Checks whether own contact is already added by checking all entries for\r
-     * isOwnContact flag\r
-     *\r
-     * @return Whether own contact is already added\r
-     */\r
-    @Override\r
-    public boolean isOwnContactAdded () {\r
-       // Default is not added\r
-       boolean isAdded = false;\r
-       \r
-       // Now get it back from address book, first get an iterator\r
-       Iterator<Contact> iterator = this.contacts.iterator();\r
-       \r
-       // Check entries\r
-       while (iterator.hasNext()) {\r
-           // Get next entry\r
-           Contact contact = iterator.next();\r
-           \r
-           // Is it valid?\r
-           if (contact instanceof Contact) {\r
-               // Get flag\r
-               isAdded = contact.isOwnContact();\r
-               \r
-               // Is this own contact?\r
-               if (isAdded) {\r
-                   // Then abort loop\r
-                   break;\r
-               }\r
-           }\r
-       }\r
-       // Return result\r
-       return isAdded;\r
-    }\r
-\r
-    @Override\r
-    public void listContacts () {\r
-       throw new UnsupportedOperationException("Not supported yet.");\r
-    }\r
-\r
-    /**\r
-     * Adds given contact to address book and flushes all entries to database\r
-     *\r
-     * @param contact Contact being added\r
-     * @todo Add check for book size\r
-     */\r
-    @Override\r
-    public void registerContact (final Contact contact) {\r
-       // Check if contact is found\r
-       if (this.isContactAlreadyAdded(contact)) {\r
-           // Contact already added\r
-           // @todo Do something here\r
-       } else if ((contact.isOwnContact()) && (this.isOwnContactAdded())) {\r
-           // Own contact already added\r
-           // @todo Do something\r
-       }\r
-       \r
-       // Debug message\r
-       /* NOISY-DEBUG: */ this.getLogger().debug(MessageFormat.format("Adding '{0}' '{1}' at pos '{2}' ...", contact.getSurname(), contact.getFamilyName(), this.size()));\r
-       \r
-       // Add contact to internal list\r
-       this.addContact(contact);\r
-       \r
-       // Flush whole list\r
-       this.flush();\r
-    }\r
-\r
-    @Override\r
-    public void searchContacts () {\r
-       throw new UnsupportedOperationException("Not supported yet.");\r
-    }\r
-\r
-    /**\r
-     * Getter for size\r
-     *\r
-     * @return size of contact "book"\r
-     */\r
-    @Override\r
-    public final int size () {\r
-       return this.contacts.size();\r
-    }\r
-\r
-    /**\r
-     * Fills the column names array with strings from bundle\r
-     */\r
-    private void fillColumnNamesFromBundle () {\r
-       // Debug message\r
-       this.getLogger().trace("CALLED!");\r
-\r
-       // First get an iterator from key set to iterate over\r
-       Iterator<String> iterator = this.getBundle().keySet().iterator();\r
-\r
-       // Then iterate over all\r
-       while (iterator.hasNext()) {\r
-           // Get next element\r
-           String key = iterator.next();\r
-\r
-           // Does the key start with ContactManager.columnName ?\r
-           if (key.startsWith("ContactManager.columnName")) {\r
-               // This is the wanted entry.\r
-               this.getLogger().debug(MessageFormat.format("key={0}", key));\r
-\r
-               // So add it\r
-               this.columnNames.add(this.getBundle().getString(key));\r
-           }\r
-       }\r
-\r
-       // Debug message\r
-       this.getLogger().trace(MessageFormat.format("getColumnCount()={0}: EXIT!", this.getColumnCount()));\r
-    }\r
-\r
-    /**\r
-     * Flushes all entries by calling database backend\r
-     */\r
-    private void flush () {\r
-       // Flusgh all\r
-       this.getContactDatabase().flushAllContacts();\r
-    }\r
-\r
-    /**\r
-     * A ContactWrapper instance\r
-     *\r
-     * @return the database\r
-     */\r
-    private ContactWrapper getContactDatabase () {\r
-       return this.contactDatabase;\r
-    }\r
-\r
-    /**\r
-     * "Getter" for own contact instance or null if not found\r
-     *\r
-     * @return Contact instance or null\r
-     */\r
-    private Contact getOwnContact () {\r
-       // Now get it back from address book, first get an iterator\r
-       Iterator<Contact> iterator = this.contacts.iterator();\r
-\r
-       // Init instance\r
-       Contact contact = null;\r
-\r
-       // Search all contact\r
-       while (iterator.hasNext()) {\r
-           // Get next instance\r
-           Contact next = iterator.next();\r
-\r
-           // Is this own contact?\r
-           if (next.isOwnContact()) {\r
-               // Found it\r
-               contact = next;\r
-               break;\r
-               \r
-           }\r
-       }\r
-\r
-       // Return instance or null\r
-       return contact;\r
-    }\r
-\r
-    /**\r
-     * Checks whether given contact was found in "address book"\r
-     *\r
-     * @param checkContact Contact to be checked\r
-     * @return TRUE if found, FALSE if not found\r
-     */\r
-    private boolean isContactAlreadyAdded (final Contact checkContact) throws NullPointerException {\r
-       // Default is not found\r
-       boolean isFound = false;\r
-\r
-       // Debug message\r
-       //* NOISY-DEBUG: */ this.getLogger().debug("Checking '" +  this.contacts.length + "' entries...");\r
-\r
-       // Now get it back from address book, first get an iterator\r
-       Iterator<Contact> iterator = this.contacts.iterator();\r
-\r
-       // Check entries\r
-       while (iterator.hasNext()) {\r
-           // Get next entry\r
-           Contact contact = iterator.next();\r
-\r
-           // Debug message\r
-           //* NOISY-DEBUG: */ this.getLogger().debug("contact=" + contact + ",checkContent=" + checkContact);\r
-\r
-           // Is it valid?\r
-           if ((contact instanceof Contact) && ((contact.equals(checkContact)))) {\r
-               // Found matching entry\r
-               isFound = true;\r
-               break;\r
-           }\r
-       }\r
-\r
-       // Return result\r
-       return isFound;\r
-    }\r
-}\r
+/*
+ * Copyright (C) 2015 Roland Haeder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.addressbook.manager.contact;
+
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import org.mxchange.addressbook.UnhandledUserChoiceException;
+import org.mxchange.addressbook.client.Client;
+import org.mxchange.addressbook.contact.Contact;
+import org.mxchange.addressbook.database.frontend.contact.ContactDatabaseFrontend;
+import org.mxchange.addressbook.database.frontend.contact.ContactWrapper;
+import org.mxchange.addressbook.manager.BaseManager;
+
+/**
+ * A manager for contacts, please note that this implementation loads the whole
+ * list into RAM.
+ *
+ * @author Roland Haeder
+ * @version 0.0
+ */
+public class ContactManager extends BaseManager implements ManageableContact {
+    /**
+     * Column name list
+     */
+    private final List<String> columnNames;
+
+    /**
+     * A ContactWrapper instance
+     */
+    private final ContactWrapper contactDatabase;
+
+    /**
+     * A list of all contacts
+     */
+    private final List<Contact> contacts;
+
+
+    /**
+     * @param maxContacts Maximum allowed contacts
+     * @param client Client instance to use
+     */
+    public ContactManager (final int maxContacts, final Client client) {
+       // Always call super constructor first
+       super();
+
+       // Set client instance
+       this.setClient(client);
+
+       // Init contacts
+       this.contacts = new ArrayList<>(maxContacts);
+
+       // Init database connection
+       this.contactDatabase = new ContactDatabaseFrontend(this);
+
+       // Initialize list
+       this.columnNames = new ArrayList<>(15);
+
+       // And fill it
+       this.fillColumnNamesFromBundle();
+
+       // Read all entries
+       this.contactDatabase.readAllContacts();
+
+       // Debug message
+       //* NOISY-DEBUG: */ this.getLogger().debug("client=" + client);
+    }
+
+    /**
+     * Adds given Contact instance to list
+     *
+     * @param contact Contact instance to add
+     */
+    @Override
+    public void addContact (final Contact contact) {
+       this.contacts.add(contact);
+    }
+
+    /**
+     * Let the user add a new other address
+     */
+    @Override
+    public void addOtherAddress () {
+       throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    /**
+     * Let the user change other address
+     */
+    @Override
+    public void changeOtherAddress () {
+       throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    /**
+     * Allows the user to change his/her own data
+     */
+    @Override
+    public void changeOwnData () {
+       /*
+        * First check if the user has registered own contact, before that
+        * nothing can be changed.
+        */
+       if (!this.isOwnContactAdded()) {
+           // Not added
+           this.getClient().outputMessage("Sie haben noch nicht Ihre Daten eingegeben.");
+           
+           // Skip any below code
+           return;
+       }
+       
+       // Instance
+       Contact contact = this.getOwnContact();
+       
+       // It must be found
+       assert(contact instanceof Contact);
+       
+       // Display contact
+       contact.show(this.getClient());
+       
+       try {
+           // Ask user what to change
+           this.getClient().userChooseChangeContactData(contact);
+       } catch (final UnhandledUserChoiceException ex) {
+           this.getLogger().catching(ex);
+       }
+    }
+
+    /**
+     * Let the user delete other address
+     */
+    @Override
+    public void deleteOtherAddress () {
+       throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    /**
+     * Let the user change address data
+     * 
+     * @param contact Instance to change data
+     * @param client Client instance to call back
+     */
+    @Override
+    public void doChangeAddressData (final Contact contact, final Client client) {
+       // First display it again
+       client.displayAddressBox(contact);
+
+       // Is it own data?
+       if (contact.isOwnContact()) {
+           // Deligate to client
+           this.getClient().doChangeOwnAddressData(contact);
+       } else {
+           // Other contact's address data to change
+           throw new UnsupportedOperationException("Changing contact entries not finished.");
+       }
+
+       // Flush whole list
+       this.flush();
+    }
+
+    /**
+     * Let the user change "name data"
+     * 
+     * @param contact Instance to change data
+     * @param client Client instance to call back
+     */
+    @Override
+    public void doChangeNameData (final Contact contact, final Client client) {
+       // First display them again
+       client.displayNameBox(contact);
+
+       // Is this own data?
+       if (contact.isOwnContact()) {
+           // Re-ask own data
+           this.getClient().doChangeOwnNameData(contact);
+       } else {
+           // Then re-ask them ...
+           throw new UnsupportedOperationException("Changing contact entries not finished.");
+       }
+
+       // Flush whole list
+       this.flush();
+    }
+
+    /**
+     * Let the user change other data
+     *
+     * @param contact Instance to change data
+     * @param client Client instance to call back
+     * @todo Didn't handle birthday
+     */
+    @Override
+    public void doChangeOtherData (final Contact contact, final Client client) {
+       // First display them again
+       this.getClient().displayOtherDataBox(contact);
+
+       // Is this own data?
+       if (contact.isOwnContact()) {
+           // Re-ask own data
+           this.getClient().doChangeOwnOtherData(contact);
+       } else {
+           // Then re-ask them ...
+           throw new UnsupportedOperationException("Changing contact entries not finished.");
+       }
+
+       // Flush whole list
+       this.flush();
+    }
+
+    /**
+     * Asks user for own data
+     */
+    @Override
+    public void doEnterOwnData () {
+       // Deligate this call to the client
+       Contact contact = this.getClient().doEnterOwnData();
+
+       // Add it to contact "book"
+       this.registerContact(contact);
+    }
+
+    /**
+     * Shuts down this contact manager
+     */
+    @Override
+    public void doShutdown () {
+       // Shut down the database layer
+       this.getContactDatabase().doShutdown();
+    }
+
+    /**
+     * Asks the user for his/her cellphone number
+     * 
+     * @return User's cellphone number
+     */
+    @Override
+    public String enterOwnCellNumber () {
+       return this.getClient().enterString(5, 30, "Bitte geben Sie Ihre Handynummer an: ", true);
+    }
+
+    /**
+     * Asks the user for his/her city's name
+     *
+     * @return City's name of the user
+     */
+    @Override
+    public String enterOwnCity () {
+       return this.getClient().enterString(3, 50, "Bitte geben Sie Ihre Wohnort ein: ", false);
+    }
+
+    /**
+     * Asks the user for his/her city's name
+     *
+     * @return City's name of the user
+     */
+    @Override
+    public String enterOwnComment () {
+       return this.getClient().enterString(0, 100, "Kommentar zu Ihrem Eintrag: ", true);
+    }
+
+    /**
+     * Asks the user for his/her company name
+     * 
+     * @return User's company name
+     */
+    @Override
+    public String enterOwnCompanyName () {
+       return this.getClient().enterString(5, 50, "Bitte geben Sie Ihre Firmenbezeichnung ein: ", true);
+    }
+
+    /**
+     * Asks user for his/her own country code
+     * 
+     * @return User's own country code
+     */
+    @Override
+    public String enterOwnCountryCode () {
+       return this.getClient().enterString(2, 2, "Bitte geben Sie den zweistelligen Ländercode von Ihrem Land ein: ", false).toUpperCase();
+    }
+
+    /**
+     * Asks user for his/her own country code
+     * 
+     * @return User's own country code
+     */
+    @Override
+    public String enterOwnEmailAddress () {
+       return this.getClient().enterString(10, 50, "Bitte geben Sie Ihre Email-Adresse ein: ", true);
+    }
+
+    /**
+     * Asks the user for family name
+     * 
+     * @return Family name of the user
+     */
+    @Override
+    public String enterOwnFamilyName () {
+       return this.getClient().enterString(2, 50, "Bitte geben Sie Ihren Nachnamen ein: ", false);
+    }
+
+    /**
+     * Asks the user for family name
+     * 
+     * @return Family name of the user
+     */
+    @Override
+    public String enterOwnFaxNumber () {
+       return this.getClient().enterString(5, 30, "Bitte geben Sie Ihre Faxnummer an: ", true);
+    }
+
+    /**
+     * Asks the user for gender, until a valid has been entered
+     * 
+     * @return Gender of the user
+     */
+    @Override
+    public char enterOwnGender () {
+       return this.getClient().enterChar(new char[] {'M', 'F', 'C'}, "Bitte geben Sie die Anrede ein: (M=Herr, F=Frau, C=Firma): ");
+    }
+
+    /**
+     * Asks the user for phone number
+     * 
+     * @return Phone number of the user
+     */
+    @Override
+    public String enterOwnPhoneNumber () {
+       return this.getClient().enterString(5, 30, "Bitte geben Sie Ihre Telefonnummer an: ", true);
+    }
+
+    /**
+     * Asks the user for own street (including number)
+     * @return Own street an number
+     */
+    @Override
+    public String enterOwnStreet () {
+       return this.getClient().enterString(5, 50, "Bitte geben Sie Ihre Strasse und Hausnummer ein: ", false);
+    }
+
+    /**
+     * Asks the user for surname
+     * @return Surname of the user
+     */
+    @Override
+    public String enterOwnSurname () {
+       return this.getClient().enterString(2, 50, "Bitte geben Sie Ihren Vornamen ein: ", false);
+    }
+
+    /**
+     * Asks the user for own ZIP code
+     * 
+     * @return ZIP code
+     */
+    @Override
+    public int enterOwnZipCode () {
+       return this.getClient().enterInt(0, 99_999, "Bitte geben Sie Ihre Postleitzahl ein: ");
+    }
+
+    @Override
+    public final int getColumnCount () {
+       return this.columnNames.size();
+    }
+
+    /**
+     * Getter for whole contact list
+     *
+     * @return List of all contacts
+     */
+    @Override
+    public List<Contact> getList () {
+       return Collections.unmodifiableList(this.contacts);
+    }
+
+    /**
+     * Checks whether own contact is already added by checking all entries for
+     * isOwnContact flag
+     *
+     * @return Whether own contact is already added
+     */
+    @Override
+    public boolean isOwnContactAdded () {
+       // Default is not added
+       boolean isAdded = false;
+       
+       // Now get it back from address book, first get an iterator
+       Iterator<Contact> iterator = this.contacts.iterator();
+       
+       // Check entries
+       while (iterator.hasNext()) {
+           // Get next entry
+           Contact contact = iterator.next();
+           
+           // Is it valid?
+           if (contact instanceof Contact) {
+               // Get flag
+               isAdded = contact.isOwnContact();
+               
+               // Is this own contact?
+               if (isAdded) {
+                   // Then abort loop
+                   break;
+               }
+           }
+       }
+       // Return result
+       return isAdded;
+    }
+
+    @Override
+    public void listContacts () {
+       throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    /**
+     * Adds given contact to address book and flushes all entries to database
+     *
+     * @param contact Contact being added
+     * @todo Add check for book size
+     */
+    @Override
+    public void registerContact (final Contact contact) {
+       // Check if contact is found
+       if (this.isContactAlreadyAdded(contact)) {
+           // Contact already added
+           // @todo Do something here
+       } else if ((contact.isOwnContact()) && (this.isOwnContactAdded())) {
+           // Own contact already added
+           // @todo Do something
+       }
+       
+       // Debug message
+       /* NOISY-DEBUG: */ this.getLogger().debug(MessageFormat.format("Adding '{0}' '{1}' at pos '{2}' ...", contact.getSurname(), contact.getFamilyName(), this.size()));
+       
+       // Add contact to internal list
+       this.addContact(contact);
+       
+       // Flush whole list
+       this.flush();
+    }
+
+    @Override
+    public void searchContacts () {
+       throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    /**
+     * Getter for size
+     *
+     * @return size of contact "book"
+     */
+    @Override
+    public final int size () {
+       return this.contacts.size();
+    }
+
+    /**
+     * Fills the column names array with strings from bundle
+     */
+    private void fillColumnNamesFromBundle () {
+       // Debug message
+       this.getLogger().trace("CALLED!");
+
+       // First get an iterator from key set to iterate over
+       Iterator<String> iterator = this.getBundle().keySet().iterator();
+
+       // Then iterate over all
+       while (iterator.hasNext()) {
+           // Get next element
+           String key = iterator.next();
+
+           // Does the key start with ContactManager.columnName ?
+           if (key.startsWith("ContactM,anager.columnName")) {
+               // This is the wanted entry.
+               this.getLogger().debug(MessageFormat.format("key={0}", key));
+
+               // So add it
+               this.columnNames.add(this.getBundle().getString(key));
+           }
+       }
+
+       // Debug message
+       this.getLogger().trace(MessageFormat.format("getColumnCount()={0}: EXIT!", this.getColumnCount()));
+    }
+
+    /**
+     * Flushes all entries by calling database backend
+     */
+    private void flush () {
+       // Flusgh all
+       this.getContactDatabase().flushAllContacts();
+    }
+
+    /**
+     * A ContactWrapper instance
+     *
+     * @return the database
+     */
+    private ContactWrapper getContactDatabase () {
+       return this.contactDatabase;
+    }
+
+    /**
+     * "Getter" for own contact instance or null if not found
+     *
+     * @return Contact instance or null
+     */
+    private Contact getOwnContact () {
+       // Now get it back from address book, first get an iterator
+       Iterator<Contact> iterator = this.contacts.iterator();
+
+       // Init instance
+       Contact contact = null;
+
+       // Search all contact
+       while (iterator.hasNext()) {
+           // Get next instance
+           Contact next = iterator.next();
+
+           // Is this own contact?
+           if (next.isOwnContact()) {
+               // Found it
+               contact = next;
+               break;
+               
+           }
+       }
+
+       // Return instance or null
+       return contact;
+    }
+
+    /**
+     * Checks whether given contact was found in "address book"
+     *
+     * @param checkContact Contact to be checked
+     * @return TRUE if found, FALSE if not found
+     */
+    private boolean isContactAlreadyAdded (final Contact checkContact) throws NullPointerException {
+       // Default is not found
+       boolean isFound = false;
+
+       // Debug message
+       //* NOISY-DEBUG: */ this.getLogger().debug("Checking '" +  this.contacts.length + "' entries...");
+
+       // Now get it back from address book, first get an iterator
+       Iterator<Contact> iterator = this.contacts.iterator();
+
+       // Check entries
+       while (iterator.hasNext()) {
+           // Get next entry
+           Contact contact = iterator.next();
+
+           // Debug message
+           //* NOISY-DEBUG: */ this.getLogger().debug("contact=" + contact + ",checkContent=" + checkContact);
+
+           // Is it valid?
+           if ((contact instanceof Contact) && ((contact.equals(checkContact)))) {
+               // Found matching entry
+               isFound = true;
+               break;
+           }
+       }
+
+       // Return result
+       return isFound;
+    }
+}
index 37f9c7cacbdaff13dcf07baa71c313a23b8ecb86..82dd838c42348a85b8c05f9492b978ce17dc6afb 100644 (file)
@@ -1,89 +1,89 @@
-/*\r
- * Copyright (C) 2015 Roland Haeder\r
- *\r
- * This program is free software: you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation, either version 3 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.\r
- */\r
-package org.mxchange.addressbook.menu.item.console;\r
-\r
-import org.mxchange.addressbook.client.Client;\r
-import org.mxchange.addressbook.menu.item.BaseMenuItem;\r
-import org.mxchange.addressbook.menu.item.SelectableMenuItem;\r
-\r
-/**\r
- *\r
- * @author Roland Haeder\r
- */\r
-public class ConsoleMenuItem extends BaseMenuItem implements SelectableMenuItem {\r
-    /**\r
-     * Access key\r
-     */\r
-    private char accessKey;\r
-\r
-    /**\r
-     * Text to user\r
-     */\r
-    private String text;\r
-\r
-    /**\r
-     * Constructor for building a console menu with access key and text\r
-     * \r
-     * @param accessKey Access key for this menu entry\r
-     * @param text Text to show to user\r
-     */\r
-    public ConsoleMenuItem (final char accessKey, final String text) {\r
-       this.accessKey = accessKey;\r
-       this.text = text;\r
-    }\r
-\r
-    /**\r
-     * Access key\r
-     * @return the accessKey\r
-     */\r
-    @Override\r
-    public char getAccessKey () {\r
-       return this.accessKey;\r
-    }\r
-\r
-    /**\r
-     * Access key\r
-     * @param accessKey the accessKey to set\r
-     */\r
-    private void setAccessKey (char accessKey) {\r
-       this.accessKey = accessKey;\r
-    }\r
-\r
-    /**\r
-     * Text to user\r
-     * @return the text\r
-     */\r
-    @Override\r
-    public String getText () {\r
-       return this.text;\r
-    }\r
-\r
-    /**\r
-     * Text to user\r
-     * @param text the text to set\r
-     */\r
-    private void setText (String text) {\r
-       this.text = text;\r
-    }\r
-\r
-    @Override\r
-    public void show (final Client client) {\r
-       // Call-back client over menu\r
-       client.showEntry(this);\r
-    }\r
-    \r
-}\r
+/*
+ * Copyright (C) 2015 Roland Haeder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.addressbook.menu.item.console;
+
+import org.mxchange.addressbook.client.Client;
+import org.mxchange.addressbook.menu.item.BaseMenuItem;
+import org.mxchange.addressbook.menu.item.SelectableMenuItem;
+
+/**
+ *
+ * @author Roland Haeder
+ */
+public class ConsoleMenuItem extends BaseMenuItem implements SelectableMenuItem {
+    /**
+     * Access key
+     */
+    private char accessKey;
+
+    /**
+     * Text to user
+     */
+    private String text;
+
+    /**
+     * Constructor for building a console menu with access key and text
+     * 
+     * @param accessKey Access key for this menu entry
+     * @param text Text to show to user
+     */
+    public ConsoleMenuItem (final char accessKey, final String text) {
+       this.accessKey = accessKey;
+       this.text = text;
+    }
+
+    /**
+     * Access key
+     * @return the accessKey
+     */
+    @Override
+    public final char getAccessKey () {
+       return this.accessKey;
+    }
+
+    /**
+     * Text to user
+     * @return the text
+     */
+    @Override
+    public String getText () {
+       return this.text;
+    }
+
+    @Override
+    public void show (final Client client) {
+       // Call-back client over menu
+       client.showEntry(this);
+    }
+
+    /**
+     * Text to user
+     * @param text the text to set
+     */
+    private void setText (String text) {
+       this.text = text;
+    }
+
+    /**
+     * Access key
+     * @param accessKey the accessKey to set
+     */
+    private void setAccessKey (char accessKey) {
+       this.accessKey = accessKey;
+    }
+    
+}