[sc1.0-cvs] CVS update: /sip-communicator-1-0-draft/src/net/java/sip/communicator/impl/gui/main/contactlist/

yanas at dev.java.net yanas at dev.java.net
Fri Feb 24 11:35:36 CET 2006


User: yanas   
Date: 2006/02/24 02:35:36

Log:
 Change all contactlist related components to get theirs data from the MetaContactList

File Changes:

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

File [changed]: ContactListTree.java
Url: https://sip-communicator-1-0-draft.dev.java.net/source/browse/sip-communicator-1-0-draft/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListTree.java?r1=1.2&r2=1.3
Delta lines:  +35 -2
--------------------
--- ContactListTree.java	7 Feb 2006 16:25:09 -0000	1.2
+++ ContactListTree.java	24 Feb 2006 10:35:33 -0000	1.3
@@ -8,6 +8,7 @@
 package net.java.sip.communicator.impl.gui.main.contactlist;
 
 import java.awt.Cursor;
+import java.util.Iterator;
 
 import javax.swing.BorderFactory;
 import javax.swing.JTree;
@@ -16,6 +17,8 @@
 import javax.swing.tree.TreeSelectionModel;
 
 import net.java.sip.communicator.impl.gui.main.ui.SIPCommTreeUI;
+import net.java.sip.communicator.service.contactlist.MetaContact;
+import net.java.sip.communicator.service.contactlist.MetaContactGroup;
 
 public class ContactListTree extends JTree {
 	
@@ -105,4 +108,34 @@
 		
 		return childNode;
 	}
+    
+	public void addAllContacts(ContactNode groupNode, MetaContactGroup group){
+        
+        if(group.countSubgroups() > 0){
+            
+            Iterator groups = group.getSubgroups();
+            
+            while(groups.hasNext()){
+                
+                MetaContactGroup subGroup = (MetaContactGroup)groups.next();
+                
+                ContactNode subGroupNode 
+                    = this.addChild(groupNode, subGroup, true);
+                                    
+                this.addAllContacts(subGroupNode, subGroup);                
+            }
+        } 
+        
+        if(group.countChildContacts() > 0 ){
+            
+            Iterator childContacts = group.getChildContacts();
+            
+            while(childContacts.hasNext()){
+                
+                MetaContact childContact = (MetaContact)childContacts.next();
+                
+                this.addChild(groupNode, childContact, true);
+            }
+        }
+    }
 }

File [changed]: ContactInfoPanel.java
Url: https://sip-communicator-1-0-draft.dev.java.net/source/browse/sip-communicator-1-0-draft/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactInfoPanel.java?r1=1.3&r2=1.4
Delta lines:  +6 -23
--------------------
--- ContactInfoPanel.java	8 Feb 2006 23:45:25 -0000	1.3
+++ ContactInfoPanel.java	24 Feb 2006 10:35:33 -0000	1.4
@@ -7,36 +7,18 @@
 
 package net.java.sip.communicator.impl.gui.main.contactlist;
 
-import java.awt.BasicStroke;
 import java.awt.BorderLayout;
-import java.awt.Color;
-import java.awt.Component;
-import java.awt.FlowLayout;
 import java.awt.Frame;
-import java.awt.Graphics;
-import java.awt.Graphics2D;
 import java.awt.GridLayout;
-import java.awt.Point;
-import java.awt.event.FocusEvent;
-import java.awt.event.FocusListener;
 import java.awt.event.WindowEvent;
 import java.awt.event.WindowFocusListener;
 
 import javax.swing.BorderFactory;
-import javax.swing.ImageIcon;
 import javax.swing.JDialog;
-import javax.swing.JFrame;
-import javax.swing.JLabel;
 import javax.swing.JPanel;
-import javax.swing.JPopupMenu;
-import javax.swing.JWindow;
-import javax.swing.SwingUtilities;
 
