- Introduces new contact list data model that allows adding of external contact sources and hence the search in such sources.
- As part of the support for external contact sources, implements a call history external source and its user interface. - Addresses issue #706 Indicate missed callscusax-fix
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1023 B |
|
After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 9.0 KiB After Width: | Height: | Size: 13 KiB |
@ -0,0 +1,153 @@
|
||||
/*
|
||||
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
package net.java.sip.communicator.impl.callhistory;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import net.java.sip.communicator.service.callhistory.*;
|
||||
import net.java.sip.communicator.service.contactsource.*;
|
||||
|
||||
/**
|
||||
* The <tt>CallHistoryContactSource</tt> is the contact source for the call
|
||||
* history.
|
||||
*
|
||||
* @author Yana Stamcheva
|
||||
*/
|
||||
public class CallHistoryContactSource implements ContactSourceService
|
||||
{
|
||||
/**
|
||||
* The display name of this contact source.
|
||||
*/
|
||||
private static final String CALL_HISTORY_NAME = "Call history";
|
||||
|
||||
/**
|
||||
* Returns the display name of this contact source.
|
||||
* @return the display name of this contact source
|
||||
*/
|
||||
public String getDisplayName()
|
||||
{
|
||||
return CALL_HISTORY_NAME;
|
||||
}
|
||||
|
||||
/**
|
||||
* Queries this contact source for the given <tt>searchString</tt>.
|
||||
* @param queryString the string to search for
|
||||
* @return the created query
|
||||
*/
|
||||
public ContactQuery queryContactSource(String queryString)
|
||||
{
|
||||
if (queryString != null && queryString.length() > 0)
|
||||
return new CallHistoryQuery(
|
||||
CallHistoryActivator.getCallHistoryService()
|
||||
.findByPeer(queryString));
|
||||
else
|
||||
return new CallHistoryQuery(
|
||||
CallHistoryActivator.getCallHistoryService()
|
||||
.findLast(50));
|
||||
}
|
||||
|
||||
/**
|
||||
* The <tt>CallHistoryQuery</tt> contains information about a current query
|
||||
* to the contact source.
|
||||
*/
|
||||
private class CallHistoryQuery implements ContactQuery
|
||||
{
|
||||
/**
|
||||
* A list of all registered query listeners.
|
||||
*/
|
||||
private final List<ContactQueryListener> queryListeners
|
||||
= new LinkedList<ContactQueryListener>();
|
||||
|
||||
/**
|
||||
* A list of all source contact results.
|
||||
*/
|
||||
private final List<SourceContact> sourceContacts
|
||||
= new LinkedList<SourceContact>();
|
||||
|
||||
/**
|
||||
* Creates a <tt>CallHistoryQuery</tt>.
|
||||
* @param callRecords a collection of the result call records
|
||||
*/
|
||||
public CallHistoryQuery(Collection<CallRecord> callRecords)
|
||||
{
|
||||
Iterator<CallRecord> recordsIter = callRecords.iterator();
|
||||
|
||||
while (recordsIter.hasNext())
|
||||
{
|
||||
sourceContacts.add(
|
||||
new CallHistorySourceContact(
|
||||
CallHistoryContactSource.this,
|
||||
recordsIter.next()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the given <tt>ContactQueryListener</tt> to the list of query
|
||||
* listeners.
|
||||
* @param l the <tt>ContactQueryListener</tt> to add
|
||||
*/
|
||||
public void addContactQueryListener(ContactQueryListener l)
|
||||
{
|
||||
synchronized (queryListeners)
|
||||
{
|
||||
queryListeners.add(l);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This query could not be canceled.
|
||||
*/
|
||||
public void cancel()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the given <tt>ContactQueryListener</tt> from the list of
|
||||
* query listeners.
|
||||
* @param l the <tt>ContactQueryListener</tt> to remove
|
||||
*/
|
||||
public void removeContactQueryListener(ContactQueryListener l)
|
||||
{
|
||||
synchronized (queryListeners)
|
||||
{
|
||||
queryListeners.remove(l);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list containing the results of this query.
|
||||
* @return a list containing the results of this query
|
||||
*/
|
||||
public List<SourceContact> getQueryResults()
|
||||
{
|
||||
return sourceContacts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the <tt>ContactSourceService</tt>, where this query was first
|
||||
* initiated.
|
||||
* @return the <tt>ContactSourceService</tt>, where this query was first
|
||||
* initiated
|
||||
*/
|
||||
public ContactSourceService getContactSource()
|
||||
{
|
||||
return CallHistoryContactSource.this;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the identifier of this contact source. Some of the common
|
||||
* identifiers are defined here (For example the CALL_HISTORY identifier
|
||||
* should be returned by all call history implementations of this interface)
|
||||
* @return the identifier of this contact source
|
||||
*/
|
||||
public String getIdentifier()
|
||||
{
|
||||
return CALL_HISTORY;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,266 @@
|
||||
/*
|
||||
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
package net.java.sip.communicator.impl.callhistory;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import net.java.sip.communicator.service.callhistory.*;
|
||||
import net.java.sip.communicator.service.contactsource.*;
|
||||
import net.java.sip.communicator.service.protocol.*;
|
||||
import net.java.sip.communicator.util.*;
|
||||
|
||||
/**
|
||||
* The <tt>CallHistorySourceContact</tt> is an implementation of the
|
||||
* <tt>SourceContact</tt> interface based on a <tt>CallRecord</tt>.
|
||||
*
|
||||
* @author Yana Stamcheva
|
||||
*/
|
||||
public class CallHistorySourceContact implements SourceContact
|
||||
{
|
||||
/**
|
||||
* The parent <tt>CallHistoryContactSource</tt>, where this contact is
|
||||
* contained.
|
||||
*/
|
||||
private final CallHistoryContactSource contactSource;
|
||||
|
||||
/**
|
||||
* The corresponding call record.
|
||||
*/
|
||||
private final CallRecord callRecord;
|
||||
|
||||
/**
|
||||
* The incoming call icon.
|
||||
*/
|
||||
private static final byte[] incomingIcon
|
||||
= CallHistoryActivator.getResources()
|
||||
.getImageInBytes("service.gui.icons.INCOMING_CALL");
|
||||
|
||||
/**
|
||||
* The outgoing call icon.
|
||||
*/
|
||||
private static byte[] outgoingIcon
|
||||
= CallHistoryActivator.getResources()
|
||||
.getImageInBytes("service.gui.icons.OUTGOING_CALL");
|
||||
|
||||
/**
|
||||
* The missed call icon.
|
||||
*/
|
||||
private static byte[] missedCallIcon
|
||||
= CallHistoryActivator.getResources()
|
||||
.getImageInBytes("service.gui.icons.MISSED_CALL");
|
||||
|
||||
/**
|
||||
* A list of all contact details.
|
||||
*/
|
||||
private final List<ContactDetail> contactDetails
|
||||
= new LinkedList<ContactDetail>();
|
||||
|
||||
/**
|
||||
* The display name of this contact.
|
||||
*/
|
||||
private String displayName = "";
|
||||
|
||||
/**
|
||||
* The display details of this contact.
|
||||
*/
|
||||
private final String displayDetails;
|
||||
|
||||
/**
|
||||
* Creates an instance of <tt>CallHistorySourceContact</tt>
|
||||
* @param contactSource
|
||||
* @param callRecord
|
||||
*/
|
||||
public CallHistorySourceContact(CallHistoryContactSource contactSource,
|
||||
CallRecord callRecord)
|
||||
{
|
||||
this.contactSource = contactSource;
|
||||
this.callRecord = callRecord;
|
||||
|
||||
this.initPeerDetails();
|
||||
|
||||
this.displayDetails
|
||||
= CallHistoryActivator.getResources()
|
||||
.getI18NString("service.gui.AT") + ": "
|
||||
+ getDateString(callRecord.getStartTime().getTime())
|
||||
+ " " + CallHistoryActivator.getResources()
|
||||
.getI18NString("service.gui.DURATION") + ": "
|
||||
+ GuiUtils.formatTime(
|
||||
GuiUtils.substractDates(
|
||||
callRecord.getEndTime(), callRecord.getStartTime()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes peer details.
|
||||
*/
|
||||
private void initPeerDetails()
|
||||
{
|
||||
Iterator<CallPeerRecord> recordsIter
|
||||
= callRecord.getPeerRecords().iterator();
|
||||
|
||||
while (recordsIter.hasNext())
|
||||
{
|
||||
String peerAddress = recordsIter.next().getPeerAddress();
|
||||
|
||||
if (displayName.length() > 0)
|
||||
displayName += "," + peerAddress;
|
||||
else
|
||||
displayName += peerAddress;
|
||||
|
||||
if (peerAddress != null)
|
||||
{
|
||||
ContactDetail contactDetail = new ContactDetail(peerAddress);
|
||||
|
||||
Map<Class<? extends OperationSet>, ProtocolProviderService>
|
||||
preferredProviders = null;
|
||||
if (callRecord.getProtocolProvider() != null)
|
||||
{
|
||||
preferredProviders
|
||||
= new Hashtable<Class<? extends OperationSet>,
|
||||
ProtocolProviderService>();
|
||||
|
||||
preferredProviders.put( OperationSetBasicTelephony.class,
|
||||
callRecord.getProtocolProvider());
|
||||
|
||||
contactDetail
|
||||
.setPreferredProviders(preferredProviders);
|
||||
}
|
||||
|
||||
// Set supported operation sets.
|
||||
LinkedList<Class<? extends OperationSet>> supportedOpSets
|
||||
= new LinkedList<Class<? extends OperationSet>>();
|
||||
|
||||
supportedOpSets.add(OperationSetBasicTelephony.class);
|
||||
contactDetail.setSupportedOpSets(supportedOpSets);
|
||||
|
||||
contactDetails.add(contactDetail);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of available contact details.
|
||||
* @return a list of available contact details
|
||||
*/
|
||||
public List<ContactDetail> getContactDetails()
|
||||
{
|
||||
return new LinkedList<ContactDetail>(contactDetails);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the parent <tt>ContactSourceService</tt> from which this contact
|
||||
* came from.
|
||||
* @return the parent <tt>ContactSourceService</tt> from which this contact
|
||||
* came from
|
||||
*/
|
||||
public ContactSourceService getContactSource()
|
||||
{
|
||||
return contactSource;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the display details of this search contact. This could be any
|
||||
* important information that should be shown to the user.
|
||||
*
|
||||
* @return the display details of the search contact
|
||||
*/
|
||||
public String getDisplayDetails()
|
||||
{
|
||||
return displayDetails;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the display name of this search contact. This is a user-friendly
|
||||
* name that could be shown in the user interface.
|
||||
*
|
||||
* @return the display name of this search contact
|
||||
*/
|
||||
public String getDisplayName()
|
||||
{
|
||||
return displayName;
|
||||
}
|
||||
|
||||
/**
|
||||
* An image (or avatar) corresponding to this search contact. If such is
|
||||
* not available this method will return null.
|
||||
*
|
||||
* @return the byte array of the image or null if no image is available
|
||||
*/
|
||||
public byte[] getImage()
|
||||
{
|
||||
if (callRecord.getDirection().equals(CallRecord.IN))
|
||||
{
|
||||
if (callRecord.getStartTime().equals(callRecord.getEndTime()))
|
||||
return missedCallIcon;
|
||||
else
|
||||
return incomingIcon;
|
||||
}
|
||||
else if (callRecord.getDirection().equals(CallRecord.OUT))
|
||||
return outgoingIcon;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of all <tt>ContactDetail</tt>s supporting the given
|
||||
* <tt>OperationSet</tt> class.
|
||||
* @param operationSet the <tt>OperationSet</tt> class we're looking for
|
||||
* @return a list of all <tt>ContactDetail</tt>s supporting the given
|
||||
* <tt>OperationSet</tt> class
|
||||
*/
|
||||
public List<ContactDetail> getContactDetails(
|
||||
Class<? extends OperationSet> operationSet)
|
||||
{
|
||||
// We support only call details.
|
||||
if (!operationSet.equals(OperationSetBasicTelephony.class))
|
||||
return null;
|
||||
|
||||
return new LinkedList<ContactDetail>(contactDetails);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the preferred <tt>ContactDetail</tt> for a given
|
||||
* <tt>OperationSet</tt> class.
|
||||
* @param operationSet the <tt>OperationSet</tt> class, for which we would
|
||||
* like to obtain a <tt>ContactDetail</tt>
|
||||
* @return the preferred <tt>ContactDetail</tt> for a given
|
||||
* <tt>OperationSet</tt> class
|
||||
*/
|
||||
public ContactDetail getPreferredContactDetail(
|
||||
Class<? extends OperationSet> operationSet)
|
||||
{
|
||||
// We support only call details.
|
||||
if (!operationSet.equals(OperationSetBasicTelephony.class))
|
||||
return null;
|
||||
|
||||
return contactDetails.get(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the date string to show for the given date.
|
||||
*
|
||||
* @param date the date to format
|
||||
* @return the date string to show for the given date
|
||||
*/
|
||||
public static String getDateString(long date)
|
||||
{
|
||||
String time = GuiUtils.formatTime(date);
|
||||
|
||||
// If the current date we don't go in there and we'll return just the
|
||||
// time.
|
||||
if (GuiUtils.compareDatesOnly(date, System.currentTimeMillis()) < 0)
|
||||
{
|
||||
StringBuffer dateStrBuf = new StringBuffer();
|
||||
|
||||
GuiUtils.formatDate(date, dateStrBuf);
|
||||
dateStrBuf.append(" ");
|
||||
dateStrBuf.append(time);
|
||||
return dateStrBuf.toString();
|
||||
}
|
||||
|
||||
return time;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,177 @@
|
||||
/*
|
||||
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
package net.java.sip.communicator.impl.gui.main.call;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import net.java.sip.communicator.impl.gui.*;
|
||||
import net.java.sip.communicator.impl.gui.main.contactlist.*;
|
||||
import net.java.sip.communicator.impl.gui.utils.*;
|
||||
import net.java.sip.communicator.util.swing.*;
|
||||
|
||||
/**
|
||||
* The <tt>CallHistoryButton</tt> is the button shown on the top of the contact
|
||||
* list.
|
||||
* @author Yana Stamcheva
|
||||
*/
|
||||
public class CallHistoryButton
|
||||
extends SIPCommTextButton
|
||||
implements MissedCallsListener
|
||||
{
|
||||
/**
|
||||
* The history icon.
|
||||
*/
|
||||
private final Image historyImage
|
||||
= ImageLoader.getImage(ImageLoader.CALL_HISTORY_BUTTON);
|
||||
|
||||
/**
|
||||
* The history pressed icon.
|
||||
*/
|
||||
private final Image pressedImage
|
||||
= ImageLoader.getImage(ImageLoader.CALL_HISTORY_BUTTON_PRESSED);
|
||||
|
||||
/**
|
||||
* Indicates if the history is visible.
|
||||
*/
|
||||
private boolean isHistoryVisible = false;
|
||||
|
||||
/**
|
||||
* Indicates if this button currently shows the number of missed calls or
|
||||
* the just the history icon.
|
||||
*/
|
||||
private boolean isMissedCallView = false;
|
||||
|
||||
/**
|
||||
* The tool tip shown when there are missed calls.
|
||||
*/
|
||||
private final static String missedCallsToolTip
|
||||
= GuiActivator.getResources().getI18NString(
|
||||
"service.gui.MISSED_CALLS_TOOL_TIP");
|
||||
|
||||
/**
|
||||
* The tool tip shown by default over the history button.
|
||||
*/
|
||||
private final static String callHistoryToolTip
|
||||
= GuiActivator.getResources().getI18NString(
|
||||
"service.gui.CALL_HISTORY_TOOL_TIP");
|
||||
|
||||
/**
|
||||
* The tool tip shown when we're in history view.
|
||||
*/
|
||||
private final static String showContactListToolTip
|
||||
= GuiActivator.getResources().getI18NString(
|
||||
"service.gui.SHOW_CONTACT_LIST_TOOL_TIP");
|
||||
|
||||
/**
|
||||
* Creates a <tt>CallHistoryButton</tt>.
|
||||
*/
|
||||
public CallHistoryButton()
|
||||
{
|
||||
super("");
|
||||
|
||||
this.setBgImage(historyImage);
|
||||
|
||||
CallManager.setMissedCallsListener(this);
|
||||
|
||||
this.setPreferredSize(new Dimension(29, 22));
|
||||
this.setForeground(Color.WHITE);
|
||||
this.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
|
||||
this.setFont(getFont().deriveFont(Font.BOLD, 10f));
|
||||
this.setToolTipText(callHistoryToolTip);
|
||||
this.setBackground(new Color(255, 255, 255, 160));
|
||||
|
||||
this.addActionListener(new ActionListener()
|
||||
{
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
if (isHistoryVisible && !isMissedCallView)
|
||||
{
|
||||
TreeContactList.searchFilter
|
||||
.setSearchSourceType(SearchFilter.DEFAULT_SOURCE);
|
||||
GuiActivator.getContactList()
|
||||
.setDefaultFilter(TreeContactList.presenceFilter);
|
||||
GuiActivator.getContactList().applyFilter(
|
||||
TreeContactList.presenceFilter);
|
||||
|
||||
isHistoryVisible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
TreeContactList.searchFilter
|
||||
.setSearchSourceType(SearchFilter.HISTORY_SOURCE);
|
||||
GuiActivator.getContactList()
|
||||
.setDefaultFilter(TreeContactList.historyFilter);
|
||||
GuiActivator.getContactList()
|
||||
.applyFilter(TreeContactList.historyFilter);
|
||||
|
||||
CallManager.clearMissedCalls();
|
||||
|
||||
isHistoryVisible = true;
|
||||
}
|
||||
setHistoryView();
|
||||
|
||||
GuiActivator.getContactList().requestFocusInWindow();
|
||||
repaint();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates that missed calls count has changed.
|
||||
* @param newCallCount the new call count
|
||||
*/
|
||||
public void missedCallCountChanged(int newCallCount)
|
||||
{
|
||||
if (newCallCount > 0)
|
||||
{
|
||||
setMissedCallsView(newCallCount);
|
||||
}
|
||||
else if (newCallCount <= 0)
|
||||
{
|
||||
setHistoryView();
|
||||
}
|
||||
|
||||
this.revalidate();
|
||||
this.repaint();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the history view.
|
||||
*/
|
||||
private void setHistoryView()
|
||||
{
|
||||
isMissedCallView = false;
|
||||
|
||||
if (isHistoryVisible)
|
||||
{
|
||||
setBgImage(pressedImage);
|
||||
setToolTipText(showContactListToolTip);
|
||||
}
|
||||
else
|
||||
{
|
||||
setBgImage(historyImage);
|
||||
setToolTipText(callHistoryToolTip);
|
||||
}
|
||||
setText("");
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the missed calls view of this button.
|
||||
* @param callCount the missed calls count
|
||||
*/
|
||||
private void setMissedCallsView(int callCount)
|
||||
{
|
||||
isMissedCallView = true;
|
||||
this.setBgImage(null);
|
||||
this.setToolTipText(missedCallsToolTip);
|
||||
this.setBackground(new Color(200, 0, 0));
|
||||
this.setText(new Integer(callCount).toString());
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,23 @@
|
||||
/*
|
||||
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
package net.java.sip.communicator.impl.gui.main.call;
|
||||
|
||||
/**
|
||||
* The <tt>MissedCallsListener</tt> listens for changes in the missed calls
|
||||
* count. It is notified each time when a missed calls is registered by the
|
||||
* <tt>CallManager</tt>.
|
||||
*
|
||||
* @author Yana Stamcheva
|
||||
*/
|
||||
public interface MissedCallsListener
|
||||
{
|
||||
/**
|
||||
* Indicates the missed calls count has changed.
|
||||
* @param newCallCount the new missed calls count
|
||||
*/
|
||||
public void missedCallCountChanged(int newCallCount);
|
||||
}
|
||||
@ -0,0 +1,154 @@
|
||||
/*
|
||||
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
package net.java.sip.communicator.impl.gui.main.contactlist;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import net.java.sip.communicator.impl.gui.*;
|
||||
import net.java.sip.communicator.impl.gui.main.contactlist.contactsource.*;
|
||||
import net.java.sip.communicator.service.contactsource.*;
|
||||
|
||||
/**
|
||||
* The <tt>CallHistoryFilter</tt> is a filter over the history contact sources.
|
||||
*
|
||||
* @author Yana Stamcheva
|
||||
*/
|
||||
public class CallHistoryFilter
|
||||
implements ContactListFilter,
|
||||
ContactQueryListener
|
||||
{
|
||||
/**
|
||||
* The <tt>ContactListTreeModel</tt>, where the results of this filter are
|
||||
* stored
|
||||
*/
|
||||
private ContactListTreeModel resultTreeModel;
|
||||
|
||||
/**
|
||||
* The current <tt>ContactQuery</tt>.
|
||||
*/
|
||||
private ContactQuery currentQuery;
|
||||
|
||||
/**
|
||||
* Applies this filter and stores the result in the given <tt>treeModel</tt>.
|
||||
*
|
||||
* @param treeModel the <tt>ContactListTreeModel</tt>, where the results
|
||||
* of this filter are stored
|
||||
*/
|
||||
public void applyFilter(ContactListTreeModel treeModel)
|
||||
{
|
||||
this.resultTreeModel = treeModel;
|
||||
|
||||
Collection<ExternalContactSource> contactSources
|
||||
= TreeContactList.getContactSources();
|
||||
|
||||
for (ExternalContactSource contactSource : contactSources)
|
||||
{
|
||||
ContactSourceService sourceService
|
||||
= contactSource.getContactSourceService();
|
||||
|
||||
if (!sourceService.getIdentifier()
|
||||
.equals(ContactSourceService.CALL_HISTORY))
|
||||
continue;
|
||||
|
||||
// We're in a case of call history contact source.
|
||||
currentQuery = sourceService.queryContactSource("");
|
||||
|
||||
// Add first available results.
|
||||
this.addMatching( currentQuery.getQueryResults(),
|
||||
contactSource);
|
||||
|
||||
currentQuery.addContactQueryListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isMatching(UIContact uiContact)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isMatching(UIGroup uiGroup)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds matching <tt>sourceContacts</tt> to the result tree model.
|
||||
* @param sourceContacts the list of <tt>SourceContact</tt>s to add
|
||||
* @param uiSource the <tt>ExternalContactSource</tt>, which contacts
|
||||
* we're adding
|
||||
*/
|
||||
private void addMatching( List<SourceContact> sourceContacts,
|
||||
ExternalContactSource uiSource)
|
||||
{
|
||||
Iterator<SourceContact> contactsIter = sourceContacts.iterator();
|
||||
|
||||
while (contactsIter.hasNext())
|
||||
{
|
||||
addHistoryContact(contactsIter.next(), uiSource);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates that a contact has been received for a query.
|
||||
* @param event the <tt>ContactReceivedEvent</tt> that notified us
|
||||
*/
|
||||
public void contactReceived(ContactReceivedEvent event)
|
||||
{
|
||||
synchronized (resultTreeModel)
|
||||
{
|
||||
ExternalContactSource sourceUI
|
||||
= TreeContactList.getContactSource(
|
||||
event.getQuerySource().getContactSource());
|
||||
|
||||
addHistoryContact(event.getContact(), sourceUI);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates that the query status has changed.
|
||||
* @param event the <tt>ContactQueryStatusEvent</tt> that notified us
|
||||
*/
|
||||
public void queryStatusChanged(ContactQueryStatusEvent event)
|
||||
{
|
||||
int eventType = event.getEventType();
|
||||
|
||||
// Remove the current query when it's stopped for some reason.
|
||||
// QUERY_COMPLETED, QUERY_COMPLETED, QUERY_ERROR
|
||||
currentQuery = null;
|
||||
|
||||
if (eventType == ContactQueryStatusEvent.QUERY_ERROR)
|
||||
{
|
||||
//TODO: Show the error to the user??
|
||||
}
|
||||
|
||||
event.getQuerySource().removeContactQueryListener(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the given <tt>sourceContact</tt> to the contact list.
|
||||
* @param sourceContact the <tt>SourceContact</tt> to add
|
||||
* @param uiSource the UI adapter for the original contact source
|
||||
*/
|
||||
private void addHistoryContact( SourceContact sourceContact,
|
||||
ExternalContactSource uiSource)
|
||||
{
|
||||
GuiActivator.getContactList()
|
||||
.addContact(resultTreeModel,
|
||||
uiSource.getUIContact(sourceContact),
|
||||
false,
|
||||
false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stops this filter current queries.
|
||||
*/
|
||||
public void stopFilter()
|
||||
{
|
||||
if (currentQuery != null)
|
||||
currentQuery.cancel();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,136 @@
|
||||
/*
|
||||
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
package net.java.sip.communicator.impl.gui.main.contactlist;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.util.*;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import net.java.sip.communicator.impl.gui.*;
|
||||
import net.java.sip.communicator.impl.gui.main.call.*;
|
||||
import net.java.sip.communicator.impl.gui.main.contactlist.contactsource.*;
|
||||
import net.java.sip.communicator.impl.gui.utils.*;
|
||||
import net.java.sip.communicator.service.contactsource.*;
|
||||
import net.java.sip.communicator.service.protocol.*;
|
||||
import net.java.sip.communicator.util.swing.*;
|
||||
|
||||
/**
|
||||
* The right button menu for external contact sources.
|
||||
* @see ExternalContactSource
|
||||
*/
|
||||
public class SourceContactRightButtonMenu
|
||||
extends JPopupMenu
|
||||
{
|
||||
private final SourceContact sourceContact;
|
||||
|
||||
/**
|
||||
* Creates an instance of <tt>SourceContactRightButtonMenu</tt> by
|
||||
* specifying the <tt>SourceContact</tt>, for which this menu is created.
|
||||
* @param sourceContact the <tt>SourceContact</tt>, for which this menu is
|
||||
* created
|
||||
*/
|
||||
public SourceContactRightButtonMenu(SourceContact sourceContact)
|
||||
{
|
||||
this.sourceContact = sourceContact;
|
||||
|
||||
this.initItems();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes menu items.
|
||||
*/
|
||||
private void initItems()
|
||||
{
|
||||
ContactDetail cDetail = sourceContact
|
||||
.getPreferredContactDetail(OperationSetBasicTelephony.class);
|
||||
|
||||
if (cDetail != null)
|
||||
add(initCallMenu());
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the call menu.
|
||||
* @return the call menu
|
||||
*/
|
||||
private Component initCallMenu()
|
||||
{
|
||||
SIPCommMenu callContactMenu = new SIPCommMenu(
|
||||
GuiActivator.getResources().getI18NString("service.gui.CALL"));
|
||||
callContactMenu.setIcon(new ImageIcon(ImageLoader
|
||||
.getImage(ImageLoader.CALL_16x16_ICON)));
|
||||
|
||||
Iterator<ContactDetail> details
|
||||
= sourceContact.getContactDetails(OperationSetBasicTelephony.class)
|
||||
.iterator();
|
||||
|
||||
while (details.hasNext())
|
||||
{
|
||||
final ContactDetail detail = details.next();
|
||||
// add all the contacts that support telephony to the call menu
|
||||
JMenuItem callContactItem = new JMenuItem();
|
||||
callContactItem.setName(detail.getContactAddress());
|
||||
callContactItem.addActionListener(new ActionListener()
|
||||
{
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
ProtocolProviderService protocolProvider
|
||||
= detail.getPreferredProtocolProvider(
|
||||
OperationSetBasicTelephony.class);
|
||||
|
||||
if (protocolProvider != null)
|
||||
CallManager.createCall( protocolProvider,
|
||||
detail.getContactAddress());
|
||||
else
|
||||
CallManager.createCall(detail.getContactAddress());
|
||||
}
|
||||
});
|
||||
callContactMenu.add(callContactItem);
|
||||
}
|
||||
return callContactMenu;
|
||||
}
|
||||
|
||||
// private Component initIMMenu()
|
||||
// {
|
||||
// SIPCommMenu callContactMenu = new SIPCommMenu(
|
||||
// GuiActivator.getResources().getI18NString(
|
||||
// "service.gui.SEND_MESSAGE"));
|
||||
// callContactMenu.setIcon(new ImageIcon(ImageLoader
|
||||
// .getImage(ImageLoader.SEND_MESSAGE_16x16_ICON)));
|
||||
//
|
||||
// Iterator<ContactDetail> details
|
||||
// = sourceContact.getContactDetails(
|
||||
// OperationSetBasicInstantMessaging.class).iterator();
|
||||
//
|
||||
// while (details.hasNext())
|
||||
// {
|
||||
// final ContactDetail detail = details.next();
|
||||
// // add all the contacts that support telephony to the call menu
|
||||
// JMenuItem callContactItem = new JMenuItem();
|
||||
// callContactItem.setName(detail.getContactAddress());
|
||||
// callContactItem.addActionListener(new ActionListener()
|
||||
// {
|
||||
// public void actionPerformed(ActionEvent e)
|
||||
// {
|
||||
// ProtocolProviderService protocolProvider
|
||||
// = detail.getPreferredProtocolProvider(
|
||||
// OperationSetBasicInstantMessaging.class);
|
||||
//
|
||||
// if (protocolProvider != null)
|
||||
// CallManager.createCall( protocolProvider,
|
||||
// detail.getContactAddress());
|
||||
// else
|
||||
// GuiActivator.getUIService().getChatWindowManager()
|
||||
// .startChat(contactItem);
|
||||
// }
|
||||
// });
|
||||
// callContactMenu.add(callContactItem);
|
||||
// }
|
||||
// return callContactMenu;
|
||||
// }
|
||||
}
|
||||
@ -0,0 +1,128 @@
|
||||
/*
|
||||
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
package net.java.sip.communicator.impl.gui.main.contactlist;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import net.java.sip.communicator.impl.gui.utils.*;
|
||||
import net.java.sip.communicator.service.protocol.*;
|
||||
|
||||
/**
|
||||
* The <tt>UIContact</tt> represents the user interface contact contained in the
|
||||
* contact list component.
|
||||
*
|
||||
* @author Yana Stamcheva
|
||||
*/
|
||||
public interface UIContact
|
||||
{
|
||||
/**
|
||||
* Returns the descriptor of this contact.
|
||||
* @return the descriptor of this contact
|
||||
*/
|
||||
public Object getDescriptor();
|
||||
|
||||
/**
|
||||
* Returns the display name of this contact.
|
||||
* @return the display name of this contact
|
||||
*/
|
||||
public String getDisplayName();
|
||||
|
||||
/**
|
||||
* Returns the display details of this contact. These would be shown
|
||||
* whenever the contact is selected.
|
||||
* @return the display details of this contact
|
||||
*/
|
||||
public String getDisplayDetails();
|
||||
|
||||
/**
|
||||
* Returns the index of this contact in its source.
|
||||
* @return the source index
|
||||
*/
|
||||
public int getSourceIndex();
|
||||
|
||||
/**
|
||||
* Returns the avatar of this contact.
|
||||
* @param isSelected indicates if the contact is selected
|
||||
* @param width the width of the avatar
|
||||
* @param height the height of the avatar
|
||||
* @return the avatar of this contact
|
||||
*/
|
||||
public ImageIcon getAvatar(boolean isSelected, int width, int height);
|
||||
|
||||
/**
|
||||
* Returns the status icon of this contact or null if no status is
|
||||
* available.
|
||||
* @return the status icon of this contact or null if no status is
|
||||
* available
|
||||
*/
|
||||
public ImageIcon getStatusIcon();
|
||||
|
||||
/**
|
||||
* Creates a tool tip for this contact. If such tooltip is
|
||||
* provided it would be shown on mouse over over this <tt>UIContact</tt>.
|
||||
* @return the tool tip for this contact descriptor
|
||||
*/
|
||||
public ExtendedTooltip getToolTip();
|
||||
|
||||
/**
|
||||
* Returns the right button menu component.
|
||||
* @return the right button menu component
|
||||
*/
|
||||
public JPopupMenu getRightButtonMenu();
|
||||
|
||||
/**
|
||||
* Returns the parent group.
|
||||
* @return the parent group
|
||||
*/
|
||||
public UIGroup getParentGroup();
|
||||
|
||||
/**
|
||||
* Returns an <tt>Iterator</tt> over a list of the search strings of this
|
||||
* contact.
|
||||
* @return an <tt>Iterator</tt> over a list of the search strings of this
|
||||
* contact
|
||||
*/
|
||||
public Iterator<String> getSearchStrings();
|
||||
|
||||
/**
|
||||
* Returns the corresponding <tt>ContactNode</tt>. The <tt>ContactNode</tt>
|
||||
* is the real node that is stored in the contact list component data model.
|
||||
* @return the corresponding <tt>ContactNode</tt>
|
||||
*/
|
||||
public ContactNode getContactNode();
|
||||
|
||||
/**
|
||||
* Sets the given <tt>contactNode</tt>. The <tt>ContactNode</tt>
|
||||
* is the real node that is stored in the contact list component data model.
|
||||
* @param contactNode the <tt>ContactNode</tt> that corresponds to this
|
||||
* <tt>UIGroup</tt>
|
||||
*/
|
||||
public void setContactNode(ContactNode contactNode);
|
||||
|
||||
/**
|
||||
* Returns the default <tt>ContactDetail</tt> to use for any operations
|
||||
* depending to the given <tt>OperationSet</tt> class.
|
||||
* @param opSetClass the <tt>OperationSet</tt> class we're interested in
|
||||
* @return the default <tt>ContactDetail</tt> to use for any operations
|
||||
* depending to the given <tt>OperationSet</tt> class
|
||||
*/
|
||||
public UIContactDetail getDefaultContactDetail(
|
||||
Class<? extends OperationSet> opSetClass);
|
||||
|
||||
/**
|
||||
* Returns a list of all <tt>UIContactDetail</tt>s corresponding to the
|
||||
* given <tt>OperationSet</tt> class.
|
||||
* @param opSetClass the <tt>OperationSet</tt> class we're looking for
|
||||
* @return a list of all <tt>UIContactDetail</tt>s corresponding to the
|
||||
* given <tt>OperationSet</tt> class
|
||||
*/
|
||||
public List<UIContactDetail> getContactDetailsForOperationSet(
|
||||
Class<? extends OperationSet> opSetClass);
|
||||
}
|
||||
@ -0,0 +1,90 @@
|
||||
/*
|
||||
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
package net.java.sip.communicator.impl.gui.main.contactlist;
|
||||
|
||||
import net.java.sip.communicator.service.protocol.*;
|
||||
|
||||
/**
|
||||
* The <tt>UIContactDetail</tt> corresponds to a particular contact detail,
|
||||
* phone number, IM identifier, email, etc. which has it's preferred mode of
|
||||
* transport <tt>ProtocolProviderService</tt>.
|
||||
*
|
||||
* @author Yana Stamcheva
|
||||
*/
|
||||
public abstract class UIContactDetail
|
||||
{
|
||||
/**
|
||||
* The address of this detail.
|
||||
*/
|
||||
private final String address;
|
||||
|
||||
/**
|
||||
* The display name of this detail.
|
||||
*/
|
||||
private final String displayName;
|
||||
|
||||
/**
|
||||
* The <tt>ProtocolProviderService</tt> corresponding to this detail.
|
||||
*/
|
||||
private final ProtocolProviderService protocolProvider;
|
||||
|
||||
/**
|
||||
* Creates a <tt>UIContactDetail</tt> by specifying the contact
|
||||
* <tt>address</tt>, the <tt>displayName</tt> and <tt>preferredProvider</tt>.
|
||||
* @param address the contact address
|
||||
* @param displayName the contact display name
|
||||
* @param preferredProvider the preferred protocol provider
|
||||
*/
|
||||
public UIContactDetail(
|
||||
String address,
|
||||
String displayName,
|
||||
ProtocolProviderService preferredProvider)
|
||||
{
|
||||
this.address = address;
|
||||
this.displayName = displayName;
|
||||
this.protocolProvider = preferredProvider;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the display name of this detail.
|
||||
* @return the display name of this detail
|
||||
*/
|
||||
public String getDisplayName()
|
||||
{
|
||||
return displayName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the address of this detail.
|
||||
* @return the address of this detail
|
||||
*/
|
||||
public String getAddress()
|
||||
{
|
||||
return address;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the protocol provider preferred for contacting this detail for
|
||||
* the given <tt>OperationSet</tt> class.
|
||||
* @param opSetClass the <tt>OperationSet</tt> class for which we're looking
|
||||
* for provider
|
||||
* @return the protocol provider preferred for contacting this detail
|
||||
*/
|
||||
public ProtocolProviderService getPreferredProtocolProvider(
|
||||
Class<? extends OperationSet> opSetClass)
|
||||
{
|
||||
return protocolProvider;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the <tt>PresenceStatus</tt> of this <tt>ContactDetail</tt> or
|
||||
* null if the detail doesn't support presence.
|
||||
* @return the <tt>PresenceStatus</tt> of this <tt>ContactDetail</tt> or
|
||||
* null if the detail doesn't support presence
|
||||
*/
|
||||
public abstract PresenceStatus getPresenceStatus();
|
||||
}
|
||||
@ -0,0 +1,89 @@
|
||||
/*
|
||||
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
package net.java.sip.communicator.impl.gui.main.contactlist;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* The <tt>UIGroup</tt> represents the user interface contact list group.
|
||||
*
|
||||
* @author Yana Stamcheva
|
||||
*/
|
||||
public interface UIGroup
|
||||
{
|
||||
/**
|
||||
* Returns the descriptor of the group. This would be the underlying object
|
||||
* that should provide all other necessary information for the group.
|
||||
* @return the descriptor of the group
|
||||
*/
|
||||
public Object getDescriptor();
|
||||
|
||||
/**
|
||||
* The display name of the group. The display name is the name to be shown
|
||||
* in the contact list group row.
|
||||
* @return the display name of the group
|
||||
*/
|
||||
public String getDisplayName();
|
||||
|
||||
/**
|
||||
* Returns the index of this group in its source. In other words this is
|
||||
* the descriptor index.
|
||||
* @return the index of this group in its source
|
||||
*/
|
||||
public int getSourceIndex();
|
||||
|
||||
/**
|
||||
* Returns the parent group.
|
||||
* @return the parent group
|
||||
*/
|
||||
public UIGroup getParentGroup();
|
||||
|
||||
/**
|
||||
* Indicates if the group is collapsed or expanded.
|
||||
* @return <tt>true</tt> to indicate that the group is collapsed,
|
||||
* <tt>false</tt> to indicate that it's expanded
|
||||
*/
|
||||
public boolean isGroupCollapsed();
|
||||
|
||||
/**
|
||||
* Returns the count of online child contacts.
|
||||
* @return the count of online child contacts
|
||||
*/
|
||||
public int countOnlineChildContacts();
|
||||
|
||||
/**
|
||||
* Returns the child contacts count.
|
||||
* @return child contacts count
|
||||
*/
|
||||
public int countChildContacts();
|
||||
|
||||
/**
|
||||
* Returns the identifier of this group.
|
||||
* @return the identifier of this group
|
||||
*/
|
||||
public String getId();
|
||||
|
||||
/**
|
||||
* Returns the <tt>GroupNode</tt> corresponding to this <tt>UIGroup</tt>.
|
||||
* The is the actual node used in the contact list component data model.
|
||||
* @return the <tt>GroupNode</tt> corresponding to this <tt>UIGroup</tt>
|
||||
*/
|
||||
public GroupNode getGroupNode();
|
||||
|
||||
/**
|
||||
* Sets the <tt>GroupNode</tt> corresponding to this <tt>UIGroup</tt>.
|
||||
* @param groupNode the <tt>GroupNode</tt> to set. The is the actual
|
||||
* node used in the contact list component data model.
|
||||
*/
|
||||
public void setGroupNode(GroupNode groupNode);
|
||||
|
||||
/**
|
||||
* Returns the right button menu for this group.
|
||||
* @return the right button menu component for this group
|
||||
*/
|
||||
public JPopupMenu getRightButtonMenu();
|
||||
}
|
||||
@ -0,0 +1,201 @@
|
||||
/*
|
||||
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
package net.java.sip.communicator.impl.gui.main.contactlist.contactsource;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import net.java.sip.communicator.impl.gui.main.contactlist.*;
|
||||
import net.java.sip.communicator.service.contactsource.*;
|
||||
|
||||
/**
|
||||
* The <tt>ExternalContactSource</tt> is the UI abstraction of the
|
||||
* <tt>ContactSourceService</tt>.
|
||||
*
|
||||
* @author Yana Stamcheva
|
||||
*/
|
||||
public class ExternalContactSource
|
||||
{
|
||||
/**
|
||||
* The <tt>SourceUIGroup</tt> containing all contacts from this source.
|
||||
*/
|
||||
private final SourceUIGroup sourceUIGroup;
|
||||
|
||||
private final ContactSourceService contactSource;
|
||||
|
||||
/**
|
||||
* Creates an <tt>ExternalContactSource</tt> based on the given
|
||||
* <tt>ContactSourceService</tt>.
|
||||
* @param contactSource the <tt>ContactSourceService</tt>, on which this
|
||||
* <tt>ExternalContactSource</tt> is based
|
||||
*/
|
||||
public ExternalContactSource(ContactSourceService contactSource)
|
||||
{
|
||||
this.contactSource = contactSource;
|
||||
sourceUIGroup
|
||||
= new SourceUIGroup(contactSource.getDisplayName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the corresponding <tt>ContactSourceService</tt>.
|
||||
* @return the corresponding <tt>ContactSourceService</tt>
|
||||
*/
|
||||
public ContactSourceService getContactSourceService()
|
||||
{
|
||||
return contactSource;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the UI group for this contact source. There's only one group
|
||||
* descriptor per external source.
|
||||
* @return the group descriptor
|
||||
*/
|
||||
public UIGroup getUIGroup()
|
||||
{
|
||||
return sourceUIGroup;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the <tt>UIContact</tt> corresponding to the given
|
||||
* <tt>sourceContact</tt>.
|
||||
* @param sourceContact the <tt>SourceContact</tt>, for which we search a
|
||||
* corresponding <tt>UIContact</tt>
|
||||
* @return the <tt>UIContact</tt> corresponding to the given
|
||||
* <tt>sourceContact</tt>
|
||||
*/
|
||||
public UIContact getUIContact(SourceContact sourceContact)
|
||||
{
|
||||
return new SourceUIContact(sourceContact, sourceUIGroup);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <tt>SourceUIGroup</tt> is the implementation of the UIGroup for the
|
||||
* <tt>ExternalContactSource</tt>. It takes the name of the source and
|
||||
* sets it as a group name.
|
||||
*/
|
||||
private class SourceUIGroup
|
||||
implements UIGroup
|
||||
{
|
||||
/**
|
||||
* The display name of the group.
|
||||
*/
|
||||
private final String displayName;
|
||||
|
||||
/**
|
||||
* The corresponding group node.
|
||||
*/
|
||||
private GroupNode groupNode;
|
||||
|
||||
/**
|
||||
* Creates an instance of <tt>SourceUIGroup</tt>.
|
||||
* @param name the name of the group
|
||||
*/
|
||||
public SourceUIGroup(String name)
|
||||
{
|
||||
this.displayName = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns null to indicate that this group doesn't have a parent group
|
||||
* and can be added directly to the root group.
|
||||
* @return null
|
||||
*/
|
||||
public UIGroup getParentGroup()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns -1 to indicate that this group doesn't have a source index.
|
||||
* @return -1
|
||||
*/
|
||||
public int getSourceIndex()
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns <tt>false</tt> to indicate that this group is always opened.
|
||||
* @return false
|
||||
*/
|
||||
public boolean isGroupCollapsed()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the display name of this group.
|
||||
* @return the display name of this group
|
||||
*/
|
||||
public String getDisplayName()
|
||||
{
|
||||
return displayName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns -1 to indicate that the child count is unknown.
|
||||
* @return -1
|
||||
*/
|
||||
public int countChildContacts()
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns -1 to indicate that the child count is unknown.
|
||||
* @return -1
|
||||
*/
|
||||
public int countOnlineChildContacts()
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the display name of the group.
|
||||
* @return the display name of the group
|
||||
*/
|
||||
public Object getDescriptor()
|
||||
{
|
||||
return displayName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns null to indicate that this group doesn't have an identifier.
|
||||
* @return null
|
||||
*/
|
||||
public String getId()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the corresponding <tt>GroupNode</tt>.
|
||||
* @return the corresponding <tt>GroupNode</tt>
|
||||
*/
|
||||
public GroupNode getGroupNode()
|
||||
{
|
||||
return groupNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the given <tt>groupNode</tt>.
|
||||
* @param groupNode the <tt>GroupNode</tt> to set
|
||||
*/
|
||||
public void setGroupNode(GroupNode groupNode)
|
||||
{
|
||||
this.groupNode = groupNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the right button menu for this group.
|
||||
* @return null
|
||||
*/
|
||||
public JPopupMenu getRightButtonMenu()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,244 @@
|
||||
/*
|
||||
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
package net.java.sip.communicator.impl.gui.main.contactlist.contactsource;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.regex.*;
|
||||
|
||||
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.protocol.*;
|
||||
|
||||
/**
|
||||
* The <tt>MetaContactListSource</tt> is an abstraction of the
|
||||
* <tt>MetaContactListService</tt>, which makes the correspondence between a
|
||||
* <tt>MetaContact</tt> and an <tt>UIContact</tt> and between a
|
||||
* <tt>MetaContactGroup</tt> and an <tt>UIGroup</tt>. It is also responsible
|
||||
* for filtering of the <tt>MetaContactListService</tt> through a given pattern.
|
||||
*
|
||||
* @author Yana Stamcheva
|
||||
*/
|
||||
public class MetaContactListSource
|
||||
{
|
||||
/**
|
||||
* The data key of the MetaContactDescriptor object used to store a
|
||||
* reference to this object in its corresponding MetaContact.
|
||||
*/
|
||||
public static final String UI_CONTACT_DATA_KEY
|
||||
= MetaUIContact.class.getName() + ".uiContactDescriptor";
|
||||
|
||||
/**
|
||||
* The data key of the MetaGroupDescriptor object used to store a
|
||||
* reference to this object in its corresponding MetaContactGroup.
|
||||
*/
|
||||
public static final String UI_GROUP_DATA_KEY
|
||||
= MetaUIGroup.class.getName() + ".uiGroupDescriptor";
|
||||
|
||||
/**
|
||||
* Returns the <tt>UIContact</tt> corresponding to the given
|
||||
* <tt>MetaContact</tt>.
|
||||
* @param metaContact the <tt>MetaContact</tt>, which corresponding UI
|
||||
* contact we're looking for
|
||||
* @return the <tt>UIContact</tt> corresponding to the given
|
||||
* <tt>MetaContact</tt>
|
||||
*/
|
||||
public static UIContact getUIContact(MetaContact metaContact)
|
||||
{
|
||||
return (UIContact) metaContact.getData(UI_CONTACT_DATA_KEY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the <tt>UIGroup</tt> corresponding to the given
|
||||
* <tt>MetaContactGroup</tt>.
|
||||
* @param metaGroup the <tt>MetaContactGroup</tt>, which UI group we're
|
||||
* looking for
|
||||
* @return the <tt>UIGroup</tt> corresponding to the given
|
||||
* <tt>MetaContactGroup</tt>
|
||||
*/
|
||||
public static UIGroup getUIGroup(MetaContactGroup metaGroup)
|
||||
{
|
||||
return (UIGroup) metaGroup.getData(UI_GROUP_DATA_KEY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <tt>UIContact</tt> for the given <tt>metaContact</tt>.
|
||||
* @param metaContact the <tt>MetaContact</tt> for which we would like to
|
||||
* create an <tt>UIContact</tt>
|
||||
* @return an <tt>UIContact</tt> for the given <tt>metaContact</tt>
|
||||
*/
|
||||
public static UIContact createUIContact(MetaContact metaContact)
|
||||
{
|
||||
UIGroup uiGroup = null;
|
||||
MetaContactGroup parentMetaGroup
|
||||
= metaContact.getParentMetaContactGroup();
|
||||
if (parentMetaGroup != null
|
||||
&& !parentMetaGroup.equals(
|
||||
GuiActivator.getContactListService().getRoot()))
|
||||
{
|
||||
uiGroup = MetaContactListSource.getUIGroup(parentMetaGroup);
|
||||
|
||||
if (uiGroup == null)
|
||||
uiGroup = MetaContactListSource.createUIGroup(parentMetaGroup);
|
||||
}
|
||||
|
||||
MetaUIContact descriptor
|
||||
= new MetaUIContact(metaContact, uiGroup);
|
||||
metaContact.setData(UI_CONTACT_DATA_KEY, descriptor);
|
||||
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the <tt>UIContact</tt> from the given <tt>metaContact</tt>.
|
||||
* @param metaContact the <tt>MetaContact</tt>, which corresponding UI
|
||||
* contact we would like to remove
|
||||
*/
|
||||
public static void removeUIContact(MetaContact metaContact)
|
||||
{
|
||||
metaContact.setData(UI_CONTACT_DATA_KEY, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <tt>UIGroupDescriptor</tt> for the given <tt>metaGroup</tt>.
|
||||
* @param metaGroup the <tt>MetaContactGroup</tt> for which we would like to
|
||||
* create an <tt>UIContact</tt>
|
||||
* @return a <tt>UIGroup</tt> for the given <tt>metaGroup</tt>
|
||||
*/
|
||||
public static UIGroup createUIGroup(MetaContactGroup metaGroup)
|
||||
{
|
||||
MetaUIGroup descriptor
|
||||
= new MetaUIGroup(metaGroup);
|
||||
metaGroup.setData(UI_GROUP_DATA_KEY, descriptor);
|
||||
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the descriptor from the given <tt>metaGroup</tt>.
|
||||
* @param metaGroup the <tt>MetaContactGroup</tt>, which descriptor we
|
||||
* would like to remove
|
||||
*/
|
||||
public static void removeUIGroup(
|
||||
MetaContactGroup metaGroup)
|
||||
{
|
||||
metaGroup.setData(UI_GROUP_DATA_KEY, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters the <tt>MetaContactListService</tt> to match the given
|
||||
* <tt>filterPattern</tt> and stores the result in the given
|
||||
* <tt>treeModel</tt>.
|
||||
* @param filterPattern the pattern to filter through
|
||||
* @param treeModel the <tt>ContactListTreeModel</tt>, in which we store
|
||||
* the results
|
||||
*/
|
||||
public void filter(Pattern filterPattern, ContactListTreeModel treeModel)
|
||||
{
|
||||
filter(filterPattern, treeModel,
|
||||
GuiActivator.getContactListService().getRoot());
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters the children in the given <tt>MetaContactGroup</tt> to match the
|
||||
* given <tt>filterPattern</tt> and stores the result in the given
|
||||
* <tt>treeModel</tt>.
|
||||
* @param filterPattern the pattern to filter through
|
||||
* @param treeModel the <tt>ContactListTreeModel</tt>, in which we store
|
||||
* the results
|
||||
* @param parentGroup the <tt>MetaContactGroup</tt> to filter
|
||||
*/
|
||||
private void filter(Pattern filterPattern,
|
||||
ContactListTreeModel treeModel,
|
||||
MetaContactGroup parentGroup)
|
||||
{
|
||||
Iterator<MetaContact> childContacts = parentGroup.getChildContacts();
|
||||
|
||||
while (childContacts.hasNext())
|
||||
{
|
||||
MetaContact metaContact = childContacts.next();
|
||||
|
||||
if (isMatching(filterPattern, metaContact))
|
||||
{
|
||||
GuiActivator.getContactList().addContact(
|
||||
treeModel,
|
||||
MetaContactListSource.createUIContact(metaContact),
|
||||
true,
|
||||
false);
|
||||
}
|
||||
}
|
||||
|
||||
Iterator<MetaContactGroup> subgroups = parentGroup.getSubgroups();
|
||||
while (subgroups.hasNext())
|
||||
{
|
||||
MetaContactGroup subgroup = subgroups.next();
|
||||
|
||||
filter(filterPattern, treeModel, subgroup);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the given <tt>metaContact</tt> is matching the given
|
||||
* <tt>filterPattern</tt>.
|
||||
* A <tt>MetaContact</tt> would be matching the filter if one of the
|
||||
* following is true:<br>
|
||||
* - its display name contains the filter string
|
||||
* - at least one of its child protocol contacts has a display name or an
|
||||
* address that contains the filter string.
|
||||
* @param filterPattern the filter pattern to check for matches
|
||||
* @param metaContact the <tt>MetaContact</tt> to check
|
||||
* @return <tt>true</tt> to indicate that the given <tt>metaContact</tt> is
|
||||
* matching the current filter, otherwise returns <tt>false</tt>
|
||||
*/
|
||||
private boolean isMatching(Pattern filterPattern, MetaContact metaContact)
|
||||
{
|
||||
Matcher matcher = filterPattern.matcher(metaContact.getDisplayName());
|
||||
|
||||
if(matcher.find())
|
||||
return true;
|
||||
|
||||
Iterator<Contact> contacts = metaContact.getContacts();
|
||||
while (contacts.hasNext())
|
||||
{
|
||||
Contact contact = contacts.next();
|
||||
|
||||
matcher = filterPattern.matcher(contact.getDisplayName());
|
||||
|
||||
if (matcher.find())
|
||||
return true;
|
||||
|
||||
matcher = filterPattern.matcher(contact.getAddress());
|
||||
|
||||
if (matcher.find())
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the given <tt>metaGroup</tt> is matching the current filter. A
|
||||
* group is matching the current filter only if it contains at least one
|
||||
* child <tt>MetaContact</tt>, which is matching the current filter.
|
||||
* @param filterPattern the filter pattern to check for matches
|
||||
* @param metaGroup the <tt>MetaContactGroup</tt> to check
|
||||
* @return <tt>true</tt> to indicate that the given <tt>metaGroup</tt> is
|
||||
* matching the current filter, otherwise returns <tt>false</tt>
|
||||
*/
|
||||
public boolean isMatching(Pattern filterPattern, MetaContactGroup metaGroup)
|
||||
{
|
||||
Iterator<MetaContact> contacts = metaGroup.getChildContacts();
|
||||
|
||||
while (contacts.hasNext())
|
||||
{
|
||||
MetaContact metaContact = contacts.next();
|
||||
|
||||
if (isMatching(filterPattern, metaContact))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,408 @@
|
||||
/*
|
||||
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
package net.java.sip.communicator.impl.gui.main.contactlist.contactsource;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import net.java.sip.communicator.impl.gui.*;
|
||||
import net.java.sip.communicator.impl.gui.main.contactlist.*;
|
||||
import net.java.sip.communicator.impl.gui.utils.*;
|
||||
import net.java.sip.communicator.service.contactlist.*;
|
||||
import net.java.sip.communicator.service.protocol.*;
|
||||
import net.java.sip.communicator.util.*;
|
||||
|
||||
/**
|
||||
* The <tt>MetaUIContact</tt> is the implementation of the UIContact interface
|
||||
* for the <tt>MetaContactListService</tt>. This implementation is based on the
|
||||
* <tt>MetaContact</tt>.
|
||||
*
|
||||
* @author Yana Stamcheva
|
||||
*/
|
||||
public class MetaUIContact
|
||||
implements UIContact
|
||||
{
|
||||
/**
|
||||
* The key of the user data in <tt>MetaContact</tt> which specifies
|
||||
* the avatar cached from previous invocations.
|
||||
*/
|
||||
private static final String AVATAR_DATA_KEY
|
||||
= MetaUIContact.class.getName() + ".avatar";
|
||||
|
||||
/**
|
||||
* A list of all search strings available for the underlying
|
||||
* <tt>MetaContact</tt>.
|
||||
*/
|
||||
private final List<String> searchStrings = new LinkedList<String>();
|
||||
|
||||
/**
|
||||
* The <tt>MetaContact</tt>, on which this implementation is based.
|
||||
*/
|
||||
private MetaContact metaContact;
|
||||
|
||||
/**
|
||||
* The corresponding <tt>ContactNode</tt> in the contact list component
|
||||
* data model.
|
||||
*/
|
||||
private ContactNode contactNode;
|
||||
|
||||
/**
|
||||
* The parent <tt>UIGroup</tt> of this contact.
|
||||
*/
|
||||
private UIGroup parentUIGroup;
|
||||
|
||||
/**
|
||||
* Creates an instance of <tt>MetaUIContact</tt> by specifying the
|
||||
* underlying <tt>MetaContact</tt>, on which it's based.
|
||||
* @param metaContact the <tt>MetaContact</tt>, on which this implementation
|
||||
* is based
|
||||
* @param group the parent <tt>UIGroup</tt>
|
||||
*/
|
||||
public MetaUIContact(MetaContact metaContact, UIGroup group)
|
||||
{
|
||||
this.metaContact = metaContact;
|
||||
this.parentUIGroup = group;
|
||||
|
||||
initSearchStrings();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the underlying <tt>MetaContact</tt>.
|
||||
* @return the underlying <tt>MetaContact</tt>
|
||||
*/
|
||||
public Object getDescriptor()
|
||||
{
|
||||
return metaContact;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the display name of this <tt>MetaUIContact</tt>.
|
||||
* @return the display name of this <tt>MetaUIContact</tt>
|
||||
*/
|
||||
public String getDisplayName()
|
||||
{
|
||||
return metaContact.getDisplayName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the index of the underlying <tt>MetaContact</tt> in its
|
||||
* <tt>MetaContactListService</tt> parent group.
|
||||
* @return the source index of the underlying <tt>MetaContact</tt>
|
||||
*/
|
||||
public int getSourceIndex()
|
||||
{
|
||||
return metaContact.getParentMetaContactGroup().indexOf(metaContact);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an <tt>Iterator</tt> over a list of strings, which can be used
|
||||
* to find this contact.
|
||||
* @return an <tt>Iterator</tt> over a list of search strings
|
||||
*/
|
||||
public Iterator<String> getSearchStrings()
|
||||
{
|
||||
return searchStrings.iterator();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the general status icon of the given MetaContact. Detects the
|
||||
* status using the priority status table. The priority is defined on
|
||||
* the "availability" factor and here the most "available" status is
|
||||
* returned.
|
||||
*
|
||||
* @return PresenceStatus The most "available" status from all
|
||||
* sub-contact statuses.
|
||||
*/
|
||||
public ImageIcon getStatusIcon()
|
||||
{
|
||||
PresenceStatus status = null;
|
||||
Iterator<Contact> i = metaContact.getContacts();
|
||||
while (i.hasNext()) {
|
||||
Contact protoContact = i.next();
|
||||
PresenceStatus contactStatus = protoContact.getPresenceStatus();
|
||||
|
||||
if (status == null)
|
||||
status = contactStatus;
|
||||
else
|
||||
status = (contactStatus.compareTo(status) > 0)
|
||||
? contactStatus
|
||||
: status;
|
||||
}
|
||||
|
||||
if (status != null)
|
||||
return new ImageIcon(Constants.getStatusIcon(status));
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the parent <tt>UIGroup</tt>.
|
||||
* @return the parent <tt>UIGroup</tt>
|
||||
*/
|
||||
public UIGroup getParentGroup()
|
||||
{
|
||||
return parentUIGroup;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the default <tt>ContactDetail</tt> to use for any operations
|
||||
* depending to the given <tt>OperationSet</tt> class.
|
||||
* @param opSetClass the <tt>OperationSet</tt> class we're interested in
|
||||
* @return the default <tt>ContactDetail</tt> to use for any operations
|
||||
* depending to the given <tt>OperationSet</tt> class
|
||||
*/
|
||||
public UIContactDetail getDefaultContactDetail(
|
||||
Class<? extends OperationSet> opSetClass)
|
||||
{
|
||||
List<UIContactDetail> details
|
||||
= getContactDetailsForOperationSet(opSetClass);
|
||||
|
||||
if (details != null && !details.isEmpty())
|
||||
return details.get(0);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of <tt>UIContactDetail</tt>s supporting the given
|
||||
* <tt>OperationSet</tt> class.
|
||||
* @param opSetClass the <tt>OperationSet</tt> class we're interested in
|
||||
* @return a list of <tt>UIContactDetail</tt>s supporting the given
|
||||
* <tt>OperationSet</tt> class
|
||||
*/
|
||||
public List<UIContactDetail> getContactDetailsForOperationSet(
|
||||
Class<? extends OperationSet> opSetClass)
|
||||
{
|
||||
List<UIContactDetail> resultList
|
||||
= new LinkedList<UIContactDetail>();
|
||||
|
||||
Iterator<Contact> contacts
|
||||
= metaContact.getContactsForOperationSet(opSetClass).iterator();
|
||||
|
||||
while (contacts.hasNext())
|
||||
{
|
||||
resultList.add(new MetaContactDetail(contacts.next()));
|
||||
}
|
||||
return resultList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the avatar of a specific <tt>MetaContact</tt> in the form of an
|
||||
* <tt>ImageIcon</tt> value.
|
||||
*
|
||||
* @param isSelected indicates if the contact is selected
|
||||
* @param width the desired icon width
|
||||
* @param height the desired icon height
|
||||
* @return an <tt>ImageIcon</tt> which represents the avatar of the
|
||||
* specified <tt>MetaContact</tt>
|
||||
*/
|
||||
public ImageIcon getAvatar(
|
||||
boolean isSelected, int width, int height)
|
||||
{
|
||||
byte[] avatarBytes = metaContact.getAvatar(true);
|
||||
ImageIcon avatar = null;
|
||||
|
||||
// If there'rs no avatar we have nothing more to do here.
|
||||
if((avatarBytes == null) || (avatarBytes.length <= 0))
|
||||
return null;
|
||||
|
||||
// If the cell is selected we return a zoomed version of the avatar
|
||||
// image.
|
||||
if (isSelected)
|
||||
return ImageUtils.getScaledRoundedIcon(
|
||||
avatarBytes,
|
||||
width,
|
||||
height);
|
||||
|
||||
// In any other case try to get the avatar from the cache.
|
||||
Object[] avatarCache
|
||||
= (Object[]) metaContact.getData(AVATAR_DATA_KEY);
|
||||
|
||||
if ((avatarCache != null) && (avatarCache[0] == avatarBytes))
|
||||
avatar = (ImageIcon) avatarCache[1];
|
||||
|
||||
// Just
|
||||
int avatarWidth = width;
|
||||
int avatarHeight = height;
|
||||
|
||||
// If the avatar isn't available or it's not up-to-date, create it.
|
||||
if (avatar == null)
|
||||
avatar = ImageUtils.getScaledRoundedIcon(
|
||||
avatarBytes,
|
||||
avatarWidth,
|
||||
avatarHeight);
|
||||
|
||||
// Cache the avatar in case it has changed.
|
||||
if (avatarCache == null)
|
||||
{
|
||||
if (avatar != null)
|
||||
metaContact.setData(
|
||||
AVATAR_DATA_KEY,
|
||||
new Object[] { avatarBytes, avatar });
|
||||
}
|
||||
else
|
||||
{
|
||||
avatarCache[0] = avatarBytes;
|
||||
avatarCache[1] = avatar;
|
||||
}
|
||||
|
||||
return avatar;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the display details for the underlying <tt>MetaContact</tt>.
|
||||
* @return the display details for the underlying <tt>MetaContact</tt>
|
||||
*/
|
||||
public String getDisplayDetails()
|
||||
{
|
||||
String statusMessage = null;
|
||||
Iterator<Contact> protoContacts = metaContact.getContacts();
|
||||
|
||||
while (protoContacts.hasNext())
|
||||
{
|
||||
Contact protoContact = protoContacts.next();
|
||||
|
||||
statusMessage = protoContact.getStatusMessage();
|
||||
if (statusMessage != null && statusMessage.length() > 0)
|
||||
break;
|
||||
}
|
||||
|
||||
return statusMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the tool tip opened on mouse over.
|
||||
* @return the tool tip opened on mouse over
|
||||
*/
|
||||
public ExtendedTooltip getToolTip()
|
||||
{
|
||||
ExtendedTooltip tip = new ExtendedTooltip(true);
|
||||
|
||||
byte[] avatarImage = metaContact.getAvatar();
|
||||
|
||||
if (avatarImage != null && avatarImage.length > 0)
|
||||
tip.setImage(new ImageIcon(avatarImage));
|
||||
|
||||
tip.setTitle(metaContact.getDisplayName());
|
||||
|
||||
Iterator<Contact> i = metaContact.getContacts();
|
||||
|
||||
String statusMessage = null;
|
||||
Contact protocolContact;
|
||||
while (i.hasNext())
|
||||
{
|
||||
protocolContact = i.next();
|
||||
|
||||
ImageIcon protocolStatusIcon
|
||||
= new ImageIcon(
|
||||
protocolContact.getPresenceStatus().getStatusIcon());
|
||||
|
||||
String contactAddress = protocolContact.getAddress();
|
||||
//String statusMessage = protocolContact.getStatusMessage();
|
||||
|
||||
tip.addLine(protocolStatusIcon, contactAddress);
|
||||
|
||||
// Set the first found status message.
|
||||
if (statusMessage == null
|
||||
&& protocolContact.getStatusMessage() != null
|
||||
&& protocolContact.getStatusMessage().length() > 0)
|
||||
statusMessage = protocolContact.getStatusMessage();
|
||||
}
|
||||
|
||||
if (statusMessage != null)
|
||||
tip.setBottomText(statusMessage);
|
||||
|
||||
return tip;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the corresponding <tt>ContactNode</tt> in the contact list
|
||||
* component data model.
|
||||
* @return the corresponding <tt>ContactNode</tt>
|
||||
*/
|
||||
public ContactNode getContactNode()
|
||||
{
|
||||
return contactNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the corresponding <tt>ContactNode</tt>.
|
||||
* @param contactNode the corresponding <tt>ContactNode</tt> in the contact
|
||||
* list component data model
|
||||
*/
|
||||
public void setContactNode(ContactNode contactNode)
|
||||
{
|
||||
this.contactNode = contactNode;
|
||||
if (contactNode == null)
|
||||
MetaContactListSource.removeUIContact(metaContact);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes all search strings for this <tt>MetaUIGroup</tt>.
|
||||
*/
|
||||
private void initSearchStrings()
|
||||
{
|
||||
searchStrings.add(metaContact.getDisplayName());
|
||||
|
||||
Iterator<Contact> contacts = metaContact.getContacts();
|
||||
while (contacts.hasNext())
|
||||
{
|
||||
Contact contact = contacts.next();
|
||||
|
||||
searchStrings.add(contact.getDisplayName());
|
||||
searchStrings.add(contact.getAddress());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The implementation of the <tt>UIContactDetail</tt> interface for the
|
||||
* <tt>MetaContactListService</tt>.
|
||||
*/
|
||||
private class MetaContactDetail extends UIContactDetail
|
||||
{
|
||||
/**
|
||||
* The underlying protocol contact.
|
||||
*/
|
||||
private Contact contact;
|
||||
|
||||
/**
|
||||
* Creates an instance of <tt>MetaContactDetail</tt> by specifying the
|
||||
* underlying protocol <tt>Contact</tt>.
|
||||
* @param contact the protocol contact, on which this implementation
|
||||
* is based
|
||||
*/
|
||||
public MetaContactDetail(Contact contact)
|
||||
{
|
||||
super( contact.getAddress(),
|
||||
contact.getDisplayName(),
|
||||
contact.getProtocolProvider());
|
||||
|
||||
this.contact = contact;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the presence status of the underlying protocol
|
||||
* <tt>Contact</tt>.
|
||||
* @return the presence status of the underlying protocol
|
||||
* <tt>Contact</tt>
|
||||
*/
|
||||
public PresenceStatus getPresenceStatus()
|
||||
{
|
||||
return contact.getPresenceStatus();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the right button menu component.
|
||||
* @return the right button menu component
|
||||
*/
|
||||
public JPopupMenu getRightButtonMenu()
|
||||
{
|
||||
return new MetaContactRightButtonMenu(metaContact);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,164 @@
|
||||
/*
|
||||
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
package net.java.sip.communicator.impl.gui.main.contactlist.contactsource;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import net.java.sip.communicator.impl.gui.*;
|
||||
import net.java.sip.communicator.impl.gui.main.contactlist.*;
|
||||
import net.java.sip.communicator.impl.gui.utils.*;
|
||||
import net.java.sip.communicator.service.contactlist.*;
|
||||
|
||||
/**
|
||||
* The <tt>MetaUIGroup</tt> is the implementation of the UIGroup for the
|
||||
* <tt>MetaContactListService</tt>. This implementation is based on the
|
||||
* <tt>MetaContactGroup</tt>.
|
||||
*
|
||||
* @author Yana Stamcheva
|
||||
*/
|
||||
public class MetaUIGroup
|
||||
implements UIGroup
|
||||
{
|
||||
/**
|
||||
* The <tt>MetaContactGroup</tt>, on which this UI group is based.
|
||||
*/
|
||||
private final MetaContactGroup metaGroup;
|
||||
|
||||
/**
|
||||
* The corresponding <tt>GroupNode</tt> in the contact list component data
|
||||
* model.
|
||||
*/
|
||||
private GroupNode groupNode;
|
||||
|
||||
/**
|
||||
* Creates an instance of <tt>MetaUIGroup</tt> by specifying the underlying
|
||||
* <tt>MetaContactGroup</tt>.
|
||||
* @param metaGroup the <tt>MetaContactGroup</tt>, on which this UI group
|
||||
* is based
|
||||
*/
|
||||
public MetaUIGroup(MetaContactGroup metaGroup)
|
||||
{
|
||||
this.metaGroup = metaGroup;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the underlying <tt>MetaContactGroup</tt>.
|
||||
* @return the underlying <tt>MetaContactGroup</tt>
|
||||
*/
|
||||
public Object getDescriptor()
|
||||
{
|
||||
return metaGroup;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the index of the underlying <tt>MetaContactGroup</tt> in its
|
||||
* <tt>MetaContactListService</tt> parent group.
|
||||
* @return the source index of the underlying <tt>MetaContactGroup</tt>
|
||||
*/
|
||||
public int getSourceIndex()
|
||||
{
|
||||
return metaGroup.getParentMetaContactGroup().indexOf(metaGroup);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the parent <tt>UIGroup</tt>.
|
||||
* @return the parent <tt>UIGroup</tt>
|
||||
*/
|
||||
public UIGroup getParentGroup()
|
||||
{
|
||||
MetaContactGroup parentGroup = metaGroup.getParentMetaContactGroup();
|
||||
|
||||
if (parentGroup != null
|
||||
&& !parentGroup.equals(
|
||||
GuiActivator.getContactListService().getRoot()))
|
||||
return new MetaUIGroup(parentGroup);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if this group was collapsed.
|
||||
* @return <tt>true</tt> to indicate that this group has been collapsed,
|
||||
* <tt>false</tt> - otherwise
|
||||
*/
|
||||
public boolean isGroupCollapsed()
|
||||
{
|
||||
return ConfigurationManager
|
||||
.isContactListGroupCollapsed(metaGroup.getMetaUID());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the display name of the underlying <tt>MetaContactGroup</tt>.
|
||||
* @return the display name of the underlying <tt>MetaContactGroup</tt>
|
||||
*/
|
||||
public String getDisplayName()
|
||||
{
|
||||
return metaGroup.getGroupName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the count of child contacts of the underlying
|
||||
* <tt>MetaContactGroup</tt>.
|
||||
* @return the count of child contacts
|
||||
*/
|
||||
public int countChildContacts()
|
||||
{
|
||||
return metaGroup.countChildContacts();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the count of online child contacts of the underlying
|
||||
* <tt>MetaContactGroup</tt>.
|
||||
* @return the count of online child contacts
|
||||
*/
|
||||
public int countOnlineChildContacts()
|
||||
{
|
||||
return metaGroup.countOnlineChildContacts();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the identifier of the underlying <tt>MetaContactGroup</tt>.
|
||||
* @return the identifier of the underlying <tt>MetaContactGroup</tt>
|
||||
*/
|
||||
public String getId()
|
||||
{
|
||||
return metaGroup.getMetaUID();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the corresponding <tt>GroupNode</tt>.
|
||||
* @return the corresponding <tt>GroupNode</tt>
|
||||
*/
|
||||
public GroupNode getGroupNode()
|
||||
{
|
||||
return groupNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the corresponding <tt>GroupNode</tt>.
|
||||
* @param groupNode the corresponding <tt>GroupNoe</tt> in the contact list
|
||||
* component data model
|
||||
*/
|
||||
public void setGroupNode(GroupNode groupNode)
|
||||
{
|
||||
this.groupNode = groupNode;
|
||||
if (groupNode == null)
|
||||
MetaContactListSource.removeUIGroup(metaGroup);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the <tt>JPopupMenu</tt> opened on a right button click over this
|
||||
* group in the contact list.
|
||||
* @return the <tt>JPopupMenu</tt> opened on a right button click over this
|
||||
* group in the contact list
|
||||
*/
|
||||
public JPopupMenu getRightButtonMenu()
|
||||
{
|
||||
return new GroupRightButtonMenu(
|
||||
GuiActivator.getUIService().getMainFrame(), metaGroup);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,282 @@
|
||||
/*
|
||||
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
package net.java.sip.communicator.impl.gui.main.contactlist.contactsource;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import net.java.sip.communicator.impl.gui.main.contactlist.*;
|
||||
import net.java.sip.communicator.impl.gui.utils.*;
|
||||
import net.java.sip.communicator.service.contactsource.*;
|
||||
import net.java.sip.communicator.service.protocol.*;
|
||||
import net.java.sip.communicator.util.*;
|
||||
|
||||
/**
|
||||
* The <tt>SourceUIContact</tt> is the implementation of the UIContact for the
|
||||
* <tt>ExternalContactSource</tt>.
|
||||
*
|
||||
* @author Yana Stamcheva
|
||||
*/
|
||||
public class SourceUIContact
|
||||
implements UIContact
|
||||
{
|
||||
/**
|
||||
* The corresponding <tt>SourceContact</tt>, on which this abstraction is
|
||||
* based.
|
||||
*/
|
||||
private final SourceContact sourceContact;
|
||||
|
||||
/**
|
||||
* The corresponding <tt>ContactNode</tt> in the contact list component.
|
||||
*/
|
||||
private ContactNode contactNode;
|
||||
|
||||
/**
|
||||
* The parent <tt>UIGroup</tt>.
|
||||
*/
|
||||
private UIGroup uiGroup;
|
||||
|
||||
/**
|
||||
* Creates an instance of <tt>SourceUIContact</tt> by specifying the
|
||||
* <tt>SourceContact</tt>, on which this abstraction is based and the
|
||||
* parent <tt>UIGroup</tt>.
|
||||
*
|
||||
* @param contact the <tt>SourceContact</tt>, on which this abstraction
|
||||
* is based
|
||||
* @param parentGroup the parent <tt>UIGroup</tt>
|
||||
*/
|
||||
public SourceUIContact( SourceContact contact,
|
||||
UIGroup parentGroup)
|
||||
{
|
||||
this.sourceContact = contact;
|
||||
this.uiGroup = parentGroup;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the display name of the underlying <tt>SourceContact</tt>.
|
||||
* @return the display name
|
||||
*/
|
||||
public String getDisplayName()
|
||||
{
|
||||
return sourceContact.getDisplayName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the parent <tt>UIGroup</tt>.
|
||||
* @return the parent <tt>UIGroup</tt>
|
||||
*/
|
||||
public UIGroup getParentGroup()
|
||||
{
|
||||
return uiGroup;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns -1 to indicate that the source index of the underlying
|
||||
* <tt>SourceContact</tt> is unknown.
|
||||
* @return -1
|
||||
*/
|
||||
public int getSourceIndex()
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns null to indicate unknown status of the underlying
|
||||
* <tt>SourceContact</tt>.
|
||||
* @return null
|
||||
*/
|
||||
public ImageIcon getStatusIcon()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the image corresponding to the underlying <tt>SourceContact</tt>.
|
||||
* @param isSelected indicates if the contact is currently selected in the
|
||||
* contact list component
|
||||
* @param width the desired image width
|
||||
* @param height the desired image height
|
||||
* @return the image
|
||||
*/
|
||||
public ImageIcon getAvatar(boolean isSelected, int width, int height)
|
||||
{
|
||||
ImageIcon icon = new ImageIcon(sourceContact.getImage());
|
||||
|
||||
if (icon.getIconWidth() > width
|
||||
|| icon.getIconHeight() > height)
|
||||
{
|
||||
icon = ImageUtils
|
||||
.getScaledRoundedIcon(icon.getImage(), width, height);
|
||||
}
|
||||
|
||||
return icon;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the default <tt>ContactDetail</tt> to use for any operations
|
||||
* depending to the given <tt>OperationSet</tt> class.
|
||||
* @param opSetClass the <tt>OperationSet</tt> class we're interested in
|
||||
* @return the default <tt>ContactDetail</tt> to use for any operations
|
||||
* depending to the given <tt>OperationSet</tt> class
|
||||
*/
|
||||
public UIContactDetail getDefaultContactDetail(
|
||||
Class<? extends OperationSet> opSetClass)
|
||||
{
|
||||
List<UIContactDetail> details
|
||||
= getContactDetailsForOperationSet(opSetClass);
|
||||
|
||||
if (details != null && !details.isEmpty())
|
||||
return details.get(0);
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the underlying <tt>SourceContact</tt> this abstraction is about.
|
||||
* @return the underlying <tt>SourceContact</tt>
|
||||
*/
|
||||
public Object getDescriptor()
|
||||
{
|
||||
return sourceContact;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the display details for the underlying <tt>SourceContact</tt>.
|
||||
* @return the display details for the underlying <tt>SourceContact</tt>
|
||||
*/
|
||||
public String getDisplayDetails()
|
||||
{
|
||||
return sourceContact.getDisplayDetails();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of <tt>UIContactDetail</tt>s supporting the given
|
||||
* <tt>OperationSet</tt> class.
|
||||
* @param opSetClass the <tt>OperationSet</tt> class we're interested in
|
||||
* @return a list of <tt>UIContactDetail</tt>s supporting the given
|
||||
* <tt>OperationSet</tt> class
|
||||
*/
|
||||
public List<UIContactDetail> getContactDetailsForOperationSet(
|
||||
Class<? extends OperationSet> opSetClass)
|
||||
{
|
||||
List<UIContactDetail> resultList
|
||||
= new LinkedList<UIContactDetail>();
|
||||
|
||||
Iterator<ContactDetail> details
|
||||
= sourceContact.getContactDetails().iterator();
|
||||
|
||||
while (details.hasNext())
|
||||
{
|
||||
ContactDetail detail = details.next();
|
||||
|
||||
if (detail.getSupportedOperationSets().contains(opSetClass))
|
||||
resultList.add(new SourceContactDetail(detail, opSetClass));
|
||||
}
|
||||
return resultList;
|
||||
}
|
||||
|
||||
public Iterator<String> getSearchStrings()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the corresponding <tt>ContactNode</tt> from the contact list
|
||||
* component.
|
||||
* @return the corresponding <tt>ContactNode</tt>
|
||||
*/
|
||||
public ContactNode getContactNode()
|
||||
{
|
||||
return contactNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the corresponding <tt>ContactNode</tt>.
|
||||
* @param contactNode the corresponding <tt>ContactNode</tt>
|
||||
*/
|
||||
public void setContactNode(ContactNode contactNode)
|
||||
{
|
||||
this.contactNode = contactNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* The implementation of the <tt>UIContactDetail</tt> interface for the
|
||||
* external source <tt>ContactDetail</tt>s.
|
||||
*/
|
||||
private class SourceContactDetail extends UIContactDetail
|
||||
{
|
||||
/**
|
||||
* Creates an instance of <tt>SourceContactDetail</tt> by specifying
|
||||
* the underlying <tt>detail</tt> and the <tt>OperationSet</tt> class
|
||||
* for it.
|
||||
* @param detail the underlying <tt>ContactDetail</tt>
|
||||
* @param opSetClass the <tt>OperationSet</tt> class for the
|
||||
* preferred protocol provider
|
||||
*/
|
||||
public SourceContactDetail( ContactDetail detail,
|
||||
Class<? extends OperationSet> opSetClass)
|
||||
{
|
||||
super( detail.getContactAddress(),
|
||||
detail.getContactAddress(),
|
||||
detail.getPreferredProtocolProvider(opSetClass));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns null to indicate that this detail doesn't support presence.
|
||||
* @return null
|
||||
*/
|
||||
public PresenceStatus getPresenceStatus()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the <tt>JPopupMenu</tt> opened on a right button click over this
|
||||
* <tt>SourceUIContact</tt>.
|
||||
* @return the <tt>JPopupMenu</tt> opened on a right button click over this
|
||||
* <tt>SourceUIContact</tt>
|
||||
*/
|
||||
public JPopupMenu getRightButtonMenu()
|
||||
{
|
||||
return new SourceContactRightButtonMenu(sourceContact);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the tool tip opened on mouse over.
|
||||
* @return the tool tip opened on mouse over
|
||||
*/
|
||||
public ExtendedTooltip getToolTip()
|
||||
{
|
||||
ExtendedTooltip tip = new ExtendedTooltip(true);
|
||||
|
||||
byte[] avatarImage = sourceContact.getImage();
|
||||
|
||||
if (avatarImage != null && avatarImage.length > 0)
|
||||
tip.setImage(new ImageIcon(avatarImage));
|
||||
|
||||
tip.setTitle(sourceContact.getDisplayName());
|
||||
|
||||
Iterator<ContactDetail> details
|
||||
= sourceContact.getContactDetails().iterator();
|
||||
|
||||
ContactDetail contactDetail;
|
||||
while (details.hasNext())
|
||||
{
|
||||
contactDetail = details.next();
|
||||
|
||||
String contactAddress = contactDetail.getContactAddress();
|
||||
//String statusMessage = protocolContact.getStatusMessage();
|
||||
|
||||
tip.addLine(null, contactAddress);
|
||||
}
|
||||
|
||||
tip.setBottomText(getDisplayDetails());
|
||||
|
||||
return tip;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
package net.java.sip.communicator.service.callhistory;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import net.java.sip.communicator.service.callhistory.event.*;
|
||||
|
||||
/**
|
||||
* The <tt>CallHistoryQuery</tt> corresponds to a query made to the
|
||||
* <tt>CallHistoryService</tt>. It allows to be canceled, to listen for changes
|
||||
* in the results and to obtain initial results if available.
|
||||
*
|
||||
* @author Yana Stamcheva
|
||||
*/
|
||||
public interface CallHistoryQuery
|
||||
{
|
||||
/**
|
||||
* Cancels this query.
|
||||
*/
|
||||
public void cancel();
|
||||
|
||||
/**
|
||||
* Returns a collection of the initial results for this query. It's up to
|
||||
* the implementation to determine, which and how many the initial results
|
||||
* would be.
|
||||
* <p>
|
||||
* This method is meant to be used in order to return first fast initial
|
||||
* results and then notify interested parties of additional results through
|
||||
* the <tt>CallHistoryQueryListener</tt>, which should improve user
|
||||
* experience when waiting for results.
|
||||
* @return a collection of the initial results for this query
|
||||
*/
|
||||
public Collection<CallRecord> getCallRecords();
|
||||
|
||||
/**
|
||||
* Adds the given <tt>CallHistoryQueryListener</tt> to the list of
|
||||
* listeners interested in query result changes.
|
||||
* @param l the <tt>CallHistoryQueryListener</tt> to add
|
||||
*/
|
||||
public void addCallRecordsListener(CallHistoryQueryListener l);
|
||||
|
||||
/**
|
||||
* Removes the given <tt>CallHistoryQueryListener</tt> from the list of
|
||||
* listeners interested in query result changes.
|
||||
* @param l the <tt>CallHistoryQueryListener</tt> to remove
|
||||
*/
|
||||
public void removeCallRecordsListener(CallHistoryQueryListener l);
|
||||
}
|
||||
@ -0,0 +1,26 @@
|
||||
/*
|
||||
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
package net.java.sip.communicator.service.callhistory.event;
|
||||
|
||||
/**
|
||||
* The <tt>CallHistoryQueryListener</tt> listens for changes in the result of
|
||||
* a given <tt>CallHistoryQuery</tt>. When a query to the call history is
|
||||
* started, this listener would be notified every time new results are available
|
||||
* for this query.
|
||||
*
|
||||
* @author Yana Stamcheva
|
||||
*/
|
||||
public interface CallHistoryQueryListener
|
||||
{
|
||||
/**
|
||||
* Indicates that new <tt>CallRecord</tt>s are received as a result of the
|
||||
* query.
|
||||
* @param event the <tt>CallRecordsEvent</tt> containing information about
|
||||
* the query results.
|
||||
*/
|
||||
public void callRecordsReceived(CallRecordsEvent event);
|
||||
}
|
||||
@ -0,0 +1,61 @@
|
||||
/*
|
||||
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
package net.java.sip.communicator.service.callhistory.event;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import net.java.sip.communicator.service.callhistory.*;
|
||||
|
||||
/**
|
||||
* The <tt>CallRecordsEvent</tt> indicates that one or more
|
||||
* <tt>CallRecord</tt>s has been received as a result of a
|
||||
* <tt>CallHistoryQuery</tt>.
|
||||
*
|
||||
* @author Yana Stamcheva
|
||||
*/
|
||||
public class CallRecordsEvent
|
||||
extends EventObject
|
||||
{
|
||||
/**
|
||||
* A collection of call records received as a result of a given
|
||||
* <tt>query</tt>.
|
||||
*/
|
||||
private final Collection<CallRecord> callRecords;
|
||||
|
||||
/**
|
||||
* Creates a <tt>ContactReceivedEvent</tt> by specifying the contact search
|
||||
* source and the received <tt>searchContact</tt>.
|
||||
* @param query the source that triggered this event
|
||||
* @param callRecords the call records received as a result from the given
|
||||
* <tt>query</tt>
|
||||
*/
|
||||
public CallRecordsEvent(CallHistoryQuery query,
|
||||
Collection<CallRecord> callRecords)
|
||||
{
|
||||
super(query);
|
||||
|
||||
this.callRecords = callRecords;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the <tt>ContactQuery</tt> that triggered this event.
|
||||
* @return the <tt>ContactQuery</tt> that triggered this event
|
||||
*/
|
||||
public CallHistoryQuery getQuerySource()
|
||||
{
|
||||
return (CallHistoryQuery) source;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the collection of <tt>CallRecord</tt>s this event is about.
|
||||
* @return the collection of <tt>CallRecord</tt>s this event is about
|
||||
*/
|
||||
public Collection<CallRecord> getCallRecords()
|
||||
{
|
||||
return callRecords;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,27 @@
|
||||
/*
|
||||
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
package net.java.sip.communicator.util.swing.event;
|
||||
|
||||
/**
|
||||
* The <tt>TextFieldChangeListener</tt> listens for any changes in the text
|
||||
* contained in a <tt>SIPCommTextField</tt>. It is notified every time a char
|
||||
* is inserted or removed from the field.
|
||||
*
|
||||
* @author Yana Stamcheva
|
||||
*/
|
||||
public interface TextFieldChangeListener
|
||||
{
|
||||
/**
|
||||
* Indicates that a text has been removed from the text field.
|
||||
*/
|
||||
public void textRemoved();
|
||||
|
||||
/**
|
||||
* Indicates that a text has been inserted to the text field.
|
||||
*/
|
||||
public void textInserted();
|
||||
}
|
||||