diff options
author | Yana Stamcheva <yana@jitsi.org> | 2011-01-17 18:52:25 +0000 |
---|---|---|
committer | Yana Stamcheva <yana@jitsi.org> | 2011-01-17 18:52:25 +0000 |
commit | 81a2a1f5d947e490cd1b31e992627445711523da (patch) | |
tree | eb373da0983029580fd49c0f9cd4e2c0fa0fe4b3 /src/net/java/sip/communicator/impl/gui/main/contactlist/SourceContactRightButtonMenu.java | |
parent | 52ef7b1f07686ddca3ae8f4c9ed4501ba9b0893d (diff) | |
download | jitsi-81a2a1f5d947e490cd1b31e992627445711523da.zip jitsi-81a2a1f5d947e490cd1b31e992627445711523da.tar.gz jitsi-81a2a1f5d947e490cd1b31e992627445711523da.tar.bz2 |
Show an add contact button for call history and external source contacts.
Diffstat (limited to 'src/net/java/sip/communicator/impl/gui/main/contactlist/SourceContactRightButtonMenu.java')
-rw-r--r-- | src/net/java/sip/communicator/impl/gui/main/contactlist/SourceContactRightButtonMenu.java | 91 |
1 files changed, 2 insertions, 89 deletions
diff --git a/src/net/java/sip/communicator/impl/gui/main/contactlist/SourceContactRightButtonMenu.java b/src/net/java/sip/communicator/impl/gui/main/contactlist/SourceContactRightButtonMenu.java index e97361f..3ddd610 100644 --- a/src/net/java/sip/communicator/impl/gui/main/contactlist/SourceContactRightButtonMenu.java +++ b/src/net/java/sip/communicator/impl/gui/main/contactlist/SourceContactRightButtonMenu.java @@ -79,7 +79,8 @@ public class SourceContactRightButtonMenu if (cDetail != null) add(initCallMenu()); - addContactComponent = initAddContactMenu(); + addContactComponent + = TreeContactList.createAddContactMenu(sourceContact); if (addContactComponent != null) add(addContactComponent); @@ -151,94 +152,6 @@ public class SourceContactRightButtonMenu return callContactMenu; } - /** - * Initializes the add contact menu item. - * @return the add contact menu item - */ - private Component initAddContactMenu() - { - Component addContactComponentTmp = null; - - List<ContactDetail> details = sourceContact.getContactDetails(); - - if (details.size() == 1) - { - addContactComponentTmp - = new JMenuItem(GuiActivator.getResources().getI18NString( - "service.gui.ADD_CONTACT"), - new ImageIcon(ImageLoader - .getImage(ImageLoader.ADD_CONTACT_16x16_ICON))); - - final ContactDetail detail = details.get(0); - - ((JMenuItem) addContactComponentTmp) - .addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - showAddContactDialog(detail); - } - }); - } - // If we have more than one details we would propose a separate menu - // item for each one of them. - else if (details.size() > 1) - { - addContactComponentTmp - = new JMenu(GuiActivator.getResources().getI18NString( - "service.gui.ADD_CONTACT")); - - Iterator<ContactDetail> detailsIter = details.iterator(); - - while (detailsIter.hasNext()) - { - final ContactDetail detail = detailsIter.next(); - - JMenuItem addMenuItem - = new JMenuItem(detail.getContactAddress()); - ((JMenu) addContactComponentTmp).add(addMenuItem); - - addMenuItem.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - showAddContactDialog(detail); - } - }); - } - } - - return addContactComponentTmp; - } - - /** - * Creates and shows an <tt>AddContactDialog</tt> with a predefined - * <tt>contactAddress</tt> and <tt>protocolProvider</tt>. - * @param contactDetail the contact detail to be added - */ - private void showAddContactDialog(ContactDetail contactDetail) - { - AddContactDialog dialog = new AddContactDialog( - GuiActivator.getUIService().getMainFrame()); - - // Try to obtain a preferred provider. - ProtocolProviderService preferredProvider = null; - List<Class<? extends OperationSet>> opSetClasses - = contactDetail.getSupportedOperationSets(); - if (opSetClasses != null - && opSetClasses.size() > 0) - { - preferredProvider - = contactDetail.getPreferredProtocolProvider( - opSetClasses.get(0)); - } - if (preferredProvider != null) - dialog.setSelectedAccount(preferredProvider); - - dialog.setContactAddress(contactDetail.getContactAddress()); - dialog.setVisible(true); - } - // private Component initIMMenu() // { // SIPCommMenu callContactMenu = new SIPCommMenu( |