From 0403db58c5ddf57362d31f1cc0a44e7502b21fd0 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Sat, 5 Sep 2015 12:29:03 +0200 Subject: [PATCH] Try to pass the manager instance directly than rather indirectly over the client Signed-off-by:Roland Haeder --- .../jswingcore/client/gui/ClientFrame.java | 2 +- .../swing/contact/ContactTableModel.java | 40 +++++++------------ 2 files changed, 15 insertions(+), 27 deletions(-) diff --git a/src/org/mxchange/jswingcore/client/gui/ClientFrame.java b/src/org/mxchange/jswingcore/client/gui/ClientFrame.java index cf4be5d..a67be40 100644 --- a/src/org/mxchange/jswingcore/client/gui/ClientFrame.java +++ b/src/org/mxchange/jswingcore/client/gui/ClientFrame.java @@ -23,7 +23,7 @@ import org.mxchange.jcore.exceptions.FrameAlreadyInitializedException; import org.mxchange.jcore.model.contact.Contact; /** - * An interface for applications with a frame + * An interface for applications with a Swing frame * * @author Roland Haeder */ diff --git a/src/org/mxchange/jswingcore/model/swing/contact/ContactTableModel.java b/src/org/mxchange/jswingcore/model/swing/contact/ContactTableModel.java index 90b3ccc..9170dc3 100644 --- a/src/org/mxchange/jswingcore/model/swing/contact/ContactTableModel.java +++ b/src/org/mxchange/jswingcore/model/swing/contact/ContactTableModel.java @@ -20,7 +20,7 @@ import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.text.MessageFormat; import javax.swing.table.TableModel; -import org.mxchange.jcore.client.Client; +import org.mxchange.jcore.manager.Manageable; import org.mxchange.jcore.model.contact.Contact; import org.mxchange.jswingcore.model.BaseModel; import org.mxchange.jswingcore.model.Model; @@ -33,22 +33,22 @@ import org.mxchange.jswingcore.model.Model; public class ContactTableModel extends BaseModel implements Model, TableModel { /** - * Constructor with Client instance which holds the contact manager + * Constructor with manager instance which holds the contact manager * - * @param client Client instance + * @param manager Manageable instance */ - public ContactTableModel (final Client client) { + public ContactTableModel (final Manageable manager) { // Trace message - this.getLogger().trace(MessageFormat.format("client={1} - CALLED!", client)); //NOI18N + this.getLogger().trace(MessageFormat.format("manager={1} - CALLED!", manager)); //NOI18N - // Client must not be null - if (null == client) { + // Manager must not be null + if (null == manager) { // Abort here - throw new NullPointerException("client is null"); //NOI18N + throw new NullPointerException("manager is null"); //NOI18N } - // Set client - this.setClient(client); + // Set manager + this.setManager(manager); } @Override @@ -59,30 +59,21 @@ public class ContactTableModel extends BaseModel implements Model, TableModel { @Override public int getColumnCount () { - // Get manager - ManageableDatabase manager = (ManageableDatabase) this.getClient().getManager(); - // Deligate this call to contact manager - return manager.getColumnCount(); + return this.getManager().getColumnCount(); } @Override public String getColumnName (final int columnIndex) { - // Get manager - ManageableDatabase manager = (ManageableDatabase) this.getClient().getManager(); - // Deligate this call to contact manager - return manager.getTranslatedColumnName(columnIndex); + return this.getManager().getTranslatedColumnName(columnIndex); } @Override public int getRowCount () { - // Get manager - ManageableDatabase manager = (ManageableDatabase) this.getClient().getManager(); - try { // Deligate this call to contact manager - return manager.size(); + return this.getManager().size(); } catch (final IOException ex) { // Log warning this.logException(ex); @@ -94,15 +85,12 @@ public class ContactTableModel extends BaseModel implements Model, TableModel { @Override public Object getValueAt (final int rowIndex, final int columnIndex) { - // Get manager - ManageableDatabase manager = (ManageableDatabase) this.getClient().getManager(); - // Init value Object value = null; try { // Deligate this call to contact manager - value = manager.getValueFromRowColumn(rowIndex, columnIndex); + value = this.getManager().getValueFromRowColumn(rowIndex, columnIndex); } catch (final NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) { // Abort here this.abortProgramWithException(ex); -- 2.39.5