X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=Addressbook%2Fsrc%2Forg%2Fmxchange%2Faddressbook%2Fclient%2FBaseClient.java;h=54d8bc32aad56c692a561fb867d766e523829b07;hb=ea30fd0dc674dcd10c3aead1acd47000a99d7334;hp=0c8bba50c4b12c8f373ca36acb97b7c9d74e22e5;hpb=2ad04803a6ef72f2ab29e655647b08a410e3bb58;p=addressbook-lib.git diff --git a/Addressbook/src/org/mxchange/addressbook/client/BaseClient.java b/Addressbook/src/org/mxchange/addressbook/client/BaseClient.java index 0c8bba5..54d8bc3 100644 --- a/Addressbook/src/org/mxchange/addressbook/client/BaseClient.java +++ b/Addressbook/src/org/mxchange/addressbook/client/BaseClient.java @@ -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 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 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 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 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); - } }