]> git.mxchange.org Git - jaddressbook-lib.git/blobdiff - Addressbook/src/org/mxchange/addressbook/client/gui/AddressbookFrame.java
Added more thrown exceptions or catch them.
[jaddressbook-lib.git] / Addressbook / src / org / mxchange / addressbook / client / gui / AddressbookFrame.java
index 7a72c690b6babaa807e0d7abf28fa6126c952d30..8661516a33c291bb518c748640fc96a2fb212853 100644 (file)
@@ -24,6 +24,8 @@ import java.awt.event.MouseAdapter;
 import java.awt.event.MouseEvent;
 import java.awt.event.WindowAdapter;
 import java.awt.event.WindowEvent;
+import java.io.IOException;
+import java.sql.SQLException;
 import java.text.MessageFormat;
 import javax.swing.BorderFactory;
 import javax.swing.BoxLayout;
@@ -46,13 +48,14 @@ import javax.swing.border.TitledBorder;
 import javax.swing.table.TableModel;
 import org.mxchange.addressbook.BaseAddressbookSystem;
 import org.mxchange.addressbook.application.AddressbookApplication;
-import org.mxchange.jcore.contact.Contact;
-import org.mxchange.jcore.contact.Gender;
 import org.mxchange.addressbook.exceptions.ContactAlreadyAddedException;
-import org.mxchange.addressbook.manager.contact.ManageableContact;
-import org.mxchange.addressbook.model.contact.ContactTableModel;
+import org.mxchange.addressbook.manager.contact.ManageableAddressbookContact;
 import org.mxchange.jcore.client.Client;
+import org.mxchange.jcore.client.gui.ClientFrame;
+import org.mxchange.jcore.contact.Contact;
+import org.mxchange.jcore.contact.Gender;
 import org.mxchange.jcore.exceptions.FrameAlreadyInitializedException;
+import org.mxchange.jcore.model.swing.contact.ContactTableModel;
 
 /**
  *
@@ -211,7 +214,7 @@ public class AddressbookFrame extends BaseAddressbookSystem implements ClientFra
                this.getLogger().trace(MessageFormat.format("client={0}: CALLED!", client)); //NOI18N
 
                // Get and cast manager instance
-               ManageableContact manager = (ManageableContact) this.getClient().getManager();
+               ManageableAddressbookContact manager = (ManageableAddressbookContact) this.getClient().getManager();
 
                // Has the user entered own data?
                if (manager.isOwnContactAdded()) {
@@ -241,7 +244,7 @@ public class AddressbookFrame extends BaseAddressbookSystem implements ClientFra
         * you may not want.
         *
         * @throws
-        * org.mxchange.addressbook.exceptions.FrameAlreadyInitializedException If
+        * org.mxchange.jcore.exceptions.FrameAlreadyInitializedException If
         * this method has been called twice
         */
        @Override
@@ -292,12 +295,41 @@ public class AddressbookFrame extends BaseAddressbookSystem implements ClientFra
                }
 
                // Call shutdown method
-               this.getClient().getApplication().doShutdown();
+               try {
+                       this.getClient().getApplication().doShutdown();
+               } catch (final SQLException | IOException ex) {
+                       // Abort here
+                       this.abortProgramWithException(ex);
+               }
 
                // Trace message
                this.getLogger().trace("EXIT!"); //NOI18N
        }
 
+       /**
+        * Adds a new menu item with given key to menu instance
+        *
+        * @param menu Menu instance to add item to
+        * @param key Message key part
+        * @param listener Listener instance
+        */
+       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
+               
+               // New instance
+               JMenuItem item = this.initMenuItemWithTooltip(key);
+               
+               // Add listener
+               item.addActionListener(listener);
+               
+               // Add item -> menu
+               menu.add(item);
+               
+               // Trace message
+               this.getLogger().trace("EXIT!"); //NOI18N
+       }
+
        /**
         * Adds a JTextField with label and tool tip to given panel
         *
@@ -644,7 +676,7 @@ public class AddressbookFrame extends BaseAddressbookSystem implements ClientFra
                        @Override
                        public void actionPerformed (final ActionEvent e) {
                                try {
-                                       ManageableContact manager = (ManageableContact) self.getClient().getManager();
+                                       ManageableAddressbookContact manager = (ManageableAddressbookContact) self.getClient().getManager();
                                        manager.doEnterOwnData();
                                } catch (final ContactAlreadyAddedException ex) {
                                        // Already added, log away
@@ -669,7 +701,7 @@ public class AddressbookFrame extends BaseAddressbookSystem implements ClientFra
                         */
                        @Override
                        public void actionPerformed (final ActionEvent e) {
-                               ManageableContact manager = (ManageableContact) self.getClient().getManager();
+                               ManageableAddressbookContact manager = (ManageableAddressbookContact) self.getClient().getManager();
                                manager.doChangeOwnData();
                        }
                });
@@ -687,7 +719,7 @@ public class AddressbookFrame extends BaseAddressbookSystem implements ClientFra
                         */
                        @Override
                        public void actionPerformed (final ActionEvent e) {
-                               ManageableContact manager = (ManageableContact) self.getClient().getManager();
+                               ManageableAddressbookContact manager = (ManageableAddressbookContact) self.getClient().getManager();
                                manager.doAddOtherAddress();
                        }
                });
@@ -702,30 +734,6 @@ public class AddressbookFrame extends BaseAddressbookSystem implements ClientFra
                this.getLogger().trace("EXIT!"); //NOI18N
        }
 
-       /**
-        * Adds a new menu item with given key to menu instance
-        *
-        * @param menu Menu instance to add item to
-        * @param key Message key part
-        * @param listener Listener instance
-        */
-       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
-
-               // New instance
-               JMenuItem item = this.initMenuItemWithTooltip(key);
-
-               // Add listener
-               item.addActionListener(listener);
-
-               // Add item -> menu
-               menu.add(item);
-
-               // Trace message
-               this.getLogger().trace("EXIT!"); //NOI18N
-       }
-
        /**
         * Initializes name panel
         *