Issue #437 User status now properly displayed and updated in sessions.

Change-Id: I7b0e077cb87f97388fddff27b846ce856cb6a999

Former-commit-id: 8ee6d7cf1a8b7e0bd2fa0abfe016cb221c60f2b3
This commit is contained in:
Roger Ferrel 2012-04-10 11:10:32 -05:00
parent ec92c842c4
commit 3fd25ff1cf
5 changed files with 117 additions and 84 deletions

View file

@ -51,10 +51,13 @@ 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.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.user.IChatID;
import com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID;
import com.raytheon.uf.viz.collaboration.comm.provider.Presence;
import com.raytheon.uf.viz.collaboration.comm.provider.TextMessage;
import com.raytheon.uf.viz.collaboration.comm.provider.roster.RosterEntry;
import com.raytheon.uf.viz.collaboration.comm.provider.session.SessionManager;
import com.raytheon.uf.viz.collaboration.ui.editor.CollaborationEditor;
import com.raytheon.uf.viz.collaboration.ui.login.LoginData;
@ -97,6 +100,8 @@ public class CollaborationDataManager {
String loginId;
private LoginData loginData;
Shell shell;
/**
@ -130,6 +135,10 @@ public class CollaborationDataManager {
return instance;
}
public LoginData getLoginData() {
return loginData;
}
/**
* Converts the venu's Id into a string that usable for a view's secondary
* ID. This is the used as the key in the session Map.
@ -199,7 +208,7 @@ public class CollaborationDataManager {
return;
}
LoginDialog dlg = new LoginDialog(shell);
LoginData loginData = null;
loginData = null;
while (isConnected() == false) {
loginData = (LoginData) dlg.open();
dlg.close();
@ -212,10 +221,10 @@ public class CollaborationDataManager {
loginId = loginData.getAccount();
DataUser user = CollaborationDataManager
.getInstance().getUser(loginId);
// TODO set mode and message here.
user.setMode(loginData.getMode());
user.type = Type.AVAILABLE;
user.statusMessage = loginData.getModeMessage();
// // TODO set mode and message here.
// user.setMode(loginData.getMode());
// user.type = Type.AVAILABLE;
// user.statusMessage = loginData.getModeMessage();
} catch (Exception e) {
MessageBox box = new MessageBox(shell, SWT.ERROR);
box.setText("Login Failed");
@ -229,25 +238,6 @@ public class CollaborationDataManager {
// e.getLocalizedMessage(), e);
}
}
// TODO this will change will be able to get existing
// presences.
Presence presence = new Presence();
presence.setProperty("dummy", "dummy");
presence.setMode(loginData.getMode());
presence.setStatusMessage(loginData.getModeMessage());
presence.setType(Type.AVAILABLE);
try {
sessionManager.getAccountManager().sendPresence(
presence);
} catch (CollaborationException e) {
// TODO Auto-generated catch block. Please revise as
// appropriate.
statusHandler.handle(Priority.PROBLEM,
e.getLocalizedMessage(), e);
} catch (Exception ex) {
ex.printStackTrace();
}
}
});
@ -263,6 +253,7 @@ public class CollaborationDataManager {
statusHandler.handle(Priority.PROBLEM,
e.getLocalizedMessage(), e);
}
fireModifiedPresence();
wbListener = new IWorkbenchListener() {
@Override
@ -573,11 +564,34 @@ public class CollaborationDataManager {
});
}
public void fireModifiedPresence() {
// TODO this will change will be able to get existing
// presences from roster.
Presence presence = new Presence();
presence.setProperty("dummy", "dummy");
presence.setMode(loginData.getMode());
presence.setStatusMessage(loginData.getModeMessage());
presence.setType(Type.AVAILABLE);
try {
sessionManager.getAccountManager().sendPresence(presence);
IRoster roster = sessionManager.getRosterManager().getRoster();
// Generate a fake entry here to update the login user presence in
// all registered views.
IChatID id = roster.getUser();
RosterEntry rosterEntry = new RosterEntry(id);
rosterEntry.setPresence(presence);
handleModifiedPresence(rosterEntry);
} catch (CollaborationException e) {
// TODO Auto-generated catch block. Please revise as
// appropriate.
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
} catch (Exception ex) {
ex.printStackTrace();
}
}
/**
*
* @param venueName
* @param sessionId
* @return
* @param entry
*/
@Subscribe
public void handleModifiedPresence(IRosterEntry entry) {

View file

@ -80,7 +80,6 @@ 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;
import com.raytheon.uf.viz.collaboration.comm.provider.Presence;
import com.raytheon.uf.viz.collaboration.comm.provider.Tools;
import com.raytheon.uf.viz.collaboration.comm.provider.session.SessionManager;
import com.raytheon.uf.viz.collaboration.data.CollaborationDataManager;
@ -429,33 +428,7 @@ public class CollaborationGroupView extends ViewPart implements IPartListener {
LoginData loginData = (LoginData) dialog.getReturnValue();
if (loginData != null) {
// TODO Remove the refresh of the usertree once rostermanger has
// handler.
LoginUser loginUser = getLoginUser();
loginUser.setMode(loginData.getMode());
loginUser.setStatusMessage(loginData.getModeMessage());
usersTreeViewer.refresh(loginUser, true);
SessionManager sessionManager = CollaborationDataManager
.getInstance().getSessionManager();
// TODO this will change will be able to get existing presences.
Presence presence = new Presence();
presence.setProperty("dummy", "dummy");
presence.setMode(loginData.getMode());
presence.setStatusMessage(loginData.getModeMessage());
presence.setType(Type.AVAILABLE);
try {
sessionManager.getAccountManager().sendPresence(presence);
} catch (CollaborationException e) {
// TODO Auto-generated catch block. Please revise as
// appropriate.
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
e);
} catch (Exception ex) {
ex.printStackTrace();
}
System.out.println("send mode change here: "
+ loginData.getMode().toString() + ", Message: \""
+ loginData.getModeMessage() + "\"");
CollaborationDataManager.getInstance().fireModifiedPresence();
}
}
@ -963,26 +936,24 @@ public class CollaborationGroupView extends ViewPart implements IPartListener {
.getSessionManager().getRosterManager();
IRoster roster = rosterManager.getRoster();
// System.out.println("rosterManager Name " /* +
// roster.getUser().getName() */
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
// 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);

View file

@ -35,6 +35,7 @@ import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import com.raytheon.uf.viz.collaboration.comm.identity.IPresence;
import com.raytheon.uf.viz.collaboration.data.CollaborationDataManager;
import com.raytheon.uf.viz.collaboration.ui.CollaborationUtils;
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
@ -62,8 +63,6 @@ public class ChangeStatusDialog extends CaveSWTDialog {
private Text messageTF;
private LoginData loginData;
public ChangeStatusDialog(Shell parentShell) {
super(parentShell, SWT.DIALOG_TRIM);
setText("Collaboration Server Log On");
@ -121,7 +120,8 @@ public class ChangeStatusDialog extends CaveSWTDialog {
@Override
protected void preOpened() {
super.preOpened();
this.loginData = LoginDialog.openUserLoginData();
LoginData loginData = CollaborationDataManager.getInstance()
.getLoginData();
userLabel.setText(loginData.getAccount());
statusCombo.select(CollaborationUtils.statusModesIndex(loginData
.getMode()));
@ -179,6 +179,8 @@ public class ChangeStatusDialog extends CaveSWTDialog {
if (val != IDialogConstants.OK_ID) {
setReturnValue(null);
} else {
LoginData loginData = CollaborationDataManager
.getInstance().getLoginData();
boolean modified = false;
IPresence.Mode mode = CollaborationUtils.statusModes[statusCombo
.getSelectionIndex()];

View file

@ -109,6 +109,10 @@ public class LoginDialog extends CaveSWTDialog {
setText("Collaboration Server Login");
}
/**
* @param parent
* @return
*/
private Control createDialogArea(Composite parent) {
GridData gd = null;
Composite body = new Composite(parent, SWT.NONE);
@ -210,6 +214,13 @@ public class LoginDialog extends CaveSWTDialog {
return body;
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#initializeComponents(org
* .eclipse.swt.widgets.Shell)
*/
@Override
protected void initializeComponents(Shell shell) {
shell.setLayout(new GridLayout(1, false));
@ -217,6 +228,9 @@ public class LoginDialog extends CaveSWTDialog {
createButtonBar(shell);
}
/**
* @param parent
*/
private void createButtonBar(Composite parent) {
GridData gd = null;
Composite bar = new Composite(parent, SWT.NONE);
@ -229,6 +243,11 @@ public class LoginDialog extends CaveSWTDialog {
IDialogConstants.CANCEL_LABEL, false);
}
/*
* (non-Javadoc)
*
* @see com.raytheon.viz.ui.dialogs.CaveSWTDialog#preOpened()
*/
@Override
protected void preOpened() {
super.preOpened();

View file

@ -59,11 +59,14 @@ 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.IMessage;
import com.raytheon.uf.viz.collaboration.comm.identity.IPresence;
import com.raytheon.uf.viz.collaboration.comm.identity.IPresence.Mode;
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.IVenueParticipantEvent;
import com.raytheon.uf.viz.collaboration.comm.identity.event.ParticipantEventType;
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.identity.user.ParticipantRole;
import com.raytheon.uf.viz.collaboration.comm.provider.Tools;
@ -207,6 +210,15 @@ public class SessionView extends AbstractSessionView {
});
}
@Subscribe
public void handleModifiedPresence(IRosterEntry rosterEntry) {
System.out.println("session view roster entry for:"
+ rosterEntry.getUser().getFQName() + " "
+ rosterEntry.getPresence().getMode() + "/"
+ rosterEntry.getPresence().getType());
usersTable.refresh();
}
/**
* Ties the view to a session.
*
@ -338,6 +350,8 @@ public class SessionView extends AbstractSessionView {
.append("\n");
builder.append("type: ").append(user.getType())
.append("\n");
builder.append("message: \"")
.append(user.getStatusMessage()).append("\"\n");
builder.append("-- Roles --");
for (ParticipantRole type : user.getRoles()) {
// TODO fake XXX take this out
@ -363,8 +377,11 @@ public class SessionView extends AbstractSessionView {
String userId = getParticipantUserId(participant);
CollaborationUser user = new CollaborationUser(userId,
sessionId);
// user.setMode(Mode.AVAILABLE);
// user.setType(Type.AVAILABLE);
if (user.getType() == Type.UNKNOWN) {
// Unknown user assume mode/type
user.setMode(Mode.AVAILABLE);
user.setType(Type.AVAILABLE);
}
// ParticipantRole[] roles = user.getRoles(sessionId);
// for (ParticipantRole role : roles) {
@ -373,8 +390,6 @@ public class SessionView extends AbstractSessionView {
user.addRole(ParticipantRole.DATA_PROVIDER);
user.addRole(ParticipantRole.SESSION_LEADER);
user.setText(participant.getFQName());
// user.setMode(mode);
// user.setType(Type.AVAILABLE);
users.add(user);
}
} else {
@ -455,8 +470,10 @@ public class SessionView extends AbstractSessionView {
public void partClosed(IWorkbenchPart part) {
super.partClosed(part);
if (this == part) {
CollaborationDataManager.getInstance().getSession(sessionId)
.unRegisterEventHandler(this);
CollaborationDataManager manager = CollaborationDataManager
.getInstance();
manager.getSession(sessionId).unRegisterEventHandler(this);
manager.unRegisterEventHandler(this);
CollaborationDataManager.getInstance().closeSession(sessionId);
}
}
@ -473,8 +490,10 @@ public class SessionView extends AbstractSessionView {
// TODO Auto-generated method stub
super.partOpened(part);
if (this == part) {
CollaborationDataManager.getInstance().getSession(sessionId)
.registerEventHandler(this);
CollaborationDataManager manager = CollaborationDataManager
.getInstance();
manager.getSession(sessionId).registerEventHandler(this);
manager.registerEventHandler(this);
}
}
@ -585,7 +604,8 @@ public class SessionView extends AbstractSessionView {
participantDeparted(participant);
break;
case PRESENCE_UPDATED:
participantPresenceUpdated(participant, presence);
// The mode for presence not set correctly do not update
// participantPresenceUpdated(participant, presence);
break;
case UPDATED:
System.out.println("---- handle update here: "
@ -633,9 +653,17 @@ public class SessionView extends AbstractSessionView {
}
}
/**
* @param participant
* @param presence
*/
@SuppressWarnings("unchecked")
private void participantPresenceUpdated(IVenueParticipant participant,
IPresence presence) {
// TODO Do not use this to set the mode since it not the user's presence
// mode.
// Keep as a place holder for now since it may be need to set
// leader/provider roles.
List<CollaborationUser> users = (List<CollaborationUser>) usersTable
.getInput();
System.out.println("++++ handle presence updated here: "
@ -655,6 +683,5 @@ public class SessionView extends AbstractSessionView {
CollaborationUser user = new CollaborationUser(name);
user.setMode(presence.getMode());
user.setType(presence.getType());
// usersTable.refresh();
}
}