Checks if a custom contact action should be shown for a given contact.

cusax-fix
Yana Stamcheva 14 years ago
parent 77a2ef87b3
commit dcd1359631

@ -976,7 +976,50 @@ public static Collection<SIPCommButton> getContactCustomActionButtons(
if (customActionButtons == null)
initCustomActionButtons();
return customActionButtons.values();
Iterator<ContactAction<Contact>> customActionsIter
= customActionButtons.keySet().iterator();
Collection<SIPCommButton> availableCustomActionButtons
= new LinkedList<SIPCommButton>();
while (customActionsIter.hasNext())
{
ContactAction<Contact> contactAction = customActionsIter.next();
SIPCommButton actionButton = customActionButtons.get(contactAction);
if (isContactActionVisible(contactAction,
(MetaContact) metaContact.getDescriptor()))
{
availableCustomActionButtons.add(actionButton);
}
}
return availableCustomActionButtons;
}
/**
* Indicates if the given <tt>ContactAction</tt> should be visible for the
* given <tt>MetaContact</tt>.
*
* @param contactAction the <tt>ContactAction</tt> to verify
* @param metaContact the <tt>MetaContact</tt> for which we verify if the
* given action should be visible
* @return <tt>true</tt> if the given <tt>ContactAction</tt> is visible for
* the given <tt>MetaContact</tt>, <tt>false</tt> - otherwise
*/
private static boolean isContactActionVisible(
ContactAction<Contact> contactAction,
MetaContact metaContact)
{
Iterator<Contact> contactDetails = metaContact.getContacts();
while (contactDetails.hasNext())
{
if (contactAction.isVisible(contactDetails.next()))
return true;
}
return false;
}
/**

@ -436,6 +436,18 @@ public void setReadMessageCount(int count)
this.readMessageCount = count;
}
/**
* Returns the notification message corresponding to this notification
* contact.
*
* @return the <tt>NotificationMessage</tt> corresponding to this
* <tt>NotificationContact</tt>
*/
public NotificationMessage getNotificationMessage()
{
return notificationMessage;
}
/**
* The implementation of the <tt>UIContactDetail</tt> interface for the
* external source <tt>ContactDetail</tt>s.

@ -17,6 +17,7 @@
import net.java.sip.communicator.impl.gui.*;
import net.java.sip.communicator.impl.gui.main.contactlist.*;
import net.java.sip.communicator.service.contactlist.*;
import net.java.sip.communicator.service.customcontactactions.*;
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.service.protocol.OperationSetMessageWaiting.MessageType;
@ -148,9 +149,9 @@ public Iterator<? extends UIContact> getNotifications(UIGroup group)
}
/**
* Returns all custom action buttons for this meta contact.
* Returns all custom action buttons for this notification contact.
*
* @return a list of all custom action buttons for this meta contact
* @return a list of all custom action buttons for this notification contact
*/
public static Collection<SIPCommButton> getContactCustomActionButtons(
final NotificationContact notificationContact)
@ -160,7 +161,47 @@ public static Collection<SIPCommButton> getContactCustomActionButtons(
if (customActionButtons == null)
initCustomActionButtons();
return customActionButtons.values();
Iterator<ContactAction<NotificationMessage>> customActionsIter
= customActionButtons.keySet().iterator();
Collection<SIPCommButton> availableCustomActionButtons
= new LinkedList<SIPCommButton>();
while (customActionsIter.hasNext())
{
ContactAction<NotificationMessage> contactAction
= customActionsIter.next();
SIPCommButton actionButton = customActionButtons.get(contactAction);
if (isContactActionVisible( contactAction,
notificationContact))
{
availableCustomActionButtons.add(actionButton);
}
}
return availableCustomActionButtons;
}
/**
* Indicates if the given <tt>ContactAction</tt> should be visible for the
* given <tt>NotificationContact</tt>.
*
* @param contactAction the <tt>ContactAction</tt> to verify
* @param notifContact the <tt>NotificationContact</tt> for which we verify
* if the given action should be visible
* @return <tt>true</tt> if the given <tt>ContactAction</tt> is visible for
* the given <tt>NotificationContact</tt>, <tt>false</tt> - otherwise
*/
private static boolean isContactActionVisible(
ContactAction<NotificationMessage> contactAction,
NotificationContact notifContact)
{
if (contactAction.isVisible(notifContact.getNotificationMessage()))
return true;
return false;
}
/**

Loading…
Cancel
Save