From 7d312c5c4ba26a03e0a886d237376065f4e2f0cb Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Fri, 7 Aug 2015 08:32:47 +0200 Subject: [PATCH] =?utf8?q?Renamed=20some=20classes/interfaces=20to=20make?= =?utf8?q?=20it=20clear=20they=20belong=20only=20to=20this=20project=20as?= =?utf8?q?=20they=20are=20currently=20not=20generic=20enough=20to=20be=20a?= =?utf8?q?dded=20to=20jcore.=20Signed-off-by:Roland=20H=C3=A4der=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../application/AddressbookApplication.java | 40 ++++++------ .../client/BaseAddressbookClient.java | 8 +-- .../client/console/ConsoleClient.java | 15 +++-- .../client/gui/AddressbookFrame.java | 64 +++++++++---------- .../addressbook/client/gui/ClientFrame.java | 4 +- .../addressbook/client/gui/SwingClient.java | 4 +- ... AddressbookContactDatabaseConstants.java} | 4 +- ...> AddressbookContactDatabaseFrontend.java} | 18 +++--- ...d.java => AddressbookContactFrontend.java} | 4 +- ...er.java => AddressbookContactManager.java} | 33 +++++----- ...java => ManageableAddressbookContact.java} | 45 +------------ .../addressbook/menu/console/ConsoleMenu.java | 3 +- .../model/contact/ContactTableModel.java | 10 +-- 13 files changed, 106 insertions(+), 146 deletions(-) rename Addressbook/src/org/mxchange/addressbook/database/contact/{ContactDatabaseConstants.java => AddressbookContactDatabaseConstants.java} (90%) rename Addressbook/src/org/mxchange/addressbook/database/frontend/contact/{ContactDatabaseFrontend.java => AddressbookContactDatabaseFrontend.java} (95%) rename Addressbook/src/org/mxchange/addressbook/database/frontend/contact/{ContactFrontend.java => AddressbookContactFrontend.java} (97%) rename Addressbook/src/org/mxchange/addressbook/manager/contact/{ContactManager.java => AddressbookContactManager.java} (96%) rename Addressbook/src/org/mxchange/addressbook/manager/contact/{ManageableContact.java => ManageableAddressbookContact.java} (82%) diff --git a/Addressbook/src/org/mxchange/addressbook/application/AddressbookApplication.java b/Addressbook/src/org/mxchange/addressbook/application/AddressbookApplication.java index 66834d9..c14c64f 100644 --- a/Addressbook/src/org/mxchange/addressbook/application/AddressbookApplication.java +++ b/Addressbook/src/org/mxchange/addressbook/application/AddressbookApplication.java @@ -146,15 +146,6 @@ public class AddressbookApplication extends BaseAddressbookSystem implements App this.initBundle(); } - /** - * Getter for printable application name - * - * @return A printable name - */ - public static String printableTitle () { - return MessageFormat.format("{0} v{1}", APP_TITLE, APP_VERSION); //NOI18N - } - /** * Bootstraps application */ @@ -240,6 +231,21 @@ public class AddressbookApplication extends BaseAddressbookSystem implements App this.getLogger().debug("Main loop exit - shutting down ..."); //NOI18N } + /** + * Shuts down the application. + */ + @Override + public void doShutdown () { + // Trace message + this.getLogger().trace("CALLED!"); //NOI18N + + // Shutdown client + this.getClient().doShutdown(); + + this.getLogger().info("End of program (last line)"); //NOI18N + System.exit(0); + } + /** * Enables console client by setting propper flag */ @@ -348,17 +354,11 @@ public class AddressbookApplication extends BaseAddressbookSystem implements App } /** - * Shuts down the application. + * Getter for printable application name + * + * @return A printable name */ - @Override - public void doShutdown () { - // Trace message - this.getLogger().trace("CALLED!"); //NOI18N - - // Shutdown client - this.getClient().doShutdown(); - - this.getLogger().info("End of program (last line)"); //NOI18N - System.exit(0); + public static String printableTitle () { + return MessageFormat.format("{0} v{1}", APP_TITLE, APP_VERSION); //NOI18N } } diff --git a/Addressbook/src/org/mxchange/addressbook/client/BaseAddressbookClient.java b/Addressbook/src/org/mxchange/addressbook/client/BaseAddressbookClient.java index ff977bb..faafb9d 100644 --- a/Addressbook/src/org/mxchange/addressbook/client/BaseAddressbookClient.java +++ b/Addressbook/src/org/mxchange/addressbook/client/BaseAddressbookClient.java @@ -19,11 +19,11 @@ package org.mxchange.addressbook.client; import java.text.MessageFormat; import java.util.HashMap; import java.util.Map; -import org.mxchange.addressbook.manager.contact.ContactManager; -import org.mxchange.addressbook.manager.contact.ManageableContact; +import org.mxchange.addressbook.manager.contact.AddressbookContactManager; import org.mxchange.addressbook.menu.Menu; import org.mxchange.jcore.client.BaseClient; import org.mxchange.jcore.client.Client; +import org.mxchange.jcore.manager.database.ManageableDatabase; /** * A general addressbook client @@ -114,7 +114,7 @@ public abstract class BaseAddressbookClient extends BaseClient { // Init contact manager with console client // @TODO Static initial amount of contacts - ManageableContact manager = new ContactManager((Client) this); + ManageableDatabase manager = new AddressbookContactManager((Client) this); // Set it here this.setContactManager(manager); @@ -145,7 +145,7 @@ public abstract class BaseAddressbookClient extends BaseClient { } // Show menu - menu.show((Client) this); + menu.show(this); // Trace message this.getLogger().trace("EXIT!"); //NOI18N diff --git a/Addressbook/src/org/mxchange/addressbook/client/console/ConsoleClient.java b/Addressbook/src/org/mxchange/addressbook/client/console/ConsoleClient.java index 3dbb702..5e8f7da 100644 --- a/Addressbook/src/org/mxchange/addressbook/client/console/ConsoleClient.java +++ b/Addressbook/src/org/mxchange/addressbook/client/console/ConsoleClient.java @@ -26,7 +26,7 @@ import org.mxchange.jcore.contact.Contact; import org.mxchange.jcore.contact.Gender; import org.mxchange.addressbook.contact.user.UserContact; import org.mxchange.addressbook.exceptions.ContactAlreadyAddedException; -import org.mxchange.addressbook.manager.contact.ManageableContact; +import org.mxchange.addressbook.manager.contact.ManageableAddressbookContact; import org.mxchange.addressbook.menu.Menu; import org.mxchange.addressbook.menu.MenuTools; import org.mxchange.addressbook.menu.console.ConsoleMenu; @@ -166,7 +166,7 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC } // Get manager and cast it - ManageableContact manager = (ManageableContact) this.getManager(); + ManageableAddressbookContact manager = (ManageableAddressbookContact) this.getManager(); // Own street and number String streetNumber = manager.enterOwnStreet(); @@ -208,7 +208,7 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC } // Get manager and cast it - ManageableContact manager = (ManageableContact) this.getManager(); + ManageableAddressbookContact manager = (ManageableAddressbookContact) this.getManager(); // Gender: Gender gender = manager.enterOwnGender(); @@ -250,7 +250,7 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC } // Get manager and cast it - ManageableContact manager = (ManageableContact) this.getManager(); + ManageableAddressbookContact manager = (ManageableAddressbookContact) this.getManager(); // Phone number String phoneNumber = manager.enterOwnPhoneNumber(); @@ -284,7 +284,7 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC this.getLogger().trace("CALLED!"); //NOI18N // Get manager and cast it - ManageableContact manager = (ManageableContact) this.getManager(); + ManageableAddressbookContact manager = (ManageableAddressbookContact) this.getManager(); // First ask for gender Gender gender = manager.enterOwnGender(); @@ -337,7 +337,7 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC char choice = this.enterChar(accessKeys, "Bitte Auswahl eingeben (0=Programm beenden): "); // Get manager and cast it - ManageableContact manager = (ManageableContact) this.getManager(); + ManageableAddressbookContact manager = (ManageableAddressbookContact) this.getManager(); // @TODO Rewrite this ugly switch() block switch (choice) { @@ -622,7 +622,7 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC char choice = this.enterChar(new char[] {'n', 'a', 'o', 'x'}, "Welchen Daten möchten Sie ändern? (n=Namensdaten, a=Anschriftsdaten, o=Andere, x=Zurück zur Hauptauswahl) "); // Get manager and cast it - ManageableContact manager = (ManageableContact) this.getManager(); + ManageableAddressbookContact manager = (ManageableAddressbookContact) this.getManager(); // @TODO Get rid of this ugly switch block, too switch (choice) { @@ -715,6 +715,7 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC /** * Fills menu map with menu entries */ + @Override protected final void fillMenuMap () { // Trace message this.getLogger().trace("CALLED!"); //NOI18N diff --git a/Addressbook/src/org/mxchange/addressbook/client/gui/AddressbookFrame.java b/Addressbook/src/org/mxchange/addressbook/client/gui/AddressbookFrame.java index 7a72c69..244c73f 100644 --- a/Addressbook/src/org/mxchange/addressbook/client/gui/AddressbookFrame.java +++ b/Addressbook/src/org/mxchange/addressbook/client/gui/AddressbookFrame.java @@ -46,12 +46,12 @@ 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.manager.contact.ManageableAddressbookContact; import org.mxchange.addressbook.model.contact.ContactTableModel; import org.mxchange.jcore.client.Client; +import org.mxchange.jcore.contact.Contact; +import org.mxchange.jcore.contact.Gender; import org.mxchange.jcore.exceptions.FrameAlreadyInitializedException; /** @@ -211,7 +211,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 +241,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 @@ -298,6 +298,30 @@ 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 + } + /** * Adds a JTextField with label and tool tip to given panel * @@ -644,7 +668,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 +693,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 +711,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 +726,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 * diff --git a/Addressbook/src/org/mxchange/addressbook/client/gui/ClientFrame.java b/Addressbook/src/org/mxchange/addressbook/client/gui/ClientFrame.java index 61cfc42..cd36ca0 100644 --- a/Addressbook/src/org/mxchange/addressbook/client/gui/ClientFrame.java +++ b/Addressbook/src/org/mxchange/addressbook/client/gui/ClientFrame.java @@ -16,9 +16,9 @@ */ package org.mxchange.addressbook.client.gui; -import org.mxchange.jcore.contact.Contact; import org.mxchange.jcore.FrameworkInterface; import org.mxchange.jcore.client.Client; +import org.mxchange.jcore.contact.Contact; import org.mxchange.jcore.exceptions.FrameAlreadyInitializedException; /** @@ -57,7 +57,7 @@ public interface ClientFrame extends FrameworkInterface { * Initializes frame * * @throws - * org.mxchange.addressbook.exceptions.FrameAlreadyInitializedException If + * org.mxchange.jcore.exceptions.FrameAlreadyInitializedException If * this method has been called twice */ public void init () throws FrameAlreadyInitializedException; diff --git a/Addressbook/src/org/mxchange/addressbook/client/gui/SwingClient.java b/Addressbook/src/org/mxchange/addressbook/client/gui/SwingClient.java index 90750c9..e43e5ac 100644 --- a/Addressbook/src/org/mxchange/addressbook/client/gui/SwingClient.java +++ b/Addressbook/src/org/mxchange/addressbook/client/gui/SwingClient.java @@ -18,11 +18,11 @@ package org.mxchange.addressbook.client.gui; import org.mxchange.addressbook.client.AddressbookClient; import org.mxchange.addressbook.client.BaseAddressbookClient; -import org.mxchange.jcore.contact.Contact; -import org.mxchange.jcore.contact.Gender; import org.mxchange.addressbook.menu.Menu; import org.mxchange.addressbook.menu.item.SelectableMenuItem; import org.mxchange.jcore.application.Application; +import org.mxchange.jcore.contact.Contact; +import org.mxchange.jcore.contact.Gender; import org.mxchange.jcore.exceptions.FrameAlreadyInitializedException; import org.mxchange.jcore.exceptions.UnhandledUserChoiceException; diff --git a/Addressbook/src/org/mxchange/addressbook/database/contact/ContactDatabaseConstants.java b/Addressbook/src/org/mxchange/addressbook/database/contact/AddressbookContactDatabaseConstants.java similarity index 90% rename from Addressbook/src/org/mxchange/addressbook/database/contact/ContactDatabaseConstants.java rename to Addressbook/src/org/mxchange/addressbook/database/contact/AddressbookContactDatabaseConstants.java index f42a164..48527ad 100644 --- a/Addressbook/src/org/mxchange/addressbook/database/contact/ContactDatabaseConstants.java +++ b/Addressbook/src/org/mxchange/addressbook/database/contact/AddressbookContactDatabaseConstants.java @@ -21,7 +21,7 @@ package org.mxchange.addressbook.database.contact; * * @author Roland Haeder */ -public final class ContactDatabaseConstants { +public final class AddressbookContactDatabaseConstants { /** * Column own_contact */ @@ -30,6 +30,6 @@ public final class ContactDatabaseConstants { /** * No instances are allowed as this class only holds static attributes */ - private ContactDatabaseConstants () { + private AddressbookContactDatabaseConstants () { } } diff --git a/Addressbook/src/org/mxchange/addressbook/database/frontend/contact/ContactDatabaseFrontend.java b/Addressbook/src/org/mxchange/addressbook/database/frontend/contact/AddressbookContactDatabaseFrontend.java similarity index 95% rename from Addressbook/src/org/mxchange/addressbook/database/frontend/contact/ContactDatabaseFrontend.java rename to Addressbook/src/org/mxchange/addressbook/database/frontend/contact/AddressbookContactDatabaseFrontend.java index 8280ad0..7442ef7 100644 --- a/Addressbook/src/org/mxchange/addressbook/database/frontend/contact/ContactDatabaseFrontend.java +++ b/Addressbook/src/org/mxchange/addressbook/database/frontend/contact/AddressbookContactDatabaseFrontend.java @@ -21,13 +21,13 @@ import java.sql.SQLException; import java.text.MessageFormat; import java.util.Iterator; import java.util.StringTokenizer; -import org.mxchange.jcore.contact.Contact; -import org.mxchange.jcore.contact.Gender; import org.mxchange.addressbook.contact.book.BookContact; import org.mxchange.addressbook.contact.user.UserContact; -import org.mxchange.addressbook.database.contact.ContactDatabaseConstants; +import org.mxchange.addressbook.database.contact.AddressbookContactDatabaseConstants; import org.mxchange.addressbook.exceptions.ContactAlreadyAddedException; -import org.mxchange.addressbook.manager.contact.ContactManager; +import org.mxchange.addressbook.manager.contact.AddressbookContactManager; +import org.mxchange.jcore.contact.Contact; +import org.mxchange.jcore.contact.Gender; import org.mxchange.jcore.database.frontend.BaseDatabaseFrontend; import org.mxchange.jcore.database.storage.Storeable; import org.mxchange.jcore.exceptions.BadTokenException; @@ -38,14 +38,14 @@ import org.mxchange.jcore.exceptions.UnsupportedDatabaseBackendException; * * @author Roland Haeder */ -public class ContactDatabaseFrontend extends BaseDatabaseFrontend implements ContactFrontend { +public class AddressbookContactDatabaseFrontend extends BaseDatabaseFrontend implements AddressbookContactFrontend { /** * Constructor which accepts a contact manager * * @param manager Manager instance */ - public ContactDatabaseFrontend (final ContactManager manager) { + public AddressbookContactDatabaseFrontend (final AddressbookContactManager manager) { // Call own constructor this(); @@ -65,7 +65,7 @@ public class ContactDatabaseFrontend extends BaseDatabaseFrontend implements Con /** * Basic constrcutor */ - protected ContactDatabaseFrontend () { + protected AddressbookContactDatabaseFrontend () { // Trace message this.getLogger().trace("CALLED!"); //NOI18N @@ -159,7 +159,7 @@ public class ContactDatabaseFrontend extends BaseDatabaseFrontend implements Con this.getLogger().trace("CALLED!"); //NOI18N // Get row index back from backend - int rowIndex = this.getBackend().getRowIndexFromColumn(ContactDatabaseConstants.COLUMN_NAME_OWN_CONTACT, true); + int rowIndex = this.getBackend().getRowIndexFromColumn(AddressbookContactDatabaseConstants.COLUMN_NAME_OWN_CONTACT, true); // Debug message this.getLogger().debug(MessageFormat.format("rowIndex={0}", rowIndex)); @@ -236,7 +236,7 @@ public class ContactDatabaseFrontend extends BaseDatabaseFrontend implements Con @Override public boolean isOwnContactFound () throws SQLException { // Deligate this call to backend - return this.getBackend().isRowFound(ContactDatabaseConstants.COLUMN_NAME_OWN_CONTACT, true); + return this.getBackend().isRowFound(AddressbookContactDatabaseConstants.COLUMN_NAME_OWN_CONTACT, true); } /** diff --git a/Addressbook/src/org/mxchange/addressbook/database/frontend/contact/ContactFrontend.java b/Addressbook/src/org/mxchange/addressbook/database/frontend/contact/AddressbookContactFrontend.java similarity index 97% rename from Addressbook/src/org/mxchange/addressbook/database/frontend/contact/ContactFrontend.java rename to Addressbook/src/org/mxchange/addressbook/database/frontend/contact/AddressbookContactFrontend.java index 0630391..3b05869 100644 --- a/Addressbook/src/org/mxchange/addressbook/database/frontend/contact/ContactFrontend.java +++ b/Addressbook/src/org/mxchange/addressbook/database/frontend/contact/AddressbookContactFrontend.java @@ -17,8 +17,8 @@ package org.mxchange.addressbook.database.frontend.contact; import java.sql.SQLException; -import org.mxchange.jcore.contact.Contact; import org.mxchange.addressbook.exceptions.ContactAlreadyAddedException; +import org.mxchange.jcore.contact.Contact; import org.mxchange.jcore.database.frontend.DatabaseFrontend; import org.mxchange.jcore.exceptions.BadTokenException; @@ -26,7 +26,7 @@ import org.mxchange.jcore.exceptions.BadTokenException; * * @author Roland Häder */ -public interface ContactFrontend extends DatabaseFrontend { +public interface AddressbookContactFrontend extends DatabaseFrontend { /** * Adds given contact instance to database diff --git a/Addressbook/src/org/mxchange/addressbook/manager/contact/ContactManager.java b/Addressbook/src/org/mxchange/addressbook/manager/contact/AddressbookContactManager.java similarity index 96% rename from Addressbook/src/org/mxchange/addressbook/manager/contact/ContactManager.java rename to Addressbook/src/org/mxchange/addressbook/manager/contact/AddressbookContactManager.java index 3ab62fc..b85e9d3 100644 --- a/Addressbook/src/org/mxchange/addressbook/manager/contact/ContactManager.java +++ b/Addressbook/src/org/mxchange/addressbook/manager/contact/AddressbookContactManager.java @@ -23,24 +23,23 @@ import java.util.Arrays; import java.util.Iterator; import java.util.List; import org.mxchange.addressbook.client.AddressbookClient; -import org.mxchange.jcore.contact.Contact; -import org.mxchange.jcore.contact.Gender; -import org.mxchange.addressbook.database.frontend.contact.ContactDatabaseFrontend; -import org.mxchange.addressbook.database.frontend.contact.ContactFrontend; +import org.mxchange.addressbook.database.frontend.contact.AddressbookContactDatabaseFrontend; +import org.mxchange.addressbook.database.frontend.contact.AddressbookContactFrontend; import org.mxchange.addressbook.exceptions.ContactAlreadyAddedException; import org.mxchange.jcore.client.Client; +import org.mxchange.jcore.contact.Contact; +import org.mxchange.jcore.contact.Gender; import org.mxchange.jcore.exceptions.BadTokenException; import org.mxchange.jcore.exceptions.UnhandledUserChoiceException; import org.mxchange.jcore.manager.BaseManager; /** - * A manager for contacts, please note that this implementation loads the whole - * list into RAM. + * A manager for contacts. * * @author Roland Haeder * @version 0.0 */ -public class ContactManager extends BaseManager implements ManageableContact { +public class AddressbookContactManager extends BaseManager implements ManageableAddressbookContact { /** * Column name list @@ -48,14 +47,14 @@ public class ContactManager extends BaseManager implements ManageableContact { private final List columnNames; /** - * Translated column name list + * A AddressbookContactFrontend instance */ - private final List translatedColumnNames; + private final AddressbookContactFrontend contactDatabase; /** - * A ContactFrontend instance + * Translated column name list */ - private final ContactFrontend contactDatabase; + private final List translatedColumnNames; /** * Constructor which accepts maxContacts for maximum (initial) contacts and @@ -63,7 +62,7 @@ public class ContactManager extends BaseManager implements ManageableContact { * * @param client Client instance to use */ - public ContactManager (final Client client) { + public AddressbookContactManager (final Client client) { // Trace message this.getLogger().trace(MessageFormat.format("client={1} - CALLED!", client)); //NOI18N @@ -77,7 +76,7 @@ public class ContactManager extends BaseManager implements ManageableContact { this.setClient(client); // Init database connection - this.contactDatabase = new ContactDatabaseFrontend(this); + this.contactDatabase = new AddressbookContactDatabaseFrontend(this); // Initialize list this.columnNames = new ArrayList<>(15); @@ -736,7 +735,7 @@ public class ContactManager extends BaseManager implements ManageableContact { // Get next element String key = iterator.next(); - // Does the key start with ContactManager.columnName ? + // 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 @@ -744,7 +743,7 @@ public class ContactManager extends BaseManager implements ManageableContact { // Convert string to array based on delimiter '.' String[] tokens = this.getArrayFromString(key, ".", 4); - // Token array must contain 4 elements (ContactManager.columnName.foo.text) + // Token array must contain 4 elements (AddressbookContactManager.columnName.foo.text) assert(tokens.length == 4) : MessageFormat.format("Array tokens contains not 4 elements: {0}", Arrays.toString(tokens)); // Get pre-last element @@ -764,11 +763,11 @@ public class ContactManager extends BaseManager implements ManageableContact { } /** - * A ContactFrontend instance + * A AddressbookContactFrontend instance * * @return the database */ - private ContactFrontend getContactDatabase () { + private AddressbookContactFrontend getContactDatabase () { return this.contactDatabase; } diff --git a/Addressbook/src/org/mxchange/addressbook/manager/contact/ManageableContact.java b/Addressbook/src/org/mxchange/addressbook/manager/contact/ManageableAddressbookContact.java similarity index 82% rename from Addressbook/src/org/mxchange/addressbook/manager/contact/ManageableContact.java rename to Addressbook/src/org/mxchange/addressbook/manager/contact/ManageableAddressbookContact.java index 277ae35..6511730 100644 --- a/Addressbook/src/org/mxchange/addressbook/manager/contact/ManageableContact.java +++ b/Addressbook/src/org/mxchange/addressbook/manager/contact/ManageableAddressbookContact.java @@ -16,16 +16,16 @@ */ package org.mxchange.addressbook.manager.contact; +import org.mxchange.addressbook.exceptions.ContactAlreadyAddedException; import org.mxchange.jcore.contact.Contact; import org.mxchange.jcore.contact.Gender; -import org.mxchange.addressbook.exceptions.ContactAlreadyAddedException; -import org.mxchange.jcore.manager.Manageable; +import org.mxchange.jcore.manager.database.ManageableDatabase; /** * * @author Roland Haeder */ -public interface ManageableContact extends Manageable { +public interface ManageableAddressbookContact extends ManageableDatabase { /** * Allows the user to enter own cellphone number. * @@ -117,43 +117,11 @@ public interface ManageableContact extends Manageable { */ public int enterOwnZipCode (); - /** - * Getter for column count - * - * @return Column count - */ - public int getColumnCount (); - /** * List all contacts */ public void doListContacts (); - /** - * Getter for column name at given index. - * - * @param columnIndex Column index - * @return Database column name - */ - public String getColumnName (final int columnIndex); - - /** - * Getter for translated column name at given index. - * - * @param columnIndex Column index - * @return Human-readable column name - */ - public String getTranslatedColumnName (int columnIndex); - - /** - * Somewhat "getter" for value from given row and column index - * - * @param rowIndex Row index - * @param columnIndex Column index - * @return Value from given row/column - */ - public Object getValueFromRowColumn (final int rowIndex, final int columnIndex); - /** * Adds given contact to address book * @@ -231,11 +199,4 @@ public interface ManageableContact extends Manageable { * @return Whether own contact is already added */ public boolean isOwnContactAdded (); - - /** - * Getter for size - * - * @return size of contact "book" - */ - public int size (); } diff --git a/Addressbook/src/org/mxchange/addressbook/menu/console/ConsoleMenu.java b/Addressbook/src/org/mxchange/addressbook/menu/console/ConsoleMenu.java index 5139c00..965f68a 100644 --- a/Addressbook/src/org/mxchange/addressbook/menu/console/ConsoleMenu.java +++ b/Addressbook/src/org/mxchange/addressbook/menu/console/ConsoleMenu.java @@ -17,7 +17,6 @@ package org.mxchange.addressbook.menu.console; import java.text.MessageFormat; -import org.mxchange.addressbook.client.AddressbookClient; import org.mxchange.addressbook.menu.AddressbookMenu; import org.mxchange.addressbook.menu.BaseMenu; import org.mxchange.addressbook.menu.Menu; @@ -49,6 +48,6 @@ public class ConsoleMenu extends BaseMenu implements Menu { this.initMenu(menuType, client); // Add all items - AddressbookMenu.addItemsToList(this.getMenuList(), menuType, (AddressbookClient) client); + AddressbookMenu.addItemsToList(this.getMenuList(), menuType, client); } } diff --git a/Addressbook/src/org/mxchange/addressbook/model/contact/ContactTableModel.java b/Addressbook/src/org/mxchange/addressbook/model/contact/ContactTableModel.java index 6c3b930..5446a83 100644 --- a/Addressbook/src/org/mxchange/addressbook/model/contact/ContactTableModel.java +++ b/Addressbook/src/org/mxchange/addressbook/model/contact/ContactTableModel.java @@ -18,8 +18,8 @@ package org.mxchange.addressbook.model.contact; import java.text.MessageFormat; import javax.swing.table.TableModel; -import org.mxchange.addressbook.manager.contact.ManageableContact; import org.mxchange.jcore.client.Client; +import org.mxchange.jcore.manager.database.ManageableDatabase; import org.mxchange.jcore.model.BaseModel; /** @@ -57,7 +57,7 @@ public class ContactTableModel extends BaseModel implements TableModel { @Override public int getColumnCount () { // Get manager - ManageableContact manager = (ManageableContact) this.getClient().getManager(); + ManageableDatabase manager = (ManageableDatabase) this.getClient().getManager(); // Deligate this call to contact manager return manager.getColumnCount(); @@ -66,7 +66,7 @@ public class ContactTableModel extends BaseModel implements TableModel { @Override public String getColumnName (final int columnIndex) { // Get manager - ManageableContact manager = (ManageableContact) this.getClient().getManager(); + ManageableDatabase manager = (ManageableDatabase) this.getClient().getManager(); // Deligate this call to contact manager return manager.getTranslatedColumnName(columnIndex); @@ -75,7 +75,7 @@ public class ContactTableModel extends BaseModel implements TableModel { @Override public int getRowCount () { // Get manager - ManageableContact manager = (ManageableContact) this.getClient().getManager(); + ManageableDatabase manager = (ManageableDatabase) this.getClient().getManager(); // Deligate this call to contact manager return manager.size(); @@ -84,7 +84,7 @@ public class ContactTableModel extends BaseModel implements TableModel { @Override public Object getValueAt (final int rowIndex, final int columnIndex) { // Get manager - ManageableContact manager = (ManageableContact) this.getClient().getManager(); + ManageableDatabase manager = (ManageableDatabase) this.getClient().getManager(); // Deligate this call to contact manager return manager.getValueFromRowColumn(rowIndex, columnIndex); -- 2.39.5