[sip-comm-cvs] CVS update: /sip-communicator/src/net/java/sip/communicator/impl/gui/main/contactlist/

yanas at dev.java.net yanas at dev.java.net
Wed Apr 11 16:16:40 CEST 2007


User: yanas   
Date: 2007-04-11 14:16:40+0000
Modified:
   sip-communicator/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListModel.java
   sip-communicator/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListPanel.java
   sip-communicator/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactList.java

Log:
 indicate in the contact list when we have non read messages from a contact

File Changes:

Directory: /sip-communicator/src/net/java/sip/communicator/impl/gui/main/contactlist/
=====================================================================================

File [changed]: ContactListModel.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListModel.java?r1=1.31&r2=1.32
Delta lines:  +79 -3
--------------------
--- ContactListModel.java	2007-02-22 12:37:59+0000	1.31
+++ ContactListModel.java	2007-04-11 14:16:37+0000	1.32
@@ -7,6 +7,10 @@
 
 package net.java.sip.communicator.impl.gui.main.contactlist;
 
+import java.awt.Graphics;
+import java.awt.Image;
+import java.awt.image.BufferedImage;
+import java.awt.image.WritableRaster;
 import java.util.*;
 
 import javax.swing.*;
@@ -37,6 +41,13 @@
 
     private Vector closedGroups = new Vector();
 
+    /**
+     * A list of all contacts that are currently "active". An "active" contact
+     * is a contact that has been sent a message. The list is used to indicate
+     * these contacts with a special icon. 
+     */
+    private Vector activeContacts = new Vector();
+    
     private boolean showOffline = true;
 
     /**
@@ -207,8 +218,32 @@
      */
     public ImageIcon getMetaContactStatusIcon(MetaContact contact)
     {
-        return new ImageIcon(Constants.getStatusIcon(this
-            .getMetaContactStatus(contact)));
+        BufferedImage statusImage = Constants.getStatusIcon(this
+                .getMetaContactStatus(contact));
+     
+        WritableRaster raster = statusImage.copyData( null );
+        BufferedImage statusImageCopy = new BufferedImage(
+                statusImage.getColorModel(),
+                raster,
+                statusImage.isAlphaPremultiplied(), null );
+        
+        Graphics g = statusImageCopy.getGraphics();
+        
+        g.drawImage(statusImage, 0, 0, null);
+        
+        if(activeContacts.contains(contact))
+        {   
+            Image msgReceivedImage
+                = ImageLoader.getImage(ImageLoader.MESSAGE_RECEIVED_ICON);
+            
+            g.drawImage(msgReceivedImage, 0,
+                5,
+                null);
+        }
+        
+        ImageIcon statusIcon = new ImageIcon(statusImageCopy);
+        
+        return statusIcon;
     }
 
     /**
@@ -556,4 +591,45 @@
 
         return false;
     }
+    
+    /**
+     * Adds the given <tt>MetaContact</tt> to the list of active contacts.
+     * 
+     * @param metaContact the <tt>MetaContact</tt> to add.
+     */
+    public void addActiveContact(MetaContact metaContact)
+    {
+        synchronized (activeContacts)
+        {
+            this.activeContacts.add(metaContact);
+        }
+    }
+    
+    /**
+     * Removes the given <tt>MetaContact</tt> from the list of active contacts.
+     * 
+     * @param metaContact the <tt>MetaContact</tt> to remove.
+     */
+    public void removeActiveContact(MetaContact metaContact)
+    {
+        synchronized (activeContacts)
+        {
+            this.activeContacts.remove(metaContact);
+        }
+    }
+    
+    /**
+     * Checks if the given contact is currently active.
+     * 
+     * @param metaContact the <tt>MetaContact</tt> to verify
+     * @return TRUE if the given <tt>MetaContact</tt> is active, FALSE -
+     * otherwise
+     */
+    public boolean isContactActive(MetaContact metaContact)
+    {
+        synchronized (activeContacts)
+        {
+            return this.activeContacts.contains(metaContact);
+        }
+    }
 }

File [changed]: ContactListPanel.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListPanel.java?r1=1.92&r2=1.93
Delta lines:  +24 -12
---------------------
--- ContactListPanel.java	2007-03-12 17:40:55+0000	1.92
+++ ContactListPanel.java	2007-04-11 14:16:38+0000	1.93
@@ -217,6 +217,12 @@
         MetaContact metaContact = mainFrame.getContactList()
                 .findMetaContactByContact(protocolContact);
         
+        if(metaContact != null)
+        {
+            ContactListModel clistModel = (ContactListModel) contactList.getModel();
+            clistModel.addActiveContact(metaContact);
+            contactList.modifyContact(metaContact);
+            
         ChatPanel chatPanel = chatWindowManager.getContactChat(
             metaContact, protocolContact, message.getMessageUID());
                 
@@ -230,6 +236,12 @@
         
         chatPanel.treatReceivedMessage(protocolContact);
     }
+        else
+        {
+            logger.trace("MetaContact not found for protocol contact: "
+                    + protocolContact + ".");
+        }
+    }
 
     /**
      * When a sent message is delivered shows it in the chat conversation panel.

File [changed]: ContactList.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactList.java?r1=1.67&r2=1.68
Delta lines:  +1 -1
-------------------




---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe at sip-communicator.dev.java.net
For additional commands, e-mail: cvs-help at sip-communicator.dev.java.net





More information about the commits mailing list