]> git.mxchange.org Git - jaddressbook-share-lib.git/commitdiff
Prepared for upcoming rewrite:
authorRoland Haeder <roland@mxchange.org>
Tue, 29 Sep 2015 13:34:54 +0000 (15:34 +0200)
committerRoland Haeder <roland@mxchange.org>
Tue, 29 Sep 2015 13:35:47 +0000 (15:35 +0200)
- added BaseAddressbookSystem class
- rewrote all logger to bean (why not working?)
- added JPA jar
Signed-off-by:Roland Häder <roland@mxchange.org>

19 files changed:
lib/jcore-logger-lib.jar
lib/jcore.jar
lib/jpa20-persistence/javax.persistence_2.1.0.v201304241213.jar [new file with mode: 0644]
lib/nblibraries.properties
nbproject/project.properties
src/org/mxchange/addressbook/BaseAddressbookSystem.java [new file with mode: 0644]
src/org/mxchange/addressbook/application/AddressbookApplication.java
src/org/mxchange/addressbook/client/BaseAddressbookClient.java
src/org/mxchange/addressbook/client/console/ConsoleClient.java
src/org/mxchange/addressbook/client/gui/AddressbookFrame.java
src/org/mxchange/addressbook/client/gui/SwingClient.java
src/org/mxchange/addressbook/manager/contact/AddressbookContactManager.java
src/org/mxchange/addressbook/menu/AddressbookMenu.java
src/org/mxchange/addressbook/menu/BaseMenu.java
src/org/mxchange/addressbook/menu/MenuTools.java
src/org/mxchange/addressbook/menu/console/ConsoleMenu.java
src/org/mxchange/addressbook/menu/item/BaseMenuItem.java
src/org/mxchange/addressbook/menu/item/SelectableMenuItem.java
src/org/mxchange/addressbook/menu/item/console/ConsoleMenuItem.java

index b95c18db6f3712483bd0000ec47c50b8ac227757..4dedcc6562e8bf1dbf9740143bd86ec1b273ee67 100644 (file)
Binary files a/lib/jcore-logger-lib.jar and b/lib/jcore-logger-lib.jar differ
index bff5c73b4f02f01a1d004c465d1c99a0d024e32c..2179b37e40284525a5cb25cce157f22bfc9b782e 100644 (file)
Binary files a/lib/jcore.jar and b/lib/jcore.jar differ
diff --git a/lib/jpa20-persistence/javax.persistence_2.1.0.v201304241213.jar b/lib/jpa20-persistence/javax.persistence_2.1.0.v201304241213.jar
new file mode 100644 (file)
index 0000000..841d2e1
Binary files /dev/null and b/lib/jpa20-persistence/javax.persistence_2.1.0.v201304241213.jar differ
index 6d0afb59d64978f1c42b37eda93de4d6acaa674c..7ee54123c81e4a4dddbf24b8bfb3425facc2f1e2 100644 (file)
@@ -2,3 +2,9 @@ libs.CopyLibs.classpath=\
     ${base}/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar
 libs.CopyLibs.displayName=CopyLibs Task
 libs.CopyLibs.prop-version=2.0
+libs.jpa20-persistence.classpath=\
+    ${base}/jpa20-persistence/javax.persistence_2.1.0.v201304241213.jar
+libs.jpa20-persistence.displayName=Persistence (JPA 2.1)
+libs.jpa20-persistence.javadoc=\
+    ${base}/jpa20-persistence/javax.persistence-2.1.0-doc.zip
+libs.jpa20-persistence.prop-maven-dependencies=org.eclipse.persistence:javax.persistence:2.1.0:jar
index c71ca3e08ea729289125bd2da5b54325325ea1dc..fb1861638b0b299308b217403b63095040056eed 100644 (file)
@@ -40,7 +40,8 @@ jar.index=${jnlp.enabled}
 javac.classpath=\
     ${file.reference.jcore.jar}:\
     ${file.reference.jcore-swing.jar}:\
-    ${file.reference.jcore-logger-lib.jar}
+    ${file.reference.jcore-logger-lib.jar}:\
+    ${libs.jpa20-persistence.classpath}
 # Space-separated list of extra javac options
 javac.compilerargs=-Xlint:deprecation -Xlint:unchecked
 javac.deprecation=true
diff --git a/src/org/mxchange/addressbook/BaseAddressbookSystem.java b/src/org/mxchange/addressbook/BaseAddressbookSystem.java
new file mode 100644 (file)
index 0000000..90674c7
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+ * 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;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import org.mxchange.jcore.BaseFrameworkSystem;
+import org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal;
+
+/**
+ * A general addressbook class
+ *
+ * @author Roland Haeder
+ */
+public abstract class BaseAddressbookSystem extends BaseFrameworkSystem {
+
+       /**
+        * Logger instance
+        */
+       private LoggerBeanLocal logger;
+
+       /**
+        * Protected constructor
+        */
+       protected BaseAddressbookSystem () {
+               try {
+                       // Get initial context
+                       Context context = new InitialContext();
+                       
+                       // Lookup logger
+                       this.logger = (LoggerBeanLocal) context.lookup("java:global/jcore-logger-ejb/logger!org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal");
+               } catch (final NamingException ex) {
+                       // Continue to throw
+                       throw new RuntimeException(ex);
+               }
+       }
+
+       /**
+        * Getter for logger instance
+        *
+        * @return Logger instance
+        */
+       protected LoggerBeanLocal getLogger () {
+               return this.logger;
+       }
+
+       /**
+        * Logs given exception
+        *
+        * @param exception Throwable
+        */
+       protected void logException (final Throwable exception) {
+               throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+       }
+
+       /**
+        * Log exception and abort program.
+        *
+        * @param throwable Throwable
+        */
+       protected void abortProgramWithException (final Throwable throwable) {
+               // Log exception
+               this.logException(throwable);
+
+               // Abort here
+               System.exit(1);
+       }
+}
index dca6fe202e2dc7e9892f2a158a474f8ef4e5e7e5..2859e5ca11c5feb02c19190c9f8b5b78c32c4be7 100644 (file)
@@ -22,12 +22,12 @@ import java.text.MessageFormat;
 import org.mxchange.addressbook.client.AddressbookClient;
 import org.mxchange.addressbook.client.console.ConsoleClient;
 import org.mxchange.addressbook.client.gui.SwingClient;
-import org.mxchange.jcore.BaseFrameworkSystem;
 import org.mxchange.jcore.application.Application;
 import org.mxchange.jcore.application.BaseApplication;
 import org.mxchange.jcore.client.Client;
 import org.mxchange.jcore.exceptions.UnhandledUserChoiceException;
 import org.mxchange.jcore.manager.application.ApplicationManager;
+import org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal;
 
 /**
  * Address book application class. Please see ROADMAP.txt for details.
@@ -57,12 +57,15 @@ public class AddressbookApplication extends BaseApplication implements Applicati
         */
        private boolean guiClient = false;
 
+       /**
+        * Logger instance
+        */
+       private LoggerBeanLocal logger;
+
        /**
         * Protected constructor
-        * <p>
-        * @throws java.io.IOException If any IO error occurs
         */
