aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDamian Minkov <damencho@jitsi.org>2007-12-07 14:27:35 +0000
committerDamian Minkov <damencho@jitsi.org>2007-12-07 14:27:35 +0000
commit449d8d983db4c30cf0b96d6a9a35b39b029a1551 (patch)
tree2876116d01a0ddfaa5d94845a3bc4d7bea8ea94c /src
parente87271480b6d86946c3148cd23822c5e93b15b1e (diff)
downloadjitsi-449d8d983db4c30cf0b96d6a9a35b39b029a1551.zip
jitsi-449d8d983db4c30cf0b96d6a9a35b39b029a1551.tar.gz
jitsi-449d8d983db4c30cf0b96d6a9a35b39b029a1551.tar.bz2
Expand whiteboard menuitem to menu so we can choose protocol contacts if any in a metacontact
Diffstat (limited to 'src')
-rw-r--r--src/net/java/sip/communicator/plugin/whiteboard/WhiteboardMenuItem.java51
-rw-r--r--src/net/java/sip/communicator/plugin/whiteboard/WhiteboardSessionManager.java36
-rw-r--r--src/net/java/sip/communicator/plugin/whiteboard/resources.properties2
3 files changed, 59 insertions, 30 deletions
diff --git a/src/net/java/sip/communicator/plugin/whiteboard/WhiteboardMenuItem.java b/src/net/java/sip/communicator/plugin/whiteboard/WhiteboardMenuItem.java
index ac4939d..b2d06d3 100644
--- a/src/net/java/sip/communicator/plugin/whiteboard/WhiteboardMenuItem.java
+++ b/src/net/java/sip/communicator/plugin/whiteboard/WhiteboardMenuItem.java
@@ -8,10 +8,12 @@ package net.java.sip.communicator.plugin.whiteboard;
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 @@ import net.java.sip.communicator.service.gui.*;
* @author Julien Waechter
*/
public class WhiteboardMenuItem
- extends JMenuItem
+ extends JMenu
implements ContactAwareComponent,
ActionListener
{
@@ -40,9 +42,8 @@ public class WhiteboardMenuItem
*/
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 class WhiteboardMenuItem
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 class WhiteboardMenuItem
*/
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
diff --git a/src/net/java/sip/communicator/plugin/whiteboard/WhiteboardSessionManager.java b/src/net/java/sip/communicator/plugin/whiteboard/WhiteboardSessionManager.java
index 8c554b4..75c0bb3 100644
--- a/src/net/java/sip/communicator/plugin/whiteboard/WhiteboardSessionManager.java
+++ b/src/net/java/sip/communicator/plugin/whiteboard/WhiteboardSessionManager.java
@@ -71,38 +71,22 @@ public class WhiteboardSessionManager
}
/**
- * 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)
{
diff --git a/src/net/java/sip/communicator/plugin/whiteboard/resources.properties b/src/net/java/sip/communicator/plugin/whiteboard/resources.properties
index c1efa10..1884ee8 100644
--- a/src/net/java/sip/communicator/plugin/whiteboard/resources.properties
+++ b/src/net/java/sip/communicator/plugin/whiteboard/resources.properties
@@ -34,6 +34,8 @@ invitationReceived=Invitation received
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