]> git.mxchange.org Git - jcore-swing.git/commitdiff
Try to pass the manager instance directly than rather indirectly over the client
authorRoland Haeder <roland@mxchange.org>
Sat, 5 Sep 2015 10:29:03 +0000 (12:29 +0200)
committerRoland Haeder <roland@mxchange.org>
Sat, 5 Sep 2015 10:30:26 +0000 (12:30 +0200)
Signed-off-by:Roland Haeder <roland@mxchange.org>

src/org/mxchange/jswingcore/client/gui/ClientFrame.java
src/org/mxchange/jswingcore/model/swing/contact/ContactTableModel.java

index cf4be5d0c5f1cca60652d58e8f59fc1fecfab683..a67be402b604dc81f7ef75cdd5dc98d99fabed4b 100644 (file)
@@ -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
  */
index 90b3ccc7f7f6e63a717e283726052685d2069bea..9170dc3b2f402b2718f7f416a98c912333229181 100644 (file)
@@ -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);