Hides transport selector box if not needed and duplicates with already visible buttons.

fix-message-formatting
Damian Minkov 12 years ago
parent e058d0ff7f
commit d48739c1a5

@ -285,30 +285,10 @@ private void initSmsLabel(final JPanel centerPanel)
@Override
public void actionPerformed(ActionEvent e)
{
if(smsMode)
{
// check are we allowed to change back to im mode
Object descr = chatPanel.getChatSession().getDescriptor();
if(descr instanceof MetaContact)
if(smsMode && !isIMAllowed())
{
List<Contact> imContact
= ((MetaContact)descr).getContactsForOperationSet(
OperationSetBasicInstantMessaging.class);
if(imContact == null || imContact.size() == 0)
return;
}
else if(descr instanceof SourceContact)
{
List<ContactDetail> imContact
= ((SourceContact)descr).getContactDetails(
OperationSetBasicInstantMessaging.class);
if(imContact == null || imContact.size() == 0)
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<Contact> imContact
= ((MetaContact)descr).getContactsForOperationSet(
OperationSetBasicInstantMessaging.class);
if(imContact == null || imContact.size() == 0)
return false;
}
else if(descr instanceof SourceContact)
{
List<ContactDetail> imContact
= ((SourceContact)descr).getContactDetails(
OperationSetBasicInstantMessaging.class);
if(imContact == null || imContact.size() == 0)
return false;
}
return true;
}
/**
* The <tt>SendMessageAction</tt> is an <tt>AbstractAction</tt> 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);
}

Loading…
Cancel
Save