]> git.mxchange.org Git - jfinancials-swing.git/commitdiff
Continued:
authorRoland Haeder <roland@mxchange.org>
Wed, 30 Sep 2015 07:25:03 +0000 (09:25 +0200)
committerRoland Haeder <roland@mxchange.org>
Wed, 30 Sep 2015 07:26:06 +0000 (09:26 +0200)
- fixed some errors (not all)
- updated jars
Signed-off-by:Roland Häder <roland@mxchange.org>

13 files changed:
lib/jcore-logger-lib.jar
lib/jcore-swing.jar
lib/jcore.jar
src/org/mxchange/addressbook/BaseAddressbookSystem.java
src/org/mxchange/addressbook/application/AddressbookApplication.java
src/org/mxchange/addressbook/client/AddressbookClient.java
src/org/mxchange/addressbook/client/BaseAddressbookClient.java
src/org/mxchange/addressbook/client/console/ConsoleClient.java
src/org/mxchange/addressbook/client/gui/SwingClient.java
src/org/mxchange/addressbook/manager/contact/AddressbookContactManager.java
src/org/mxchange/addressbook/menu/BaseMenu.java
src/org/mxchange/addressbook/menu/Menu.java
src/org/mxchange/addressbook/menu/MenuTools.java

index e03e3ca7f07b8329c9394a969445845a637d6cb3..463d15b1a912757aca434cba7c2b1b3e7270e54b 100644 (file)
Binary files a/lib/jcore-logger-lib.jar and b/lib/jcore-logger-lib.jar differ
index 224efdf7f20ff51381fa6924d96d1004ef09eb1b..bcf9b93079c88d93034bb5b39be2ae8e5c77b143 100644 (file)
Binary files a/lib/jcore-swing.jar and b/lib/jcore-swing.jar differ
index af5610d8249b2810fa4e15fbf2d0d48adaaba8dc..848bebf4503c8caeeb9557874ffa4a124337d3fb 100644 (file)
Binary files a/lib/jcore.jar and b/lib/jcore.jar differ
index 90674c725f1520da060d543f13eff75f24b48fee..6f4ec4ac64909598d09d2dfcb61a4b472db9c7a0 100644 (file)
@@ -20,11 +20,12 @@ import javax.naming.Context;
 import javax.naming.InitialContext;
 import javax.naming.NamingException;
 import org.mxchange.jcore.BaseFrameworkSystem;
