From e5cd3360e64a00c103c62bca7eb702feee68e0af Mon Sep 17 00:00:00 2001 From: Yana Stamcheva Date: Fri, 28 May 2010 10:57:54 +0000 Subject: [PATCH] Fixed bug reported by Lubomir Marinov on dev ( May 28, 2010, subject : "Call from history... strangeness") --- resources/languages/resources.properties | 1 + .../ContactListTreeCellRenderer.java | 132 ++++++++++-------- 2 files changed, 74 insertions(+), 59 deletions(-) diff --git a/resources/languages/resources.properties b/resources/languages/resources.properties index eecc3d16b..be1245f37 100644 --- a/resources/languages/resources.properties +++ b/resources/languages/resources.properties @@ -75,6 +75,7 @@ service.gui.BROWSE=Browse service.gui.BUSY_MESSAGE=Sorry, I'm busy right now. service.gui.CALL=Call service.gui.CALL_CONTACT=Call contact +service.gui.CALL_FAILED=Call failed service.gui.CALL_HISTORY_TOOL_TIP=Click here to show call history service.gui.CALL_VIA=Call via: service.gui.CALL_NOT_SUPPORTING_PARTICIPANT=This call only supports participants from the {0} network and your {1} account. {2} does not contain any address for this network or account. diff --git a/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListTreeCellRenderer.java b/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListTreeCellRenderer.java index bad9e926e..dea55287d 100644 --- a/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListTreeCellRenderer.java +++ b/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListTreeCellRenderer.java @@ -16,6 +16,7 @@ import javax.swing.tree.*; import net.java.sip.communicator.impl.gui.*; +import net.java.sip.communicator.impl.gui.customcontrols.*; import net.java.sip.communicator.impl.gui.main.call.*; import net.java.sip.communicator.impl.gui.utils.*; import net.java.sip.communicator.service.contactlist.*; @@ -231,67 +232,9 @@ public ContactListTreeCellRenderer() { public void actionPerformed(ActionEvent e) { - ChooseCallAccountPopupMenu chooseAccountDialog = null; - if (treeNode != null && treeNode instanceof ContactNode) { - List telephonyContacts - = ((ContactNode) treeNode).getContactDescriptor() - .getContactDetailsForOperationSet( - OperationSetBasicTelephony.class); - - if (telephonyContacts.size() == 1) - { - UIContactDetail detail - = telephonyContacts.get(0); - - ProtocolProviderService preferredProvider - = detail.getPreferredProtocolProvider( - OperationSetBasicTelephony.class); - - if (preferredProvider != null) - CallManager.createCall( - preferredProvider, - detail.getAddress()); - else - { - List providers - = CallManager.getTelephonyProviders(); - - int providersCount = providers.size(); - - if (providersCount == 1) - CallManager.createCall( - providers.get(0), - detail.getAddress()); - else if (providersCount > 1) - chooseAccountDialog - = new ChooseCallAccountPopupMenu( - tree, detail.getAddress(), providers); - } - } - else if (telephonyContacts.size() > 1) - { - chooseAccountDialog - = new ChooseCallAccountPopupMenu( - tree, - telephonyContacts); - } - - // If the choose dialog is created we're going to show it. - if (chooseAccountDialog != null) - { - Point location = new Point(callButton.getX(), - callButton.getY() + callButton.getHeight()); - - SwingUtilities.convertPointToScreen( - location, tree); - - location.y = location.y - + tree.getPathBounds(tree.getSelectionPath()).y; - chooseAccountDialog - .showPopupMenu(location.x + 8, location.y - 8); - } + call(treeNode); } } }); @@ -701,4 +644,75 @@ public JButton getCallButton() { return callButton; } + + /** + * Calls the given treeNode. + * @param treeNode the TreeNode to call + */ + private void call(TreeNode treeNode) + { + List telephonyContacts + = ((ContactNode) treeNode).getContactDescriptor() + .getContactDetailsForOperationSet( + OperationSetBasicTelephony.class); + + ChooseCallAccountPopupMenu chooseAccountDialog = null; + + if (telephonyContacts.size() == 1) + { + UIContactDetail detail = telephonyContacts.get(0); + + ProtocolProviderService preferredProvider + = detail.getPreferredProtocolProvider( + OperationSetBasicTelephony.class); + + if (preferredProvider != null && preferredProvider.isRegistered()) + { + CallManager.createCall(preferredProvider, detail.getAddress()); + } + else + { + List providers + = CallManager.getTelephonyProviders(); + + int providersCount = providers.size(); + + if (providersCount <= 0) + { + new ErrorDialog(null, + GuiActivator.getResources().getI18NString( + "service.gui.CALL_FAILED"), + GuiActivator.getResources().getI18NString( + "service.gui.NO_ONLINE_TELEPHONY_ACCOUNT")) + .showDialog(); + } + else if (providersCount == 1) + { + CallManager.createCall(providers.get(0), detail.getAddress()); + } + else if (providersCount > 1) + chooseAccountDialog = new ChooseCallAccountPopupMenu( + tree, detail.getAddress(), providers); + } + } + else if (telephonyContacts.size() > 1) + { + chooseAccountDialog + = new ChooseCallAccountPopupMenu(tree, telephonyContacts); + } + + // If the choose dialog is created we're going to show it. + if (chooseAccountDialog != null) + { + Point location = new Point(callButton.getX(), + callButton.getY() + callButton.getHeight()); + + SwingUtilities.convertPointToScreen(location, tree); + + location.y = location.y + + tree.getPathBounds(tree.getSelectionPath()).y; + + chooseAccountDialog.showPopupMenu(location.x + 8, location.y - 8); + } + } } \ No newline at end of file