]> git.mxchange.org Git - jaddressbook-lib.git/blobdiff - Addressbook/src/org/mxchange/addressbook/client/BaseClient.java
Global commit: Changed spaces to tabs, because all Java files have tabs for indenting
[jaddressbook-lib.git] / Addressbook / src / org / mxchange / addressbook / client / BaseClient.java
index 0c8bba50c4b12c8f373ca36acb97b7c9d74e22e5..54d8bc32aad56c692a561fb867d766e523829b07 100644 (file)
@@ -30,151 +30,153 @@ import org.mxchange.addressbook.menu.Menu;
  */
 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);
+       /**
+        * 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);
        }
-       
-       // 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.");
+
+       /**
+        * 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);
        }
-       
-       // Show menu
-       menu.show((Client) this);
-    }
 }