X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2Forg%2Fmxchange%2Faddressbook%2Fclient%2Fconsole%2FConsoleClient.java;h=8452a4aa3dbbc35cda2413438042a37ce2f296d6;hb=f81c4418fe2cb0635f77f1a208875af887b2e985;hp=dd7eee810cd87df5556f12666d8791dd0fb293eb;hpb=166da67a6b9077b6df3e34892439adb0f8c6b91c;p=jfinancials-swing.git diff --git a/src/org/mxchange/addressbook/client/console/ConsoleClient.java b/src/org/mxchange/addressbook/client/console/ConsoleClient.java index dd7eee8..8452a4a 100644 --- a/src/org/mxchange/addressbook/client/console/ConsoleClient.java +++ b/src/org/mxchange/addressbook/client/console/ConsoleClient.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Roland Haeder + * Copyright (C) 2016 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 @@ -17,7 +17,6 @@ package org.mxchange.addressbook.client.console; import java.io.IOException; -import java.lang.reflect.InvocationTargetException; import java.sql.SQLException; import java.text.MessageFormat; import java.util.Arrays; @@ -25,26 +24,29 @@ import java.util.Scanner; import org.mxchange.addressbook.application.AddressbookApplication; import org.mxchange.addressbook.client.AddressbookClient; import org.mxchange.addressbook.client.BaseAddressbookClient; -import org.mxchange.addressbook.contact.user.UserContact; -import org.mxchange.addressbook.exceptions.ContactAlreadyAddedException; -import org.mxchange.addressbook.manager.contact.ManageableAddressbookContact; +import org.mxchange.addressbook.facade.contact.ContactFacade; import org.mxchange.addressbook.menu.Menu; import org.mxchange.addressbook.menu.MenuTools; import org.mxchange.addressbook.menu.console.ConsoleMenu; import org.mxchange.addressbook.menu.item.SelectableMenuItem; import org.mxchange.addressbook.menu.item.console.ConsoleMenuItem; +import org.mxchange.jcontacts.contact.Contact; +import org.mxchange.jcontacts.contact.UserContact; +import org.mxchange.jcontacts.contact.gender.Gender; +import org.mxchange.jcontacts.contact.gender.GenderUtils; +import org.mxchange.jcontacts.exceptions.ContactAlreadyAddedException; import org.mxchange.jcore.application.Application; -import org.mxchange.jcore.contact.Contact; -import org.mxchange.jcore.contact.gender.Gender; -import org.mxchange.jcore.exceptions.BadTokenException; -import org.mxchange.jcore.exceptions.CorruptedDatabaseFileException; +import org.mxchange.jcore.exceptions.MenuInitializationException; import org.mxchange.jcore.exceptions.UnhandledUserChoiceException; -import org.mxchange.jcore.exceptions.UnsupportedDatabaseBackendException; +import org.mxchange.jcountry.data.Country; +import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber; +import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber; +import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber; /** * A client for the console - * - * @author Roland Haeder + *

+ * @author Roland Haeder */ public class ConsoleClient extends BaseAddressbookClient implements AddressbookClient { @@ -55,12 +57,12 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC /** * Parameterless constructor - * + *

* @param application An instance of an Application class */ public ConsoleClient (final Application application) { // Trace message - this.getLogger().trace(MessageFormat.format("application={0} - CALLED!", application)); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("application={0} - CALLED!", application)); //NOI18N // Set application instance this.setApplication(application); @@ -69,18 +71,13 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC this.scanner = new Scanner(System.in, "UTF-8"); //NOI18N // Trace message - this.getLogger().trace("EXIT!"); //NOI18N + this.getLoggerBeanLocal().logTrace("EXIT!"); //NOI18N } - /** - * Displays a textual address "box" of given contact - * - * @param contact Contact to show address for - */ @Override public void displayAddressBox (final Contact contact) { // Trace message - this.getLogger().trace(MessageFormat.format("contact={0} - CALLED!", contact)); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("contact={0} - CALLED!", contact)); //NOI18N // Is it null? if (null == contact) { @@ -89,21 +86,16 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC } // Simple display ... - this.outputMessage(MessageFormat.format("Strasse, PLZ Ort, Land: {0}\n{1} {2}\n{3}", contact.getStreet(), contact.getZipCode(), contact.getCity(), contact.getCountryCode())); + this.outputMessage(MessageFormat.format("Strasse, PLZ Ort, Land: {0}\n{1} {2}\n{3}", contact.getContactStreet(), contact.getContactZipCode(), contact.getContactCity(), contact.getContactCountry())); // Trace message - this.getLogger().trace("EXIT!"); //NOI18N + this.getLoggerBeanLocal().logTrace("EXIT!"); //NOI18N } - /** - * Displays a textual name "box" of given contact - * - * @param contact Contact to show name for - */ @Override public void displayNameBox (final Contact contact) { // Trace message - this.getLogger().trace(MessageFormat.format("contact={0} - CALLED!", contact)); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("contact={0} - CALLED!", contact)); //NOI18N // Is it null? if (null == contact) { @@ -112,34 +104,19 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC } // Get translated gender as the user may want to see "Mr.", "Mrs." - String gender = contact.getTranslatedGender(); - - // Get company name - String companyName = contact.getCompanyName(); - - // If it is empty/null, then assume private contact - if ((null == companyName) || (companyName.isEmpty())) { - // Now put all together: gender, surname, family name - // TODO Use mask - this.outputMessage(MessageFormat.format("Anrede, Vorname, Name: {0} {1} {2}", gender, contact.getFirstName(), contact.getFamilyName())); - } else { - // Company contact - this.outputMessage(MessageFormat.format("Firma: {0}\nAnsprechpartner: {1} {2} {3}", companyName, gender, contact.getFirstName(), contact.getFamilyName())); - } + String gender = GenderUtils.getTranslatedGender(contact); + + // Now put all together: gender, surname, family name + this.outputMessage(MessageFormat.format("Anrede, Vorname, Name: {0} {1} {2}", gender, contact.getContactFirstName(), contact.getContactFamilyName())); // Trace message - this.getLogger().trace("EXIT!"); //NOI18N + this.getLoggerBeanLocal().logTrace("EXIT!"); //NOI18N } - /** - * Displays a textual other data "box" of given contact - * - * @param contact Contact to show other data for - */ @Override public void displayOtherDataBox (final Contact contact) { // Trace message - this.getLogger().trace(MessageFormat.format("contact={0} - CALLED!", contact)); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("contact={0} - CALLED!", contact)); //NOI18N // Is it null? if (null == contact) { @@ -148,16 +125,16 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC } // Cellphone and such ... - this.outputMessage(MessageFormat.format("Telefonnumer: {0}\nFaxnummer: {1}\nHandy: {2}\nKommentar:\n{3}", contact.getPhoneNumber(), contact.getFaxNumber(), contact.getCellphoneNumber(), contact.getComment())); + this.outputMessage(MessageFormat.format("Telefonnumer: {0}\nFaxnummer: {1}\nHandy: {2}\nKommentar:\n{3}", contact.getContactLandLineNumber(), contact.getContactFaxNumber(), contact.getContactMobileNumber(), contact.getContactComment())); // Trace message - this.getLogger().trace("EXIT!"); //NOI18N + this.getLoggerBeanLocal().logTrace("EXIT!"); //NOI18N } @Override public void doChangeOwnAddressData (final Contact contact) { // Trace message - this.getLogger().trace(MessageFormat.format("contact={0} - CALLED!", contact)); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("contact={0} - CALLED!", contact)); //NOI18N // Is it null? if (null == contact) { @@ -172,34 +149,34 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC } // Get manager and cast it - ManageableAddressbookContact manager = (ManageableAddressbookContact) this.getManager(); + ContactFacade manager = (ContactFacade) this.getFacade(); // Own street and number String streetNumber = manager.enterOwnStreet(); // Get zip code - Long zipCode = (long) manager.enterOwnZipCode(); + Integer zipCode = manager.enterOwnZipCode(); // Get city name String city = manager.enterOwnCity(); // Get country code - String countryCode = manager.enterOwnCountryCode(); + Country country = manager.enterOwnCountryCode(); // Update address data - contact.setStreet(streetNumber); - contact.setZipCode(zipCode); - contact.setCity(city); - contact.setCountryCode(countryCode); + contact.setContactStreet(streetNumber); + contact.setContactZipCode(zipCode); + contact.setContactCity(city); + contact.setContactCountry(country); // Trace message - this.getLogger().trace("EXIT!"); //NOI18N + this.getLoggerBeanLocal().logTrace("EXIT!"); //NOI18N } @Override public void doChangeOwnNameData (final Contact contact) { // Trace message - this.getLogger().trace(MessageFormat.format("contact={0} - CALLED!", contact)); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("contact={0} - CALLED!", contact)); //NOI18N // Is it null? if (null == contact) { @@ -214,7 +191,7 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC } // Get manager and cast it - ManageableAddressbookContact manager = (ManageableAddressbookContact) this.getManager(); + ContactFacade manager = (ContactFacade) this.getFacade(); // Gender: Gender gender = manager.enterOwnGender(); @@ -225,23 +202,19 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC // Family name String familyName = manager.enterOwnFamilyName(); - // And company - String companyName = manager.enterOwnCompanyName(); - // Update contact instance - contact.setGender(gender); - contact.setFirstName(firstName); - contact.setFamilyName(familyName); - contact.setCompanyName(companyName); + contact.setContactGender(gender); + contact.setContactFirstName(firstName); + contact.setContactFamilyName(familyName); // Trace message - this.getLogger().trace("EXIT!"); //NOI18N + this.getLoggerBeanLocal().logTrace("EXIT!"); //NOI18N } @Override public void doChangeOwnOtherData (final Contact contact) { // Trace message - this.getLogger().trace(MessageFormat.format("contact={0} - CALLED!", contact)); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("contact={0} - CALLED!", contact)); //NOI18N // Is it null? if (null == contact) { @@ -256,16 +229,16 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC } // Get manager and cast it - ManageableAddressbookContact manager = (ManageableAddressbookContact) this.getManager(); + ContactFacade manager = (ContactFacade) this.getFacade(); // Phone number - String phoneNumber = manager.enterOwnPhoneNumber(); + DialableLandLineNumber phoneNumber = manager.enterOwnPhoneNumber(); // Phone number - String cellphonePhoneNumber = manager.enterOwnCellNumber(); + DialableMobileNumber cellphonePhoneNumber = manager.enterOwnCellNumber(); // Fax number - String faxNumber = manager.enterOwnFaxNumber(); + DialableFaxNumber faxNumber = manager.enterOwnFaxNumber(); // Email address String email = manager.enterOwnEmailAddress(); @@ -274,67 +247,60 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC String comment = manager.enterOwnComment(); // Update contact instance - contact.setPhoneNumber(phoneNumber); - contact.setCellphoneNumber(cellphonePhoneNumber); - contact.setFaxNumber(faxNumber); - contact.setEmailAddress(email); - contact.setComment(comment); + contact.setContactLandLineNumber(phoneNumber); + contact.setContactCellphoneNumber(cellphonePhoneNumber); + contact.setContactFaxNumber(faxNumber); + contact.setContactEmailAddress(email); + contact.setContactComment(comment); // Trace message - this.getLogger().trace("EXIT!"); //NOI18N + this.getLoggerBeanLocal().logTrace("EXIT!"); //NOI18N } @Override public Contact doEnterOwnData () { // Trace message - this.getLogger().trace("CALLED!"); //NOI18N + this.getLoggerBeanLocal().logTrace("CALLED!"); //NOI18N // Get manager and cast it - ManageableAddressbookContact manager = (ManageableAddressbookContact) this.getManager(); + ContactFacade manager = (ContactFacade) this.getFacade(); // First ask for gender Gender gender = manager.enterOwnGender(); - // 2nd for surname - String surname = manager.enterOwnFirstName(); + // 2nd for first name + String firstName = manager.enterOwnFirstName(); // And 3rd for family name String familyName = manager.enterOwnFamilyName(); - // Company name ... - String companyName = manager.enterOwnCompanyName(); - // Construct UserContact instance - Contact contact = new UserContact(gender, surname, familyName, companyName); + Contact contact = new UserContact(gender, firstName, familyName); // Trace message - this.getLogger().trace(MessageFormat.format("contact={0} - EXIT!", contact)); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("contact={0} - EXIT!", contact)); //NOI18N // And return object return contact; } - /** - * Shutdown this client - */ @Override public void doShutdown () throws SQLException, IOException { // Trace message - this.getLogger().trace("CALLED!"); //NOI18N + this.getLoggerBeanLocal().logTrace("CALLED!"); //NOI18N // Parent call super.doShutdown(); // TODO Add other shutdown stuff - // Trace message - this.getLogger().trace("EXIT!"); //NOI18N + this.getLoggerBeanLocal().logTrace("EXIT!"); //NOI18N } @Override - public void doUserMenuChoice () throws UnhandledUserChoiceException { + public void doUserMenuChoice () throws UnhandledUserChoiceException, MenuInitializationException { // Trace message - this.getLogger().trace("CALLED!"); //NOI18N + this.getLoggerBeanLocal().logTrace("CALLED!"); //NOI18N // Get all access keys from menu char[] accessKeys = MenuTools.getAccessKeysFromMenuMap(this.getMenus(), this.getCurrentMenu()); @@ -343,45 +309,43 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC char choice = this.enterChar(accessKeys, "Bitte Auswahl eingeben (0=Programm beenden): "); // Get manager and cast it - ManageableAddressbookContact manager = (ManageableAddressbookContact) this.getManager(); + ContactFacade manager = (ContactFacade) this.getFacade(); - // Try it! - try { - // TODO Rewrite this ugly switch() block - switch (choice) { - case '1': - try { - // Enter/add own data - manager.doEnterOwnData(); - } catch (final ContactAlreadyAddedException ex) { - // Already added - this.outputMessage("Sie haben bereits Ihre eigenen Daten eingegeben."); - } - break; - - case '2': // Change own data - manager.doChangeOwnData(); - break; - - case '3': // Add new addess - manager.doAddOtherAddress(); - break; - - case '4': // List contacts - manager.doListContacts(); - break; - - case '5': // Search addresses - manager.doSearchContacts(); - break; - - case '6': // Change other addess - manager.doChangeOtherAddress(); - break; - - case '7': // Delete other address - manager.doDeleteOtherAddress(); - break; + // TODO Rewrite this ugly switch() block + switch (choice) { + case '1': + try { + // Enter/add own data + manager.doEnterOwnData(); + } catch (final ContactAlreadyAddedException ex) { + // Already added + this.outputMessage("Sie haben bereits Ihre eigenen Daten eingegeben."); + } + break; + + case '2': // Change own data + manager.doChangeOwnData(); + break; + + case '3': // Add new addess + manager.doAddOtherAddress(); + break; + + case '4': // List contacts + manager.doListContacts(); + break; + + case '5': // Search addresses + manager.doSearchContacts(); + break; + + case '6': // Change other addess + manager.doChangeOtherAddress(); + break; + + case '7': // Delete other address + manager.doDeleteOtherAddress(); + break; case '0': try { @@ -392,30 +356,20 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC } break; - default: - // TODO throw own exception - throw new UnhandledUserChoiceException(MessageFormat.format("Choice '{0}' not handled yet.", choice)); //NOI18N - } - } catch (final IOException | BadTokenException | CorruptedDatabaseFileException | SQLException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) { - // Something bad happened - this.abortProgramWithException(ex); + default: + // TODO throw own exception + throw new UnhandledUserChoiceException(MessageFormat.format("Choice '{0}' not handled yet.", choice)); //NOI18N } // Trace message - this.getLogger().trace("EXIT!"); //NOI18N + this.getLoggerBeanLocal().logTrace("EXIT!"); //NOI18N } - /** - * Asks the the user to enter a single character which must match validChars - * - * @param validChars Valid chars that are accepted - * @param message Message to user - * @return Allowed character - */ @Override + @SuppressWarnings ("UseOfSystemOutOrSystemErr") public char enterChar (final char[] validChars, final String message) { // Trace message - this.getLogger().trace(MessageFormat.format("validChars={0},message={1} - CALLED!", Arrays.toString(validChars), message)); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("validChars={0},message={1} - CALLED!", Arrays.toString(validChars), message)); //NOI18N // The validChars must not null be null and filled with at least one char if (null == validChars) { @@ -441,28 +395,23 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC } // Trace message - this.getLogger().trace(MessageFormat.format("input={0} - EXIT!", input)); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("input={0} - EXIT!", input)); //NOI18N // Return read char return input; } - /** - * Asks the user to enter his/her gender - * - * @param message Message to the user - * @return Gender enum - */ @Override public Gender enterGender (final String message) { // Trace message - this.getLogger().trace(MessageFormat.format("message={0} - CALLED!", message)); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("message={0} - CALLED!", message)); //NOI18N // Get valid chars char[] validChars = Gender.validChars(); // Debug message //* NOISY-DEBUG: */ System.out.println(validChars); + // Call inner method char gender = this.enterChar(validChars, message); @@ -470,31 +419,24 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC Gender g = Gender.fromChar(gender); // g must not be null - assert(g instanceof Gender) : "g is not set."; //NOI18N + assert (g instanceof Gender) : "g is not set."; //NOI18N // Trace message - this.getLogger().trace(MessageFormat.format("g={0} - EXIT!", g)); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("g={0} - EXIT!", g)); //NOI18N // Return it return g; } - /** - * Reads an integer (int) with a textural message from the user - * - * @param minimum Minimum allowed number - * @param maximum Maximum allowed number - * @param message Messager to display in console - * @return - */ @Override + @SuppressWarnings ("UseOfSystemOutOrSystemErr") public int enterInt (final int minimum, final int maximum, final String message) { // Trace message - this.getLogger().trace(MessageFormat.format("minimum={0},maximum={1},message={2} - CALLED!", minimum, maximum, message)); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("minimum={0},maximum={1},message={2} - CALLED!", minimum, maximum, message)); //NOI18N // Minimum should not be below zero - assert (minimum >= 0); - assert (maximum > minimum); + assert (minimum >= 0) : MessageFormat.format("minimum={0} is below zero", minimum); //NOI18N + assert (maximum > minimum) : MessageFormat.format("maximum {0} is smaller than minimum {1}", maximum, minimum); //NOI18N // Init input int input = -1; @@ -508,25 +450,17 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC } // Trace message - this.getLogger().trace(MessageFormat.format("input={0} - EXIT!", input)); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("input={0} - EXIT!", input)); //NOI18N // Return it return input; } - /** - * Reads a string of minimum and maximum length from the user - * - * @param minLength Minimum length of the string to read - * @param maxLength Maximum length of the string to read - * @param message Message to user - * @param allowEmpty Whether to allow empty string - * @return Entered string by user or null for empty strings - */ @Override + @SuppressWarnings ("UseOfSystemOutOrSystemErr") public String enterString (final int minLength, final int maxLength, final String message, final boolean allowEmpty) { // Trace message - this.getLogger().trace(MessageFormat.format("minLength={0},maxLength={1},message={2}allowEmpty={3} - CALLED!", minLength, maxLength, message, allowEmpty)); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("minLength={0},maxLength={1},message={2}allowEmpty={3} - CALLED!", minLength, maxLength, message, allowEmpty)); //NOI18N // Check on length, e.g. country codes are excactly 2 chars long assert (maxLength >= minLength); @@ -544,38 +478,27 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC } // Trace message - this.getLogger().trace(MessageFormat.format("input={0} - EXIT!", input)); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("input={0} - EXIT!", input)); //NOI18N // Return it return input; } - /** - * Returns a console menu item - * - * @param accessKey Key to access the menu - * @param text Text to show to user - * @return A SelectableMenuItem - * TODO Make sure the access key is unique - */ @Override public SelectableMenuItem getMenuItem (final char accessKey, final String text) { // Return a new console menu item return new ConsoleMenuItem(accessKey, text); } - /** - * Initializes this client - */ @Override public void init () { // Trace message - this.getLogger().trace("CALLED!"); //NOI18N + this.getLoggerBeanLocal().logTrace("CALLED!"); //NOI18N // Init contact manager here try { this.initContactManager(); - } catch (final UnsupportedDatabaseBackendException | SQLException ex) { + } catch (final SQLException ex) { // End here this.abortProgramWithException(ex); } @@ -584,55 +507,45 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC this.fillMenuMap(); // Trace message - this.getLogger().trace("EXIT!"); //NOI18N + this.getLoggerBeanLocal().logTrace("EXIT!"); //NOI18N } - /** - * Displays textural message to the user - * - * @param message - */ @Override + @SuppressWarnings ("UseOfSystemOutOrSystemErr") public void outputMessage (final String message) { System.out.println(message); } - /** - * Shows textural menu on console - */ + @Override + public void show (final Contact contact) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + @Override public void showCurrentMenu () { this.showMenu(this.getCurrentMenu()); } - /** - * Shows given menu entry to user - * - * @param item Menu entry - */ @Override public void showEntry (final SelectableMenuItem item) { // Access key then text - this.outputMessage(MessageFormat.format("[{0}] {1}", item.getAccessKey(), item.getText())); + this.outputMessage(MessageFormat.format("[{0}] {1}", item.getAccessKey(), item.getText())); //NOI18N } - /** - * Shows a textural message to the user - */ @Override public void showWelcome () { - this.outputMessage(MessageFormat.format("Welcome to {0}", AddressbookApplication.printableTitle())); - this.outputMessage(""); - this.outputMessage("Copyright(c) 2015 by Roland Haeder, this is free software"); + this.outputMessage(MessageFormat.format("Welcome to {0}", AddressbookApplication.printableTitle())); //NOI18N + this.outputMessage(""); //NOI18N + this.outputMessage("Copyright(c) 2016 by Roland Haeder, this is free software"); //NOI18N // Debug message - this.getLogger().debug("Intro shown to user"); //NOI18N + this.getLoggerBeanLocal().logDebug("Intro shown to user"); //NOI18N } @Override public void userChooseChangeContactData (final Contact contact) throws UnhandledUserChoiceException { // Trace message - this.getLogger().trace(MessageFormat.format("contact={0} CALLED!", contact)); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("contact={0} CALLED!", contact)); //NOI18N // Contact must not be null if (null == contact) { @@ -641,10 +554,10 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC } // Ask the user for editing [name], [a]ddress or [other] data - char choice = this.enterChar(new char[] {'n', 'a', 'o', 'x'}, "Welchen Daten möchten Sie ändern? (n=Namensdaten, a=Anschriftsdaten, o=Andere, x=Zurück zur Hauptauswahl) "); + char choice = this.enterChar(new char[]{'n', 'a', 'o', 'x'}, "Welchen Daten möchten Sie ändern? (n=Namensdaten, a=Anschriftsdaten, o=Andere, x=Zurück zur Hauptauswahl) "); // Get manager and cast it - ManageableAddressbookContact manager = (ManageableAddressbookContact) this.getManager(); + ContactFacade manager = (ContactFacade) this.getFacade(); // TODO Get rid of this ugly switch block, too switch (choice) { @@ -670,12 +583,12 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC } // Trace message - this.getLogger().trace("EXIT!"); //NOI18N + this.getLoggerBeanLocal().logTrace("EXIT!"); //NOI18N } /** * Reads one character - * + *

* @return A single character */ private char readChar () { @@ -683,7 +596,7 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC String input = this.readString(); // Debug message - this.getLogger().debug(MessageFormat.format("input={0}", input)); //NOI18N + this.getLoggerBeanLocal().logDebug(MessageFormat.format("input={0}", input)); //NOI18N // This must be only one character if (input.length() != 1) { @@ -697,7 +610,7 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC /** * Reads an integer (int) from user - * + *

* @return An integer number */ private int readInt () { @@ -705,7 +618,7 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC String input = this.readString(); // Debug message - this.getLogger().debug(MessageFormat.format("input={0}", input)); //NOI18N + this.getLoggerBeanLocal().logDebug(MessageFormat.format("input={0}", input)); //NOI18N // Init number with invalid value int num = -1; @@ -715,11 +628,11 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC num = Integer.parseInt(input); } catch (final NumberFormatException e) { this.outputMessage("Bitte geben Sie nur Zahlen ein!"); - this.getLogger().warn(MessageFormat.format("No numbers-only entered. input={0},message={1}", input, e.getMessage())); //NOI18N + this.getLoggerBeanLocal().logWarning(MessageFormat.format("No numbers-only entered. input={0},message={1}", input, e.getMessage())); //NOI18N } // Trace message - this.getLogger().trace(MessageFormat.format("num={0} - EXIT!", num)); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("num={0} - EXIT!", num)); //NOI18N // Return read number return num; @@ -727,20 +640,17 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC /** * Reads a string from a scanner until RETURN is pressed - * + *

* @return Read string from scanner */ private String readString () { return this.scanner.nextLine(); } - /** - * Fills menu map with menu entries - */ @Override - protected final void fillMenuMap () { + protected void fillMenuMap () { // Trace message - this.getLogger().trace("CALLED!"); //NOI18N + this.getLoggerBeanLocal().logTrace("CALLED!"); //NOI18N // Initialize first (main) menu Menu menu = new ConsoleMenu("main", this); //NOI18N @@ -749,6 +659,6 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC this.getMenus().put("main", menu); //NOI18N // Trace message - this.getLogger().trace("EXIT!"); //NOI18N + this.getLoggerBeanLocal().logTrace("EXIT!"); //NOI18N } }