-import net.java.sip.communicator.impl.gui.main.ContactItem;
 import net.java.sip.communicator.impl.gui.main.customcontrols.TransparentBackground;
-
-import net.java.sip.communicator.impl.gui.main.utils.AntialiasingManager;
-import net.java.sip.communicator.impl.gui.main.utils.Constants;
+import net.java.sip.communicator.service.contactlist.MetaContact;
 
 /**
  * @author Yana Stamcheva
@@ -49,11 +31,11 @@
 
 	private JPanel	protocolsPanel = new JPanel(new GridLayout(0, 1));
 	
-	private ContactItem contactItem;
+	private MetaContact contactItem;
 	
 	TransparentBackground bg;
 	
-	public ContactInfoPanel(Frame owner, ContactItem contactItem){		
+	public ContactInfoPanel(Frame owner, MetaContact contactItem){		
 		
 		super(owner);
 				
@@ -86,8 +68,8 @@
 	}
 	
 	private void init() {
-		
-		String[] protocolList = this.contactItem.getProtocolList();
+		/*
+		String[] protocolList = this.contactItem.getC();
 		
 		if(protocolsPanel.getComponentCount() == 0){
 			for(int i = 0; i < protocolList.length; i ++){
@@ -101,6 +83,7 @@
 		}
 					
 		this.bg.add(protocolsPanel, BorderLayout.CENTER);
+        */
 	}
 
 	public JPanel getProtocolsPanel() {

File [changed]: ContactNode.java
Url: https://sip-communicator-1-0-draft.dev.java.net/source/browse/sip-communicator-1-0-draft/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactNode.java?r1=1.1&r2=1.2
Delta lines:  +10 -11
---------------------
--- ContactNode.java	5 Feb 2006 19:32:00 -0000	1.1
+++ ContactNode.java	24 Feb 2006 10:35:33 -0000	1.2
@@ -7,13 +7,10 @@
 
 package net.java.sip.communicator.impl.gui.main.contactlist;
 
-import java.awt.Cursor;
-
 import javax.swing.tree.DefaultMutableTreeNode;
-import javax.swing.tree.TreeNode;
 
-import net.java.sip.communicator.impl.gui.main.ContactItem;
-import net.java.sip.communicator.impl.gui.main.GroupItem;
+import net.java.sip.communicator.service.contactlist.MetaContact;
+import net.java.sip.communicator.service.contactlist.MetaContactGroup;
 
 public class ContactNode extends DefaultMutableTreeNode {
 
@@ -32,13 +29,15 @@
     	String result = "";
     	
 		if (userObject == null) {
+		    
 		    return null;
+            
 		} else {
-			//TODO: to replace ContactItem with MetaContact and GroupItem with MetaGroup
-			if (userObject instanceof ContactItem)
-				result = ((ContactItem)userObject).getNickName();
-			else if (userObject instanceof GroupItem)
-				result = ((GroupItem)userObject).getGroupName();
+            
+			if (userObject instanceof MetaContact)
+				result = ((MetaContact)userObject).getDisplayName();
+			else if (userObject instanceof MetaContactGroup)
+				result = ((MetaContactGroup)userObject).getGroupName();
 		}
 		
 		return result;

File [changed]: ContactListCellRenderer.java
Url: https://sip-communicator-1-0-draft.dev.java.net/source/browse/sip-communicator-1-0-draft/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListCellRenderer.java?r1=1.3&r2=1.4
Delta lines:  +8 -20
--------------------
--- ContactListCellRenderer.java	21 Feb 2006 17:28:51 -0000	1.3
+++ ContactListCellRenderer.java	24 Feb 2006 10:35:33 -0000	1.4
@@ -7,42 +7,30 @@
 
 package net.java.sip.communicator.impl.gui.main.contactlist;
 
-import gov.nist.javax.sip.parser.ContactParser;
-
 import java.awt.BasicStroke;
 import java.awt.BorderLayout;
 import java.awt.Color;
 import java.awt.Component;
 import java.awt.Cursor;
 import java.awt.Dimension;
-import java.awt.FlowLayout;
 import java.awt.Font;
-import java.awt.GradientPaint;
 import java.awt.Graphics;
 import java.awt.Graphics2D;
-import java.awt.Rectangle;
-import java.awt.Stroke;
-import java.awt.Transparency;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
 
 import javax.swing.BorderFactory;
 import javax.swing.ImageIcon;
-import javax.swing.JButton;
 import javax.swing.JLabel;
 import javax.swing.JPanel;
 import javax.swing.JTree;
-import javax.swing.JWindow;
-import javax.swing.tree.DefaultMutableTreeNode;
 import javax.swing.tree.TreeCellRenderer;
 
-import net.java.sip.communicator.impl.gui.main.ContactItem;
-import net.java.sip.communicator.impl.gui.main.GroupItem;
 import net.java.sip.communicator.impl.gui.main.customcontrols.SIPCommButton;
-import net.java.sip.communicator.impl.gui.main.customcontrols.TransparentBackground;
 import net.java.sip.communicator.impl.gui.main.utils.AntialiasingManager;
 import net.java.sip.communicator.impl.gui.main.utils.Constants;
 import net.java.sip.communicator.impl.gui.main.utils.ImageLoader;
+import net.java.sip.communicator.service.contactlist.MetaContact;
+import net.java.sip.communicator.service.contactlist.MetaContactGroup;
+import net.kano.joscar.ssiitem.GroupItem;
 
 public class ContactListCellRenderer extends JPanel 
 	implements TreeCellRenderer {
@@ -87,13 +75,13 @@
 		
 		if(leaf){
 			
-			if (node.getUserObject() instanceof ContactItem) {
+			if (node.getUserObject() instanceof MetaContact) {
 							
-				ContactItem contactItem = (ContactItem) node.getUserObject();
+                MetaContact contactItem = (MetaContact) node.getUserObject();
 
-				this.nameLabel.setText(contactItem.getNickName());
+				this.nameLabel.setText(contactItem.getDisplayName());
 	
-				this.nameLabel.setIcon(contactItem.getUserIcon());
+				//this.nameLabel.setIcon(contactItem.getUserIcon());
 	
 				this.nameLabel.setFont(this.getFont().deriveFont(Font.PLAIN));
 				
@@ -105,7 +93,7 @@
 			} 
 		}
 		else{ 
-			if (node.getUserObject() instanceof GroupItem) {		
+			if (node.getUserObject() instanceof MetaContactGroup) {		
 
 				GroupItem groupItem = (GroupItem) node.getUserObject();
 					

File [changed]: ContactListPanel.java
Url: https://sip-communicator-1-0-draft.dev.java.net/source/browse/sip-communicator-1-0-draft/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListPanel.java?r1=1.4&r2=1.5
Delta lines:  +38 -36
---------------------
--- ContactListPanel.java	8 Feb 2006 23:45:25 -0000	1.4
+++ ContactListPanel.java	24 Feb 2006 10:35:33 -0000	1.5
@@ -10,12 +10,10 @@
 import java.awt.BorderLayout;

 import java.awt.Color;

 import java.awt.Component;

-import java.awt.Cursor;

 import java.awt.Point;

 import java.awt.event.InputEvent;

 import java.awt.event.MouseEvent;

 import java.awt.event.MouseListener;

-import java.awt.event.WindowEvent;

 import java.util.Hashtable;

 

 import javax.swing.JButton;

@@ -24,17 +22,14 @@
 import javax.swing.JPanel;

 import javax.swing.JScrollPane;

 import javax.swing.SwingUtilities;

-import javax.swing.event.TreeSelectionEvent;

-import javax.swing.event.TreeSelectionListener;

 import javax.swing.tree.DefaultMutableTreeNode;

 import javax.swing.tree.TreePath;

 

-import net.java.sip.communicator.impl.gui.main.ContactItem;

-import net.java.sip.communicator.impl.gui.main.ContactList;

 import net.java.sip.communicator.impl.gui.main.ContactRightButtonMenu;

-import net.java.sip.communicator.impl.gui.main.GroupItem;

 import net.java.sip.communicator.impl.gui.main.MainFrame;

 import net.java.sip.communicator.impl.gui.main.message.MessageWindow;

+import net.java.sip.communicator.service.contactlist.MetaContact;

+import net.java.sip.communicator.service.contactlist.MetaContactGroup;

 import net.java.sip.communicator.service.contactlist.MetaContactListService;

 

 /**

@@ -45,7 +40,11 @@
 public class ContactListPanel extends JScrollPane 

 	implements MouseListener {

 

-	private ContactList contactList;

+	private MetaContactListService contactList;

+    

+    private MetaContactGroup root;

+

+    private ContactNode rootNode;

 

 	private MainFrame parent;

 

@@ -59,34 +58,25 @@
 

 		this.parent = parent;

 

-		this.contactList = parent.getContactList();

+		this.getViewport().add(treePanel);

 

-		this.contactListTree = new ContactListTree(new ContactNode(

-				new GroupItem("root")));

+		this.treePanel.setBackground(Color.WHITE);

+	}

 

-		this.contactListTree.addMouseListener(this);

+	private void initTree() {

 

-		this.initTree();

+	    this.root = this.contactList.getRoot();

 

-		this.treePanel.add(contactListTree, BorderLayout.NORTH);

+        this.rootNode = new ContactNode(this.root);

 

-		this.getViewport().add(treePanel);

+        this.contactListTree = new ContactListTree(rootNode);

 

-		this.treePanel.setBackground(Color.WHITE);

-	}

+        this.contactListTree.addAllContacts(this.rootNode, root); 

 

-	private void initTree() {

+        this.contactListTree.addMouseListener(this);

+

+        this.treePanel.add(contactListTree, BorderLayout.NORTH);

 

-		// TODO: To be removed!!!!

-		ContactNode generalGroup = (ContactNode) this.contactListTree

-				.addChild(new GroupItem("General"));

-

-		for (int i = 0; i < this.contactList.getAllContacts().size(); i++) {

-

-			this.contactListTree.addChild(generalGroup,

-					(ContactItem) this.contactList.getAllContacts().get(i),

-					true);

-		}

 	}

 

 	public void mouseClicked(MouseEvent e) {

@@ -142,7 +132,7 @@
 					Component component = renderer.findComponentAt(translatedX,

 							translatedY);

 

-					ContactItem contactItem = (ContactItem) node

+					MetaContact contactItem = (MetaContact) node

 							.getUserObject();

 

 					if (component instanceof JLabel) {

@@ -189,9 +179,9 @@
 

 	private class RunMessageWindow implements Runnable {

 

-		private ContactItem contactItem;

+		private MetaContact contactItem;

 

-		private RunMessageWindow(ContactItem contactItem) {

+		private RunMessageWindow(MetaContact contactItem) {

 			this.contactItem = contactItem;

 		}

 

@@ -223,13 +213,14 @@
 	}

 	

 	

+	

 	private class RunInfoWindow implements Runnable {

 

-		private ContactItem contactItem;

+		private MetaContact contactItem;

 

 		private Point p;

 		

-		private RunInfoWindow(Point p, ContactItem contactItem) {

+		private RunInfoWindow(Point p, MetaContact contactItem) {

 		

 			this.p = p;

 			this.contactItem = contactItem;

@@ -250,4 +241,15 @@
 

 		}

 	}

+

+    public MetaContactListService getContactList() {

+        return contactList;

+    }

+

+    public void setContactList(MetaContactListService contactList) {

+        

+        this.contactList = contactList;

+        

+        this.initTree();

+    }

 }




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





More information about the commits mailing list