FileDocCategorySizeDatePackage
ViewParticipantList.javaAPI DocJMF 2.1.1e7924Mon May 12 12:20:34 BST 2003jmapps.rtp

ViewParticipantList

public class ViewParticipantList extends JMPanel

Fields Summary
public static final String
PARTICIPANTS
public static final String
NONE
public static final String
REMOTE
public static final String
LOCAL
public static final String
PASSIVE
public static final String
ACTIVE
private SessionManager
mngrSession
private List
listParticipantsRemote
private List
listParticipantsLocal
private List
listParticipantsActive
private List
listParticipantsPassive
private Vector
lastRemoteList
private Vector
lastLocalList
private Vector
lastActiveList
private Vector
lastPassiveList
long
lastCheckTime
Constructors Summary
public ViewParticipantList(SessionManager mngrSession)



          
	    super ();

        this.mngrSession = mngrSession;
        try {
            init();
        }
        catch (Exception e) {
            e.printStackTrace();
        }
    
Methods Summary
booleancompare(java.util.Vector list1, java.util.Vector list2)

	if (list1.size() != list2.size())
	    return false;
	for (int i = 0; i < list1.size(); i++) {
	    if (!list2.contains(list1.elementAt(i)))
		return false;
	}
	return true;
    
public static java.util.VectorgetParticipants(javax.media.rtp.SessionManager mngrSession, java.lang.String strListType)

        Vector  vectorParticipants = null;

        if ( strListType.equals(REMOTE) ) {
            vectorParticipants = mngrSession.getRemoteParticipants ();
        }
        else if ( strListType.equals(LOCAL) ) {
            vectorParticipants = new Vector ();
            vectorParticipants.addElement ( mngrSession.getLocalParticipant() );
        }
        else if ( strListType.equals(PASSIVE) ) {
            vectorParticipants = mngrSession.getPassiveParticipants ();
        }
        else if ( strListType.equals(ACTIVE) ) {
            vectorParticipants = mngrSession.getActiveParticipants ();
        }

        return ( vectorParticipants );
    
private voidinit()

        JMPanel panel;
        Label   label;

        this.setLayout ( new GridLayout(0,1,6,6) );

        panel = new JMPanel ( new BorderLayout() );
        this.add ( panel );
        label = new Label ( REMOTE + ":" );
        panel.add ( label, BorderLayout.NORTH );
        listParticipantsRemote = new List ();
        panel.add ( listParticipantsRemote, BorderLayout.CENTER );

        panel = new JMPanel ( new BorderLayout() );
        this.add ( panel );
        label = new Label ( LOCAL + ":" );
        panel.add ( label, BorderLayout.NORTH );
        listParticipantsLocal = new List ();
        panel.add ( listParticipantsLocal, BorderLayout.CENTER );

        panel = new JMPanel ( new BorderLayout() );
        this.add ( panel );
        label = new Label ( ACTIVE + ":" );
        panel.add ( label, BorderLayout.NORTH );
        listParticipantsActive = new List ();
        panel.add ( listParticipantsActive, BorderLayout.CENTER );

        panel = new JMPanel ( new BorderLayout() );
        this.add ( panel );
        label = new Label ( PASSIVE + ":" );
        panel.add ( label, BorderLayout.NORTH );
        listParticipantsPassive = new List ();
        panel.add ( listParticipantsPassive, BorderLayout.CENTER );

        updateFields ();
    
public voidupdateFields()


        
        int     i;
        int     nCount;
        Vector  vectorParticipants;
        Object  objParticipant;

	long now = System.currentTimeMillis();

	// Check at only every 3 seconds interval.
	if (now - lastCheckTime < 3000L)
	    return;

	lastCheckTime = now;

	// list the remote users.
        vectorParticipants = getParticipants ( mngrSession, REMOTE );
	if (!compare(lastRemoteList, vectorParticipants)) {
	    if (listParticipantsRemote.getItemCount() > 0)
                listParticipantsRemote.removeAll ();
            nCount = vectorParticipants.size ();
            for ( i = 0;  i < nCount;  i++ ) {
                objParticipant = vectorParticipants.elementAt ( i );
                if ( objParticipant != null  &&  objParticipant instanceof Participant )
                    listParticipantsRemote.add ( ((Participant)objParticipant).getCNAME() );
            }

            if ( nCount < 1 )
                listParticipantsRemote.add ( NONE );

	    lastRemoteList.removeAllElements();
	    for (int j = 0; j < vectorParticipants.size(); j++)
	        lastRemoteList.addElement(vectorParticipants.elementAt(j));	
	}

	// List the local users.
        vectorParticipants = getParticipants ( mngrSession, LOCAL );
	if (!compare(lastLocalList, vectorParticipants)) {
	    if (listParticipantsLocal.getItemCount() > 0)
                listParticipantsLocal.removeAll ();
            nCount = vectorParticipants.size ();
            for ( i = 0;  i < nCount;  i++ ) {
                objParticipant = vectorParticipants.elementAt ( i );
                if ( objParticipant != null  &&  objParticipant instanceof Participant )
                    listParticipantsLocal.add ( ((Participant)objParticipant).getCNAME() );
            }
            if ( nCount < 1 )
                listParticipantsLocal.add ( NONE );

	    lastLocalList.removeAllElements();
	    for (int j = 0; j < vectorParticipants.size(); j++)
	        lastLocalList.addElement(vectorParticipants.elementAt(j));	
	}

	// List the active users.
        vectorParticipants = getParticipants ( mngrSession, ACTIVE );
	if (!compare(lastActiveList, vectorParticipants)) {
	    if (listParticipantsActive.getItemCount() > 0)
                listParticipantsActive.removeAll ();
            nCount = vectorParticipants.size ();
            for ( i = 0;  i < nCount;  i++ ) {
                objParticipant = vectorParticipants.elementAt ( i );
                if ( objParticipant != null  &&  objParticipant instanceof Participant )
                    listParticipantsActive.add ( ((Participant)objParticipant).getCNAME() );
            }
            if ( nCount < 1 )
                listParticipantsActive.add ( NONE );

	    lastActiveList.removeAllElements();
	    for (int j = 0; j < vectorParticipants.size(); j++)
	        lastActiveList.addElement(vectorParticipants.elementAt(j));	
        }

	// List the passive users.
        vectorParticipants = getParticipants ( mngrSession, PASSIVE );
	if (!compare(lastPassiveList, vectorParticipants)) {
	    if (listParticipantsPassive.getItemCount() > 0)
                listParticipantsPassive.removeAll ();
            nCount = vectorParticipants.size ();
            for ( i = 0;  i < nCount;  i++ ) {
                objParticipant = vectorParticipants.elementAt ( i );
                if ( objParticipant != null  &&  objParticipant instanceof Participant )
                    listParticipantsPassive.add ( ((Participant)objParticipant).getCNAME() );
            }
            if ( nCount < 1 )
                listParticipantsPassive.add ( NONE );

	    lastPassiveList.removeAllElements();
	    for (int j = 0; j < vectorParticipants.size(); j++)
	        lastPassiveList.addElement(vectorParticipants.elementAt(j));	
        }