From d73c2b92d68de84a73be4b65203de5a301fe7795 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Fri, 24 Jul 2015 12:41:00 +0200 Subject: [PATCH] =?utf8?q?Implemented=20getColumnName()=20+=20added=20it?= =?utf8?q?=20to=20ContactManager=20as=20this=20class=20holds=20the=20colum?= =?utf8?q?n=20names=20+=20added=20some=20for=20testing=20Signed-off-by:Rol?= =?utf8?q?and=20H=C3=A4der=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../localization/bundle_de_DE.properties | 7 +++++++ .../localization/bundle_en_US.properties | 7 +++++++ .../manager/contact/ContactManager.java | 14 +++++++++++++- .../manager/contact/ManageableContact.java | 8 ++++++++ .../model/address/AddressTableModel.java | 6 ++++-- 5 files changed, 39 insertions(+), 3 deletions(-) diff --git a/Addressbook/src/org/mxchange/addressbook/localization/bundle_de_DE.properties b/Addressbook/src/org/mxchange/addressbook/localization/bundle_de_DE.properties index e6907ee..1239e97 100644 --- a/Addressbook/src/org/mxchange/addressbook/localization/bundle_de_DE.properties +++ b/Addressbook/src/org/mxchange/addressbook/localization/bundle_de_DE.properties @@ -24,3 +24,10 @@ AddressbookFrame.menuItem.addOwnData.text=Eigene Adresse hinzuf\u00fcgen AddressbookFrame.menuItem.addOwnData.toolTipText=Erlaubt das Hinzuf\u00fcgen eigener Daten. AddressbookFrame.menuItem.editOwnData.text=Eigene Adresse \u00e4ndern AddressbookFrame.menuItem.editOwnData.toolTipText=Erlaubt das \u00c4ndern eigener Daten. +ContactManager.columnName.gender.text=Anrede +ContactManager.columnName.surname.text=Vorname +ContactManager.columnName.familyName.text=Nachname +ContactManager.columnName.street.text=Strasse +ContactManager.columnName.houseNumber.text=Hausnummer +ContactManager.columnName.zipCode.text=Postleitzahl +ContactManager.columnName.city.text=Stadt diff --git a/Addressbook/src/org/mxchange/addressbook/localization/bundle_en_US.properties b/Addressbook/src/org/mxchange/addressbook/localization/bundle_en_US.properties index c929532..e8c1bf4 100644 --- a/Addressbook/src/org/mxchange/addressbook/localization/bundle_en_US.properties +++ b/Addressbook/src/org/mxchange/addressbook/localization/bundle_en_US.properties @@ -24,3 +24,10 @@ AddressbookFrame.menuItem.addOwnData.text=Add own address AddressbookFrame.menuItem.addOwnData.toolTipText=Allows the user to add own address data AddressbookFrame.menuItem.editOwnData.text=Edit own data AddressbookFrame.menuItem.editOwnData.toolTipText=Allows the user to edit own address data +ContactManager.columnName.gender.text=Gender +ContactManager.columnName.surname.text=Surname +ContactManager.columnName.familyName.text=Family name +ContactManager.columnName.street.text=Street +ContactManager.columnName.houseNumber.text=House number +ContactManager.columnName.zipCode.text=ZIP code +ContactManager.columnName.city.text=City diff --git a/Addressbook/src/org/mxchange/addressbook/manager/contact/ContactManager.java b/Addressbook/src/org/mxchange/addressbook/manager/contact/ContactManager.java index e950e42..c958c1d 100644 --- a/Addressbook/src/org/mxchange/addressbook/manager/contact/ContactManager.java +++ b/Addressbook/src/org/mxchange/addressbook/manager/contact/ContactManager.java @@ -485,7 +485,7 @@ public class ContactManager extends BaseManager implements ManageableContact { String key = iterator.next(); // Does the key start with ContactManager.columnName ? - if (key.startsWith("ContactM,anager.columnName")) { + if (key.startsWith("ContactManager.columnName")) { // This is the wanted entry. this.getLogger().debug(MessageFormat.format("key={0}", key)); @@ -498,6 +498,18 @@ public class ContactManager extends BaseManager implements ManageableContact { this.getLogger().trace(MessageFormat.format("getColumnCount()={0}: EXIT!", this.getColumnCount())); } + /** + * Getter for column name at given index. + * + * @param columnIndex Column index + * @return Human-readable column name + */ + @Override + public String getColumnName (final int columnIndex) { + // Get column name at index + return this.columnNames.get(columnIndex); + } + /** * Flushes all entries by calling database backend */ diff --git a/Addressbook/src/org/mxchange/addressbook/manager/contact/ManageableContact.java b/Addressbook/src/org/mxchange/addressbook/manager/contact/ManageableContact.java index 6914a26..928df17 100644 --- a/Addressbook/src/org/mxchange/addressbook/manager/contact/ManageableContact.java +++ b/Addressbook/src/org/mxchange/addressbook/manager/contact/ManageableContact.java @@ -135,6 +135,14 @@ public interface ManageableContact extends Manageable { */ public void doListContacts (); + /** + * Getter for column name at given index. + * + * @param columnIndex Column index + * @return Human-readable column name + */ + public String getColumnName (final int columnIndex); + /** * Adds given contact to address book * diff --git a/Addressbook/src/org/mxchange/addressbook/model/address/AddressTableModel.java b/Addressbook/src/org/mxchange/addressbook/model/address/AddressTableModel.java index c3fcbc6..0041637 100644 --- a/Addressbook/src/org/mxchange/addressbook/model/address/AddressTableModel.java +++ b/Addressbook/src/org/mxchange/addressbook/model/address/AddressTableModel.java @@ -46,17 +46,19 @@ public class AddressTableModel extends BaseModel implements TableModel { @Override public int getColumnCount () { - // Deligate this call to the contact manager + // Deligate this call to contact manager return this.getClient().getContactManager().getColumnCount(); } @Override public String getColumnName (final int columnIndex) { - throw new UnsupportedOperationException("Not supported yet. columnIndex=" + columnIndex); //To change body of generated methods, choose Tools | Templates. + // Deligate this call to contact manager + return this.getClient().getContactManager().getColumnName(columnIndex); } @Override public int getRowCount () { + // Deligate this call to contact manager return this.getClient().getContactManager().size(); } -- 2.39.5