${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
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
--- /dev/null
+/*
+ * 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);
+ }
+}
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.
*/
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();
*/
@Override
public void doBootstrap () {
- this.getLogger().debug("Initializing application ..."); //NOI18N
+ this.getLogger().logDebug("Initializing application ..."); //NOI18N
// Init client variable
Client client = null;
// 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();
this.getClient().enableIsRunning();
// Trace message
- this.getLogger().trace("EXIT!"); //NOI18N
+ this.getLogger().logTrace("EXIT!"); //NOI18N
}
/**
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
// Ask for user input and run proper method
client.doUserMenuChoice();
} catch (final UnhandledUserChoiceException ex) {
- this.getLogger().catching(ex);
+ this.getLogger().logException(ex);
}
try {
// --- Main loop ends here ---
// Debug message
- this.getLogger().debug("Main loop exit - shutting down ..."); //NOI18N
+ this.getLogger().logDebug("Main loop exit - shutting down ..."); //NOI18N
}
/**
@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;
}
* 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;
}
*/
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
*/
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
}
/**
* @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();
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);
}
}
* @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);
}
/**
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;
+ }
}
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
*/
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);
+ }
}
/**
*/
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
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
}
/**
*/
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);
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);
}
}
*/
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);
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) {
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) {
}
// 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) {
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) {
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) {
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) {
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();
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;
@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());
}
// 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) {
}
// 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;
@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();
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;
@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
}
// 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;
@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);
}
// 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;
@Override
public void init () {
// Trace message
- this.getLogger().trace("CALLED!"); //NOI18N
+ this.getLogger().logTrace("CALLED!"); //NOI18N
// Init contact manager here
try {
this.fillMenuMap();
// Trace message
- this.getLogger().trace("EXIT!"); //NOI18N
+ this.getLogger().logTrace("EXIT!"); //NOI18N
}
@Override
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) {
}
// Trace message
- this.getLogger().trace("EXIT!"); //NOI18N
+ this.getLogger().logTrace("EXIT!"); //NOI18N
}
/**
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) {
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;
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;
@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
this.getMenus().put("main", menu); //NOI18N
// Trace message
- this.getLogger().trace("EXIT!"); //NOI18N
+ this.getLogger().logTrace("EXIT!"); //NOI18N
}
}
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
*/
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();
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()) {
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;
@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
}
/**
@Override
public void enableMainWindow () {
// Trace message
- this.getLogger().trace("CALLED!"); //NOI18N
+ this.getLogger().logTrace("CALLED!"); //NOI18N
// Enable it again
this.frame.setEnabled(true);
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.
}
/**
@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);
this.updateStatus("done"); //NOI18N
// Trace message
- this.getLogger().trace("EXIT!"); //NOI18N
+ this.getLogger().logTrace("EXIT!"); //NOI18N
}
/**
@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()) {
this.initialized = true;
// Trace message
- this.getLogger().trace("EXIT!"); //NOI18N
+ this.getLogger().logTrace("EXIT!"); //NOI18N
}
/**
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;
}
}
// Trace message
- this.getLogger().trace("EXIT!"); //NOI18N
+ this.getLogger().logTrace("EXIT!"); //NOI18N
}
/**
*/
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);
menu.add(item);
// Trace message
- this.getLogger().trace("EXIT!"); //NOI18N
+ this.getLogger().logTrace("EXIT!"); //NOI18N
}
/**
*/
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
panel.add(field);
// Trace message
- this.getLogger().trace("EXIT!"); //NOI18N
+ this.getLogger().logTrace("EXIT!"); //NOI18N
}
/**
*/
private void initAddCancelButtons () {
// Trace message
- this.getLogger().trace("CALLED!"); //NOI18N
+ this.getLogger().logTrace("CALLED!"); //NOI18N
// Init panel
JPanel panel = new JPanel();
this.addContact.add(panel);
// Trace message
- this.getLogger().trace("EXIT!"); //NOI18N
+ this.getLogger().logTrace("EXIT!"); //NOI18N
}
/**
*/
private void initAddContactDialog () {
// Trace message
- this.getLogger().trace("CALLED!"); //NOI18N
+ this.getLogger().logTrace("CALLED!"); //NOI18N
// Instance dialog and set title
this.addContact = new JDialog();
*/ this.addContact.setVisible(true);
// Trace message
- this.getLogger().trace("EXIT!"); //NOI18N
+ this.getLogger().logTrace("EXIT!"); //NOI18N
}
/**
*/
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();
dialog.add(addressPanel);
// Trace message
- this.getLogger().trace("EXIT!"); //NOI18N
+ this.getLogger().logTrace("EXIT!"); //NOI18N
}
/**
*/
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);
this.initOtherDialogs();
// Trace message
- this.getLogger().trace("EXIT!"); //NOI18N
+ this.getLogger().logTrace("EXIT!"); //NOI18N
}
/**
*/
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;
*/
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();
this.frame.add(menuBar, BorderLayout.NORTH);
// Trace message
- this.getLogger().trace("EXIT!"); //NOI18N
+ this.getLogger().logTrace("EXIT!"); //NOI18N
}
/**
*/
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();
dialog.add(namePanel);
// Trace message
- this.getLogger().trace("EXIT!"); //NOI18N
+ this.getLogger().logTrace("EXIT!"); //NOI18N
}
/**
*/
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();
dialog.add(otherPanel);
// Trace message
- this.getLogger().trace("EXIT!"); //NOI18N
+ this.getLogger().logTrace("EXIT!"); //NOI18N
}
/**
*/
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
}
/**
*/
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();
this.frame.add(panel, BorderLayout.SOUTH);
// Trace message
- this.getLogger().trace("EXIT!"); //NOI18N
+ this.getLogger().logTrace("EXIT!"); //NOI18N
}
/**
*/
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());
this.frame.add(scroller, BorderLayout.CENTER);
// Trace message
- this.getLogger().trace("EXIT!"); //NOI18N
+ this.getLogger().logTrace("EXIT!"); //NOI18N
}
/**
*/
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
/**
* Class for "cancel address" button
*/
- private static class CancelActionListener extends BaseFrameworkSystem implements ActionListener {
+ private static class CancelActionListener extends BaseAddressbookSystem implements ActionListener {
/**
* Dialog instance
import org.mxchange.jcoreswing.client.gui.ClientFrame;
/**
+ * A swing client
*
* @author Roland Haeder
*/
*/
public SwingClient (final Application application) {
// Debug message
- this.getLogger().trace("CALLED!"); //NOI18N
+ this.getLogger().logTrace("CALLED!"); //NOI18N
// Set application instance
this.setApplication(application);
this.frame = AddressbookFrame.getSelfInstance(this);
// Trace message
- this.getLogger().trace("EXIT!"); //NOI18N
+ this.getLogger().logTrace("EXIT!"); //NOI18N
}
@Override
@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();
@Override
public void doShutdown () throws SQLException, IOException {
// Debug message
- this.getLogger().trace("CALLED!"); //NOI18N
+ this.getLogger().logTrace("CALLED!"); //NOI18N
// Parent call
super.doShutdown();
// 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
}
@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;
@Override
public void init () {
// Debug message
- this.getLogger().trace("CALLED!"); //NOI18N
+ this.getLogger().logTrace("CALLED!"); //NOI18N
try {
// Init contact manager here
}
// Debug message
- this.getLogger().trace("EXIT!"); //NOI18N
+ this.getLogger().logTrace("EXIT!"); //NOI18N
}
@Override
@Override
public void showCurrentMenu () {
// Debug message
- //* NOISY-DEBUG: */ this.getLogger().trace("CALLED!");
+ //* NOISY-DEBUG: */ this.getLogger().logTrace("CALLED!");
// Not implemented here
}
@Override
public void showWelcome () {
// Debug message
- this.getLogger().trace("CALLED!"); //NOI18N
+ this.getLogger().logTrace("CALLED!"); //NOI18N
// Not implemented here
}
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.
*/
private final List<String> translatedColumnNames;
+ /**
+ * Logger instance
+ */
+ private LoggerBeanLocal logger;
+
/**
* Constructor which accepts maxContacts for maximum (initial) contacts and
* a client instance.
*/
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) {
this.fillColumnNamesFromBundle();
// Debug message
- //* NOISY-DEBUG: */ this.getLogger().debug("client=" + client);
+ //* NOISY-DEBUG: */ this.getLogger().logDebug("client=" + client);
}
/**
@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) {
((AddressbookContactFrontend) this.getFrontend()).addContact(contact);
// Trace message
- this.getLogger().trace("EXIT!"); //NOI18N
+ this.getLogger().logTrace("EXIT!"); //NOI18N
}
/**
@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) {
}
// Trace message
- this.getLogger().trace("EXIT!"); //NOI18N
+ this.getLogger().logTrace("EXIT!"); //NOI18N
}
/**
@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) {
}
// Trace message
- this.getLogger().trace("EXIT!"); //NOI18N
+ this.getLogger().logTrace("EXIT!"); //NOI18N
}
/**
@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) {
}
// Trace message
- this.getLogger().trace("EXIT!"); //NOI18N
+ this.getLogger().logTrace("EXIT!"); //NOI18N
}
/**
@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
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();
// 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
}
/**
@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()) {
}
// Trace message
- this.getLogger().trace("EXIT!"); //NOI18N
+ this.getLogger().logTrace("EXIT!"); //NOI18N
}
@Override
@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
}
/**
@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();
@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();
@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();
@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();
@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();
@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();
@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();
@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();
@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();
@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();
@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();
@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();
@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();
@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;
}
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;
}
// 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;
@Override
public boolean isOwnContactAdded () throws IOException {
// Trace message
- this.getLogger().trace("CALLED!"); //NOI18N
+ this.getLogger().logTrace("CALLED!"); //NOI18N
// Init variable
boolean isAdded = false;
}
// 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>
@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) {
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
}
// 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);
}
/**
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();
// 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
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);
}
// 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;
}
/**
*/
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;
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;
* @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
// 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
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);
}
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
*/
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) {
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()) {
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
}
/**
*/
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
}
}
*/
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.
* @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);
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);
}
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++;
*/
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) {
*/
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 {
}
*/
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
@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) {
c.showEntry(this);
// Trace message
- this.getLogger().trace("EXIT!"); //NOI18N
+ this.getLogger().logTrace("EXIT!"); //NOI18N
}
}