-       protected AddressbookApplication () throws IOException {
+       protected AddressbookApplication () {
                // Init properties file
                this.initProperties();
 
@@ -79,7 +82,7 @@ public class AddressbookApplication extends BaseApplication implements Applicati
         */
        @Override
        public void doBootstrap () {
-               this.getLogger().debug("Initializing application ..."); //NOI18N
+               this.getLogger().logDebug("Initializing application ..."); //NOI18N
 
                // Init client variable
                Client client = null;
@@ -87,19 +90,19 @@ public class AddressbookApplication extends BaseApplication implements Applicati
                // Is console or Swing choosen?
                if (this.isConsole()) {
                        // Debug message
-                       this.getLogger().debug("Initializing console client ..."); //NOI18N
+                       this.getLogger().logDebug("Initializing console client ..."); //NOI18N
 
                        // Init console client instance
                        client = new ConsoleClient(this);
                } else if (this.isGui()) {
                        // Debug message
-                       this.getLogger().debug("Initializing GUI (Swing) client ..."); //NOI18N
+                       this.getLogger().logDebug("Initializing GUI (Swing) client ..."); //NOI18N
 
                        // Init console instance
                        client = new SwingClient(this);
                } else {
                        // Not client choosen
-                       this.getLogger().error("No client choosen. Cannot launch."); //NOI18N
+                       this.getLogger().logError("No client choosen. Cannot launch."); //NOI18N
 
                        try {
                                this.doShutdown();
@@ -122,7 +125,7 @@ public class AddressbookApplication extends BaseApplication implements Applicati
                this.getClient().enableIsRunning();
 
                // Trace message
-               this.getLogger().trace("EXIT!"); //NOI18N
+               this.getLogger().logTrace("EXIT!"); //NOI18N
        }
 
        /**
@@ -134,7 +137,7 @@ public class AddressbookApplication extends BaseApplication implements Applicati
                AddressbookClient client = (AddressbookClient) this.getClient();
 
                // Debug message
-               this.getLogger().trace("CALLED!"); //NOI18N
+               this.getLogger().logTrace("CALLED!"); //NOI18N
 
                // TODO The application should be running now
                // Output introduction
@@ -152,7 +155,7 @@ public class AddressbookApplication extends BaseApplication implements Applicati
                                // Ask for user input and run proper method
                                client.doUserMenuChoice();
                        } catch (final UnhandledUserChoiceException ex) {
-                               this.getLogger().catching(ex);
+                               this.getLogger().logException(ex);
                        }
 
                        try {
@@ -165,7 +168,7 @@ public class AddressbookApplication extends BaseApplication implements Applicati
                // --- Main loop ends here ---
 
                // Debug message
-               this.getLogger().debug("Main loop exit - shutting down ..."); //NOI18N
+               this.getLogger().logDebug("Main loop exit - shutting down ..."); //NOI18N
        }
 
        /**
@@ -174,20 +177,49 @@ public class AddressbookApplication extends BaseApplication implements Applicati
        @Override
        public void doShutdown () throws SQLException, IOException {
                // Trace message
-               this.getLogger().trace("CALLED!"); //NOI18N
+               this.getLogger().logTrace("CALLED!"); //NOI18N
 
                // Shutdown client
                this.getClient().doShutdown();
 
-               this.getLogger().info("End of program (last line)"); //NOI18N
+               this.getLogger().logInfo("End of program (last line)"); //NOI18N
                System.exit(0);
        }
 
+       /**
+        * Logs given exception
+        *
+        * @param exception Throwable
+        */
+       protected void logException (final Throwable exception) {
+               this.getLogger().logException(exception);
+       }
+
+       /**
+        * Initializes properties
+        */
+       private void initProperties () throws IOException {
+               throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+       }
+
+       /**
+        * Log exception and abort program.
+        *
+        * @param throwable Throwable
+        */
+       protected void abortProgramWithException (final Throwable throwable) {
+               // Log exception
+               this.logException(throwable);
+
+               // Abort here
+               System.exit(1);
+       }
+
        /**
         * Enables console client by setting propper flag
         */
        private void enableConsoleClient () {
-               this.getLogger().debug("Enabling console client (may become optional client) ..."); //NOI18N
+               this.getLogger().logDebug("Enabling console client (may become optional client) ..."); //NOI18N
                this.consoleClient = true;
                this.guiClient = false;
        }
@@ -196,7 +228,7 @@ public class AddressbookApplication extends BaseApplication implements Applicati
         * Enables GUI client by setting propper flag
         */
        private void enableGuiClient () {
-               this.getLogger().debug("Enabling GUI client (may become new default client) ..."); //NOI18N
+               this.getLogger().logDebug("Enabling GUI client (may become new default client) ..."); //NOI18N
                this.consoleClient = false;
                this.guiClient = true;
        }
@@ -228,10 +260,10 @@ public class AddressbookApplication extends BaseApplication implements Applicati
         */
        private void parseArguments (final String[] args) {
                // Trace message
-               this.getLogger().trace(MessageFormat.format("args()={0} - CALLED!", args.length)); //NOI18N
+               this.getLogger().logTrace(MessageFormat.format("args()={0} - CALLED!", args.length)); //NOI18N
 
                // Debug message
-               this.getLogger().debug(MessageFormat.format("Parsing {0} arguments ...", args.length)); //NOI18N
+               this.getLogger().logDebug(MessageFormat.format("Parsing {0} arguments ...", args.length)); //NOI18N
 
                for (final String arg : args) {
                        // Switch on it
@@ -252,13 +284,13 @@ public class AddressbookApplication extends BaseApplication implements Applicati
         */
        private void showIntro () {
                // Trace message
-               this.getLogger().trace("CALLED!"); //NOI18N
+               this.getLogger().logTrace("CALLED!"); //NOI18N
 
                // Let the client show it
                this.getClient().showWelcome();
 
                // Trace message
-               this.getLogger().trace("EXIT!"); //NOI18N
+               this.getLogger().logTrace("EXIT!"); //NOI18N
        }
 
        /**
@@ -267,7 +299,8 @@ public class AddressbookApplication extends BaseApplication implements Applicati
         * @param args Arguments handled to program
         */
        private void start (final String args[]) {
-               this.getLogger().info("Program is started."); //NOI18N
+               this.getLogger().logInfo("Program is started."); //NOI18N
+
                try {
                        // Init properties file
                        this.initProperties();
@@ -283,10 +316,12 @@ public class AddressbookApplication extends BaseApplication implements Applicati
                ApplicationManager.getSingeltonManager(this).start();
 
                // Good bye, but this should not be reached ...
-               this.getLogger().warn("Unusual exit reached."); //NOI18N
+               this.getLogger().logWarning("Unusual exit reached."); //NOI18N
+
                try {
                        this.doShutdown();
                } catch (final SQLException | IOException ex) {
+                       // Something bad happened
                        this.abortProgramWithException(ex);
                }
        }
@@ -297,14 +332,8 @@ public class AddressbookApplication extends BaseApplication implements Applicati
         * @param args the command line arguments
         */
        public static void main (String[] args) {
-               try {
-                       // Start application
-                       new AddressbookApplication().start(args);
-               } catch (final IOException ex) {
-                       // Get instance
-                       BaseFrameworkSystem.getInstance().getLogger().catching(ex);
-                       System.exit(1);
-               }
+               // Start application
+               new AddressbookApplication().start(args);
        }
 
        /**
@@ -315,4 +344,13 @@ public class AddressbookApplication extends BaseApplication implements Applicati
        public static String printableTitle () {
                return MessageFormat.format("{0} v{1}", APP_TITLE, APP_VERSION); //NOI18N
        }
+
+       /**
+        * Getter for logger instance
+        *
+        * @return Logger instance
+        */
+       protected LoggerBeanLocal getLogger () {
+               return this.logger;
+       }
 }
index 4b42d53d5a3dcd05b0bfce153340db06fe077e65..094d0ecee9a485b2d3369cbbb86dfc1658b0a0fd 100644 (file)
@@ -20,11 +20,15 @@ import java.sql.SQLException;
 import java.text.MessageFormat;
 import java.util.HashMap;
 import java.util.Map;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
 import org.mxchange.addressbook.manager.contact.AddressbookContactManager;
 import org.mxchange.addressbook.manager.contact.ManageableContactAddressbook;
 import org.mxchange.addressbook.menu.Menu;
 import org.mxchange.jcore.client.BaseClient;
 import org.mxchange.jcore.client.Client;
+import org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal;
 
 /**
  * A general addressbook client
@@ -43,12 +47,29 @@ public abstract class BaseAddressbookClient extends BaseClient implements Addres
         */
        private final Map<String, Menu> menus;
 
+       /**
+        * Logger instance
+        */
+       private LoggerBeanLocal logger;
+
        /**
         * No instances can be created of this class
         */
        protected BaseAddressbookClient () {
                // Init menu map
                this.menus = new HashMap<>(10);
+
+               // Try it
+               try {
+                       // Get context
+                       Context context = new InitialContext();
+
+                       // Lookup logger
+                       this.logger = (LoggerBeanLocal) context.lookup("java:global/jcore-logger-ejb/logger!org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal");
+               } catch (final NamingException ex) {
+                       // Continue to throw
+                       throw new RuntimeException(ex);
+               }
        }
 
        /**
@@ -106,10 +127,10 @@ public abstract class BaseAddressbookClient extends BaseClient implements Addres
         */
        protected void initContactManager () throws SQLException {
                // Trace message
-               this.getLogger().trace("CALLED!"); //NOI18N
+               this.getLogger().logTrace("CALLED!"); //NOI18N
 
                // Debug message
-               this.getLogger().debug("Initializing contact manager ..."); //NOI18N
+               this.getLogger().logDebug("Initializing contact manager ..."); //NOI18N
 
                // Init contact manager with console client
                // TODO Static initial amount of contacts
@@ -119,10 +140,10 @@ public abstract class BaseAddressbookClient extends BaseClient implements Addres
                this.setManager(manager);
 
                // Debug message
-               this.getLogger().debug("Contact manager has been initialized."); //NOI18N
+               this.getLogger().logDebug("Contact manager has been initialized."); //NOI18N
 
                // Trace message
-               this.getLogger().trace("EXIT!"); //NOI18N
+               this.getLogger().logTrace("EXIT!"); //NOI18N
        }
 
        /**
@@ -132,7 +153,7 @@ public abstract class BaseAddressbookClient extends BaseClient implements Addres
         */
        protected void showMenu (final String menuType) {
                // Trace message
-               this.getLogger().trace(MessageFormat.format("menuType={0} - CALLED!", menuType)); //NOI18N
+               this.getLogger().logTrace(MessageFormat.format("menuType={0} - CALLED!", menuType)); //NOI18N
 
                // Get menu from type
                Menu menu = this.getMenu(menuType);
@@ -148,6 +169,38 @@ public abstract class BaseAddressbookClient extends BaseClient implements Addres
                menu.show(this);
 
                // Trace message
-               this.getLogger().trace("EXIT!"); //NOI18N
+               this.getLogger().logTrace("EXIT!"); //NOI18N
+       }
+
+       /**
+        * Getter for logger instance
+        *
+        * @return Logger instance
+        */
+       protected LoggerBeanLocal getLogger () {
+               return this.logger;
+       }
+
+       /**
+        * Logs an exception
+        *
+        * @param throwable Throwable
+        */
+       protected void logException (final Throwable throwable) {
+               // Deligate to logger
+               this.getLogger().logException(throwable);
+       }
+
+       /**
+        * Logs exception and exits program
+        *
+        * @param throwable Throwable
+        */
+       protected void abortProgramWithException (final Throwable throwable) {
+               // Log exception
+               this.logException(throwable);
+
+               // Abort here
+               System.exit(1);
        }
 }
index 408ebf0107a5bb45ed9fc5f3787c64ab81f5757e..5deface1b526c4c01d336563c8f9adfc89f16f01 100644 (file)
@@ -58,7 +58,7 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC
         */
        public ConsoleClient (final Application application) {
                // Trace message
-               this.getLogger().trace(MessageFormat.format("application={0} - CALLED!", application)); //NOI18N
+               this.getLogger().logTrace(MessageFormat.format("application={0} - CALLED!", application)); //NOI18N
 
                // Set application instance
                this.setApplication(application);
@@ -67,13 +67,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.getLogger().logTrace("EXIT!"); //NOI18N
        }
 
        @Override
        public void displayAddressBox (final Contact contact) {
                // Trace message
-               this.getLogger().trace(MessageFormat.format("contact={0} - CALLED!", contact)); //NOI18N
+               this.getLogger().logTrace(MessageFormat.format("contact={0} - CALLED!", contact)); //NOI18N
 
                // Is it null?
                if (null == contact) {
@@ -85,13 +85,13 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC
                this.outputMessage(MessageFormat.format("Strasse, PLZ Ort, Land: {0}\n{1} {2}\n{3}", contact.getStreet(), contact.getZipCode(), contact.getCity(), contact.getCountryCode()));
 
                // Trace message
-               this.getLogger().trace("EXIT!"); //NOI18N
+               this.getLogger().logTrace("EXIT!"); //NOI18N
        }
 
        @Override
        public void displayNameBox (final Contact contact) {
                // Trace message
-               this.getLogger().trace(MessageFormat.format("contact={0} - CALLED!", contact)); //NOI18N
+               this.getLogger().logTrace(MessageFormat.format("contact={0} - CALLED!", contact)); //NOI18N
 
                // Is it null?
                if (null == contact) {
@@ -116,13 +116,13 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC
                }
 
                // Trace message
-               this.getLogger().trace("EXIT!"); //NOI18N
+               this.getLogger().logTrace("EXIT!"); //NOI18N
        }
 
        @Override
        public void displayOtherDataBox (final Contact contact) {
                // Trace message
-               this.getLogger().trace(MessageFormat.format("contact={0} - CALLED!", contact)); //NOI18N
+               this.getLogger().logTrace(MessageFormat.format("contact={0} - CALLED!", contact)); //NOI18N
 
                // Is it null?
                if (null == contact) {
@@ -134,13 +134,13 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC
                this.outputMessage(MessageFormat.format("Telefonnumer: {0}\nFaxnummer: {1}\nHandy: {2}\nKommentar:\n{3}", contact.getPhoneNumber(), contact.getFaxNumber(), contact.getCellphoneNumber(), contact.getComment()));
 
                // Trace message
-               this.getLogger().trace("EXIT!"); //NOI18N
+               this.getLogger().logTrace("EXIT!"); //NOI18N
        }
 
        @Override
        public void doChangeOwnAddressData (final Contact contact) {
                // Trace message
-               this.getLogger().trace(MessageFormat.format("contact={0} - CALLED!", contact)); //NOI18N
+               this.getLogger().logTrace(MessageFormat.format("contact={0} - CALLED!", contact)); //NOI18N
 
                // Is it null?
                if (null == contact) {
@@ -176,13 +176,13 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC
                contact.setCountryCode(countryCode);
 
                // Trace message
-               this.getLogger().trace("EXIT!"); //NOI18N
+               this.getLogger().logTrace("EXIT!"); //NOI18N
        }
 
        @Override
        public void doChangeOwnNameData (final Contact contact) {
                // Trace message
-               this.getLogger().trace(MessageFormat.format("contact={0} - CALLED!", contact)); //NOI18N
+               this.getLogger().logTrace(MessageFormat.format("contact={0} - CALLED!", contact)); //NOI18N
 
                // Is it null?
                if (null == contact) {
@@ -218,13 +218,13 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC
                contact.setCompanyName(companyName);
 
                // Trace message
-               this.getLogger().trace("EXIT!"); //NOI18N
+               this.getLogger().logTrace("EXIT!"); //NOI18N
        }
 
        @Override
        public void doChangeOwnOtherData (final Contact contact) {
                // Trace message
-               this.getLogger().trace(MessageFormat.format("contact={0} - CALLED!", contact)); //NOI18N
+               this.getLogger().logTrace(MessageFormat.format("contact={0} - CALLED!", contact)); //NOI18N
 
                // Is it null?
                if (null == contact) {
@@ -264,13 +264,13 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC
                contact.setComment(comment);
 
                // Trace message
-               this.getLogger().trace("EXIT!"); //NOI18N
+               this.getLogger().logTrace("EXIT!"); //NOI18N
        }
 
        @Override
        public Contact doEnterOwnData () {
                // Trace message
-               this.getLogger().trace("CALLED!"); //NOI18N
+               this.getLogger().logTrace("CALLED!"); //NOI18N
 
                // Get manager and cast it
                ManageableContactAddressbook manager = (ManageableContactAddressbook) this.getManager();
@@ -291,7 +291,7 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC
                Contact contact = new UserContact(gender, firstName, familyName, companyName);
 
                // Trace message
-               this.getLogger().trace(MessageFormat.format("contact={0} - EXIT!", contact)); //NOI18N
+               this.getLogger().logTrace(MessageFormat.format("contact={0} - EXIT!", contact)); //NOI18N
 
                // And return object
                return contact;
@@ -300,20 +300,20 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC
        @Override
        public void doShutdown () throws SQLException, IOException {
                // Trace message
-               this.getLogger().trace("CALLED!"); //NOI18N
+               this.getLogger().logTrace("CALLED!"); //NOI18N
 
                // Parent call
                super.doShutdown();
 
                // TODO Add other shutdown stuff
                // Trace message
-               this.getLogger().trace("EXIT!"); //NOI18N
+               this.getLogger().logTrace("EXIT!"); //NOI18N
        }
 
        @Override
        public void doUserMenuChoice () throws UnhandledUserChoiceException {
                // Trace message
-               this.getLogger().trace("CALLED!"); //NOI18N
+               this.getLogger().logTrace("CALLED!"); //NOI18N
 
                // Get all access keys from menu
                char[] accessKeys = MenuTools.getAccessKeysFromMenuMap(this.getMenus(), this.getCurrentMenu());
@@ -381,13 +381,13 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC
                }
 
                // Trace message
-               this.getLogger().trace("EXIT!"); //NOI18N
+               this.getLogger().logTrace("EXIT!"); //NOI18N
        }
 
        @Override
        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.getLogger().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) {
@@ -413,7 +413,7 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC
                }
 
                // Trace message
-               this.getLogger().trace(MessageFormat.format("input={0} - EXIT!", input)); //NOI18N
+               this.getLogger().logTrace(MessageFormat.format("input={0} - EXIT!", input)); //NOI18N
 
                // Return read char
                return input;
@@ -422,7 +422,7 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC
        @Override
        public Gender enterGender (final String message) {
                // Trace message
-               this.getLogger().trace(MessageFormat.format("message={0} - CALLED!", message)); //NOI18N
+               this.getLogger().logTrace(MessageFormat.format("message={0} - CALLED!", message)); //NOI18N
 
                // Get valid chars
                char[] validChars = Gender.validChars();
@@ -439,7 +439,7 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC
                assert (g instanceof Gender) : "g is not set."; //NOI18N
 
                // Trace message
-               this.getLogger().trace(MessageFormat.format("g={0} - EXIT!", g)); //NOI18N
+               this.getLogger().logTrace(MessageFormat.format("g={0} - EXIT!", g)); //NOI18N
 
                // Return it
                return g;
@@ -448,7 +448,7 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC
        @Override
        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.getLogger().logTrace(MessageFormat.format("minimum={0},maximum={1},message={2} - CALLED!", minimum, maximum, message)); //NOI18N
 
                // Minimum should not be below zero
                assert (minimum >= 0) : MessageFormat.format("minimum={0} is below zero", minimum); //NOI18N
@@ -466,7 +466,7 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC
                }
 
                // Trace message
-               this.getLogger().trace(MessageFormat.format("input={0} - EXIT!", input)); //NOI18N
+               this.getLogger().logTrace(MessageFormat.format("input={0} - EXIT!", input)); //NOI18N
 
                // Return it
                return input;
@@ -475,7 +475,7 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC
        @Override
        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.getLogger().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);
@@ -493,7 +493,7 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC
                }
 
                // Trace message
-               this.getLogger().trace(MessageFormat.format("input={0} - EXIT!", input)); //NOI18N
+               this.getLogger().logTrace(MessageFormat.format("input={0} - EXIT!", input)); //NOI18N
 
                // Return it
                return input;
@@ -508,7 +508,7 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC
        @Override
        public void init () {
                // Trace message
-               this.getLogger().trace("CALLED!"); //NOI18N
+               this.getLogger().logTrace("CALLED!"); //NOI18N
 
                // Init contact manager here
                try {
@@ -522,7 +522,7 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC
                this.fillMenuMap();
 
                // Trace message
-               this.getLogger().trace("EXIT!"); //NOI18N
+               this.getLogger().logTrace("EXIT!"); //NOI18N
        }
 
        @Override
@@ -548,13 +548,13 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC
                this.outputMessage("Copyright(c) 2015 by Roland Haeder, this is free software"); //NOI18N
 
                // Debug message
-               this.getLogger().debug("Intro shown to user"); //NOI18N
+               this.getLogger().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.getLogger().logTrace(MessageFormat.format("contact={0} CALLED!", contact)); //NOI18N
 
                // Contact must not be null
                if (null == contact) {
@@ -592,7 +592,7 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC
                }
 
                // Trace message
-               this.getLogger().trace("EXIT!"); //NOI18N
+               this.getLogger().logTrace("EXIT!"); //NOI18N
        }
 
        /**
@@ -605,7 +605,7 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC
                String input = this.readString();
 
                // Debug message
-               this.getLogger().debug(MessageFormat.format("input={0}", input)); //NOI18N
+               this.getLogger().logDebug(MessageFormat.format("input={0}", input)); //NOI18N
 
                // This must be only one character
                if (input.length() != 1) {
@@ -627,7 +627,7 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC
                String input = this.readString();
 
                // Debug message
-               this.getLogger().debug(MessageFormat.format("input={0}", input)); //NOI18N
+               this.getLogger().logDebug(MessageFormat.format("input={0}", input)); //NOI18N
 
                // Init number with invalid value
                int num = -1;
@@ -637,11 +637,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.getLogger().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.getLogger().logTrace(MessageFormat.format("num={0} - EXIT!", num)); //NOI18N
 
                // Return read number
                return num;
@@ -659,7 +659,7 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC
        @Override
        protected final void fillMenuMap () {
                // Trace message
-               this.getLogger().trace("CALLED!"); //NOI18N
+               this.getLogger().logTrace("CALLED!"); //NOI18N
 
                // Initialize first (main) menu
                Menu menu = new ConsoleMenu("main", this); //NOI18N
@@ -668,6 +668,6 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC
                this.getMenus().put("main", menu); //NOI18N
 
                // Trace message
-               this.getLogger().trace("EXIT!"); //NOI18N
+               this.getLogger().logTrace("EXIT!"); //NOI18N
        }
 }
index 05e123980458799189f35a486d30b36facc75881..bc09644749ed8eb6dca4b233e76ea9d16e045bef 100644 (file)
@@ -47,22 +47,25 @@ import javax.swing.JTextArea;
 import javax.swing.JTextField;
 import javax.swing.border.TitledBorder;
 import javax.swing.table.TableModel;
+import org.mxchange.addressbook.BaseAddressbookSystem;
 import org.mxchange.addressbook.application.AddressbookApplication;
 import org.mxchange.addressbook.exceptions.ContactAlreadyAddedException;
 import org.mxchange.addressbook.manager.contact.ManageableContactAddressbook;
-import org.mxchange.jcore.BaseFrameworkSystem;
+import org.mxchange.jcore.application.Application;
 import org.mxchange.jcore.client.Client;
 import org.mxchange.jcore.exceptions.FrameAlreadyInitializedException;
+import org.mxchange.jcore.manager.Manageable;
 import org.mxchange.jcore.model.contact.Contact;
 import org.mxchange.jcore.model.contact.gender.Gender;
 import org.mxchange.jcoreswing.client.gui.ClientFrame;
 import org.mxchange.jcoreswing.model.swing.contact.ContactTableModel;
 
 /**
+ * A Swing frame for addressbook.
  *
  * @author Roland Haeder
  */
-public class AddressbookFrame extends BaseFrameworkSystem implements ClientFrame {
+public class AddressbookFrame extends BaseAddressbookSystem implements ClientFrame {
 
        /**
         * Own instance
@@ -133,7 +136,7 @@ public class AddressbookFrame extends BaseFrameworkSystem implements ClientFrame
         */
        private AddressbookFrame (final Client client) {
                // Debug line
-               this.getLogger().trace(MessageFormat.format("client={0}: CALLED!", client)); //NOI18N
+               this.getLogger().logTrace(MessageFormat.format("client={0}: CALLED!", client)); //NOI18N
 
                // Set frame instance
                this.frame = new JFrame();
@@ -143,13 +146,13 @@ public class AddressbookFrame extends BaseFrameworkSystem implements ClientFrame
                this.setClient(client);
 
                // Trace message
-               this.getLogger().trace("EXIT!"); //NOI18N
+               this.getLogger().logTrace("EXIT!"); //NOI18N
        }
 
        @Override
        public Contact doEnterOwnData () {
                // Trace message
-               this.getLogger().trace("CALLED!"); //NOI18N
+               this.getLogger().logTrace("CALLED!"); //NOI18N
 
                // Is the "add contact" window visible?
                if (this.addContact.isVisible()) {
@@ -164,7 +167,7 @@ public class AddressbookFrame extends BaseFrameworkSystem implements ClientFrame
                this.addContact.setVisible(true);
 
                // Trace message
-               this.getLogger().trace("Returning null : EXIT!"); //NOI18N
+               this.getLogger().logTrace("Returning null : EXIT!"); //NOI18N
 
                // Return value is not supported
                return null;
@@ -176,13 +179,13 @@ public class AddressbookFrame extends BaseFrameworkSystem implements ClientFrame
        @Override
        public void doShutdown () {
                // Trace message
-               this.getLogger().trace("CALLED!"); //NOI18N
+               this.getLogger().logTrace("CALLED!"); //NOI18N
 
                // First only show shutdown status
                this.updateStatus("shutdown"); //NOI18N
 
                // Trace message
-               this.getLogger().trace("EXIT!"); //NOI18N
+               this.getLogger().logTrace("EXIT!"); //NOI18N
        }
 
        /**
@@ -191,7 +194,7 @@ public class AddressbookFrame extends BaseFrameworkSystem implements ClientFrame
        @Override
        public void enableMainWindow () {
                // Trace message
-               this.getLogger().trace("CALLED!"); //NOI18N
+               this.getLogger().logTrace("CALLED!"); //NOI18N
 
                // Enable it again
                this.frame.setEnabled(true);
@@ -200,7 +203,27 @@ public class AddressbookFrame extends BaseFrameworkSystem implements ClientFrame
                this.frame.requestFocus();
 
                // Trace message
-               this.getLogger().trace("EXIT!"); //NOI18N
+               this.getLogger().logTrace("EXIT!"); //NOI18N
+       }
+
+       @Override
+       public Application getApplication () {
+               throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+       }
+
+       @Override
+       public Client getClient () {
+               throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+       }
+
+       @Override
+       public Manageable getManager () {
+               throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+       }
+
+       @Override
+       public String getMessageStringFromKey (String key) {
+               throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }
 
        /**
@@ -211,12 +234,12 @@ public class AddressbookFrame extends BaseFrameworkSystem implements ClientFrame
        @Override
        public void setupFrame (final Client client) throws IOException {
                // Debug line
-               this.getLogger().trace(MessageFormat.format("client={0}: CALLED!", client)); //NOI18N
+               this.getLogger().logTrace(MessageFormat.format("client={0}: CALLED!", client)); //NOI18N
 
                // Has the user entered own data?
                if (((ManageableContactAddressbook) this.getClient().getManager()).isOwnContactAdded()) {
                        // Debug message
-                       this.getLogger().debug("Disabling menus: isOwnContactAdded()=false"); //NOI18N
+                       this.getLogger().logDebug("Disabling menus: isOwnContactAdded()=false"); //NOI18N
 
                        // Not entered yet, so disable "add" menu
                        this.addOwnItem.setEnabled(false);
@@ -232,7 +255,7 @@ public class AddressbookFrame extends BaseFrameworkSystem implements ClientFrame
                this.updateStatus("done"); //NOI18N
 
                // Trace message
-               this.getLogger().trace("EXIT!"); //NOI18N
+               this.getLogger().logTrace("EXIT!"); //NOI18N
        }
 
        /**
@@ -246,7 +269,7 @@ public class AddressbookFrame extends BaseFrameworkSystem implements ClientFrame
        @Override
        public void init () throws FrameAlreadyInitializedException {
                // Debug line
-               this.getLogger().trace("CALLED!"); //NOI18N
+               this.getLogger().logTrace("CALLED!"); //NOI18N
 
                // Has this frame been initialized?
                if (this.isInitialized()) {
@@ -261,7 +284,7 @@ public class AddressbookFrame extends BaseFrameworkSystem implements ClientFrame
                this.initialized = true;
 
                // Trace message
-               this.getLogger().trace("EXIT!"); //NOI18N
+               this.getLogger().logTrace("EXIT!"); //NOI18N
        }
 
        /**
@@ -275,18 +298,23 @@ public class AddressbookFrame extends BaseFrameworkSystem implements ClientFrame
                return this.initialized;
        }
 
+       @Override
+       public void logException (Throwable exception) {
+               throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+       }
+
        /**
         * Shuts down the application.
         */
        @Override
        public void shutdownApplication () {
                // Trace message
-               this.getLogger().trace("CALLED!"); //NOI18N
+               this.getLogger().logTrace("CALLED!"); //NOI18N
 
                // To do this, the frame must be initialized
                if (!this.isInitialized()) {
                        // Not initalized, so bad call
-                       this.getLogger().fatal("Bad call of shutdownApplication(). Please report this."); //NOI18N
+                       this.getLogger().logFatal("Bad call of shutdownApplication(). Please report this."); //NOI18N
                        return;
                }
 
@@ -299,7 +327,7 @@ public class AddressbookFrame extends BaseFrameworkSystem implements ClientFrame
                }
 
                // Trace message
-               this.getLogger().trace("EXIT!"); //NOI18N
+               this.getLogger().logTrace("EXIT!"); //NOI18N
        }
 
        /**
@@ -311,7 +339,7 @@ public class AddressbookFrame extends BaseFrameworkSystem implements ClientFrame
         */
        private void addMenuItem (final JMenu menu, final String key, final ActionListener listener) {
                // Trace message
-               this.getLogger().trace(MessageFormat.format("menu={0},key={1},listener={2} - CALLED!", menu, key, listener)); //NOI18N
+               this.getLogger().logTrace(MessageFormat.format("menu={0},key={1},listener={2} - CALLED!", menu, key, listener)); //NOI18N
 
                // New instance
                JMenuItem item = this.initMenuItemWithTooltip(key);
@@ -323,7 +351,7 @@ public class AddressbookFrame extends BaseFrameworkSystem implements ClientFrame
                menu.add(item);
 
                // Trace message
-               this.getLogger().trace("EXIT!"); //NOI18N
+               this.getLogger().logTrace("EXIT!"); //NOI18N
        }
 
        /**
@@ -335,7 +363,7 @@ public class AddressbookFrame extends BaseFrameworkSystem implements ClientFrame
         */
        private void addTextFieldWithLabelToPanel (final JPanel panel, final String key, final int fieldLength) {
                // Trace message
-               this.getLogger().trace(MessageFormat.format("panel={0},key={1},fieldLength={2} - CALLED!", panel, key, fieldLength)); //NOI18N
+               this.getLogger().logTrace(MessageFormat.format("panel={0},key={1},fieldLength={2} - CALLED!", panel, key, fieldLength)); //NOI18N
 
                // Init label for given key
                JLabel label = new JLabel(this.getBundle().getString(String.format("AddressbookFrame.%s.text", key))); //NOI18N
@@ -349,7 +377,7 @@ public class AddressbookFrame extends BaseFrameworkSystem implements ClientFrame
                panel.add(field);
 
                // Trace message
-               this.getLogger().trace("EXIT!"); //NOI18N
+               this.getLogger().logTrace("EXIT!"); //NOI18N
        }
 
        /**
@@ -389,7 +417,7 @@ public class AddressbookFrame extends BaseFrameworkSystem implements ClientFrame
         */
        private void initAddCancelButtons () {
                // Trace message
-               this.getLogger().trace("CALLED!"); //NOI18N
+               this.getLogger().logTrace("CALLED!"); //NOI18N
 
                // Init panel
                JPanel panel = new JPanel();
@@ -417,7 +445,7 @@ public class AddressbookFrame extends BaseFrameworkSystem implements ClientFrame
                this.addContact.add(panel);
 
                // Trace message
-               this.getLogger().trace("EXIT!"); //NOI18N
+               this.getLogger().logTrace("EXIT!"); //NOI18N
        }
 
        /**
@@ -425,7 +453,7 @@ public class AddressbookFrame extends BaseFrameworkSystem implements ClientFrame
         */
        private void initAddContactDialog () {
                // Trace message
-               this.getLogger().trace("CALLED!"); //NOI18N
+               this.getLogger().logTrace("CALLED!"); //NOI18N
 
                // Instance dialog and set title
                this.addContact = new JDialog();
@@ -493,7 +521,7 @@ public class AddressbookFrame extends BaseFrameworkSystem implements ClientFrame
                 */ this.addContact.setVisible(true);
 
                // Trace message
-               this.getLogger().trace("EXIT!"); //NOI18N
+               this.getLogger().logTrace("EXIT!"); //NOI18N
        }
 
        /**
@@ -503,7 +531,7 @@ public class AddressbookFrame extends BaseFrameworkSystem implements ClientFrame
         */
        private void initAddressDataPanel (final JDialog dialog) {
                // Trace message
-               this.getLogger().trace("CALLED!"); //NOI18N
+               this.getLogger().logTrace("CALLED!"); //NOI18N
 
                // Panel "address" input boxes
                JPanel addressPanel = new JPanel();
@@ -544,7 +572,7 @@ public class AddressbookFrame extends BaseFrameworkSystem implements ClientFrame
                dialog.add(addressPanel);
 
                // Trace message
-               this.getLogger().trace("EXIT!"); //NOI18N
+               this.getLogger().logTrace("EXIT!"); //NOI18N
        }
 
        /**
@@ -552,7 +580,7 @@ public class AddressbookFrame extends BaseFrameworkSystem implements ClientFrame
         */
        private void initComponents () {
                // Debug line
-               this.getLogger().trace("CALLED!"); //NOI18N
+               this.getLogger().logTrace("CALLED!"); //NOI18N
 
                // Set default close operation
                this.frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
@@ -601,7 +629,7 @@ public class AddressbookFrame extends BaseFrameworkSystem implements ClientFrame
                this.initOtherDialogs();
 
                // Trace message
-               this.getLogger().trace("EXIT!"); //NOI18N
+               this.getLogger().logTrace("EXIT!"); //NOI18N
        }
 
        /**
@@ -612,13 +640,13 @@ public class AddressbookFrame extends BaseFrameworkSystem implements ClientFrame
         */
        private JMenuItem initMenuItemWithTooltip (final String key) {
                // Debug line
-               this.getLogger().trace(MessageFormat.format("key={0} - CALLED!", key)); //NOI18N
+               this.getLogger().logTrace(MessageFormat.format("key={0} - CALLED!", key)); //NOI18N
 
                JMenuItem item = new JMenuItem(this.getBundle().getString(String.format("AddressbookFrame.menuItem.%s.text", key))); //NOI18N
                item.setToolTipText(this.getBundle().getString(String.format("AddressbookFrame.menuItem.%s.toolTipText", key))); //NOI18N
 
                // Trace message
-               this.getLogger().trace(MessageFormat.format("item={0} - EXIT!", item)); //NOI18N
+               this.getLogger().logTrace(MessageFormat.format("item={0} - EXIT!", item)); //NOI18N
 
                // Return it
                return item;
@@ -629,7 +657,7 @@ public class AddressbookFrame extends BaseFrameworkSystem implements ClientFrame
         */
        private void initMenuSystem () {
                // Trace message
-               this.getLogger().trace("CALLED!"); //NOI18N
+               this.getLogger().logTrace("CALLED!"); //NOI18N
 
                // Init menu bar, menu and item instances
                JMenuBar menuBar = new JMenuBar();
@@ -733,7 +761,7 @@ public class AddressbookFrame extends BaseFrameworkSystem implements ClientFrame
                this.frame.add(menuBar, BorderLayout.NORTH);
 
                // Trace message
-               this.getLogger().trace("EXIT!"); //NOI18N
+               this.getLogger().logTrace("EXIT!"); //NOI18N
        }
 
        /**
@@ -743,7 +771,7 @@ public class AddressbookFrame extends BaseFrameworkSystem implements ClientFrame
         */
        private void initNameDataPanel (final JDialog dialog) {
                // Trace message
-               this.getLogger().trace(MessageFormat.format("dialog={0} - CALLED!", dialog)); //NOI18N
+               this.getLogger().logTrace(MessageFormat.format("dialog={0} - CALLED!", dialog)); //NOI18N
 
                // Panel "name" input boxes
                JPanel namePanel = new JPanel();
@@ -776,7 +804,7 @@ public class AddressbookFrame extends BaseFrameworkSystem implements ClientFrame
                dialog.add(namePanel);
 
                // Trace message
-               this.getLogger().trace("EXIT!"); //NOI18N
+               this.getLogger().logTrace("EXIT!"); //NOI18N
        }
 
        /**
@@ -787,7 +815,7 @@ public class AddressbookFrame extends BaseFrameworkSystem implements ClientFrame
         */
        private void initOtherDataPanel (final JDialog dialog) {
                // Trace message
-               this.getLogger().trace(MessageFormat.format("dialog={0} - CALLED!", dialog)); //NOI18N
+               this.getLogger().logTrace(MessageFormat.format("dialog={0} - CALLED!", dialog)); //NOI18N
 
                // Panel "other" input boxes
                JPanel otherPanel = new JPanel();
@@ -821,7 +849,7 @@ public class AddressbookFrame extends BaseFrameworkSystem implements ClientFrame
                dialog.add(otherPanel);
 
                // Trace message
-               this.getLogger().trace("EXIT!"); //NOI18N
+               this.getLogger().logTrace("EXIT!"); //NOI18N
        }
 
        /**
@@ -829,14 +857,14 @@ public class AddressbookFrame extends BaseFrameworkSystem implements ClientFrame
         */
        private void initOtherDialogs () {
                // Trace message
-               this.getLogger().trace("CALLED!"); //NOI18N
+               this.getLogger().logTrace("CALLED!"); //NOI18N
 
                // Init other windows:
                // 1) Add contact
                initAddContactDialog();
 
                // Trace message
-               this.getLogger().trace("EXIT!"); //NOI18N
+               this.getLogger().logTrace("EXIT!"); //NOI18N
        }
 
        /**
@@ -844,7 +872,7 @@ public class AddressbookFrame extends BaseFrameworkSystem implements ClientFrame
         */
        private void initStatusPanel () {
                // Trace message
-               this.getLogger().trace("CALLED!"); //NOI18N
+               this.getLogger().logTrace("CALLED!"); //NOI18N
 
                // Init status label (which needs to be updated
                this.statusLabel = new JLabel();
@@ -860,7 +888,7 @@ public class AddressbookFrame extends BaseFrameworkSystem implements ClientFrame
                this.frame.add(panel, BorderLayout.SOUTH);
 
                // Trace message
-               this.getLogger().trace("EXIT!"); //NOI18N
+               this.getLogger().logTrace("EXIT!"); //NOI18N
        }
 
        /**
@@ -868,7 +896,7 @@ public class AddressbookFrame extends BaseFrameworkSystem implements ClientFrame
         */
        private void initTable () {
                // Trace message
-               this.getLogger().trace("CALLED!"); //NOI18N
+               this.getLogger().logTrace("CALLED!"); //NOI18N
 
                // Instance table model
                this.dataModel = new ContactTableModel(this.getClient().getManager());
@@ -901,7 +929,7 @@ public class AddressbookFrame extends BaseFrameworkSystem implements ClientFrame
                this.frame.add(scroller, BorderLayout.CENTER);
 
                // Trace message
-               this.getLogger().trace("EXIT!"); //NOI18N
+               this.getLogger().logTrace("EXIT!"); //NOI18N
        }
 
        /**
@@ -911,19 +939,19 @@ public class AddressbookFrame extends BaseFrameworkSystem implements ClientFrame
         */
        private void updateStatus (final String type) {
                // Trace message
-               this.getLogger().trace(MessageFormat.format("type={0} - CALLED!", type)); //NOI18N
+               this.getLogger().logTrace(MessageFormat.format("type={0} - CALLED!", type)); //NOI18N
 
                // Set status message
                this.statusLabel.setText(this.getBundle().getString(String.format("AddressbookFrame.statusLabel.%s.text", type))); //NOI18N
 
                // Trace message
-               this.getLogger().trace("EXIT!"); //NOI18N
+               this.getLogger().logTrace("EXIT!"); //NOI18N
        }
 
        /**
         * Class for "add address" button
         */
-       private static class AddActionListener extends BaseFrameworkSystem implements ActionListener {
+       private static class AddActionListener extends BaseAddressbookSystem implements ActionListener {
 
                /**
                 * Dialog instance
@@ -961,7 +989,7 @@ public class AddressbookFrame extends BaseFrameworkSystem implements ClientFrame
        /**
         * Class for "cancel address" button
         */
-       private static class CancelActionListener extends BaseFrameworkSystem implements ActionListener {
+       private static class CancelActionListener extends BaseAddressbookSystem implements ActionListener {
 
                /**
                 * Dialog instance
index 13d05ca1922da69d51782123186425ccd38e1e80..d2316ce83646042c78604b8ff27fa82f8b8f8732 100644 (file)
@@ -29,6 +29,7 @@ import org.mxchange.jcore.model.contact.gender.Gender;
 import org.mxchange.jcoreswing.client.gui.ClientFrame;
 
 /**
+ * A swing client
  *
  * @author Roland Haeder
  */
@@ -46,7 +47,7 @@ public class SwingClient extends BaseAddressbookClient implements AddressbookCli
         */
        public SwingClient (final Application application) {
                // Debug message
-               this.getLogger().trace("CALLED!"); //NOI18N
+               this.getLogger().logTrace("CALLED!"); //NOI18N
 
                // Set application instance
                this.setApplication(application);
@@ -55,7 +56,7 @@ public class SwingClient extends BaseAddressbookClient implements AddressbookCli
                this.frame = AddressbookFrame.getSelfInstance(this);
 
                // Trace message
-               this.getLogger().trace("EXIT!"); //NOI18N
+               this.getLogger().logTrace("EXIT!"); //NOI18N
        }
 
        @Override
@@ -96,7 +97,7 @@ public class SwingClient extends BaseAddressbookClient implements AddressbookCli
        @Override
        public Contact doEnterOwnData () {
                // Trace message
-               this.getLogger().trace("CALLED!"); //NOI18N
+               this.getLogger().logTrace("CALLED!"); //NOI18N
 
                // Deligate this call to the frame
                return this.frame.doEnterOwnData();
@@ -108,7 +109,7 @@ public class SwingClient extends BaseAddressbookClient implements AddressbookCli
        @Override
        public void doShutdown () throws SQLException, IOException {
                // Debug message
-               this.getLogger().trace("CALLED!"); //NOI18N
+               this.getLogger().logTrace("CALLED!"); //NOI18N
 
                // Parent call
                super.doShutdown();
@@ -118,13 +119,13 @@ public class SwingClient extends BaseAddressbookClient implements AddressbookCli
 
                // TODO Add other shutdown stuff
                // Debug message
-               this.getLogger().trace("EXIT!"); //NOI18N
+               this.getLogger().logTrace("EXIT!"); //NOI18N
        }
 
        @Override
        public void doUserMenuChoice () throws UnhandledUserChoiceException {
                // Debug message
-               //* NOISY-DEBUG: */ this.getLogger().trace("CALLED!");
+               //* NOISY-DEBUG: */ this.getLogger().logTrace("CALLED!");
 
                // Not implemented here
        }
@@ -159,7 +160,7 @@ public class SwingClient extends BaseAddressbookClient implements AddressbookCli
        @Override
        public SelectableMenuItem getMenuItem (final char accessKey, final String text) {
                // Debug message
-               this.getLogger().trace("CALLED!"); //NOI18N
+               this.getLogger().logTrace("CALLED!"); //NOI18N
 
                // Returns null as the menu is now no longer controlled here.
                return null;
@@ -171,7 +172,7 @@ public class SwingClient extends BaseAddressbookClient implements AddressbookCli
        @Override
        public void init () {
                // Debug message
-               this.getLogger().trace("CALLED!"); //NOI18N
+               this.getLogger().logTrace("CALLED!"); //NOI18N
 
                try {
                        // Init contact manager here
@@ -188,7 +189,7 @@ public class SwingClient extends BaseAddressbookClient implements AddressbookCli
                }
 
                // Debug message
-               this.getLogger().trace("EXIT!"); //NOI18N
+               this.getLogger().logTrace("EXIT!"); //NOI18N
        }
 
        @Override
@@ -199,7 +200,7 @@ public class SwingClient extends BaseAddressbookClient implements AddressbookCli
        @Override
        public void showCurrentMenu () {
                // Debug message
-               //* NOISY-DEBUG: */ this.getLogger().trace("CALLED!");
+               //* NOISY-DEBUG: */ this.getLogger().logTrace("CALLED!");
 
                // Not implemented here
        }
@@ -212,7 +213,7 @@ public class SwingClient extends BaseAddressbookClient implements AddressbookCli
        @Override
        public void showWelcome () {
                // Debug message
-               this.getLogger().trace("CALLED!"); //NOI18N
+               this.getLogger().logTrace("CALLED!"); //NOI18N
 
                // Not implemented here
        }
index 805c3a41b6faee54c86b7f5fce54c19f561dd210..beafc29e5a20f918ac0fd9edbb9b2969cebc2458 100644 (file)
@@ -31,6 +31,7 @@ import org.mxchange.jcore.exceptions.UnhandledUserChoiceException;
 import org.mxchange.jcore.manager.BaseManager;
 import org.mxchange.jcore.model.contact.Contact;
 import org.mxchange.jcore.model.contact.gender.Gender;
+import org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal;
 
 /**
  * A manager for contacts.
@@ -50,6 +51,11 @@ public class AddressbookContactManager extends BaseManager implements Manageable
         */
        private final List<String> translatedColumnNames;
 
+       /**
+        * Logger instance
+        */
+       private LoggerBeanLocal logger;
+
        /**
         * Constructor which accepts maxContacts for maximum (initial) contacts and
         * a client instance.
@@ -59,7 +65,7 @@ public class AddressbookContactManager extends BaseManager implements Manageable
         */
        public AddressbookContactManager (final Client client) throws SQLException {
                // Trace message
-               this.getLogger().trace(MessageFormat.format("client={1} - CALLED!", client)); //NOI18N
+               this.getLogger().logTrace(MessageFormat.format("client={1} - CALLED!", client)); //NOI18N
 
                // Make sure all parameters are set correctly
                if (null == client) {
@@ -82,7 +88,7 @@ public class AddressbookContactManager extends BaseManager implements Manageable
                this.fillColumnNamesFromBundle();
 
                // Debug message
-               //* NOISY-DEBUG: */ this.getLogger().debug("client=" + client);
+               //* NOISY-DEBUG: */ this.getLogger().logDebug("client=" + client);
        }
 
        /**
@@ -93,7 +99,7 @@ public class AddressbookContactManager extends BaseManager implements Manageable
        @Override
        public void addContact (final Contact contact) throws ContactAlreadyAddedException {
                // Trace message
-               this.getLogger().trace(MessageFormat.format("contact={0} - CALLED!", contact)); //NOI18N
+               this.getLogger().logTrace(MessageFormat.format("contact={0} - CALLED!", contact)); //NOI18N
 
                // Contact instance must not be null
                if (null == contact) {
@@ -105,7 +111,7 @@ public class AddressbookContactManager extends BaseManager implements Manageable
                ((AddressbookContactFrontend) this.getFrontend()).addContact(contact);
 
                // Trace message
-               this.getLogger().trace("EXIT!"); //NOI18N
+               this.getLogger().logTrace("EXIT!"); //NOI18N
        }
 
        /**
@@ -124,7 +130,7 @@ public class AddressbookContactManager extends BaseManager implements Manageable
        @Override
        public void doChangeAddressData (final Contact contact) {
                // Trace message
-               this.getLogger().trace(MessageFormat.format("contact={0} CALLED!", contact)); //NOI18N
+               this.getLogger().logTrace(MessageFormat.format("contact={0} CALLED!", contact)); //NOI18N
 
                // Contact must not be null
                if (null == contact) {
@@ -152,7 +158,7 @@ public class AddressbookContactManager extends BaseManager implements Manageable
                }
 
                // Trace message
-               this.getLogger().trace("EXIT!"); //NOI18N
+               this.getLogger().logTrace("EXIT!"); //NOI18N
        }
 
        /**
@@ -163,7 +169,7 @@ public class AddressbookContactManager extends BaseManager implements Manageable
        @Override
        public void doChangeNameData (final Contact contact) {
                // Trace message
-               this.getLogger().trace(MessageFormat.format("contact={0} CALLED!", contact)); //NOI18N
+               this.getLogger().logTrace(MessageFormat.format("contact={0} CALLED!", contact)); //NOI18N
 
                // Contact must not be null
                if (null == contact) {
@@ -187,7 +193,7 @@ public class AddressbookContactManager extends BaseManager implements Manageable
                }
 
                // Trace message
-               this.getLogger().trace("EXIT!"); //NOI18N
+               this.getLogger().logTrace("EXIT!"); //NOI18N
        }
 
        /**
@@ -206,7 +212,7 @@ public class AddressbookContactManager extends BaseManager implements Manageable
        @Override
        public void doChangeOtherData (final Contact contact) {
                // Trace message
-               this.getLogger().trace(MessageFormat.format("contact={0} CALLED!", contact)); //NOI18N
+               this.getLogger().logTrace(MessageFormat.format("contact={0} CALLED!", contact)); //NOI18N
 
                // Contact must not be null
                if (null == contact) {
@@ -230,7 +236,7 @@ public class AddressbookContactManager extends BaseManager implements Manageable
                }
 
                // Trace message
-               this.getLogger().trace("EXIT!"); //NOI18N
+               this.getLogger().logTrace("EXIT!"); //NOI18N
        }
 
        /**
@@ -239,7 +245,7 @@ public class AddressbookContactManager extends BaseManager implements Manageable
        @Override
        public void doChangeOwnData () throws IOException, SQLException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
                // Trace message
-               this.getLogger().trace("CALLED!"); //NOI18N
+               this.getLogger().logTrace("CALLED!"); //NOI18N
 
                /*
                 * First check if the user has registered own contact, before that
@@ -257,10 +263,10 @@ public class AddressbookContactManager extends BaseManager implements Manageable
                Contact contact = this.getOwnContact();
 
                // It must be found
-               assert (contact instanceof Contact);
+               assert (contact instanceof Contact) : ": contact is not implementing Contact: " + contact;
 
                // Display contact
-               contact.show(this.getClient());
+               this.getClient().show(contact);
 
                // Get and cast client instance
                AddressbookClient client = (AddressbookClient) this.getClient();
@@ -269,11 +275,11 @@ public class AddressbookContactManager extends BaseManager implements Manageable
                        // Ask user what to change
                        client.userChooseChangeContactData(contact);
                } catch (final UnhandledUserChoiceException ex) {
-                       this.getLogger().catching(ex);
+                       this.getLogger().logException(ex);
                }
 
                // Trace message
-               this.getLogger().trace("EXIT!"); //NOI18N
+               this.getLogger().logTrace("EXIT!"); //NOI18N
        }
 
        /**
@@ -290,7 +296,7 @@ public class AddressbookContactManager extends BaseManager implements Manageable
        @Override
        public void doEnterOwnData () throws ContactAlreadyAddedException, IOException {
                // Trace message
-               this.getLogger().trace("CALLED!"); //NOI18N
+               this.getLogger().logTrace("CALLED!"); //NOI18N
 
                // Is own contact already added?
                if (this.isOwnContactAdded()) {
@@ -311,7 +317,7 @@ public class AddressbookContactManager extends BaseManager implements Manageable
                }
 
                // Trace message
-               this.getLogger().trace("EXIT!"); //NOI18N
+               this.getLogger().logTrace("EXIT!"); //NOI18N
        }
 
        @Override
@@ -333,13 +339,13 @@ public class AddressbookContactManager extends BaseManager implements Manageable
        @Override
        public void doShutdown () throws SQLException, IOException {
                // Trace message
-               this.getLogger().trace("CALLED!"); //NOI18N
+               this.getLogger().logTrace("CALLED!"); //NOI18N
 
                // Shut down the database layer
                ((AddressbookContactFrontend) this.getFrontend()).doShutdown();
 
                // Trace message
-               this.getLogger().trace("EXIT!"); //NOI18N
+               this.getLogger().logTrace("EXIT!"); //NOI18N
        }
 
        /**
@@ -350,7 +356,7 @@ public class AddressbookContactManager extends BaseManager implements Manageable
        @Override
        public String enterOwnCellNumber () {
                // Trace message
-               this.getLogger().trace("CALLED!"); //NOI18N
+               this.getLogger().logTrace("CALLED!"); //NOI18N
 
                // Get and cast client instance
                AddressbookClient client = (AddressbookClient) this.getClient();
@@ -366,7 +372,7 @@ public class AddressbookContactManager extends BaseManager implements Manageable
        @Override
        public String enterOwnCity () {
                // Trace message
-               this.getLogger().trace("CALLED!"); //NOI18N
+               this.getLogger().logTrace("CALLED!"); //NOI18N
 
                // Get and cast client instance
                AddressbookClient client = (AddressbookClient) this.getClient();
@@ -382,7 +388,7 @@ public class AddressbookContactManager extends BaseManager implements Manageable
        @Override
        public String enterOwnComment () {
                // Trace message
-               this.getLogger().trace("CALLED!"); //NOI18N
+               this.getLogger().logTrace("CALLED!"); //NOI18N
 
                // Get and cast client instance
                AddressbookClient client = (AddressbookClient) this.getClient();
@@ -398,7 +404,7 @@ public class AddressbookContactManager extends BaseManager implements Manageable
        @Override
        public String enterOwnCompanyName () {
                // Trace message
-               this.getLogger().trace("CALLED!"); //NOI18N
+               this.getLogger().logTrace("CALLED!"); //NOI18N
 
                // Get and cast client instance
                AddressbookClient client = (AddressbookClient) this.getClient();
@@ -414,7 +420,7 @@ public class AddressbookContactManager extends BaseManager implements Manageable
        @Override
        public String enterOwnCountryCode () {
                // Trace message
-               this.getLogger().trace("CALLED!"); //NOI18N
+               this.getLogger().logTrace("CALLED!"); //NOI18N
 
                // Get and cast client instance
                AddressbookClient client = (AddressbookClient) this.getClient();
@@ -430,7 +436,7 @@ public class AddressbookContactManager extends BaseManager implements Manageable
        @Override
        public String enterOwnEmailAddress () {
                // Trace message
-               this.getLogger().trace("CALLED!"); //NOI18N
+               this.getLogger().logTrace("CALLED!"); //NOI18N
 
                // Get and cast client instance
                AddressbookClient client = (AddressbookClient) this.getClient();
@@ -446,7 +452,7 @@ public class AddressbookContactManager extends BaseManager implements Manageable
        @Override
        public String enterOwnFamilyName () {
                // Trace message
-               this.getLogger().trace("CALLED!"); //NOI18N
+               this.getLogger().logTrace("CALLED!"); //NOI18N
 
                // Get and cast client instance
                AddressbookClient client = (AddressbookClient) this.getClient();
@@ -462,7 +468,7 @@ public class AddressbookContactManager extends BaseManager implements Manageable
        @Override
        public String enterOwnFaxNumber () {
                // Trace message
-               this.getLogger().trace("CALLED!"); //NOI18N
+               this.getLogger().logTrace("CALLED!"); //NOI18N
 
                // Get and cast client instance
                AddressbookClient client = (AddressbookClient) this.getClient();
@@ -478,7 +484,7 @@ public class AddressbookContactManager extends BaseManager implements Manageable
        @Override
        public String enterOwnFirstName () {
                // Trace message
-               this.getLogger().trace("CALLED!"); //NOI18N
+               this.getLogger().logTrace("CALLED!"); //NOI18N
 
                // Get and cast client instance
                AddressbookClient client = (AddressbookClient) this.getClient();
@@ -494,7 +500,7 @@ public class AddressbookContactManager extends BaseManager implements Manageable
        @Override
        public Gender enterOwnGender () {
                // Trace message
-               this.getLogger().trace("CALLED!"); //NOI18N
+               this.getLogger().logTrace("CALLED!"); //NOI18N
 
                // Get and cast client instance
                AddressbookClient client = (AddressbookClient) this.getClient();
@@ -510,7 +516,7 @@ public class AddressbookContactManager extends BaseManager implements Manageable
        @Override
        public String enterOwnPhoneNumber () {
                // Trace message
-               this.getLogger().trace("CALLED!"); //NOI18N
+               this.getLogger().logTrace("CALLED!"); //NOI18N
 
                // Get and cast client instance
                AddressbookClient client = (AddressbookClient) this.getClient();
@@ -526,7 +532,7 @@ public class AddressbookContactManager extends BaseManager implements Manageable
        @Override
        public String enterOwnStreet () {
                // Trace message
-               this.getLogger().trace("CALLED!"); //NOI18N
+               this.getLogger().logTrace("CALLED!"); //NOI18N
 
                // Get and cast client instance
                AddressbookClient client = (AddressbookClient) this.getClient();
@@ -542,7 +548,7 @@ public class AddressbookContactManager extends BaseManager implements Manageable
        @Override
        public int enterOwnZipCode () {
                // Trace message
-               this.getLogger().trace("CALLED!"); //NOI18N
+               this.getLogger().logTrace("CALLED!"); //NOI18N
 
                // Get and cast client instance
                AddressbookClient client = (AddressbookClient) this.getClient();
@@ -576,18 +582,18 @@ public class AddressbookContactManager extends BaseManager implements Manageable
        @Override
        public Object getValueFromRowColumn (final int rowIndex, final int columnIndex) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
                // Trace message
-               this.getLogger().trace(MessageFormat.format("rowIndex={0},columnIndex={1} CALLED!", rowIndex, columnIndex)); //NOI18N
+               this.getLogger().logTrace(MessageFormat.format("rowIndex={0},columnIndex={1} CALLED!", rowIndex, columnIndex)); //NOI18N
 
                // Then get specific row from database which is a Contact instance
                Storable storable = this.getFrontend().getStorableAtRow(rowIndex);
 
                // Debug message
-               this.getLogger().debug(MessageFormat.format("storable={0}", storable)); //NOI18N
+               this.getLogger().logDebug(MessageFormat.format("storable={0}", storable)); //NOI18N
 
                // It may return null
                if (null == storable) {
                        // Nothing found
-                       this.getLogger().warn("contact is null - returning null ..."); //NOI18N
+                       this.getLogger().logWarning("contact is null - returning null ..."); //NOI18N
                        return null;
                }
 
@@ -595,7 +601,7 @@ public class AddressbookContactManager extends BaseManager implements Manageable
                String columnName = this.getColumnName(columnIndex);
 
                // Debug message
-               this.getLogger().debug(MessageFormat.format("columnName={0}", columnName)); //NOI18N
+               this.getLogger().logDebug(MessageFormat.format("columnName={0}", columnName)); //NOI18N
 
                // Now get that column
                Object value = null;
@@ -606,7 +612,7 @@ public class AddressbookContactManager extends BaseManager implements Manageable
                }
 
                // Trace message
-               this.getLogger().trace(MessageFormat.format("value={0} - EXIT!", value)); //NOI18N
+               this.getLogger().logTrace(MessageFormat.format("value={0} - EXIT!", value)); //NOI18N
 
                // Return it
                return value;
@@ -621,7 +627,7 @@ public class AddressbookContactManager extends BaseManager implements Manageable
        @Override
        public boolean isOwnContactAdded () throws IOException {
                // Trace message
-               this.getLogger().trace("CALLED!"); //NOI18N
+               this.getLogger().logTrace("CALLED!"); //NOI18N
 
                // Init variable
                boolean isAdded = false;
@@ -635,12 +641,17 @@ public class AddressbookContactManager extends BaseManager implements Manageable
                }
 
                // Trace message
-               this.getLogger().trace(MessageFormat.format("isAdded={0} : EXIT!", isAdded)); //NOI18N
+               this.getLogger().logTrace(MessageFormat.format("isAdded={0} : EXIT!", isAdded)); //NOI18N
 
                // Return result
                return isAdded;
        }
 
+       @Override
+       public void logException (final Throwable exception) {
+               this.getLogger().logException(exception);
+       }
+
        /**
         * Adds given contact to address book and flushes all entries to database
         * <p>
@@ -649,7 +660,7 @@ public class AddressbookContactManager extends BaseManager implements Manageable
        @Override
        public void registerContact (final Contact contact) {
                // Trace message
-               this.getLogger().trace(MessageFormat.format("contact={0} CALLED!", contact)); //NOI18N
+               this.getLogger().logTrace(MessageFormat.format("contact={0} CALLED!", contact)); //NOI18N
 
                // Sanity check
                if (null == contact) {
@@ -657,12 +668,6 @@ public class AddressbookContactManager extends BaseManager implements Manageable
                        throw new NullPointerException("contact is null"); //NOI18N
                }
                try {
-
-                       // Debug message
-                       /*
-                        * NOISY-DEBUG:
-                        */ this.getLogger().debug(MessageFormat.format("Adding '{0}' '{1}' at pos '{2}' ...", contact.getFirstName(), contact.getFamilyName(), this.size())); //NOI18N
-
                        // Check if contact is found
                        if (((AddressbookContactFrontend) this.getFrontend()).isContactFound(contact)) {
                                // Contact already added
@@ -680,7 +685,20 @@ public class AddressbookContactManager extends BaseManager implements Manageable
                }
 
                // Trace message
-               this.getLogger().trace("EXIT!"); //NOI18N
+               this.getLogger().logTrace("EXIT!"); //NOI18N
+       }
+
+       /**
+        * Logs given exception and exits program
+        *
+        * @param throwable Throwable
+        */
+       private void abortProgramWithException (Throwable throwable) {
+               // Log exception
+               this.logException(throwable);
+
+               // Abort here
+               System.exit(1);
        }
 
        /**
@@ -691,7 +709,7 @@ public class AddressbookContactManager extends BaseManager implements Manageable
                assert (this.translatedColumnNames instanceof List) : "this.translatedColumnNames is not initialized"; //NOI18N
 
                // Debug message
-               this.getLogger().trace("CALLED!"); //NOI18N
+               this.getLogger().logTrace("CALLED!"); //NOI18N
 
                // First get an iterator from key set to iterate over
                Iterator<String> iterator = this.getBundle().keySet().iterator();
@@ -704,7 +722,7 @@ public class AddressbookContactManager extends BaseManager implements Manageable
                        // Does the key start with AddressbookContactManager.columnName ?
                        if (key.startsWith("ContactManager.columnName")) { //NOI18N
                                // This is the wanted entry.
-                               this.getLogger().debug(MessageFormat.format("key={0}", key)); //NOI18N
+                               this.getLogger().logDebug(MessageFormat.format("key={0}", key)); //NOI18N
 
                                // Convert string to array based on delimiter '.'
                                String[] tokens = this.getArrayFromString(key, "."); //NOI18N
@@ -716,7 +734,7 @@ public class AddressbookContactManager extends BaseManager implements Manageable
                                String columnName = tokens[tokens.length - 2];
 
                                // Debug message
-                               this.getLogger().debug(MessageFormat.format("columnName={0} - adding ...", columnName)); //NOI18N
+                               this.getLogger().logDebug(MessageFormat.format("columnName={0} - adding ...", columnName)); //NOI18N
 
                                // So add it
                                this.columnNames.add(columnName);
@@ -725,7 +743,16 @@ public class AddressbookContactManager extends BaseManager implements Manageable
                }
 
                // Debug message
-               this.getLogger().trace(MessageFormat.format("getColumnCount()={0}: EXIT!", this.getColumnCount())); //NOI18N
+               this.getLogger().logTrace(MessageFormat.format("getColumnCount()={0}: EXIT!", this.getColumnCount())); //NOI18N
+       }
+
+       /**
+        * Getter for logger instance
+        *
+        * @return Logger instance
+        */
+       private LoggerBeanLocal getLogger () {
+               return this.logger;
        }
 
        /**
@@ -740,13 +767,13 @@ public class AddressbookContactManager extends BaseManager implements Manageable
         */
        private Contact getOwnContact () throws IOException, SQLException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
                // Trace message
-               this.getLogger().trace("CALLED!"); //NOI18N
+               this.getLogger().logTrace("CALLED!"); //NOI18N
 
                // Deligate this call to database frontend
                Contact contact = ((AddressbookContactFrontend) this.getFrontend()).getOwnContact();
 
                // Trace message
-               this.getLogger().trace(MessageFormat.format("contact={0} - EXIT!", contact)); //NOI18N
+               this.getLogger().logTrace(MessageFormat.format("contact={0} - EXIT!", contact)); //NOI18N
 
                // Return instance or null
                return contact;
index c939abd348f8a1ebbf993cb3a33977155aecbb27..8ef43f4ce3bdb430ab1fb3ee3113af519d6d3a83 100644 (file)
@@ -18,7 +18,6 @@ package org.mxchange.addressbook.menu;
 
 import java.text.MessageFormat;
 import java.util.List;
-import org.apache.logging.log4j.Logger;
 import org.mxchange.addressbook.client.AddressbookClient;
 import org.mxchange.addressbook.menu.item.SelectableMenuItem;
 import org.mxchange.jcore.client.Client;
@@ -38,12 +37,6 @@ public class AddressbookMenu extends BaseMenu {
         * @param client Client instance to call back
         */
        public static void addItemsToList (final List<SelectableMenuItem> menuList, final String menuType, final Client client) {
-               // Get logger
-               Logger log = new AddressbookMenu().getLogger();
-
-               // Trace call
-               log.trace(MessageFormat.format("menuList={0},menuType={1},client={2} - CALLED!", menuList, menuType, client)); //NOI18N
-
                // Some instances must be set
                if (null == menuList) {
                        // Abort here
@@ -62,9 +55,6 @@ public class AddressbookMenu extends BaseMenu {
                // Get list size
                int size = menuList.size();
 
-               // Debug message
-               log.debug(MessageFormat.format("Adding menu for '{0}' (old size: '{1}') ...", menuType, size)); //NOI18N
-
                // Depends on type
                switch (menuType) {
                        case "main": // Main menu //NOI18N
@@ -94,7 +84,7 @@ public class AddressbookMenu extends BaseMenu {
                                break;
 
                        default: // Not supported
-                               log.error(MessageFormat.format("Menu type '{0}' ont supported", menuType)); //NOI18N
+                               System.err.println(MessageFormat.format("Menu type '{0}' ont supported", menuType)); //NOI18N
                                System.exit(1);
                }
 
index a02c885136f9d6911c7fc03130ba54ef7d375b12..ad8c2e593884b7f4313b83f9cc686cbed5aacbcb 100644 (file)
@@ -20,16 +20,15 @@ import java.text.MessageFormat;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
-import org.mxchange.addressbook.client.AddressbookClient;
+import org.mxchange.addressbook.BaseAddressbookSystem;
 import org.mxchange.addressbook.menu.item.SelectableMenuItem;
-import org.mxchange.jcore.BaseFrameworkSystem;
 import org.mxchange.jcore.client.Client;
 
 /**
  *
  * @author Roland Haeder
  */
-public class BaseMenu extends BaseFrameworkSystem {
+public class BaseMenu extends BaseAddressbookSystem {
 
        /**
         * Menu list
@@ -67,7 +66,7 @@ public class BaseMenu extends BaseFrameworkSystem {
         */
        public void show (final Client client) {
                // Trace message
-               this.getLogger().trace(MessageFormat.format("client={0} CALLED!", client)); //NOI18N
+               this.getLogger().logTrace(MessageFormat.format("client={0} CALLED!", client)); //NOI18N
 
                // Client must not be null
                if (null == client) {
@@ -79,7 +78,7 @@ public class BaseMenu extends BaseFrameworkSystem {
                Iterator<SelectableMenuItem> iterator = this.menuList.iterator();
 
                // Debug message
-               this.getLogger().debug("Showing menu with '" + this.menuList.size() + "' entries.");
+               this.getLogger().logDebug("Showing menu with '" + this.menuList.size() + "' entries.");
 
                // Output all menus
                while (iterator.hasNext()) {
@@ -87,11 +86,11 @@ public class BaseMenu extends BaseFrameworkSystem {
                        SelectableMenuItem item = iterator.next();
 
                        // Show this item
-                       item.show((AddressbookClient) client);
+                       item.show(client);
                }
 
                // Trace message
-               this.getLogger().trace("EXIT!"); //NOI18N
+               this.getLogger().logTrace("EXIT!"); //NOI18N
        }
 
        /**
@@ -111,12 +110,12 @@ public class BaseMenu extends BaseFrameworkSystem {
         */
        protected void initMenu (final String menuType, final Client client) {
                // Trace message
-               this.getLogger().trace(MessageFormat.format("menuType={0},client={1} - CALLED!", menuType, client)); //NOI18N
+               this.getLogger().logTrace(MessageFormat.format("menuType={0},client={1} - CALLED!", menuType, client)); //NOI18N
 
                // Init menu list
                this.menuList = new ArrayList<>(5);
 
                // Trace message
-               this.getLogger().trace("EXIT!"); //NOI18N
+               this.getLogger().logTrace("EXIT!"); //NOI18N
        }
 }
index 943962d09f3d44e321468c5b923abe9ec0bd6c2f..54d7c968e9d113b48694cba0d2fb95ca94307825 100644 (file)
  */
 package org.mxchange.addressbook.menu;
 
+import java.text.MessageFormat;
 import java.util.Iterator;
 import java.util.Map;
-import org.apache.logging.log4j.Logger;
+import org.mxchange.addressbook.BaseAddressbookSystem;
 import org.mxchange.addressbook.menu.item.SelectableMenuItem;
-import org.mxchange.jcore.BaseFrameworkSystem;
 
 /**
+ * Menu utilities
  *
  * @author Roland Haeder
  */
-public class MenuTools extends BaseFrameworkSystem {
+public class MenuTools extends BaseAddressbookSystem {
 
        /**
         * Gets an array with all available access keys back from given menu map.
@@ -37,9 +38,6 @@ public class MenuTools extends BaseFrameworkSystem {
         * @return An array with available access chars
         */
        public static char[] getAccessKeysFromMenuMap (final Map<String, Menu> menus, final String menuType) {
-               // Get logger
-               Logger logger = new MenuTools().getLogger();
-
                // First search for the proper menu class
                Menu menu = menus.get(menuType);
 
@@ -47,7 +45,7 @@ public class MenuTools extends BaseFrameworkSystem {
                if (!(menu instanceof Menu)) {
                        // Not found
                        // TODO Rewrite to exception
-                       logger.error("Menu '" + menuType + "' not found.");
+                       System.err.println(MessageFormat.format("menu is not implementing Menu: {0}", menu)); //NOI18N
                        System.exit(1);
                }
 
@@ -62,11 +60,11 @@ public class MenuTools extends BaseFrameworkSystem {
                while (iterator.hasNext()) {
                        // Get item
                        SelectableMenuItem item = iterator.next();
-                       //* NOISY-DEBUG: */ logger.debug("item=" + item);
+                       //* NOISY-DEBUG: */ logger.logDebug("item=" + item);
 
                        // Get access key from item and add it to the array
                        accessKeys[i] = item.getAccessKey();
-                       //* NOISY-DEBUG: */ logger.debug("accessKeys[" + i + "]=" + accessKeys[i]);
+                       //* NOISY-DEBUG: */ logger.logDebug("accessKeys[" + i + "]=" + accessKeys[i]);
 
                        // Increment counter
                        i++;
index e2b840cc532d1a29c426ba9f86aa18402d65489d..ad325cb752bc930063d9e32b013ee7bcfa22ad19 100644 (file)
@@ -36,7 +36,7 @@ public class ConsoleMenu extends BaseMenu implements Menu {
         */
        public ConsoleMenu (final String menuType, final Client client) {
                // Trace message
-               this.getLogger().trace(MessageFormat.format("menuType={0},client={1} - CALLED!", menuType, client)); //NOI18N
+               this.getLogger().logTrace(MessageFormat.format("menuType={0},client={1} - CALLED!", menuType, client)); //NOI18N
 
                // Client must not be null
                if (null == client) {
index a750aaf7a76dcaa944eab75445ed2d63895d257c..665923ef03b2101566e4d948eb5fe8c89a7dd41d 100644 (file)
  */
 package org.mxchange.addressbook.menu.item;
 
-import org.mxchange.jcore.BaseFrameworkSystem;
+import org.mxchange.addressbook.BaseAddressbookSystem;
 
 /**
+ * A general menu item class
  *
  * @author Roland Haeder
  */
-public class BaseMenuItem extends BaseFrameworkSystem {
+public class BaseMenuItem extends BaseAddressbookSystem {
 
 }
index f3cf4cc7056ccb7a30361f102d992f17c9c8a98c..28fa76bb95a038784d87c072eb320944f27c1e64 100644 (file)
  */
 package org.mxchange.addressbook.menu.item;
 
+import org.mxchange.jcore.FrameworkInterface;
 import org.mxchange.jcore.client.Client;
 
 /**
  *
  * @author Roland Haeder
  */
-public interface SelectableMenuItem {
+public interface SelectableMenuItem extends FrameworkInterface {
 
        /**
         * Shows this menu item
index 50f8500cffa1893911842f999d32f0e6a2d52343..fd008a9bb0c1864fc595fa1a41bf66db3ce05159 100644 (file)
@@ -90,7 +90,7 @@ public class ConsoleMenuItem extends BaseMenuItem implements SelectableMenuItem
        @Override
        public void show (final Client client) {
                // Trace message
-               this.getLogger().trace(MessageFormat.format("client={0} - CALLED!", client)); //NOI18N
+               this.getLogger().logTrace(MessageFormat.format("client={0} - CALLED!", client)); //NOI18N
 
                // Client must not be null
                if (null == client) {
@@ -108,7 +108,7 @@ public class ConsoleMenuItem extends BaseMenuItem implements SelectableMenuItem
                c.showEntry(this);
 
                // Trace message
-               this.getLogger().trace("EXIT!"); //NOI18N
+               this.getLogger().logTrace("EXIT!"); //NOI18N
        }
 
 }