svn commit: r3295 - trunk/src/net/java/sip/communicator/plugin/whiteboard

damencho at dev.java.net damencho at dev.java.net
Fri Dec 7 15:27:37 CET 2007


Author: damencho
Date: 2007-12-07 14:27:35+0000
New Revision: 3295

Modified:
   trunk/src/net/java/sip/communicator/plugin/whiteboard/WhiteboardMenuItem.java
   trunk/src/net/java/sip/communicator/plugin/whiteboard/WhiteboardSessionManager.java
   trunk/src/net/java/sip/communicator/plugin/whiteboard/resources.properties

Log:
Expand whiteboard menuitem to menu so we can choose protocol contacts if any in a metacontact

Modified: trunk/src/net/java/sip/communicator/plugin/whiteboard/WhiteboardMenuItem.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/trunk/src/net/java/sip/communicator/plugin/whiteboard/WhiteboardMenuItem.java?view=diff&rev=3295&p1=trunk/src/net/java/sip/communicator/plugin/whiteboard/WhiteboardMenuItem.java&p2=trunk/src/net/java/sip/communicator/plugin/whiteboard/WhiteboardMenuItem.java&r1=3294&r2=3295
==============================================================================
--- trunk/src/net/java/sip/communicator/plugin/whiteboard/WhiteboardMenuItem.java	(original)
+++ trunk/src/net/java/sip/communicator/plugin/whiteboard/WhiteboardMenuItem.java	2007-12-07 14:27:35+0000
@@ -8,10 +8,12 @@
 
 import java.awt.event.*;
 
+import java.util.*;
 import javax.swing.*;
 
 import net.java.sip.communicator.service.contactlist.*;
 import net.java.sip.communicator.service.gui.*;
+import net.java.sip.communicator.service.protocol.*;
 
 /**
  * WhiteboardMenuItem
@@ -19,7 +21,7 @@
  * @author Julien Waechter
  */
 public class WhiteboardMenuItem
-    extends JMenuItem
+    extends JMenu
     implements  ContactAwareComponent,
                 ActionListener
 {
@@ -40,9 +42,8 @@
      */
     public WhiteboardMenuItem (WhiteboardSessionManager session)
     {
-        super ("Whiteboard plugin");
+        super (Resources.getString("whiteboardMenuItemText"));
         this.session = session;
-        this.addActionListener (this);
         this.setIcon (Resources.getImage ("mpenIcon"));
     }
 
@@ -54,6 +55,36 @@
     public void setCurrentContact (MetaContact metaContact)
     {
         this.metaContact = metaContact;
+        
+        this.removeAll();
+        
+        Iterator iter = metaContact.getContacts();
+        while (iter.hasNext())
+        {
+            Contact contact = (Contact)iter.next();
+            ProtocolProviderService pps = contact.getProtocolProvider();
+            
+            OperationSetWhiteboarding opSetWb = (OperationSetWhiteboarding)
+                pps.getOperationSet(OperationSetWhiteboarding.class);
+
+            String contactDisplayName = contact.getDisplayName();
+            
+            JMenuItem contactItem = new JMenuItem(contactDisplayName);
+            contactItem.setName(contact.getDisplayName() + pps.getProtocolName());
+
+            if (opSetWb != null)
+            {
+                contactItem.addActionListener(this);
+            }
+            else
+            {
+                contactItem.setEnabled(false);
+                contactItem.setToolTipText(
+                        Resources.getString("whiteboardMenuItemNotSupportedTooltip"));
+            }
+            
+            this.add(contactItem);
+        }
     }
 
     /**
@@ -72,6 +103,18 @@
      */
     public void actionPerformed (ActionEvent e)
     {
-        session.initWhiteboard (this.metaContact);
+        String itemID = ((JMenuItem)e.getSource()).getName();
+        Iterator i = this.metaContact.getContacts();
+
+        while(i.hasNext()) 
+        {
+            Contact contact = (Contact)i.next();
+
+            String id = contact.getAddress()
+                + contact.getProtocolProvider().getProtocolName();
+
+            if(itemID.equals(id)) 
+                session.initWhiteboard (contact);
+        }
     }
 }
\ No newline at end of file

Modified: trunk/src/net/java/sip/communicator/plugin/whiteboard/WhiteboardSessionManager.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/trunk/src/net/java/sip/communicator/plugin/whiteboard/WhiteboardSessionManager.java?view=diff&rev=3295&p1=trunk/src/net/java/sip/communicator/plugin/whiteboard/WhiteboardSessionManager.java&p2=trunk/src/net/java/sip/communicator/plugin/whiteboard/WhiteboardSessionManager.java&r1=3294&r2=3295
==============================================================================
--- trunk/src/net/java/sip/communicator/plugin/whiteboard/WhiteboardSessionManager.java	(original)
+++ trunk/src/net/java/sip/communicator/plugin/whiteboard/WhiteboardSessionManager.java	2007-12-07 14:27:35+0000
@@ -71,38 +71,22 @@
     }
 
     /**
-     * Initialize (a new) Whiteboard with meta contact.
-     * Finds the first protocol contact that supports Whiteboarding
-     *
-     * @param mc Contact used to init whiteboard
-     */
-    public void initWhiteboard (MetaContact mc)
-    {
-        Contact contact = null;
-        ProtocolProviderService pps = null;
-        Iterator iter = mc.getContacts();
-        while (iter.hasNext())
-        {
-            contact = (Contact)iter.next();
-            pps = contact.getProtocolProvider();
-            
-            opSetWb = (OperationSetWhiteboarding)
-                pps.getOperationSet(OperationSetWhiteboarding.class);
-
-            if (opSetWb != null)
-                initWhiteboard(contact);
-        }
-        
-        logger.info("No contact found that supports whiteboarding");
-    }
-
-    /**
      * Initialize (a new) Whiteboard with contact
      *
      * @param contact Contact used to init whiteboard
      */
     public void initWhiteboard (final Contact contact)
     {
+        opSetWb = (OperationSetWhiteboarding)
+            contact.getProtocolProvider().
+                getOperationSet(OperationSetWhiteboarding.class);
+        
+        if (opSetWb == null)
+        {
+            logger.info("Contact does not support whiteboarding");
+            return;
+        }
+        
         WhiteboardFrame wbf = getWhiteboardFrame (contact);
         if(wbf != null)
         {

Modified: trunk/src/net/java/sip/communicator/plugin/whiteboard/resources.properties
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/trunk/src/net/java/sip/communicator/plugin/whiteboard/resources.properties?view=diff&rev=3295&p1=trunk/src/net/java/sip/communicator/plugin/whiteboard/resources.properties&p2=trunk/src/net/java/sip/communicator/plugin/whiteboard/resources.properties&r1=3294&r2=3295
==============================================================================
--- trunk/src/net/java/sip/communicator/plugin/whiteboard/resources.properties	(original)
+++ trunk/src/net/java/sip/communicator/plugin/whiteboard/resources.properties	2007-12-07 14:27:35+0000
@@ -34,6 +34,8 @@
 invitationReceivedFormInfo={0} has invited you to join {1} whiteboard. You could accept, reject or ignore this invitation.
 invitation=Invitation text
 whiteboardTitle=Whiteboard [Beta]
+whiteboardMenuItemText=Whiteboard
+whiteboardMenuItemNotSupportedTooltip=This contact does not support whiteboarding
 cancel=Cancel
 yes=Yes
 no=No

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





More information about the commits mailing list