From a13e9f50f15fedcd511756ab80d554064b13e9e2 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Sat, 5 Sep 2015 12:29:03 +0200 Subject: [PATCH] =?utf8?q?Try=20to=20pass=20the=20manager=20instance=20dir?= =?utf8?q?ectly=20than=20rather=20indirectly=20over=20the=20client=20Signe?= =?utf8?q?d-off-by:Roland=20H=C3=A4der=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../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