diff options
Diffstat (limited to 'src/net/java')
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 |