+import org.mxchange.jcoreeelogger.beans.local.logger.Log;
 import org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal;
 
 /**
  * A general addressbook class
- *
+ * <p>
  * @author Roland Haeder
  */
 public abstract class BaseAddressbookSystem extends BaseFrameworkSystem {
@@ -32,6 +33,7 @@ public abstract class BaseAddressbookSystem extends BaseFrameworkSystem {
        /**
         * Logger instance
         */
+       @Log
        private LoggerBeanLocal logger;
 
        /**
@@ -41,7 +43,7 @@ public abstract class BaseAddressbookSystem extends BaseFrameworkSystem {
                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) {
@@ -52,7 +54,7 @@ public abstract class BaseAddressbookSystem extends BaseFrameworkSystem {
 
        /**
         * Getter for logger instance
-        *
+        * <p>
         * @return Logger instance
         */
        protected LoggerBeanLocal getLogger () {
@@ -61,7 +63,7 @@ public abstract class BaseAddressbookSystem extends BaseFrameworkSystem {
 
        /**
         * Logs given exception
-        *
+        * <p>
         * @param exception Throwable
         */
        protected void logException (final Throwable exception) {
@@ -70,7 +72,7 @@ public abstract class BaseAddressbookSystem extends BaseFrameworkSystem {
 
        /**
         * Log exception and abort program.
-        *
+        * <p>
         * @param throwable Throwable
         */
        protected void abortProgramWithException (final Throwable throwable) {
index 2859e5ca11c5feb02c19190c9f8b5b78c32c4be7..4f07e31ebd8b103eeea7b08d1de9ee944d6bf3e7 100644 (file)
@@ -19,14 +19,19 @@ package org.mxchange.addressbook.application;
 import java.io.IOException;
 import java.sql.SQLException;
 import java.text.MessageFormat;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
 import org.mxchange.addressbook.client.AddressbookClient;
 import org.mxchange.addressbook.client.console.ConsoleClient;
 import org.mxchange.addressbook.client.gui.SwingClient;
 import org.mxchange.jcore.application.Application;
 import org.mxchange.jcore.application.BaseApplication;
 import org.mxchange.jcore.client.Client;
+import org.mxchange.jcore.exceptions.MenuInitializationException;
 import org.mxchange.jcore.exceptions.UnhandledUserChoiceException;
 import org.mxchange.jcore.manager.application.ApplicationManager;
+import org.mxchange.jcoreeelogger.beans.local.logger.Log;
 import org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal;
 
 /**
@@ -60,21 +65,30 @@ public class AddressbookApplication extends BaseApplication implements Applicati
        /**
         * Logger instance
         */
+       @Log
        private LoggerBeanLocal logger;
 
        /**
         * Protected constructor
         */
        protected AddressbookApplication () {
-               // Init properties file
-               this.initProperties();
+               // Try this
+               try {
+                       // Get context
+                       Context context = new InitialContext();
 
-               // Is the bundle initialized?
-               if (!isBundledInitialized()) {
-                       // Temporary initialize default bundle
-                       // TODO The enum Gender uses this
-                       this.initBundle();
+                       // Get logger
+                       this.logger = (LoggerBeanLocal) context.lookup("java:global/jcore-logger-ejb/logger!org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal");
+               } catch (final NamingException ex) {
+                       // Output it and exit
+                       System.err.println(MessageFormat.format("Cannot initialize: {0}", ex));
+
+                       // Abort here
+                       System.exit(1);
                }
+
+               // Call init method
+               this.init();
        }
 
        /**
@@ -132,7 +146,7 @@ public class AddressbookApplication extends BaseApplication implements Applicati
         * Main loop of the application
         */
        @Override
-       public void doMainLoop () {
+       public void doMainLoop () throws MenuInitializationException {
                // Get client and cast it
                AddressbookClient client = (AddressbookClient) this.getClient();
 
@@ -155,6 +169,7 @@ public class AddressbookApplication extends BaseApplication implements Applicati
                                // Ask for user input and run proper method
                                client.doUserMenuChoice();
                        } catch (final UnhandledUserChoiceException ex) {
+                               // Log exception
                                this.getLogger().logException(ex);
                        }
 
@@ -182,10 +197,32 @@ public class AddressbookApplication extends BaseApplication implements Applicati
                // Shutdown client
                this.getClient().doShutdown();
 
+               // Regular exit reached
                this.getLogger().logInfo("End of program (last line)"); //NOI18N
                System.exit(0);
        }
 
+       /**
+        * Initializes this application
+        */
+       private void init () {
+               // Try this
+               try {
+                       // Init properties file
+                       this.initProperties();
+               } catch (final IOException ex) {
+                       // Abort here
+                       this.abortProgramWithException(ex);
+               }
+
+               // Is the bundle initialized?
+               if (!isBundledInitialized()) {
+                       // Temporary initialize default bundle
+                       // TODO The enum Gender uses this
+                       this.initBundle();
+               }
+       }
+
        /**
         * Logs given exception
         *
@@ -312,8 +349,13 @@ public class AddressbookApplication extends BaseApplication implements Applicati
                // Parse arguments
                this.parseArguments(args);
 
-               // Launch application
-               ApplicationManager.getSingeltonManager(this).start();
+               try {
+                       // Launch application
+                       ApplicationManager.getSingeltonManager(this).start();
+               } catch (final MenuInitializationException ex) {
+                       // Something bad happened
+                       this.abortProgramWithException(ex);
+               }
 
                // Good bye, but this should not be reached ...
                this.getLogger().logWarning("Unusual exit reached."); //NOI18N
index e884edb7b4d3011cd70e06056b3205500400899a..c53c27d2c79168f4545ff4331d84318c9b8889e9 100644 (file)
@@ -16,6 +16,7 @@
  */
 package org.mxchange.addressbook.client;
 
+import org.mxchange.jcore.exceptions.MenuInitializationException;
 import org.mxchange.addressbook.menu.item.SelectableMenuItem;
 import org.mxchange.jcore.client.Client;
 import org.mxchange.jcore.exceptions.UnhandledUserChoiceException;
@@ -78,8 +79,9 @@ public interface AddressbookClient extends Client {
         * Asks the user for a choice and proceeds accordingly
         * <p>
         * @throws UnhandledUserChoiceException If choice is not supported
+        * @throws org.mxchange.jcore.exceptions.MenuInitializationException If the menu cannot be initialized
         */
-       public void doUserMenuChoice () throws UnhandledUserChoiceException;
+       public void doUserMenuChoice () throws UnhandledUserChoiceException, MenuInitializationException;
 
        /**
         * Asks the the user to enter a single character which must match validChars
index 094d0ecee9a485b2d3369cbbb86dfc1658b0a0fd..00a55bdc0ba512578a46213387951e4068dc454f 100644 (file)
@@ -28,6 +28,7 @@ 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.Log;
 import org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal;
 
 /**
@@ -50,6 +51,7 @@ public abstract class BaseAddressbookClient extends BaseClient implements Addres
        /**
         * Logger instance
         */
+       @Log
        private LoggerBeanLocal logger;
 
        /**
index 5deface1b526c4c01d336563c8f9adfc89f16f01..b01739eee7226ac4354f94d8a5fff0abf9154502 100644 (file)
@@ -26,6 +26,7 @@ import org.mxchange.addressbook.application.AddressbookApplication;
 import org.mxchange.addressbook.client.AddressbookClient;
 import org.mxchange.addressbook.client.BaseAddressbookClient;
 import org.mxchange.addressbook.exceptions.ContactAlreadyAddedException;
+import org.mxchange.jcore.exceptions.MenuInitializationException;
 import org.mxchange.addressbook.manager.contact.ManageableContactAddressbook;
 import org.mxchange.addressbook.menu.Menu;
 import org.mxchange.addressbook.menu.MenuTools;
@@ -311,7 +312,7 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC
        }
 
        @Override
-       public void doUserMenuChoice () throws UnhandledUserChoiceException {
+       public void doUserMenuChoice () throws UnhandledUserChoiceException, MenuInitializationException {
                // Trace message
                this.getLogger().logTrace("CALLED!"); //NOI18N
 
@@ -530,6 +531,11 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC
                System.out.println(message);
        }
 
+       @Override
+       public void show (final Contact contact) {
+               throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+       }
+
        @Override
        public void showCurrentMenu () {
                this.showMenu(this.getCurrentMenu());
index d2316ce83646042c78604b8ff27fa82f8b8f8732..8d91d075abb948656aa4b504e3b3f9ad588eaafc 100644 (file)
@@ -197,6 +197,11 @@ public class SwingClient extends BaseAddressbookClient implements AddressbookCli
                throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //NOI18N
        }
 
+       @Override
+       public void show (final Contact contact) {
+               throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+       }
+
        @Override
        public void showCurrentMenu () {
                // Debug message
index beafc29e5a20f918ac0fd9edbb9b2969cebc2458..d5833c45921a99f542344ad719d7ecec7ae4e44e 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.Log;
 import org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal;
 
 /**
@@ -54,6 +55,7 @@ public class AddressbookContactManager extends BaseManager implements Manageable
        /**
         * Logger instance
         */
+       @Log
        private LoggerBeanLocal logger;
 
        /**
@@ -647,8 +649,12 @@ public class AddressbookContactManager extends BaseManager implements Manageable
                return isAdded;
        }
 
-       @Override
-       public void logException (final Throwable exception) {
+       /**
+        * Logs given exception
+        * <p>
+        * @param exception Throwable
+        */
+       protected void logException (final Throwable exception) {
                this.getLogger().logException(exception);
        }
 
index ad8c2e593884b7f4313b83f9cc686cbed5aacbcb..019c8e03b4778fdd8395100a7828f2bd27d672ef 100644 (file)
@@ -25,10 +25,11 @@ import org.mxchange.addressbook.menu.item.SelectableMenuItem;
 import org.mxchange.jcore.client.Client;
 
 /**
+ * A general menu class
  *
  * @author Roland Haeder
  */
-public class BaseMenu extends BaseAddressbookSystem {
+public abstract class BaseMenu extends BaseAddressbookSystem {
 
        /**
         * Menu list
index e027a47a270d5c2f050f6b843f713059318e23b5..909d2ef2fbf251f03ab3ae96b6fb7b1426d3a2c3 100644 (file)
@@ -21,7 +21,8 @@ import org.mxchange.addressbook.menu.item.SelectableMenuItem;
 import org.mxchange.jcore.client.Client;
 
 /**
- *
+ * An interface for menus
+ * <p>
  * @author Roland Haeder TODO find better name
  */
 public interface Menu {
index 54d7c968e9d113b48694cba0d2fb95ca94307825..9f424755423583db5a98ef321dcb5fd77d6eaaf0 100644 (file)
  */
 package org.mxchange.addressbook.menu;
 
-import java.text.MessageFormat;
 import java.util.Iterator;
 import java.util.Map;
 import org.mxchange.addressbook.BaseAddressbookSystem;
 import org.mxchange.addressbook.menu.item.SelectableMenuItem;
+import org.mxchange.jcore.exceptions.MenuInitializationException;
 
 /**
  * Menu utilities
@@ -36,17 +36,16 @@ public class MenuTools extends BaseAddressbookSystem {
         * @param menus A Map with all menus and their entries
         * @param menuType Menu type
         * @return An array with available access chars
+        * @throws org.mxchange.jcore.exceptions.MenuInitializationException If the menu cannot be initialized
         */
-       public static char[] getAccessKeysFromMenuMap (final Map<String, Menu> menus, final String menuType) {
+       public static char[] getAccessKeysFromMenuMap (final Map<String, Menu> menus, final String menuType) throws MenuInitializationException {
                // First search for the proper menu class
                Menu menu = menus.get(menuType);
 
                // Is it there?
                if (!(menu instanceof Menu)) {
                        // Not found
-                       // TODO Rewrite to exception
-                       System.err.println(MessageFormat.format("menu is not implementing Menu: {0}", menu)); //NOI18N
-                       System.exit(1);
+                       throw new MenuInitializationException(menu, menuType);
                }
 
                // Get iterator