diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/ChatWritePanel.java b/src/net/java/sip/communicator/impl/gui/main/chat/ChatWritePanel.java index 9862e70a4..4b29106fa 100755 --- a/src/net/java/sip/communicator/impl/gui/main/chat/ChatWritePanel.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/ChatWritePanel.java @@ -285,29 +285,9 @@ private void initSmsLabel(final JPanel centerPanel) @Override public void actionPerformed(ActionEvent e) { - if(smsMode) + if(smsMode && !isIMAllowed()) { - // check are we allowed to change back to im mode - Object descr = chatPanel.getChatSession().getDescriptor(); - - if(descr instanceof MetaContact) - { - List imContact - = ((MetaContact)descr).getContactsForOperationSet( - OperationSetBasicInstantMessaging.class); - - if(imContact == null || imContact.size() == 0) - return; - } - else if(descr instanceof SourceContact) - { - List imContact - = ((SourceContact)descr).getContactDetails( - OperationSetBasicInstantMessaging.class); - - if(imContact == null || imContact.size() == 0) - return; - } + return; } smsMode = smsButton.isSelected(); @@ -496,6 +476,39 @@ public boolean isSmsSelected() return smsMode; } + /** + * Checks if sending IM message is allowed. When in sms mode, it + * can be the only method to send message. We will disable sms -> im + * switching. + * @return is IM allowed. + */ + private boolean isIMAllowed() + { + // check are we allowed to change back to im mode + Object descr = chatPanel.getChatSession().getDescriptor(); + + if(descr instanceof MetaContact) + { + List imContact + = ((MetaContact)descr).getContactsForOperationSet( + OperationSetBasicInstantMessaging.class); + + if(imContact == null || imContact.size() == 0) + return false; + } + else if(descr instanceof SourceContact) + { + List imContact + = ((SourceContact)descr).getContactDetails( + OperationSetBasicInstantMessaging.class); + + if(imContact == null || imContact.size() == 0) + return false; + } + + return true; + } + /** * The SendMessageAction is an AbstractAction that * sends the text that is currently in the write message area. @@ -1011,8 +1024,9 @@ private Component createChatTransportSelectorBox() chatPanel.getChatSession(), chatPanel.getChatSession().getCurrentChatTransport()); - if(ConfigurationUtils.isHideAccountSelectionWhenPossibleEnabled() + if((ConfigurationUtils.isHideAccountSelectionWhenPossibleEnabled() && transportSelectorBox.getMenu().getItemCount() <= 1) + || !isIMAllowed()) transportSelectorBox.setVisible(false); }