package org.mxchange.addressbook.client.console;
import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
import java.sql.SQLException;
import java.text.MessageFormat;
import java.util.Arrays;
// Get manager and cast it
ContactFacade manager = (ContactFacade) this.getFacade();
- // Try it!
- try {
- // TODO Rewrite this ugly switch() block
- switch (choice) {
- case '1':
- try {
- // Enter/add own data
- manager.doEnterOwnData();
- } catch (final ContactAlreadyAddedException ex) {
- // Already added
- this.outputMessage("Sie haben bereits Ihre eigenen Daten eingegeben.");
- }
- break;
-
- case '2': // Change own data
- manager.doChangeOwnData();
- break;
-
- case '3': // Add new addess
- manager.doAddOtherAddress();
- break;
-
- case '4': // List contacts
- manager.doListContacts();
- break;
-
- case '5': // Search addresses
- manager.doSearchContacts();
- break;
-
- case '6': // Change other addess
- manager.doChangeOtherAddress();
- break;
-
- case '7': // Delete other address
- manager.doDeleteOtherAddress();
- break;
-
- case '0':
- try {
- // Program exit
- this.getApplication().doShutdown();
- } catch (final SQLException | IOException ex) {
- this.abortProgramWithException(ex);
- }
- break;
-
- default:
- // TODO throw own exception
- throw new UnhandledUserChoiceException(MessageFormat.format("Choice '{0}' not handled yet.", choice)); //NOI18N
- }
- } catch (final IOException | SQLException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
- // Something bad happened
- this.abortProgramWithException(ex);
+ // TODO Rewrite this ugly switch() block
+ switch (choice) {
+ case '1':
+ try {
+ // Enter/add own data
+ manager.doEnterOwnData();
+ } catch (final ContactAlreadyAddedException ex) {
+ // Already added
+ this.outputMessage("Sie haben bereits Ihre eigenen Daten eingegeben.");
+ }
+ break;
+
+ case '2': // Change own data
+ manager.doChangeOwnData();
+ break;
+
+ case '3': // Add new addess
+ manager.doAddOtherAddress();
+ break;
+
+ case '4': // List contacts
+ manager.doListContacts();
+ break;
+
+ case '5': // Search addresses
+ manager.doSearchContacts();
+ break;
+
+ case '6': // Change other addess
+ manager.doChangeOtherAddress();
+ break;
+
+ case '7': // Delete other address
+ manager.doDeleteOtherAddress();
+ break;
+
+ case '0':
+ try {
+ // Program exit
+ this.getApplication().doShutdown();
+ } catch (final SQLException | IOException ex) {
+ this.abortProgramWithException(ex);
+ }
+ break;
+
+ default:
+ // TODO throw own exception
+ throw new UnhandledUserChoiceException(MessageFormat.format("Choice '{0}' not handled yet.", choice)); //NOI18N
}
// Trace message
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
import java.sql.SQLException;
import java.text.MessageFormat;
import javax.swing.BorderFactory;
// Already added, log away
// TODO maybe output message here?
self.logException(ex);
- } catch (final IOException ex) {
- // Somethind bad happened here
- // TODO Output error message here?
}
}
});
*/
@Override
public void actionPerformed (final ActionEvent e) {
- try {
- ((ContactFacade) self.getClient().getFacade()).doChangeOwnData();
- } catch (final IOException | SQLException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
- self.logException(ex);
- }
+ ((ContactFacade) self.getClient().getFacade()).doChangeOwnData();
}
});