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

Change-Id: I4a7501859f2681b290ad0babf4dab9cbca80e102

Former-commit-id: 8d7cad314e [formerly cd66a9c29c] [formerly 04b5a92838] [formerly ce72b7b583 [formerly 04b5a92838 [formerly a264abfff059a9c5942ef1db91a6390fad12a110]]]
Former-commit-id: ce72b7b583
Former-commit-id: 3e15f252346e997b4631ee9819dc1ded143057fb [formerly 053c4ba597]
Former-commit-id: e649f9da42
This commit is contained in:
Roger Ferrel 2012-03-22 16:57:30 -05:00
parent 2ba6735324
commit 15245a25d6
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.swt;bundle-version="3.6.1",
org.eclipse.ecf;bundle-version="3.1.0", org.eclipse.ecf;bundle-version="3.1.0",
com.raytheon.uf.viz.core;bundle-version="1.12.1174", 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, Import-Package: com.raytheon.uf.common.status,
com.raytheon.uf.viz.core.maps.display, com.raytheon.uf.viz.core.maps.display,
com.raytheon.uf.viz.core.maps.rsc 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.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority; 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.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.LoginData;
import com.raytheon.uf.viz.collaboration.ui.login.LoginDialog; import com.raytheon.uf.viz.collaboration.ui.login.LoginDialog;
import com.raytheon.uf.viz.core.VizApp; import com.raytheon.uf.viz.core.VizApp;
@ -155,8 +155,8 @@ public class CollaborationDataManager {
loginId = loginData.getAccount(); loginId = loginData.getAccount();
DataUser user = CollaborationDataManager DataUser user = CollaborationDataManager
.getInstance().getUser(loginId); .getInstance().getUser(loginId);
// TODO set status and message here. // TODO set mode and message here.
user.status = loginData.getStatus(); user.setMode(loginData.getStatus());
user.statusMessage = loginData.getMessage(); user.statusMessage = loginData.getMessage();
wbListener = new IWorkbenchListener() { wbListener = new IWorkbenchListener() {
@ -274,23 +274,33 @@ public class CollaborationDataManager {
sessionsMap.put(sessionId, session); 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 // TODO Start CAVE editor associated with this session and make sure the
// user is data provider and session leader. // user is data provider and session leader.
return sessionId; return sessionId;
} }
public boolean isConnected() {
return manager != null;
}
public String joinCollaborationSession(String venuName, String sessionId) { public String joinCollaborationSession(String venuName, String sessionId) {
if (sessionsMap.get(sessionId) == null) { if (sessionsMap.get(sessionId) == null) {
IVenueSession session = null;
try { try {
IVenueSession session = getSessionManager() session = getSessionManager().createCollaborationSession();
.createCollaborationSession();
sessionsMap.put(sessionId, session); sessionsMap.put(sessionId, session);
session.joinVenue(venuName); 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; return sessionId;

View file

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

View file

@ -25,6 +25,9 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; 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 * A Data class that contains all the user information needed for the current
* instance of CAVE. * instance of CAVE.
@ -44,18 +47,26 @@ import java.util.Map;
*/ */
public class DataUser { public class DataUser {
public static enum StatusType { // public static enum StatusType {
AVAILABLE("Available"), AWAY("Away"), DO_NOT_DISTURB("Do Not Disturb"), NOT_ON_LINE( // AVAILABLE("Available"), AWAY("Away"), DO_NOT_DISTURB("Do Not Disturb"),
"UnAvailable"); // NOT_ON_LINE(
// "UnAvailable");
//
// private final String value;
//
// StatusType(String value) {
// this.value = value;
// }
//
// public String value() {
// return value;
// }
// }
private final String value; private static final Map<String, IPresence.Mode> modeMap = new HashMap<String, IPresence.Mode>();
static {
StatusType(String value) { for (Mode mode : Mode.values()) {
this.value = value; modeMap.put(mode.name(), mode);
}
public String value() {
return value;
} }
} }
@ -73,7 +84,7 @@ public class DataUser {
} }
} }
StatusType status; IPresence.Mode mode;
String statusMessage; String statusMessage;
@ -103,7 +114,7 @@ public class DataUser {
this.id = id; this.id = id;
groupsMap = new HashMap<String, DataGroup>(); groupsMap = new HashMap<String, DataGroup>();
sessionsMap = new HashMap<String, String>(); sessionsMap = new HashMap<String, String>();
status = StatusType.NOT_ON_LINE; mode = Mode.EXTENDED_AWAY;
roleMap = new HashMap<String, List<RoleType>>(); roleMap = new HashMap<String, List<RoleType>>();
} }
@ -179,17 +190,21 @@ public class DataUser {
} }
/** /**
* @param status * @param mode
* the status to set * the mode to set
*/ */
public void setStatus(StatusType status) { public void setMode(Mode status) {
this.status = status; this.mode = status;
}
public void setMode(String name) {
this.mode = modeMap.get(name);
} }
/** /**
* @return the status * @return the mode
*/ */
public StatusType getStatus() { public Mode getMode() {
return status; 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.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority; 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.ISession;
import com.raytheon.uf.viz.collaboration.comm.identity.IVenueSession; 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.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.CollaborationDataManager;
import com.raytheon.uf.viz.collaboration.data.CollaborationGroup; import com.raytheon.uf.viz.collaboration.data.CollaborationGroup;
import com.raytheon.uf.viz.collaboration.data.CollaborationNode; import com.raytheon.uf.viz.collaboration.data.CollaborationNode;
import com.raytheon.uf.viz.collaboration.data.CollaborationUser; 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.LoginUser;
import com.raytheon.uf.viz.collaboration.data.SessionGroup; import com.raytheon.uf.viz.collaboration.data.SessionGroup;
import com.raytheon.uf.viz.collaboration.ui.session.AbstractSessionView; 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 private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(CollaborationGroupView.class); .getHandler(CollaborationGroupView.class);
private SessionGroup activeSessionGroup = null; private SessionGroup activeSessionGroup;
private TreeViewer usersTreeViewer; private TreeViewer usersTreeViewer;
CollaborationGroup topLevel = new CollaborationGroup("kickstart"); CollaborationGroup topLevel;
SessionGroup acitveSessionGroup;
Map<String, String[]> groupMap; Map<String, String[]> groupMap;
@ -123,6 +126,8 @@ public class CollaborationGroupView extends ViewPart {
private Action peerToPeerChatAction; private Action peerToPeerChatAction;
private Action logonAction;
private Action logoutAction; private Action logoutAction;
private Action aliasAction; private Action aliasAction;
@ -162,17 +167,11 @@ public class CollaborationGroupView extends ViewPart {
createUsersTree(parent); createUsersTree(parent);
addDoubleClickListeners(); addDoubleClickListeners();
createContextMenu(); createContextMenu();
if (CollaborationDataManager.getInstance().isConnected()) {
CollaborationDataManager dManager = CollaborationDataManager populateTree();
.getInstance(); } else {
SessionManager manager = null; usersTreeViewer.getTree().setEnabled(false);
if (dManager != null) {
manager = dManager.getSessionManager();
} }
if (manager == null) {
System.err.println("Unable to connect");
}
populateTree();
} }
/** /**
@ -189,6 +188,8 @@ public class CollaborationGroupView extends ViewPart {
}; };
createSessionAction.setImageDescriptor(CollaborationUtils createSessionAction.setImageDescriptor(CollaborationUtils
.getImageDescriptor("add_collaborate.gif")); .getImageDescriptor("add_collaborate.gif"));
createSessionAction.setEnabled(CollaborationDataManager.getInstance()
.isConnected());
linkToEditorAction = new Action("Link Editor to Chat Session", linkToEditorAction = new Action("Link Editor to Chat Session",
Action.AS_CHECK_BOX) { 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") { logoutAction = new Action("Logout") {
@Override @Override
public void run() { public void run() {
performLogout(); performLogout();
} }
}; };
logoutAction.setImageDescriptor(CollaborationUtils logoutAction.setImageDescriptor(CollaborationUtils
.getImageDescriptor("logout.gif")); .getImageDescriptor("logout.gif"));
@ -411,20 +422,18 @@ public class CollaborationGroupView extends ViewPart {
} }
private void fillStatusMenu(Menu menu) { private void fillStatusMenu(Menu menu) {
for (DataUser.StatusType type : DataUser.StatusType.values()) { for (IPresence.Mode type : CollaborationUtils.statusModes) {
if (type != DataUser.StatusType.NOT_ON_LINE) { Action action = new Action(type.getMode()) {
Action action = new Action(type.value()) { public void run() {
public void run() { changeStatusAction.setId(getId());
changeStatusAction.setId(getId()); changeStatusAction.run();
changeStatusAction.run();
};
}; };
action.setId(type.name()); };
ActionContributionItem item = new ActionContributionItem(action); action.setId(type.name());
action.setImageDescriptor(CollaborationUtils ActionContributionItem item = new ActionContributionItem(action);
.getImageDescriptor(type.name().toLowerCase() + ".gif")); action.setImageDescriptor(CollaborationUtils
item.fill(menu, -1); .getImageDescriptor(type.name().toLowerCase() + ".gif"));
} item.fill(menu, -1);
} }
} }
@ -440,6 +449,14 @@ public class CollaborationGroupView extends ViewPart {
private void createMenubar() { private void createMenubar() {
IMenuManager mgr = getViewSite().getActionBars().getMenuManager(); IMenuManager mgr = getViewSite().getActionBars().getMenuManager();
createMenu(mgr); createMenu(mgr);
mgr.addMenuListener(new IMenuListener() {
@Override
public void menuAboutToShow(IMenuManager manager) {
manager.removeAll();
createMenu(manager);
}
});
} }
private void createMenu(IMenuManager mgr) { private void createMenu(IMenuManager mgr) {
@ -451,7 +468,11 @@ public class CollaborationGroupView extends ViewPart {
mgr.add(changeMessageAction); mgr.add(changeMessageAction);
mgr.add(changePasswordAction); mgr.add(changePasswordAction);
mgr.add(new Separator()); mgr.add(new Separator());
mgr.add(logoutAction); if (CollaborationDataManager.getInstance().isConnected()) {
mgr.add(logoutAction);
} else {
mgr.add(logonAction);
}
} }
private void createSession() { private void createSession() {
@ -636,6 +657,8 @@ public class CollaborationGroupView extends ViewPart {
usersTreeViewer.setContentProvider(new UsersTreeContentProvider()); usersTreeViewer.setContentProvider(new UsersTreeContentProvider());
usersTreeViewer.setLabelProvider(new UsersTreeLabelProvider()); usersTreeViewer.setLabelProvider(new UsersTreeLabelProvider());
usersTreeViewer.setSorter(new UsersTreeViewerSorter()); usersTreeViewer.setSorter(new UsersTreeViewerSorter());
topLevel = new CollaborationGroup("kickstart");
usersTreeViewer.setInput(topLevel);
treeEditor = new TreeEditor(usersTreeViewer.getTree()); treeEditor = new TreeEditor(usersTreeViewer.getTree());
} }
@ -737,8 +760,7 @@ public class CollaborationGroupView extends ViewPart {
CollaborationDataManager manager = CollaborationDataManager CollaborationDataManager manager = CollaborationDataManager
.getInstance(); .getInstance();
SessionManager sessionManager = manager.getSessionManager(); SessionManager sessionManager = manager.getSessionManager();
topLevel = new CollaborationGroup("kickstart"); topLevel.removeChildren();
usersTreeViewer.setInput(topLevel);
if (sessionManager == null) { if (sessionManager == null) {
usersTreeViewer.getTree().setEnabled(false); usersTreeViewer.getTree().setEnabled(false);
return; return;
@ -752,43 +774,12 @@ public class CollaborationGroupView extends ViewPart {
populateActiveSessions(); populateActiveSessions();
// TODO get from server. populateGroups();
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);
}
}
// TODO get from server // usersTreeViewer.setInput(topLevel);
for (String g : new String[] { "OAX", "DSM", "LBF", "FSD" }) { usersTreeViewer.getTree().setEnabled(true);
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.refresh(topLevel, true); usersTreeViewer.refresh(topLevel, true);
createSessionAction.setEnabled(true);
} }
private void refreshActiveSessions() { private void refreshActiveSessions() {
@ -806,12 +797,98 @@ public class CollaborationGroupView extends ViewPart {
gp.setText(venu.getVenueName()); gp.setText(venu.getVenueName());
if (venu.getParticipantCount() > 0) { if (venu.getParticipantCount() > 0) {
// TODO add current participants of the venu here. // TODO add current participants of the venu here?
} }
activeSessionGroup.addChild(gp); 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 * @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.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus; 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.CollaborationGroup;
import com.raytheon.uf.viz.collaboration.data.CollaborationNode; import com.raytheon.uf.viz.collaboration.data.CollaborationNode;
import com.raytheon.uf.viz.collaboration.data.CollaborationUser; import com.raytheon.uf.viz.collaboration.data.CollaborationUser;
import com.raytheon.uf.viz.collaboration.data.DataUser;
import com.raytheon.uf.viz.collaboration.data.SessionGroup; import com.raytheon.uf.viz.collaboration.data.SessionGroup;
/** /**
@ -59,6 +60,9 @@ public class CollaborationUtils {
private static final transient IUFStatusHandler statusHandler = UFStatus private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(CollaborationUtils.class); .getHandler(CollaborationUtils.class);
public static final IPresence.Mode[] statusModes = { Mode.AVAILABLE,
Mode.DND, Mode.AWAY };
public static ImageDescriptor getImageDescriptor(String string) { public static ImageDescriptor getImageDescriptor(String string) {
String iconPath = "icons" + File.separator; String iconPath = "icons" + File.separator;
URL url = FileLocator.find(Activator.getDefault().getBundle(), URL url = FileLocator.find(Activator.getDefault().getBundle(),
@ -74,11 +78,11 @@ public class CollaborationUtils {
Image nodeImage = null; Image nodeImage = null;
if (node instanceof CollaborationUser) { if (node instanceof CollaborationUser) {
CollaborationUser user = (CollaborationUser) node; CollaborationUser user = (CollaborationUser) node;
if (user.getStatus() == DataUser.StatusType.AVAILABLE) { if (user.getMode() == IPresence.Mode.AVAILABLE) {
nodeImage = getImageDescriptor("available.gif").createImage(); nodeImage = getImageDescriptor("available.gif").createImage();
} else if (user.getStatus() == DataUser.StatusType.AWAY) { } else if (user.getMode() == IPresence.Mode.AWAY) {
nodeImage = getImageDescriptor("away.gif").createImage(); 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") nodeImage = getImageDescriptor("do_not_disturb.gif")
.createImage(); .createImage();
} else { } else {
@ -134,8 +138,8 @@ public class CollaborationUtils {
// } // }
} }
public static void changeStatus(DataUser.StatusType type) { public static void changeStatus(IPresence.Mode statusMode) {
System.out.println("Changing status..."); System.out.println("Changing mode...");
// IPresenceContainerAdapter presence = CollaborationData.getInstance() // IPresenceContainerAdapter presence = CollaborationData.getInstance()
// .getPresence(); // .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.comm.identity.info.IVenueInfo;
import com.raytheon.uf.viz.collaboration.data.CollaborationDataManager; import com.raytheon.uf.viz.collaboration.data.CollaborationDataManager;
import com.raytheon.uf.viz.collaboration.data.DataUser;
import com.raytheon.viz.ui.dialogs.CaveSWTDialog; import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
/** /**
@ -63,7 +62,6 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
* @version 1.0 * @version 1.0
*/ */
public class CreateSessionDialog extends CaveSWTDialog { public class CreateSessionDialog extends CaveSWTDialog {
private static DataUser.StatusType[] status = null;
private Text nameTF; private Text nameTF;
@ -86,17 +84,6 @@ public class CreateSessionDialog extends CaveSWTDialog {
} }
private Control createDialogArea(Composite parent) { 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); Composite body = new Composite(parent, SWT.NONE);
body.setLayout(new GridLayout(2, false)); body.setLayout(new GridLayout(2, false));
// body.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL // body.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL

View file

@ -1,6 +1,12 @@
package com.raytheon.uf.viz.collaboration.ui.login; 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, * 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> * <pre>
* *
@ -38,24 +45,37 @@ import com.raytheon.uf.viz.collaboration.data.DataUser;
* @author rferrel * @author rferrel
* @version 1.0 * @version 1.0
*/ */
public class LoginData { @XmlRootElement(name = "CollaborationLogon")
@XmlAccessorType(XmlAccessType.NONE)
public class LoginData implements ISerializableObject {
@XmlElement(name = "user")
private String user; private String user;
@XmlElement(name = "server")
private String 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; 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, 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) { final String statusMessage) {
this.user = user; this.user = user;
this.server = server; this.server = server;
this.password = password; this.password = password;
this.status = status; this.status = status.name();
this.statusMessage = statusMessage; this.statusMessage = statusMessage;
} }
@ -71,7 +91,7 @@ public class LoginData {
password = null; password = null;
} }
public DataUser.StatusType getStatus() { public String getStatus() {
return status; return status;
} }
@ -88,17 +108,8 @@ public class LoginData {
} }
public String toString() { public String toString() {
return "userId: \"" + user + "\", server \"" + server + "\", status:\"" return "userId: \"" + user + "\", server \"" + server + "\", mode:\""
+ status.value() + "\", statusMessage: \"" + statusMessage + status + "\", statusMessage: \"" + statusMessage + "\", pw: "
+ "\", pw: "
+ ((password == null) ? "null" : password.length()); + ((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.Shell;
import org.eclipse.swt.widgets.Text; 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; import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
/** /**
@ -59,9 +60,6 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
* @version 1.0 * @version 1.0
*/ */
public class LoginDialog extends CaveSWTDialog { 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 userTF;
private Text serverTF; private Text serverTF;
@ -85,7 +83,7 @@ public class LoginDialog extends CaveSWTDialog {
private LoginData loginData; private LoginData loginData;
public LoginDialog(Shell parentShell) { public LoginDialog(Shell parentShell) {
super(parentShell); super(parentShell, SWT.DIALOG_TRIM);
setText("Collaboration Server Log On"); setText("Collaboration Server Log On");
} }
@ -94,17 +92,6 @@ public class LoginDialog extends CaveSWTDialog {
} }
private Control createDialogArea(Composite parent) { 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; GridData gd = null;
Composite body = new Composite(parent, SWT.NONE); Composite body = new Composite(parent, SWT.NONE);
body.setLayout(new GridLayout(3, false)); body.setLayout(new GridLayout(3, false));
@ -182,9 +169,9 @@ public class LoginDialog extends CaveSWTDialog {
label.setText("Status: "); label.setText("Status: ");
statusCombo = new Combo(body, SWT.DEFAULT); statusCombo = new Combo(body, SWT.DEFAULT);
// TODO get status messages from config file? // TODO get mode messages from config file?
for (DataUser.StatusType type : status) { for (IPresence.Mode mode : CollaborationUtils.statusModes) {
statusCombo.add(type.value()); statusCombo.add(mode.getMode());
} }
statusCombo.select(0); statusCombo.select(0);
label = new Label(body, SWT.NONE); label = new Label(body, SWT.NONE);
@ -230,8 +217,7 @@ public class LoginDialog extends CaveSWTDialog {
if (loginData != null) { if (loginData != null) {
userTF.setText(loginData.getUser()); userTF.setText(loginData.getUser());
serverTF.setText(loginData.getServer()); serverTF.setText(loginData.getServer());
statusCombo.select(statusCombo.indexOf(loginData.getStatus() statusCombo.select(statusCombo.indexOf(loginData.getStatus()));
.value()));
messageTF.setText(loginData.getMessage()); messageTF.setText(loginData.getMessage());
} }
userTF.setFocus(); userTF.setFocus();
@ -315,8 +301,9 @@ public class LoginDialog extends CaveSWTDialog {
} }
if (focusField == null) { if (focusField == null) {
loginData = new LoginData(user, server, password, loginData = new LoginData(user, server, password,
status[statusCombo.getSelectionIndex()], CollaborationUtils.statusModes[statusCombo
messageTF.getText().trim()); .getSelectionIndex()], messageTF
.getText().trim());
setReturnValue(loginData); setReturnValue(loginData);
LoginDialog.this.getShell().dispose(); LoginDialog.this.getShell().dispose();
} else { } else {

View file

@ -86,7 +86,6 @@ public class ParticipantsLabelProvider implements ITableColorProvider,
@Override @Override
public Image getColumnImage(Object element, int columnIndex) { public Image getColumnImage(Object element, int columnIndex) {
System.out.println("getColumnImage");
CollaborationUser user = (CollaborationUser) element; CollaborationUser user = (CollaborationUser) element;
CollaborationDataManager.getInstance().getUser(user.getId()); CollaborationDataManager.getInstance().getUser(user.getId());
Image image = CollaborationUtils.getNodeImage(user); Image image = CollaborationUtils.getNodeImage(user);
@ -105,7 +104,7 @@ public class ParticipantsLabelProvider implements ITableColorProvider,
@Override @Override
public Font getFont(Object element, int columnIndex) { public Font getFont(Object element, int columnIndex) {
System.out.println("getFont"); // System.out.println("getFont");
return null; return null;
} }
@ -118,7 +117,7 @@ public class ParticipantsLabelProvider implements ITableColorProvider,
@Override @Override
public Color getBackground(Object element, int columnIndex) { public Color getBackground(Object element, int columnIndex) {
System.out.println("getBackground"); // System.out.println("getBackground");
// TODO Auto-generated method stub // TODO Auto-generated method stub
return null; 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.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus; 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.ISession;
import com.raytheon.uf.viz.collaboration.comm.identity.listener.IMessageListener; 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; import com.raytheon.uf.viz.collaboration.data.CollaborationDataManager;
/** /**
@ -168,12 +169,15 @@ public class PeerToPeerView extends AbstractSessionView {
} else { } else {
try { try {
session = CollaborationDataManager.getInstance() session = CollaborationDataManager.getInstance()
.getSessionManager().createPeerToPeerSession(); .getSessionManager().createPeerToPeerSession();
} catch(CollaborationException ce) { // 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.ArrayList;
import java.util.Arrays;
import java.util.Calendar; import java.util.Calendar;
import java.util.Collection;
import java.util.List; import java.util.List;
import org.eclipse.jface.action.Action; import org.eclipse.jface.action.Action;
@ -56,12 +56,15 @@ import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.PartInitException; import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI; import org.eclipse.ui.PlatformUI;
import com.google.common.eventbus.Subscribe;
import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority; 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.IMessage;
import com.raytheon.uf.viz.collaboration.comm.identity.IPresence; 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.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.info.IVenueInfo;
import com.raytheon.uf.viz.collaboration.comm.identity.listener.IMessageFilter; import com.raytheon.uf.viz.collaboration.comm.identity.listener.IMessageFilter;
import com.raytheon.uf.viz.collaboration.comm.identity.listener.IMessageListener; import com.raytheon.uf.viz.collaboration.comm.identity.listener.IMessageListener;
@ -212,7 +215,6 @@ public class SessionView extends AbstractSessionView {
IVenueSession session = CollaborationDataManager.getInstance() IVenueSession session = CollaborationDataManager.getInstance()
.getSession(sessionId); .getSession(sessionId);
if (session != null) { if (session != null) {
// setPartName(session.getVenue().getInfo().getVenueDescription());
messageListener = new IMessageListener() { messageListener = new IMessageListener() {
@Override @Override
@ -235,50 +237,53 @@ public class SessionView extends AbstractSessionView {
} }
}); });
participantListener = new IVenueParticipantListener() { session.registerEventHandler(this);
@Override // participantListener = new IVenueParticipantListener() {
public void handleUpdated(IVenueParticipant participant) { // @Override
System.out.println("updated"); // public void handleUpdated(IVenueParticipant participant) {
} // System.out.println("updated");
// }
@Override //
public void handlePresenceUpdated(IVenueParticipant fromID, // @Override
IPresence presence) { // public void handlePresenceUpdated(IVenueParticipant fromID,
// not the best way to do it, should just be adding the // IPresence presence) {
// new // // not the best way to do it, should just be adding the
// user instead of requerying for participants // // new
Collection<IVenueParticipant> participants = CollaborationDataManager // // user instead of requerying for participants
.getInstance().getSession(sessionId).getVenue() // Collection<IVenueParticipant> participants =
.getParticipants(); // CollaborationDataManager
final List<CollaborationUser> users = new ArrayList<CollaborationUser>(); // .getInstance().getSession(sessionId).getVenue()
for (IVenueParticipant part : participants) { // .getParticipants();
CollaborationUser user = new CollaborationUser( // final List<CollaborationUser> users = new
part.getName()); // ArrayList<CollaborationUser>();
user.setStatus(presence.getMode()); // for (IVenueParticipant part : participants) {
user.setText(user.getId()); // CollaborationUser user = new CollaborationUser(
users.add(user); // part.getName());
} // user.setMode(presence.getMode());
VizApp.runAsync(new Runnable() { // user.setText(user.getId());
@Override // users.add(user);
public void run() { // }
usersTable.setInput(users // VizApp.runAsync(new Runnable() {
.toArray(new CollaborationUser[users.size()])); // @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 handleDeparted(IVenueParticipant participant) {
// System.out.println("goodbye");
@Override //
public void handleArrived(IVenueParticipant participant) { // }
System.out.println("you've got mail"); //
} // @Override
}; // public void handleArrived(IVenueParticipant participant) {
session.addVenueParticipantListener(participantListener); // System.out.println("you've got mail");
// }
// };
// session.addVenueParticipantListener(participantListener);
} }
} }
@ -551,6 +556,9 @@ public class SessionView extends AbstractSessionView {
.removeVenueParticipantListener(participantListener); .removeVenueParticipantListener(participantListener);
} }
CollaborationDataManager.getInstance().getSession(sessionId)
.unRegisterEventHandler(this);
// dispose of the images first // dispose of the images first
disposeArrow(highlightedDownArrow); disposeArrow(highlightedDownArrow);
disposeArrow(highlightedRightArrow); disposeArrow(highlightedRightArrow);
@ -691,6 +699,7 @@ public class SessionView extends AbstractSessionView {
// session.removeMessageListener(list); // session.removeMessageListener(list);
// } // }
session.removeVenueParticipantListener(participantListener); session.removeVenueParticipantListener(participantListener);
session.unRegisterEventHandler(this);
} }
// this.getViewSite().getWorkbenchWindow().getPartService() // this.getViewSite().getWorkbenchWindow().getPartService()
// .removePartListener(this); // .removePartListener(this);
@ -793,4 +802,103 @@ public class SessionView extends AbstractSessionView {
} }
return session.getVenue().getInfo().getVenueDescription(); 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());
}
} }