Issue #244 Added participant even handler for SessionView and put in code to get groups(rosters).

Change-Id: I4a7501859f2681b290ad0babf4dab9cbca80e102

Former-commit-id: a264abfff059a9c5942ef1db91a6390fad12a110
This commit is contained in:
Roger Ferrel 2012-03-22 16:57:30 -05:00
parent 615962f5dd
commit 04b5a92838
13 changed files with 435 additions and 231 deletions

View file

@ -13,7 +13,8 @@ Require-Bundle: com.raytheon.viz.ui,
org.eclipse.swt;bundle-version="3.6.1",
org.eclipse.ecf;bundle-version="3.1.0",
com.raytheon.uf.viz.core;bundle-version="1.12.1174",
org.geotools;bundle-version="2.6.4"
org.geotools;bundle-version="2.6.4",
com.google.guava;bundle-version="1.0.0"
Import-Package: com.raytheon.uf.common.status,
com.raytheon.uf.viz.core.maps.display,
com.raytheon.uf.viz.core.maps.rsc

View file

Before

Width:  |  Height:  |  Size: 329 B

After

Width:  |  Height:  |  Size: 329 B

View file

@ -33,9 +33,9 @@ import org.eclipse.ui.PlatformUI;
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.provider.SessionManager;
import com.raytheon.uf.viz.collaboration.comm.identity.IVenueSession;
import com.raytheon.uf.viz.collaboration.comm.identity.CollaborationException;
import com.raytheon.uf.viz.collaboration.comm.identity.IVenueSession;
import com.raytheon.uf.viz.collaboration.comm.provider.SessionManager;
import com.raytheon.uf.viz.collaboration.ui.login.LoginData;
import com.raytheon.uf.viz.collaboration.ui.login.LoginDialog;
import com.raytheon.uf.viz.core.VizApp;
@ -155,8 +155,8 @@ public class CollaborationDataManager {
loginId = loginData.getAccount();
DataUser user = CollaborationDataManager
.getInstance().getUser(loginId);
// TODO set status and message here.
user.status = loginData.getStatus();
// TODO set mode and message here.
user.setMode(loginData.getStatus());
user.statusMessage = loginData.getMessage();
wbListener = new IWorkbenchListener() {
@ -274,23 +274,33 @@ public class CollaborationDataManager {
sessionsMap.put(sessionId, session);
}
}
} catch(CollaborationException ce) {
} catch (CollaborationException e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
sessionId = null;
}
// TODO Start CAVE editor associated with this session and make sure the
// user is data provider and session leader.
return sessionId;
}
public boolean isConnected() {
return manager != null;
}
public String joinCollaborationSession(String venuName, String sessionId) {
if (sessionsMap.get(sessionId) == null) {
IVenueSession session = null;
try {
IVenueSession session = getSessionManager()
.createCollaborationSession();
session = getSessionManager().createCollaborationSession();
sessionsMap.put(sessionId, session);
session.joinVenue(venuName);
} catch (CollaborationException ce) {
} catch (CollaborationException e) {
// TODO Auto-generated catch block. Please revise as
// appropriate.
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
e);
}
}
return sessionId;

View file

