*/
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);
- }
}