Issue #437 Implemented Roster event handlers.
Change-Id: Ibc6cf9a077eca6893efa048aa780e16ec4f2190d Former-commit-id:353230a7c3
[formerly11f3edb4f2
] [formerly711becf60b
] [formerly353230a7c3
[formerly11f3edb4f2
] [formerly711becf60b
] [formerlyc5fb910ea0
[formerly711becf60b
[formerly 2cf4fbe9225b9442c8368e7fa3d7109976e557b0]]]] Former-commit-id:c5fb910ea0
Former-commit-id:90b58d7453
[formerly95765e4579
] [formerly 174f920dd3137e958c892925e0d9a3f9f2448317 [formerly775d70567c
]] Former-commit-id: 1c4e940cd05c673b367f526e69521c8b3409be81 [formerlyf9d18ba538
] Former-commit-id:3ace27eff2
This commit is contained in:
parent
d093e7390e
commit
b2d8a211b2
9 changed files with 554 additions and 99 deletions
|
@ -22,8 +22,10 @@ package com.raytheon.uf.viz.collaboration.data;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.core.runtime.Assert;
|
||||
import org.eclipse.swt.SWT;
|
||||
|
@ -47,12 +49,17 @@ import com.raytheon.uf.common.status.UFStatus;
|
|||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.CollaborationException;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.IPresence;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.IPresence.Type;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.ISession;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.ISharedDisplaySession;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.IVenueSession;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.event.IRosterChangeEvent;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.event.IRosterEventSubscriber;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.event.ITextMessageEvent;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.event.IVenueInvitationEvent;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.roster.IRoster;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.roster.IRosterEntry;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.roster.IRosterGroup;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.user.IChatID;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID;
|
||||
import com.raytheon.uf.viz.collaboration.comm.provider.Presence;
|
||||
|
@ -88,7 +95,7 @@ import com.raytheon.viz.ui.editor.AbstractEditor;
|
|||
* @author rferrel
|
||||
* @version 1.0
|
||||
*/
|
||||
public class CollaborationDataManager {
|
||||
public class CollaborationDataManager implements IRosterEventSubscriber {
|
||||
private static CollaborationDataManager instance;
|
||||
|
||||
private static final transient IUFStatusHandler statusHandler = UFStatus
|
||||
|
@ -116,6 +123,8 @@ public class CollaborationDataManager {
|
|||
*/
|
||||
Map<String, DataUser> usersMap;
|
||||
|
||||
Set<DataGroup> groupsSet;
|
||||
|
||||
private boolean linkCollaboration;
|
||||
|
||||
/**
|
||||
|
@ -156,6 +165,7 @@ public class CollaborationDataManager {
|
|||
*/
|
||||
private CollaborationDataManager() {
|
||||
linkCollaboration = false;
|
||||
groupsSet = new HashSet<DataGroup>();
|
||||
usersMap = new HashMap<String, DataUser>();
|
||||
sessionsMap = new HashMap<String, IVenueSession>();
|
||||
roleEventControllersMap = HashMultimap.create();
|
||||
|
@ -163,6 +173,93 @@ public class CollaborationDataManager {
|
|||
eventBus = new EventBus();
|
||||
}
|
||||
|
||||
private void populateGroups() {
|
||||
IRoster roster = sessionManager.getRosterManager().getRoster();
|
||||
System.out.println("rosterManager Name " + roster.getUser().getName()
|
||||
+ ": group size " + roster.getGroups().size() + ": entry size "
|
||||
+ roster.getEntries().size());
|
||||
|
||||
groupsSet.clear();
|
||||
|
||||
for (IRosterGroup rosterGroup : roster.getGroups()) {
|
||||
String groupName = rosterGroup.getName();
|
||||
DataGroup group = new DataGroup(groupName);
|
||||
groupsSet.add(group);
|
||||
for (IRosterEntry rosterEntry : rosterGroup.getEntries()) {
|
||||
DataUser user = getUser(CollaborationUtils
|
||||
.makeUserId(rosterEntry));
|
||||
user.addGroup(groupName);
|
||||
user.setPresence(rosterEntry.getPresence());
|
||||
}
|
||||
}
|
||||
|
||||
// Orphan users not in any group.
|
||||
for (IRosterEntry rosterEntry : roster.getEntries()) {
|
||||
DataUser user = getUser(CollaborationUtils.makeUserId(rosterEntry));
|
||||
user.setPresence(rosterEntry.getPresence());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a sorted list of groups
|
||||
*
|
||||
* @param allGroups
|
||||
* - When true all groups otherwise the groups selected for
|
||||
* display.
|
||||
* @return groups
|
||||
*/
|
||||
public List<String> getGroups(boolean allGroups) {
|
||||
List<String> result = new ArrayList<String>();
|
||||
if (allGroups) {
|
||||
for (DataGroup dataGroup : groupsSet) {
|
||||
result.add(dataGroup.getId());
|
||||
}
|
||||
} else {
|
||||
for (DataGroup dataGroup : groupsSet) {
|
||||
if (dataGroup.isDisplay()) {
|
||||
result.add(dataGroup.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<String> getUsersInGroup(String groupId) {
|
||||
List<String> userList = new ArrayList<String>();
|
||||
for (String userId : usersMap.keySet()) {
|
||||
DataUser user = usersMap.get(userId);
|
||||
for (String group : user.groups) {
|
||||
if (groupId.equals(group)) {
|
||||
userList.add(userId);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return userList;
|
||||
}
|
||||
|
||||
public boolean displayGroup(String groupId) {
|
||||
boolean display = true;
|
||||
for (DataGroup group : groupsSet) {
|
||||
if (groupId.equals(group.getId())) {
|
||||
display = group.isDisplay();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return display;
|
||||
}
|
||||
|
||||
public List<String> getOrphanUsers() {
|
||||
List<String> orphanList = new ArrayList<String>();
|
||||
for (String userId : usersMap.keySet()) {
|
||||
DataUser user = usersMap.get(userId);
|
||||
if (user.groups.size() == 0 && userId.equals(loginId) == false) {
|
||||
orphanList.add(userId);
|
||||
}
|
||||
}
|
||||
return orphanList;
|
||||
}
|
||||
|
||||
public String getLoginId() {
|
||||
return loginId;
|
||||
}
|
||||
|
@ -210,7 +307,8 @@ public class CollaborationDataManager {
|
|||
if (shell == null) {
|
||||
return;
|
||||
}
|
||||
LoginDialog dlg = new LoginDialog(shell);
|
||||
LoginDialog dlg = new LoginDialog(shell,
|
||||
CollaborationDataManager.this);
|
||||
loginData = null;
|
||||
loginData = (LoginData) dlg.open();
|
||||
dlg.close();
|
||||
|
@ -268,6 +366,7 @@ public class CollaborationDataManager {
|
|||
sessionManager.setPresence(presence);
|
||||
}
|
||||
fireModifiedPresence();
|
||||
populateGroups();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -276,7 +375,7 @@ public class CollaborationDataManager {
|
|||
|
||||
synchronized public void closeManager() {
|
||||
if (sessionManager != null) {
|
||||
sessionManager.unRegisterEventHandler(this);
|
||||
// The close unRegisters the event handler
|
||||
sessionManager.closeManager();
|
||||
sessionManager = null;
|
||||
}
|
||||
|
@ -559,6 +658,7 @@ public class CollaborationDataManager {
|
|||
public void fireModifiedPresence() {
|
||||
IPresence presence = sessionManager.getPresence();
|
||||
presence.setMode(loginData.getMode());
|
||||
presence.setType(Type.AVAILABLE);
|
||||
presence.setStatusMessage(loginData.getModeMessage());
|
||||
try {
|
||||
sessionManager.getAccountManager().sendPresence(presence);
|
||||
|
@ -592,9 +692,7 @@ public class CollaborationDataManager {
|
|||
System.out.println("\tuserId: " + userId + " DataUser: " + user);
|
||||
System.out.println(usersMap.keySet());
|
||||
if (user != null) {
|
||||
user.mode = rosterEntry.getPresence().getMode();
|
||||
user.type = rosterEntry.getPresence().getType();
|
||||
user.statusMessage = rosterEntry.getPresence().getStatusMessage();
|
||||
user.setPresence(rosterEntry.getPresence());
|
||||
// Assumes only UI updates will be registered.
|
||||
VizApp.runAsync(new Runnable() {
|
||||
|
||||
|
@ -606,6 +704,75 @@ public class CollaborationDataManager {
|
|||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void handleRosterChangeEvent(IRosterChangeEvent event) {
|
||||
final IRosterChangeEvent rosterChangeEvent = event;
|
||||
// TODO update the event's user groups here for the desired type
|
||||
IRosterEntry rosterEntry = rosterChangeEvent.getEntry();
|
||||
String userId = CollaborationUtils.makeUserId(rosterEntry);
|
||||
DataUser user = getUser(userId);
|
||||
System.out.println("=== RosterChangeEvent<" + event.getType() + ">: "
|
||||
+ userId);
|
||||
IPresence presence = rosterChangeEvent.getEntry().getPresence();
|
||||
if (presence != null) {
|
||||
System.out.println("\t" + presence.getMode() + "/"
|
||||
+ presence.getType() + ": \"" + presence.getStatusMessage()
|
||||
+ "\"");
|
||||
}
|
||||
Collection<IRosterGroup> userGroups = rosterEntry.getGroups();
|
||||
switch (rosterChangeEvent.getType()) {
|
||||
case ADD:
|
||||
user.clearGroups();
|
||||
for (IRosterGroup group : userGroups) {
|
||||
String groupName = group.getName();
|
||||
user.addGroup(groupName);
|
||||
DataGroup dataGroup = null;
|
||||
for (DataGroup dGroup : groupsSet) {
|
||||
if (groupName.equals(dGroup.getId())) {
|
||||
dataGroup = dGroup;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (dataGroup == null) {
|
||||
groupsSet.add(new DataGroup(groupName));
|
||||
}
|
||||
}
|
||||
break;
|
||||
case DELETE:
|
||||
// Assume user no longer exists and remove.
|
||||
usersMap.remove(user);
|
||||
break;
|
||||
case MODIFY:
|
||||
// Assume only the presence needs to be updated.
|
||||
user.setPresence(rosterEntry.getPresence());
|
||||
break;
|
||||
case PRESENCE:
|
||||
System.out.println("\tIgnore assume only presence change");
|
||||
return;
|
||||
// break;
|
||||
default:
|
||||
statusHandler.handle(Priority.PROBLEM, "Unknown type: "
|
||||
+ rosterChangeEvent.getType());
|
||||
return;
|
||||
|
||||
}
|
||||
// synchronized (registerCnt) {
|
||||
// if (registerCnt.compareAndSet(0, 0)) {
|
||||
// System.out.println("post delayed");
|
||||
// rosterChangeEventQueue.add(event);
|
||||
// } else {
|
||||
// Assume only views to be updated will register.
|
||||
System.out.println("post now");
|
||||
VizApp.runAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
eventBus.post(rosterChangeEvent);
|
||||
}
|
||||
});
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public String joinCollaborationSession(String venueName, String sessionId) {
|
||||
String result = sessionId;
|
||||
|
|
|
@ -82,13 +82,18 @@ public class CollaborationUser extends CollaborationNode implements
|
|||
return CollaborationDataManager.getInstance().getUser(id).type;
|
||||
}
|
||||
|
||||
public void setMode(IPresence.Mode mode) {
|
||||
CollaborationDataManager.getInstance().getUser(id).mode = mode;
|
||||
public void setPresence(IPresence presence) {
|
||||
CollaborationDataManager.getInstance().getUser(id)
|
||||
.setPresence(presence);
|
||||
}
|
||||
|
||||
public void setType(IPresence.Type type) {
|
||||
CollaborationDataManager.getInstance().getUser(id).type = type;
|
||||
}
|
||||
// public void setMode(IPresence.Mode mode) {
|
||||
// CollaborationDataManager.getInstance().getUser(id).mode = mode;
|
||||
// }
|
||||
//
|
||||
// public void setType(IPresence.Type type) {
|
||||
// CollaborationDataManager.getInstance().getUser(id).type = type;
|
||||
// }
|
||||
|
||||
// public void setStatus(IPresence.Mode mode) {
|
||||
// if (mode.getMode().equals(Mode.AWAY)) {
|
||||
|
@ -107,9 +112,10 @@ public class CollaborationUser extends CollaborationNode implements
|
|||
return CollaborationDataManager.getInstance().getUser(id).statusMessage;
|
||||
}
|
||||
|
||||
public void setStatusMessage(String statusMessage) {
|
||||
CollaborationDataManager.getInstance().getUser(id).statusMessage = statusMessage;
|
||||
}
|
||||
// public void setStatusMessage(String statusMessage) {
|
||||
// CollaborationDataManager.getInstance().getUser(id).statusMessage =
|
||||
// statusMessage;
|
||||
// }
|
||||
|
||||
@Override
|
||||
public int compareTo(CollaborationUser o) {
|
||||
|
|
|
@ -35,10 +35,19 @@ package com.raytheon.uf.viz.collaboration.data;
|
|||
* @author rferrel
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class DataGroup {
|
||||
/**
|
||||
* The fully qualified group name. When a subgroup the name should contain
|
||||
* all the groups ancestors. For example if "C" is a subgroup of "B" which
|
||||
* is a subgroup of "A" then C's id would be "A.B.C".
|
||||
*/
|
||||
String id;
|
||||
|
||||
/**
|
||||
* Indicates if the user wants to display the groups information.
|
||||
*/
|
||||
boolean display;
|
||||
|
||||
/**
|
||||
* Only allow classes in the package to use the constructor.
|
||||
*
|
||||
|
@ -46,5 +55,21 @@ public class DataGroup {
|
|||
*/
|
||||
DataGroup(String id) {
|
||||
this.id = id;
|
||||
this.display = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return display
|
||||
*/
|
||||
public boolean isDisplay() {
|
||||
return display;
|
||||
}
|
||||
|
||||
public void setDisplay(boolean display) {
|
||||
this.display = display;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,9 @@
|
|||
package com.raytheon.uf.viz.collaboration.data;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.IPresence;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.IPresence.Mode;
|
||||
|
@ -61,7 +63,7 @@ public class DataUser {
|
|||
/**
|
||||
* The groups being tracked that user belongs to.
|
||||
*/
|
||||
private Map<String, DataGroup> groupsMap;
|
||||
Set<String> groups;
|
||||
|
||||
/**
|
||||
* The active sessions the user is in.
|
||||
|
@ -74,40 +76,48 @@ public class DataUser {
|
|||
* @param id
|
||||
*/
|
||||
DataUser(String id) {
|
||||
groupsMap = new HashMap<String, DataGroup>();
|
||||
groups = new HashSet<String>();
|
||||
sessionsMap = new HashMap<String, String>();
|
||||
mode = Mode.EXTENDED_AWAY;
|
||||
type = Type.UNKNOWN;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
DataGroup getGroup(String id) {
|
||||
DataGroup group = groupsMap.get(id);
|
||||
if (group == null) {
|
||||
group = new DataGroup(id);
|
||||
groupsMap.put(id, group);
|
||||
}
|
||||
return group;
|
||||
public void addGroup(String group) {
|
||||
groups.add(group);
|
||||
}
|
||||
|
||||
public Set<String> getGroups() {
|
||||
return groups;
|
||||
}
|
||||
|
||||
public void clearGroups() {
|
||||
groups.clear();
|
||||
}
|
||||
|
||||
public String getSessString(String key) {
|
||||
return sessionsMap.get(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mode
|
||||
* the mode to set
|
||||
*/
|
||||
public void setMode(Mode status) {
|
||||
this.mode = status;
|
||||
public void setPresence(IPresence presence) {
|
||||
type = presence.getType();
|
||||
mode = presence.getMode();
|
||||
statusMessage = presence.getStatusMessage();
|
||||
if (statusMessage == null) {
|
||||
statusMessage = "";
|
||||
}
|
||||
}
|
||||
|
||||
public void setMode(String name) {
|
||||
this.mode = modeMap.get(name);
|
||||
}
|
||||
// /**
|
||||
// * @param mode
|
||||
// * the mode to set
|
||||
// */
|
||||
// public void setMode(Mode status) {
|
||||
// this.mode = status;
|
||||
// }
|
||||
//
|
||||
// public void setMode(String name) {
|
||||
// this.mode = modeMap.get(name);
|
||||
// }
|
||||
|
||||
/**
|
||||
* @return the mode
|
||||
|
@ -120,7 +130,7 @@ public class DataUser {
|
|||
return type;
|
||||
}
|
||||
|
||||
public void setType(Type type) {
|
||||
this.type = type;
|
||||
}
|
||||
// public void setType(Type type) {
|
||||
// this.type = type;
|
||||
// }
|
||||
}
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* This software product contains export-restricted data whose
|
||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
* to non-U.S. persons whether in the United States or abroad requires
|
||||
* an export license or other authorization.
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address: 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.uf.viz.collaboration.data;
|
||||
|
||||
/**
|
||||
* A special group to places users not in any group.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Apr 11, 2012 rferrel Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author rferrel
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class OrphanGroup extends CollaborationGroup {
|
||||
|
||||
/**
|
||||
* @param id
|
||||
*/
|
||||
public OrphanGroup(String id) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
}
|
|
@ -76,8 +76,8 @@ import com.raytheon.uf.viz.collaboration.comm.identity.IPresence;
|
|||
import com.raytheon.uf.viz.collaboration.comm.identity.IPresence.Type;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.ISession;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.IVenueSession;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.event.IRosterChangeEvent;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.info.IVenueInfo;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.roster.IRoster;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.roster.IRosterEntry;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.roster.IRosterGroup;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.roster.IRosterManager;
|
||||
|
@ -88,6 +88,7 @@ import com.raytheon.uf.viz.collaboration.data.CollaborationGroup;
|
|||
import com.raytheon.uf.viz.collaboration.data.CollaborationNode;
|
||||
import com.raytheon.uf.viz.collaboration.data.CollaborationUser;
|
||||
import com.raytheon.uf.viz.collaboration.data.LoginUser;
|
||||
import com.raytheon.uf.viz.collaboration.data.OrphanGroup;
|
||||
import com.raytheon.uf.viz.collaboration.data.SessionGroup;
|
||||
import com.raytheon.uf.viz.collaboration.ui.editor.CollaborationEditor;
|
||||
import com.raytheon.uf.viz.collaboration.ui.login.ChangeStatusDialog;
|
||||
|
@ -123,6 +124,8 @@ public class CollaborationGroupView extends ViewPart implements IPartListener {
|
|||
private static final transient IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(CollaborationGroupView.class);
|
||||
|
||||
private static String ORPHAN_GROUP_ID = "Orphan Users";
|
||||
|
||||
private SessionGroup activeSessionGroup;
|
||||
|
||||
private TreeViewer usersTreeViewer;
|
||||
|
@ -778,16 +781,19 @@ public class CollaborationGroupView extends ViewPart implements IPartListener {
|
|||
CollaborationNode node = (CollaborationNode) item
|
||||
.getData();
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("ID: ").append(node.getId());
|
||||
if (node instanceof CollaborationUser) {
|
||||
builder.append("ID: ").append(node.getId());
|
||||
CollaborationUser user = (CollaborationUser) node;
|
||||
builder.append("\nStatus: ")
|
||||
builder.append("\nMode: ")
|
||||
.append(user.getMode().getMode())
|
||||
.append("\n");
|
||||
builder.append("Type: ").append(user.getType())
|
||||
.append("\n");
|
||||
builder.append("Message: \"").append(
|
||||
user.getStatusMessage() + "\"");
|
||||
} else if (node instanceof SessionGroup
|
||||
&& ((SessionGroup) node).isSessionRoot() == false) {
|
||||
builder.append("ID: ").append(node.getId());
|
||||
IVenueInfo info = CollaborationDataManager
|
||||
.getInstance().getSession(node.getId())
|
||||
.getVenue().getInfo();
|
||||
|
@ -996,52 +1002,98 @@ public class CollaborationGroupView extends ViewPart implements IPartListener {
|
|||
* Clear and populate the groups from the roster manager entries.
|
||||
*/
|
||||
private void populateGroups() {
|
||||
CollaborationDataManager manager = CollaborationDataManager
|
||||
.getInstance();
|
||||
|
||||
for (CollaborationNode node : topLevel.getChildren()) {
|
||||
if (!(node instanceof LoginUser || node instanceof SessionGroup)) {
|
||||
topLevel.removeChild(node);
|
||||
}
|
||||
}
|
||||
|
||||
IRosterManager rosterManager = CollaborationDataManager.getInstance()
|
||||
.getSessionManager().getRosterManager();
|
||||
|
||||
IRoster roster = rosterManager.getRoster();
|
||||
|
||||
String name = null;
|
||||
int rsize = -1;
|
||||
int gsize = -1;
|
||||
if (roster != null) {
|
||||
// TODO remove DEBUG start
|
||||
if (roster.getUser() != null) {
|
||||
name = roster.getUser().getName();
|
||||
for (String groupId : manager.getGroups(false)) {
|
||||
CollaborationGroup child = new CollaborationGroup(groupId);
|
||||
for (String userId : manager.getUsersInGroup(groupId)) {
|
||||
CollaborationUser user = new CollaborationUser(userId);
|
||||
child.addChild(user);
|
||||
}
|
||||
if (roster.getEntries() != null) {
|
||||
rsize = roster.getEntries().size();
|
||||
}
|
||||
if (roster.getGroups() != null) {
|
||||
gsize = roster.getGroups().size();
|
||||
}
|
||||
System.out.println("rosterManager Name " + name + ": group size "
|
||||
+ gsize + ": entry size " + rsize);
|
||||
// TODO DEBUG end remove
|
||||
for (IRosterGroup rosterGroup : roster.getGroups()) {
|
||||
if (rosterGroup != null) {
|
||||
populateGroup(topLevel, rosterGroup);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO Are these buddies not in a group that need to be displayed?
|
||||
if (roster.getEntries() != null && roster.getEntries().size() > 0) {
|
||||
for (IRosterEntry e : roster.getEntries()) {
|
||||
System.out.println(name + " entry: "
|
||||
+ e.getUser().getName() + "@"
|
||||
+ e.getUser().getHost() + "/"
|
||||
+ e.getUser().getResource());
|
||||
}
|
||||
topLevel.addChild(child);
|
||||
}
|
||||
List<String> orphanList = manager.getOrphanUsers();
|
||||
if (orphanList.size() > 0) {
|
||||
OrphanGroup orphanGroup = new OrphanGroup(ORPHAN_GROUP_ID);
|
||||
for (String userId : orphanList) {
|
||||
orphanGroup.addChild(new CollaborationUser(userId));
|
||||
}
|
||||
topLevel.addChild(orphanGroup);
|
||||
}
|
||||
}
|
||||
|
||||
// private void populateGroups() {
|
||||
// for (CollaborationNode node : topLevel.getChildren()) {
|
||||
// if (!(node instanceof LoginUser || node instanceof SessionGroup)) {
|
||||
// topLevel.removeChild(node);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // CollaborationDataManager.getInstance().repopulateGroups();
|
||||
//
|
||||
// IRosterManager rosterManager = CollaborationDataManager.getInstance()
|
||||
// .getSessionManager().getRosterManager();
|
||||
//
|
||||
// IRoster roster = rosterManager.getRoster();
|
||||
//
|
||||
// String name = null;
|
||||
// int rsize = -1;
|
||||
// int gsize = -1;
|
||||
// if (roster != null) {
|
||||
// // TODO remove DEBUG start
|
||||
// if (roster.getUser() != null) {
|
||||
// name = roster.getUser().getName();
|
||||
// }
|
||||
// if (roster.getEntries() != null) {
|
||||
// rsize = roster.getEntries().size();
|
||||
// }
|
||||
// if (roster.getGroups() != null) {
|
||||
// gsize = roster.getGroups().size();
|
||||
// }
|
||||
// System.out.println("rosterManager Name " + name + ": group size "
|
||||
// + gsize + ": entry size " + rsize);
|
||||
// // TODO DEBUG end remove
|
||||
// for (IRosterGroup rosterGroup : roster.getGroups()) {
|
||||
// if (rosterGroup != null) {
|
||||
// populateGroup(topLevel, rosterGroup);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // add users not in a group to an orphan group.
|
||||
// if (roster.getEntries() != null && roster.getEntries().size() > 0) {
|
||||
// CollaborationGroup groupNode = new OrphanGroup(ORPHAN_GROUP_ID);
|
||||
// for (IRosterEntry e : roster.getEntries()) {
|
||||
// System.out.println(name + " entry: "
|
||||
// + e.getUser().getName() + "@"
|
||||
// + e.getUser().getHost() + "/"
|
||||
// + e.getUser().getResource());
|
||||
// String userId = CollaborationUtils.makeUserId(e);
|
||||
// CollaborationUser child = new CollaborationUser(userId);
|
||||
// child.setPresence(e.getPresence());
|
||||
// groupNode.addChild(child);
|
||||
// }
|
||||
// topLevel.addChild(groupNode);
|
||||
// } else {
|
||||
// // TODO test do not check in with this else
|
||||
// CollaborationGroup groupNode = new OrphanGroup(
|
||||
// "a test of Orphan Users");
|
||||
// String userId = "foo@bar.com";
|
||||
// CollaborationUser child = new CollaborationUser(userId);
|
||||
// child.setPresence(new Presence(Mode.AWAY, Type.UNAVAILABLE,
|
||||
// "R.I.P."));
|
||||
// groupNode.addChild(child);
|
||||
// topLevel.addChild(groupNode);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* This creates a group node, populates it with its children and makes it a
|
||||
* child of its parent.
|
||||
|
@ -1070,25 +1122,11 @@ public class CollaborationGroupView extends ViewPart implements IPartListener {
|
|||
for (IRosterEntry e : rosterGroup.getEntries()) {
|
||||
String userId = CollaborationUtils.makeUserId(e);
|
||||
CollaborationUser child = new CollaborationUser(userId);
|
||||
IPresence presence = e.getPresence();
|
||||
child.setMode(presence.getMode());
|
||||
child.setType(presence.getType());
|
||||
child.setStatusMessage(presence.getStatusMessage());
|
||||
child.setPresence(e.getPresence());
|
||||
groupNode.addChild(child);
|
||||
}
|
||||
}
|
||||
|
||||
// private LoginUser getLoginUser() {
|
||||
// LoginUser loginUser = null;
|
||||
// for (CollaborationNode node : topLevel.getChildren()) {
|
||||
// if (node instanceof LoginUser) {
|
||||
// loginUser = (LoginUser) node;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// return loginUser;
|
||||
// }
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
|
@ -1341,12 +1379,160 @@ public class CollaborationGroupView extends ViewPart implements IPartListener {
|
|||
*/
|
||||
@Subscribe
|
||||
public void handleModifiedPresence(IRosterEntry rosterEntry) {
|
||||
// Assumes the Data Manager has already update
|
||||
// Only need to update the usersTreeViewer.
|
||||
System.out.println("group view roster entry for:"
|
||||
+ rosterEntry.getUser().getName() + "@"
|
||||
+ rosterEntry.getUser().getHost() + " "
|
||||
+ rosterEntry.getPresence().getMode() + "/"
|
||||
+ rosterEntry.getPresence().getType());
|
||||
refreshUser(CollaborationUtils.makeUserId(rosterEntry), topLevel);
|
||||
usersTreeViewer.refresh(topLevel, true);
|
||||
}
|
||||
|
||||
private void refreshUser(String userId, CollaborationGroup groupNode) {
|
||||
for (CollaborationNode child : groupNode.getChildren()) {
|
||||
if (child instanceof CollaborationUser) {
|
||||
if (userId.equals(child.getId())) {
|
||||
usersTreeViewer.refresh(child, true);
|
||||
}
|
||||
} else if (child instanceof CollaborationGroup) {
|
||||
refreshUser(userId, (CollaborationGroup) child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void handleRosterChangeEvent(IRosterChangeEvent rosterChangeEvent) {
|
||||
// Assume the CollaborationDataManager has updated the back end.
|
||||
// Only need to update the usersTreeView.
|
||||
System.out.println("CollaborationGroupView rosterChangeEvent<"
|
||||
+ rosterChangeEvent.getType() + ">: "
|
||||
+ rosterChangeEvent.getEntry().getUser().getFQName());
|
||||
IRosterEntry rosterEntry = rosterChangeEvent.getEntry();
|
||||
String userId = CollaborationUtils.makeUserId(rosterEntry);
|
||||
List<String> groups = new ArrayList<String>();
|
||||
for (IRosterGroup rosterGroup : rosterEntry.getGroups()) {
|
||||
groups.add(rosterGroup.getName());
|
||||
}
|
||||
switch (rosterChangeEvent.getType()) {
|
||||
case ADD:
|
||||
// Should be a rare event after initial population.
|
||||
// User should only be in enter on list in groups.
|
||||
OrphanGroup orphanGroup = null;
|
||||
if (groups.size() == 0) {
|
||||
// remove from all groups and add to Orphans.
|
||||
for (CollaborationNode node : topLevel.getChildren()) {
|
||||
if (node instanceof OrphanGroup) {
|
||||
CollaborationUser user = null;
|
||||
orphanGroup = (OrphanGroup) node;
|
||||
for (CollaborationNode child : orphanGroup
|
||||
.getChildren()) {
|
||||
if (userId.equals(child.getId())) {
|
||||
user = (CollaborationUser) child;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (user == null) {
|
||||
orphanGroup.addChild(new CollaborationUser(userId));
|
||||
usersTreeViewer.refresh(orphanGroup);
|
||||
}
|
||||
} else if (node instanceof CollaborationGroup
|
||||
&& !(node instanceof SessionGroup)) {
|
||||
CollaborationGroup groupNode = (CollaborationGroup) node;
|
||||
for (CollaborationNode child : groupNode.getChildren()) {
|
||||
if (userId.equals(child.getId())) {
|
||||
if (!groups.contains(groupNode.getId())) {
|
||||
groupNode.removeChild(child);
|
||||
usersTreeViewer.refresh(groupNode);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (orphanGroup == null) {
|
||||
orphanGroup = new OrphanGroup(ORPHAN_GROUP_ID);
|
||||
orphanGroup.addChild(new CollaborationUser(userId));
|
||||
topLevel.addChild(orphanGroup);
|
||||
usersTreeViewer.refresh();
|
||||
}
|
||||
} else {
|
||||
// TODO add user to all in groups and remove from others.
|
||||
for (CollaborationNode node : topLevel.getChildren()) {
|
||||
if (node instanceof CollaborationGroup
|
||||
&& !(node instanceof SessionGroup)) {
|
||||
CollaborationGroup group = (CollaborationGroup) node;
|
||||
for (CollaborationNode child : group.getChildren()) {
|
||||
if (userId.equals(child.getId())) {
|
||||
if (groups.contains(group.getId())) {
|
||||
// User already in the group no need to add.
|
||||
groups.remove(group.getId());
|
||||
} else {
|
||||
// User no longer in this group.
|
||||
group.removeChild(child);
|
||||
usersTreeViewer.refresh(group);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// groups now contains new groups. See if they are on the
|
||||
// display list.
|
||||
if (groups.size() > 0) {
|
||||
CollaborationDataManager manager = CollaborationDataManager
|
||||
.getInstance();
|
||||
for (String groupId : groups) {
|
||||
if (manager.displayGroup(groupId)) {
|
||||
topLevel.addChild(new CollaborationGroup(groupId));
|
||||
}
|
||||
}
|
||||
usersTreeViewer.refresh(topLevel);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case DELETE:
|
||||
// Should be a rare event.
|
||||
for (CollaborationNode node : topLevel.getChildren()) {
|
||||
if (node instanceof CollaborationGroup
|
||||
&& !(node instanceof SessionGroup)) {
|
||||
CollaborationGroup groupNode = (CollaborationGroup) node;
|
||||
for (CollaborationNode child : groupNode.getChildren()) {
|
||||
if (userId.equals(child.getId())) {
|
||||
groupNode.removeChild(child);
|
||||
usersTreeViewer.refresh(groupNode);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case MODIFY:
|
||||
// Assume this only changes the presence of a user in the desire
|
||||
// groups.
|
||||
// Since this is handled by the handleModifiedPresence nothing needs
|
||||
// to be done.
|
||||
for (String groupId : groups) {
|
||||
for (CollaborationNode node : topLevel.getChildren()) {
|
||||
if (node instanceof CollaborationGroup
|
||||
&& !(node instanceof SessionGroup)
|
||||
&& groupId.equals(node.getId())) {
|
||||
CollaborationGroup groupNode = (CollaborationGroup) node;
|
||||
for (CollaborationNode child : groupNode.getChildren()) {
|
||||
if (userId.equals(child.getId())) {
|
||||
usersTreeViewer.refresh(child, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
statusHandler.handle(Priority.PROBLEM, "Unknown type: "
|
||||
+ rosterChangeEvent.getType());
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ import org.eclipse.jface.viewers.Viewer;
|
|||
import org.eclipse.jface.viewers.ViewerSorter;
|
||||
|
||||
import com.raytheon.uf.viz.collaboration.data.LoginUser;
|
||||
import com.raytheon.uf.viz.collaboration.data.OrphanGroup;
|
||||
import com.raytheon.uf.viz.collaboration.data.SessionGroup;
|
||||
|
||||
/**
|
||||
|
@ -67,6 +68,12 @@ public class UsersTreeViewerSorter extends ViewerSorter {
|
|||
return 1;
|
||||
}
|
||||
|
||||
if (e1 instanceof OrphanGroup) {
|
||||
return 1;
|
||||
}
|
||||
if (e2 instanceof OrphanGroup) {
|
||||
return -1;
|
||||
}
|
||||
return super.compare(viewer, e1, e2);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,6 +54,7 @@ import com.raytheon.uf.common.status.IUFStatusHandler;
|
|||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.IPresence;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.event.IRosterEventSubscriber;
|
||||
import com.raytheon.uf.viz.collaboration.comm.provider.session.SessionManager;
|
||||
import com.raytheon.uf.viz.collaboration.data.CollaborationDataManager;
|
||||
import com.raytheon.uf.viz.collaboration.data.DataUser;
|
||||
|
@ -107,12 +108,15 @@ public class LoginDialog extends CaveSWTDialog {
|
|||
|
||||
private LoginData loginData;
|
||||
|
||||
private IRosterEventSubscriber rosterEventSubscriber;
|
||||
|
||||
private SessionManager sessionManager;
|
||||
|
||||
public LoginDialog(Shell parentShell) {
|
||||
public LoginDialog(Shell parentShell,
|
||||
IRosterEventSubscriber rosterEventSubscriber) {
|
||||
super(parentShell, SWT.DIALOG_TRIM);
|
||||
setText("Collaboration Server Login");
|
||||
this.loginData = loginData;
|
||||
this.rosterEventSubscriber = rosterEventSubscriber;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -375,7 +379,8 @@ public class LoginDialog extends CaveSWTDialog {
|
|||
// .getText().trim());
|
||||
try {
|
||||
sessionManager = new SessionManager(loginData
|
||||
.getAccount(), loginData.getPassword());
|
||||
.getAccount(), loginData.getPassword(),
|
||||
rosterEventSubscriber);
|
||||
DataUser dUser = CollaborationDataManager
|
||||
.getInstance().getUser(
|
||||
loginData.getAccount());
|
||||
|
|
|
@ -68,6 +68,7 @@ import com.raytheon.uf.viz.collaboration.comm.identity.event.ParticipantEventTyp
|
|||
import com.raytheon.uf.viz.collaboration.comm.identity.info.IVenueInfo;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.roster.IRosterEntry;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.user.IVenueParticipant;
|
||||
import com.raytheon.uf.viz.collaboration.comm.provider.Presence;
|
||||
import com.raytheon.uf.viz.collaboration.comm.provider.session.SessionManager;
|
||||
import com.raytheon.uf.viz.collaboration.data.CollaborationDataManager;
|
||||
import com.raytheon.uf.viz.collaboration.data.CollaborationUser;
|
||||
|
@ -362,8 +363,8 @@ public class SessionView extends AbstractSessionView {
|
|||
sessionId);
|
||||
if (user.getType() == Type.UNKNOWN) {
|
||||
// Unknown user assume mode/type
|
||||
user.setMode(Mode.AVAILABLE);
|
||||
user.setType(Type.AVAILABLE);
|
||||
user.setPresence(new Presence(Mode.AVAILABLE,
|
||||
Type.AVAILABLE, ""));
|
||||
}
|
||||
|
||||
user.setText(participant.getFQName());
|
||||
|
|
Loading…
Add table
Reference in a new issue