@ -1,8 +1,6 @@
package com.raytheon.uf.viz.collaboration.data;
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.data.DataUser.StatusType;
/**
* This software was developed and / or modified by Raytheon Company,
@ -66,7 +64,7 @@ public class CollaborationUser extends CollaborationNode implements
*/
@Override
public String getImageKey() {
return getStatus().toString();
return getMode().toString();
}
public DataUser.RoleType[] getRoles(String session) {
@ -89,23 +87,26 @@ public class CollaborationUser extends CollaborationNode implements
.removeSession(session);
}
public DataUser.StatusType getStatus() {
return CollaborationDataManager.getInstance().getUser(id).status;
public IPresence.Mode getMode() {
return CollaborationDataManager.getInstance().getUser(id).mode;
}
public void setStatus(DataUser.StatusType status) {
CollaborationDataManager.getInstance().getUser(id).status = status;
public void setMode(IPresence.Mode mode) {
CollaborationDataManager.getInstance().getUser(id).mode = mode;
}
public void setStatus(IPresence.Mode mode) {
if (mode.getMode().equals(Mode.AWAY)) {
CollaborationDataManager.getInstance().getUser(id).status = StatusType.AWAY;
} else if (mode.getMode().equals(Mode.DND)) {
CollaborationDataManager.getInstance().getUser(id).status = StatusType.DO_NOT_DISTURB;
} else if (mode.getMode().equals(Mode.AVAILABLE)) {
CollaborationDataManager.getInstance().getUser(id).status = StatusType.AVAILABLE;
}
}
// public void setStatus(IPresence.Mode mode) {
// if (mode.getMode().equals(Mode.AWAY)) {
// CollaborationDataManager.getInstance().getUser(id).mode =
// StatusType.AWAY;
// } else if (mode.getMode().equals(Mode.DND)) {
// CollaborationDataManager.getInstance().getUser(id).mode =
// StatusType.DO_NOT_DISTURB;
// } else if (mode.getMode().equals(Mode.AVAILABLE)) {
// CollaborationDataManager.getInstance().getUser(id).mode =
// StatusType.AVAILABLE;
// }
// }
public String getStatusMessage() {
return CollaborationDataManager.getInstance().getUser(id).statusMessage;

View file

@ -25,6 +25,9 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import com.raytheon.uf.viz.collaboration.comm.identity.IPresence;
import com.raytheon.uf.viz.collaboration.comm.identity.IPresence.Mode;
/**
* A Data class that contains all the user information needed for the current
* instance of CAVE.
@ -44,18 +47,26 @@ import java.util.Map;
*/
public class DataUser {
public static enum StatusType {
AVAILABLE("Available"), AWAY("Away"), DO_NOT_DISTURB("Do Not Disturb"), NOT_ON_LINE(
"UnAvailable");
// public static enum StatusType {
// AVAILABLE("Available"), AWAY("Away"), DO_NOT_DISTURB("Do Not Disturb"),
// NOT_ON_LINE(
// "UnAvailable");
//
// private final String value;
//
// StatusType(String value) {
// this.value = value;
// }
//
// public String value() {
// return value;
// }
// }
private final String value;
StatusType(String value) {
this.value = value;
}
public String value() {
return value;
private static final Map<String, IPresence.Mode> modeMap = new HashMap<String, IPresence.Mode>();
static {
for (Mode mode : Mode.values()) {
modeMap.put(mode.name(), mode);
}
}
@ -73,7 +84,7 @@ public class DataUser {
}
}
StatusType status;
IPresence.Mode mode;
String statusMessage;
@ -103,7 +114,7 @@ public class DataUser {
this.id = id;
groupsMap = new HashMap<String, DataGroup>();
sessionsMap = new HashMap<String, String>();
status = StatusType.NOT_ON_LINE;
mode = Mode.EXTENDED_AWAY;
roleMap = new HashMap<String, List<RoleType>>();
}
@ -179,17 +190,21 @@ public class DataUser {
}
/**
* @param status
* the status to set
* @param mode
* the mode to set
*/
public void setStatus(StatusType status) {
this.status = status;
public void setMode(Mode status) {
this.mode = status;
}
public void setMode(String name) {
this.mode = modeMap.get(name);
}
/**
* @return the status
* @return the mode
*/
public StatusType getStatus() {
return status;
public Mode getMode() {
return mode;
}
}

View file

@ -62,15 +62,20 @@ import org.eclipse.ui.part.ViewPart;
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.provider.SessionManager;
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.ISession;
import com.raytheon.uf.viz.collaboration.comm.identity.IVenueSession;
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;
import com.raytheon.uf.viz.collaboration.comm.provider.SessionManager;
import com.raytheon.uf.viz.collaboration.data.CollaborationDataManager;
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.DataUser;
import com.raytheon.uf.viz.collaboration.data.LoginUser;
import com.raytheon.uf.viz.collaboration.data.SessionGroup;
import com.raytheon.uf.viz.collaboration.ui.session.AbstractSessionView;
@ -101,13 +106,11 @@ public class CollaborationGroupView extends ViewPart {
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(CollaborationGroupView.class);
private SessionGroup activeSessionGroup = null;
private SessionGroup activeSessionGroup;
private TreeViewer usersTreeViewer;
CollaborationGroup topLevel = new CollaborationGroup("kickstart");
SessionGroup acitveSessionGroup;
CollaborationGroup topLevel;
Map<String, String[]> groupMap;
@ -123,6 +126,8 @@ public class CollaborationGroupView extends ViewPart {
private Action peerToPeerChatAction;
private Action logonAction;
private Action logoutAction;
private Action aliasAction;
@ -162,17 +167,11 @@ public class CollaborationGroupView extends ViewPart {
createUsersTree(parent);
addDoubleClickListeners();
createContextMenu();
CollaborationDataManager dManager = CollaborationDataManager
.getInstance();
SessionManager manager = null;
if (dManager != null) {
manager = dManager.getSessionManager();
if (CollaborationDataManager.getInstance().isConnected()) {
populateTree();
} else {
usersTreeViewer.getTree().setEnabled(false);
}
if (manager == null) {
System.err.println("Unable to connect");
}
populateTree();
}
/**
@ -189,6 +188,8 @@ public class CollaborationGroupView extends ViewPart {
};
createSessionAction.setImageDescriptor(CollaborationUtils
.getImageDescriptor("add_collaborate.gif"));
createSessionAction.setEnabled(CollaborationDataManager.getInstance()
.isConnected());
linkToEditorAction = new Action("Link Editor to Chat Session",
Action.AS_CHECK_BOX) {
@ -225,12 +226,22 @@ public class CollaborationGroupView extends ViewPart {
}
};
logonAction = new Action("Logon...") {
@Override
public void run() {
populateTree();
}
};
logonAction.setImageDescriptor(CollaborationUtils
.getImageDescriptor("logout.gif"));
logoutAction = new Action("Logout") {
@Override
public void run() {
performLogout();
}
};
logoutAction.setImageDescriptor(CollaborationUtils
.getImageDescriptor("logout.gif"));
@ -411,20 +422,18 @@ public class CollaborationGroupView extends ViewPart {
}
private void fillStatusMenu(Menu menu) {
for (DataUser.StatusType type : DataUser.StatusType.values()) {
if (type != DataUser.StatusType.NOT_ON_LINE) {
Action action = new Action(type.value()) {
public void run() {
changeStatusAction.setId(getId());
changeStatusAction.run();
};
for (IPresence.Mode type : CollaborationUtils.statusModes) {
Action action = new Action(type.getMode()) {
public void run() {
changeStatusAction.setId(getId());
changeStatusAction.run();
};
action.setId(type.name());
ActionContributionItem item = new ActionContributionItem(action);
action.setImageDescriptor(CollaborationUtils
.getImageDescriptor(type.name().toLowerCase() + ".gif"));
item.fill(menu, -1);
}
};
action.setId(type.name());
ActionContributionItem item = new ActionContributionItem(action);
action.setImageDescriptor(CollaborationUtils
.getImageDescriptor(type.name().toLowerCase() + ".gif"));
item.fill(menu, -1);
}
}
@ -440,6 +449,14 @@ public class CollaborationGroupView extends ViewPart {
private void createMenubar() {
IMenuManager mgr = getViewSite().getActionBars().getMenuManager();
createMenu(mgr);
mgr.addMenuListener(new IMenuListener() {
@Override
public void menuAboutToShow(IMenuManager manager) {
manager.removeAll();
createMenu(manager);
}
});
}
private void createMenu(IMenuManager mgr) {
@ -451,7 +468,11 @@ public class CollaborationGroupView extends ViewPart {
mgr.add(changeMessageAction);
mgr.add(changePasswordAction);
mgr.add(new Separator());
mgr.add(logoutAction);
if (CollaborationDataManager.getInstance().isConnected()) {
mgr.add(logoutAction);
} else {
mgr.add(logonAction);
}
}
private void createSession() {
@ -636,6 +657,8 @@ public class CollaborationGroupView extends ViewPart {
usersTreeViewer.setContentProvider(new UsersTreeContentProvider());
usersTreeViewer.setLabelProvider(new UsersTreeLabelProvider());
usersTreeViewer.setSorter(new UsersTreeViewerSorter());
topLevel = new CollaborationGroup("kickstart");
usersTreeViewer.setInput(topLevel);
treeEditor = new TreeEditor(usersTreeViewer.getTree());
}
@ -737,8 +760,7 @@ public class CollaborationGroupView extends ViewPart {
CollaborationDataManager manager = CollaborationDataManager
.getInstance();
SessionManager sessionManager = manager.getSessionManager();
topLevel = new CollaborationGroup("kickstart");
usersTreeViewer.setInput(topLevel);
topLevel.removeChildren();
if (sessionManager == null) {
usersTreeViewer.getTree().setEnabled(false);
return;
@ -752,43 +774,12 @@ public class CollaborationGroupView extends ViewPart {
populateActiveSessions();
// TODO get from server.
for (String g : new String[] { "Mybuddy1", "buddy1" }) {
CollaborationGroup group = new CollaborationGroup(g);
group.setLocal(true);
group.setModifiable(true);
topLevel.addChild(group);
for (String u : new String[] { "OAX_user1", "DSM_user3",
"LBF_user2", "mnash@awipscm.omaha.us.ray.com" }) {
CollaborationUser item = new CollaborationUser(u);
group.addChild(item);
item.setStatus(DataUser.StatusType.AVAILABLE);
}
}
populateGroups();
// TODO get from server
for (String g : new String[] { "OAX", "DSM", "LBF", "FSD" }) {
CollaborationGroup group = new CollaborationGroup(g);
group.setLocal(false);
topLevel.addChild(group);
for (String u : new String[] { g + "_user2", g + "_user3",
g + "_user1" }) {
CollaborationUser item = new CollaborationUser(u);
group.addChild(item);
item.setStatus(DataUser.StatusType.AWAY);
}
}
CollaborationUser me = new CollaborationUser("OAX_rferrel");
me.setStatus(DataUser.StatusType.AVAILABLE);
for (CollaborationNode node : topLevel.getChildren()) {
if ("OAX".equals(node.getId())) {
((CollaborationGroup) node).addChild(me);
break;
}
}
usersTreeViewer.setInput(topLevel);
// usersTreeViewer.setInput(topLevel);
usersTreeViewer.getTree().setEnabled(true);
usersTreeViewer.refresh(topLevel, true);
createSessionAction.setEnabled(true);
}
private void refreshActiveSessions() {
@ -806,12 +797,98 @@ public class CollaborationGroupView extends ViewPart {
gp.setText(venu.getVenueName());
if (venu.getParticipantCount() > 0) {
// TODO add current participants of the venu here.
// TODO add current participants of the venu here?
}
activeSessionGroup.addChild(gp);
}
}
private void populateGroups() {
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();
System.out.println("rosterManager Name " + roster.getUser().getName()
+ ": group size " + roster.getGroups().size() + ": entry size "
+ roster.getEntries().size());
for (IRosterGroup rosterGroup : roster.getGroups()) {
populateGroup(topLevel, rosterGroup);
}
// TODO get Groups from server.
for (String g : new String[] { "Mybuddy1", "buddy1" }) {
CollaborationGroup group = new CollaborationGroup(g);
group.setLocal(true);
group.setModifiable(true);
topLevel.addChild(group);
for (String u : new String[] { "jkorman@awipscm.omaha.us.ray.com",
"abc@awipscm.omaha.us.ray.com",
"mnash@awipscm.omaha.us.ray.com" }) {
CollaborationUser item = new CollaborationUser(u);
group.addChild(item);
item.setMode(Mode.AVAILABLE);
}
}
// TODO get from server
for (String g : new String[] { "OAX", "DSM", "LBF", "FSD" }) {
CollaborationGroup group = new CollaborationGroup(g);
group.setLocal(false);
topLevel.addChild(group);
for (String u : new String[] { g + "_user2", g + "_user3",
g + "_user1" }) {
CollaborationUser item = new CollaborationUser(u);
group.addChild(item);
item.setMode(Mode.AWAY);
}
}
CollaborationUser me = new CollaborationUser("OAX_rferrel");
me.setMode(Mode.AVAILABLE);
for (CollaborationNode node : topLevel.getChildren()) {
if ("OAX".equals(node.getId())) {
((CollaborationGroup) node).addChild(me);
break;
}
}
}
/**
* This creates a group node, populates it with its children and makes it a
* child of its parent.
*
* @param parent
* @param rosterGroup
* - Information about the group and its children -
*/
private void populateGroup(CollaborationGroup parent,
IRosterGroup rosterGroup) {
CollaborationGroup groupNode = new CollaborationGroup(
rosterGroup.getName());
// TODO determine if group is modifiable (User) or System group.
groupNode.setLocal(true);
groupNode.setModifiable(true);
parent.addChild(groupNode);
System.out.println("group Name " + rosterGroup.getName() + ": entries "
+ rosterGroup.getEntries());
if (rosterGroup.getGroups() != null) {
for (IRosterGroup childGroup : rosterGroup.getGroups()) {
populateGroup(groupNode, childGroup);
}
}
for (IRosterEntry e : rosterGroup.getEntries()) {
CollaborationUser child = new CollaborationUser(e.getName());
groupNode.addChild(child);
}
}
/**
* @return
*/

View file

@ -31,10 +31,11 @@ import org.eclipse.swt.graphics.Image;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
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.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.DataUser;
import com.raytheon.uf.viz.collaboration.data.SessionGroup;
/**
@ -59,6 +60,9 @@ public class CollaborationUtils {
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(CollaborationUtils.class);
public static final IPresence.Mode[] statusModes = { Mode.AVAILABLE,
Mode.DND, Mode.AWAY };
public static ImageDescriptor getImageDescriptor(String string) {
String iconPath = "icons" + File.separator;
URL url = FileLocator.find(Activator.getDefault().getBundle(),
@ -74,11 +78,11 @@ public class CollaborationUtils {
Image nodeImage = null;
if (node instanceof CollaborationUser) {
CollaborationUser user = (CollaborationUser) node;
if (user.getStatus() == DataUser.StatusType.AVAILABLE) {
if (user.getMode() == IPresence.Mode.AVAILABLE) {
nodeImage = getImageDescriptor("available.gif").createImage();
} else if (user.getStatus() == DataUser.StatusType.AWAY) {
} else if (user.getMode() == IPresence.Mode.AWAY) {
nodeImage = getImageDescriptor("away.gif").createImage();
} else if (user.getStatus() == DataUser.StatusType.DO_NOT_DISTURB) {
} else if (user.getMode() == IPresence.Mode.DND) {
nodeImage = getImageDescriptor("do_not_disturb.gif")
.createImage();
} else {
@ -134,8 +138,8 @@ public class CollaborationUtils {
// }
}
public static void changeStatus(DataUser.StatusType type) {
System.out.println("Changing status...");
public static void changeStatus(IPresence.Mode statusMode) {
System.out.println("Changing mode...");
// IPresenceContainerAdapter presence = CollaborationData.getInstance()
// .getPresence();
//

View file

@ -43,7 +43,6 @@ import org.eclipse.swt.widgets.Text;
import com.raytheon.uf.viz.collaboration.comm.identity.info.IVenueInfo;
import com.raytheon.uf.viz.collaboration.data.CollaborationDataManager;
import com.raytheon.uf.viz.collaboration.data.DataUser;
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
/**
@ -63,7 +62,6 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
* @version 1.0
*/
public class CreateSessionDialog extends CaveSWTDialog {
private static DataUser.StatusType[] status = null;
private Text nameTF;
@ -86,17 +84,6 @@ public class CreateSessionDialog extends CaveSWTDialog {
}
private Control createDialogArea(Composite parent) {
if (status == null) {
DataUser.StatusType[] types = DataUser.StatusType.values();
status = new DataUser.StatusType[types.length - 1];
int index = 0;
for (DataUser.StatusType type : types) {
if (type != DataUser.StatusType.NOT_ON_LINE) {
status[index] = type;
++index;
}
}
}
Composite body = new Composite(parent, SWT.NONE);
body.setLayout(new GridLayout(2, false));
// body.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL

View file

@ -1,6 +1,12 @@
package com.raytheon.uf.viz.collaboration.ui.login;
import com.raytheon.uf.viz.collaboration.data.DataUser;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import com.raytheon.uf.common.serialization.ISerializableObject;
import com.raytheon.uf.viz.collaboration.comm.identity.IPresence;
/**
* This software was developed and / or modified by Raytheon Company,
@ -23,7 +29,8 @@ import com.raytheon.uf.viz.collaboration.data.DataUser;
**/
/**
* TODO Add Description
* Data class that provides logon information. All but the password may be saved
* and from a localized file.
*
* <pre>
*
@ -38,24 +45,37 @@ import com.raytheon.uf.viz.collaboration.data.DataUser;
* @author rferrel
* @version 1.0
*/
public class LoginData {
@XmlRootElement(name = "CollaborationLogon")
@XmlAccessorType(XmlAccessType.NONE)
public class LoginData implements ISerializableObject {
@XmlElement(name = "user")
private String user;
@XmlElement(name = "server")
private String server;
transient private String password;
private transient String password;
private DataUser.StatusType status;
@XmlElement(name = "mode")
private String status;
@XmlElement(name = "statusMessage")
private String statusMessage;
public LoginData() {
this.user = "";
this.server = "";
this.password = "";
this.status = IPresence.Mode.AVAILABLE.name();
}
public LoginData(final String user, final String server,
final String password, final DataUser.StatusType status,
final String password, final IPresence.Mode status,
final String statusMessage) {
this.user = user;
this.server = server;
this.password = password;
this.status = status;
this.status = status.name();
this.statusMessage = statusMessage;
}
@ -71,7 +91,7 @@ public class LoginData {
password = null;
}
public DataUser.StatusType getStatus() {
public String getStatus() {
return status;
}
@ -88,17 +108,8 @@ public class LoginData {
}
public String toString() {
return "userId: \"" + user + "\", server \"" + server + "\", status:\""
+ status.value() + "\", statusMessage: \"" + statusMessage
+ "\", pw: "
return "userId: \"" + user + "\", server \"" + server + "\", mode:\""
+ status + "\", statusMessage: \"" + statusMessage + "\", pw: "
+ ((password == null) ? "null" : password.length());
}
// public void addErrorMessage(String error) {
// errorMessages.add(error);
// }
//
// public List<String> getErrorMessages() {
// return errorMessages;
// }
}

View file

@ -39,7 +39,8 @@ import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import com.raytheon.uf.viz.collaboration.data.DataUser;
import com.raytheon.uf.viz.collaboration.comm.identity.IPresence;
import com.raytheon.uf.viz.collaboration.ui.CollaborationUtils;
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
/**
@ -59,9 +60,6 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
* @version 1.0
*/
public class LoginDialog extends CaveSWTDialog {
// TODO get default user, server, status and message from localized file.
private static DataUser.StatusType[] status = null;
private Text userTF;
private Text serverTF;
@ -85,7 +83,7 @@ public class LoginDialog extends CaveSWTDialog {
private LoginData loginData;
public LoginDialog(Shell parentShell) {
super(parentShell);
super(parentShell, SWT.DIALOG_TRIM);
setText("Collaboration Server Log On");
}
@ -94,17 +92,6 @@ public class LoginDialog extends CaveSWTDialog {
}
private Control createDialogArea(Composite parent) {
if (status == null) {
DataUser.StatusType[] types = DataUser.StatusType.values();
status = new DataUser.StatusType[types.length - 1];
int index = 0;
for (DataUser.StatusType type : types) {
if (type != DataUser.StatusType.NOT_ON_LINE) {
status[index] = type;
++index;
}
}
}
GridData gd = null;
Composite body = new Composite(parent, SWT.NONE);
body.setLayout(new GridLayout(3, false));
@ -182,9 +169,9 @@ public class LoginDialog extends CaveSWTDialog {
label.setText("Status: ");
statusCombo = new Combo(body, SWT.DEFAULT);
// TODO get status messages from config file?
for (DataUser.StatusType type : status) {
statusCombo.add(type.value());
// TODO get mode messages from config file?
for (IPresence.Mode mode : CollaborationUtils.statusModes) {
statusCombo.add(mode.getMode());
}
statusCombo.select(0);
label = new Label(body, SWT.NONE);
@ -230,8 +217,7 @@ public class LoginDialog extends CaveSWTDialog {
if (loginData != null) {
userTF.setText(loginData.getUser());
serverTF.setText(loginData.getServer());
statusCombo.select(statusCombo.indexOf(loginData.getStatus()
.value()));
statusCombo.select(statusCombo.indexOf(loginData.getStatus()));
messageTF.setText(loginData.getMessage());
}
userTF.setFocus();
@ -315,8 +301,9 @@ public class LoginDialog extends CaveSWTDialog {
}
if (focusField == null) {
loginData = new LoginData(user, server, password,
status[statusCombo.getSelectionIndex()],
messageTF.getText().trim());
CollaborationUtils.statusModes[statusCombo
.getSelectionIndex()], messageTF
.getText().trim());
setReturnValue(loginData);
LoginDialog.this.getShell().dispose();
} else {

View file

@ -86,7 +86,6 @@ public class ParticipantsLabelProvider implements ITableColorProvider,
@Override
public Image getColumnImage(Object element, int columnIndex) {
System.out.println("getColumnImage");
CollaborationUser user = (CollaborationUser) element;
CollaborationDataManager.getInstance().getUser(user.getId());
Image image = CollaborationUtils.getNodeImage(user);
@ -105,7 +104,7 @@ public class ParticipantsLabelProvider implements ITableColorProvider,
@Override
public Font getFont(Object element, int columnIndex) {
System.out.println("getFont");
// System.out.println("getFont");
return null;
}
@ -118,7 +117,7 @@ public class ParticipantsLabelProvider implements ITableColorProvider,
@Override
public Color getBackground(Object element, int columnIndex) {
System.out.println("getBackground");
// System.out.println("getBackground");
// TODO Auto-generated method stub
return null;
}

View file

@ -26,9 +26,10 @@ import org.eclipse.swt.widgets.Label;
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.CollaborationException;
import com.raytheon.uf.viz.collaboration.comm.identity.ISession;
import com.raytheon.uf.viz.collaboration.comm.identity.listener.IMessageListener;
import com.raytheon.uf.viz.collaboration.comm.identity.CollaborationException;
import com.raytheon.uf.viz.collaboration.data.CollaborationDataManager;
/**
@ -168,12 +169,15 @@ public class PeerToPeerView extends AbstractSessionView {
} else {
try {
session = CollaborationDataManager.getInstance()
.getSessionManager().createPeerToPeerSession();
} catch(CollaborationException ce) {
.getSessionManager().createPeerToPeerSession();
// session.sendTextMessage(toUser, message);
// session.close();
} catch (CollaborationException e) {
// TODO Auto-generated catch block. Please revise as
// appropriate.
statusHandler.handle(Priority.PROBLEM,
e.getLocalizedMessage(), e);
}
// session.sendTextMessage(toUser, message);
// session.close();
}
}
}

View file

@ -21,8 +21,8 @@ package com.raytheon.uf.viz.collaboration.ui.session;
**/
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collection;
import java.util.List;
import org.eclipse.jface.action.Action;
@ -56,12 +56,15 @@ import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import com.google.common.eventbus.Subscribe;
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.IMessage;
import com.raytheon.uf.viz.collaboration.comm.identity.IPresence;
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.listener.IMessageFilter;
import com.raytheon.uf.viz.collaboration.comm.identity.listener.IMessageListener;
@ -212,7 +215,6 @@ public class SessionView extends AbstractSessionView {
IVenueSession session = CollaborationDataManager.getInstance()
.getSession(sessionId);
if (session != null) {
// setPartName(session.getVenue().getInfo().getVenueDescription());
messageListener = new IMessageListener() {
@Override
@ -235,50 +237,53 @@ public class SessionView extends AbstractSessionView {
}
});
participantListener = new IVenueParticipantListener() {
@Override
public void handleUpdated(IVenueParticipant participant) {
System.out.println("updated");
}
@Override
public void handlePresenceUpdated(IVenueParticipant fromID,
IPresence presence) {
// not the best way to do it, should just be adding the
// new
// user instead of requerying for participants
Collection<IVenueParticipant> participants = CollaborationDataManager
.getInstance().getSession(sessionId).getVenue()
.getParticipants();
final List<CollaborationUser> users = new ArrayList<CollaborationUser>();
for (IVenueParticipant part : participants) {
CollaborationUser user = new CollaborationUser(
part.getName());
user.setStatus(presence.getMode());
user.setText(user.getId());
users.add(user);
}
VizApp.runAsync(new Runnable() {
@Override
public void run() {
usersTable.setInput(users
.toArray(new CollaborationUser[users.size()]));
}
});
}
@Override
public void handleDeparted(IVenueParticipant participant) {
System.out.println("goodbye");
}
@Override
public void handleArrived(IVenueParticipant participant) {
System.out.println("you've got mail");
}
};
session.addVenueParticipantListener(participantListener);
session.registerEventHandler(this);
// participantListener = new IVenueParticipantListener() {
// @Override
// public void handleUpdated(IVenueParticipant participant) {
// System.out.println("updated");
// }
//
// @Override
// public void handlePresenceUpdated(IVenueParticipant fromID,
// IPresence presence) {
// // not the best way to do it, should just be adding the
// // new
// // user instead of requerying for participants
// Collection<IVenueParticipant> participants =
// CollaborationDataManager
// .getInstance().getSession(sessionId).getVenue()
// .getParticipants();
// final List<CollaborationUser> users = new
// ArrayList<CollaborationUser>();
// for (IVenueParticipant part : participants) {
// CollaborationUser user = new CollaborationUser(
// part.getName());
// user.setMode(presence.getMode());
// user.setText(user.getId());
// users.add(user);
// }
// VizApp.runAsync(new Runnable() {
// @Override
// public void run() {
// usersTable.setInput(users
// .toArray(new CollaborationUser[users.size()]));
// }
// });
// }
//
// @Override
// public void handleDeparted(IVenueParticipant participant) {
// System.out.println("goodbye");
//
// }
//
// @Override
// public void handleArrived(IVenueParticipant participant) {
// System.out.println("you've got mail");
// }
// };
// session.addVenueParticipantListener(participantListener);
}
}
@ -551,6 +556,9 @@ public class SessionView extends AbstractSessionView {
.removeVenueParticipantListener(participantListener);
}
CollaborationDataManager.getInstance().getSession(sessionId)
.unRegisterEventHandler(this);
// dispose of the images first
disposeArrow(highlightedDownArrow);
disposeArrow(highlightedRightArrow);
@ -691,6 +699,7 @@ public class SessionView extends AbstractSessionView {
// session.removeMessageListener(list);
// }
session.removeVenueParticipantListener(participantListener);
session.unRegisterEventHandler(this);
}
// this.getViewSite().getWorkbenchWindow().getPartService()
// .removePartListener(this);
@ -793,4 +802,103 @@ public class SessionView extends AbstractSessionView {
}
return session.getVenue().getInfo().getVenueDescription();
}
@Subscribe
public void participantHandler(IVenueParticipantEvent event)
throws Exception {
System.out.println("++ ParticipantHander type " + event.getEventType()
// + ": presence " + event.getPresence() + ": participant "
// + event.getParticipant());
);
final ParticipantEventType type = event.getEventType();
final IVenueParticipant participant = event.getParticipant();
final IPresence presence = event.getPresence();
VizApp.runAsync(new Runnable() {
@Override
public void run() {
switch (type) {
case ARRIVED:
participantArrived(participant);
break;
case DEPARTED:
participantDeparted(participant);
break;
case PRESENCE_UPDATED:
participantPresenceUpdated(participant, presence);
break;
case UPDATED:
System.out.println("++++ handle update here: "
+ participant.getName());
break;
default:
System.err.println("Unknown Event type");
}
}
});
}
private void participantArrived(IVenueParticipant participant) {
// System.out
// .println("++++ handle arrival here: " + participant.getName());
CollaborationUser[] users = (CollaborationUser[]) usersTable.getInput();
String name = participant.getName();
for (CollaborationUser user : users) {
if (name.equals(user.getId())) {
return;
}
}
CollaborationUser user = new CollaborationUser(name);
user.setText(name);
CollaborationUser[] usersNew = Arrays.copyOf(users, users.length + 1);
usersNew[users.length] = user;
usersTable.setInput(usersNew);
}
private void participantDeparted(IVenueParticipant participant) {
// System.out.println("++++ handle departed here: "
// + participant.getName());
int index = -1;
CollaborationUser[] users = (CollaborationUser[]) usersTable.getInput();
String name = participant.getName();
for (int i = 0; i < users.length; ++i) {
if (name.equals(users[i].getId())) {
index = i;
break;
}
}
if (index >= 0) {
CollaborationUser[] usersNew = new CollaborationUser[users.length - 1];
for (int i = 0; i < index; ++i) {
usersNew[i] = users[i];
}
for (int i = index + 1; i < users.length; ++i) {
usersNew[i - 1] = users[i];
}
usersTable.setInput(usersNew);
}
}
private void participantPresenceUpdated(IVenueParticipant participant,
IPresence presence) {
System.out.println("++++ handle presence here: " + presence.getMode()
+ ": " + participant.getName());
CollaborationUser[] users = (CollaborationUser[]) usersTable.getInput();
String name = participant.getName();
int index = -1;
for (int i = 0; i < users.length; ++i) {
if (name.equals(users[i].getId())) {
index = i;
break;
}
}
CollaborationUser user = null;
if (index >= 0) {
user = users[index];
} else {
user = new CollaborationUser(name);
}
user.setMode(presence.getMode());
}
}