Issue #437 Added change status menu option.
Change-Id: Ie4b1d453aa3e75b77e360c26dcc838c13b7b6223 Former-commit-id:69ea7c724e
[formerly69ea7c724e
[formerly 82ae4e9433e71e9027566aed4595046ce0ef6dfa]] Former-commit-id:020be00301
Former-commit-id:8fa193bcbe
This commit is contained in:
parent
d8e1fad3c0
commit
ca8d18c8f9
2 changed files with 161 additions and 86 deletions
|
@ -45,7 +45,7 @@ import com.raytheon.uf.common.status.IUFStatusHandler;
|
|||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.CollaborationException;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.IPresence.Type;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.IPresence;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.ISession;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.ISharedDisplaySession;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.IVenueSession;
|
||||
|
@ -221,6 +221,12 @@ public class CollaborationDataManager {
|
|||
loginId = loginData.getAccount();
|
||||
DataUser user = CollaborationDataManager
|
||||
.getInstance().getUser(loginId);
|
||||
// try {
|
||||
// System.out.println("enter sleep...");
|
||||
// Thread.sleep(5000L);
|
||||
// System.out.println("Wake from sleep...");
|
||||
// } catch (InterruptedException e) {
|
||||
// }
|
||||
// // TODO set mode and message here.
|
||||
// user.setMode(loginData.getMode());
|
||||
// user.type = Type.AVAILABLE;
|
||||
|
@ -253,7 +259,6 @@ public class CollaborationDataManager {
|
|||
statusHandler.handle(Priority.PROBLEM,
|
||||
e.getLocalizedMessage(), e);
|
||||
}
|
||||
fireModifiedPresence();
|
||||
wbListener = new IWorkbenchListener() {
|
||||
|
||||
@Override
|
||||
|
@ -282,6 +287,24 @@ public class CollaborationDataManager {
|
|||
}
|
||||
};
|
||||
PlatformUI.getWorkbench().addWorkbenchListener(wbListener);
|
||||
// TODO this sleep needs to go away. It is a temporary fix to
|
||||
// allow the roster manager to get all its entries before we
|
||||
// use
|
||||
// it. Once we have needed eventhandlers for roster updating
|
||||
// this can go away.
|
||||
try {
|
||||
System.out.println("enter sleep...");
|
||||
Thread.sleep(5000L);
|
||||
System.out.println("Wake from sleep...");
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
IPresence presence = sessionManager.getPresence();
|
||||
if (sessionManager.getPresence() == null) {
|
||||
presence = new Presence();
|
||||
presence.setProperty("dummy", "dummy");
|
||||
sessionManager.setPresence(presence);
|
||||
}
|
||||
fireModifiedPresence();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -565,13 +588,9 @@ 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");
|
||||
IPresence presence = sessionManager.getPresence();
|
||||
presence.setMode(loginData.getMode());
|
||||
presence.setStatusMessage(loginData.getModeMessage());
|
||||
presence.setType(Type.AVAILABLE);
|
||||
try {
|
||||
sessionManager.getAccountManager().sendPresence(presence);
|
||||
IRoster roster = sessionManager.getRosterManager().getRoster();
|
||||
|
@ -596,15 +615,13 @@ public class CollaborationDataManager {
|
|||
@Subscribe
|
||||
public void handleModifiedPresence(IRosterEntry entry) {
|
||||
final IRosterEntry rosterEntry = entry;
|
||||
// System.out.println("CollaborationDataManager.handleModifiedPresence");
|
||||
// System.out.println(" user " + rosterEntry.getUser().getFQName());
|
||||
// System.out.println(" mode " +
|
||||
// rosterEntry.getPresence().getMode());
|
||||
// System.out.println(" type " +
|
||||
// rosterEntry.getPresence().getType());
|
||||
// System.out.println(" message"
|
||||
// + rosterEntry.getPresence().getStatusMessage());
|
||||
// System.out.println(" groups " + rosterEntry.getGroups());
|
||||
System.out.println("CollaborationDataManager.handleModifiedPresence");
|
||||
System.out.println(" user " + rosterEntry.getUser().getFQName());
|
||||
System.out.println(" mode " + rosterEntry.getPresence().getMode());
|
||||
System.out.println(" type " + rosterEntry.getPresence().getType());
|
||||
System.out.println(" message"
|
||||
+ rosterEntry.getPresence().getStatusMessage());
|
||||
System.out.println(" groups " + rosterEntry.getGroups());
|
||||
String userId = rosterEntry.getUser().getFQName();
|
||||
DataUser user = usersMap.get(userId);
|
||||
if (user != null) {
|
||||
|
|
|
@ -21,13 +21,14 @@ package com.raytheon.uf.viz.collaboration.ui;
|
|||
**/
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.jface.action.Action;
|
||||
import org.eclipse.jface.action.ActionContributionItem;
|
||||
import org.eclipse.jface.action.IMenuCreator;
|
||||
import org.eclipse.jface.action.IMenuListener;
|
||||
import org.eclipse.jface.action.IMenuManager;
|
||||
import org.eclipse.jface.action.IToolBarManager;
|
||||
|
@ -91,6 +92,7 @@ import com.raytheon.uf.viz.collaboration.data.SessionGroup;
|
|||
import com.raytheon.uf.viz.collaboration.ui.editor.CollaborationEditor;
|
||||
import com.raytheon.uf.viz.collaboration.ui.login.ChangeStatusDialog;
|
||||
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.session.AbstractSessionView;
|
||||
import com.raytheon.uf.viz.collaboration.ui.session.CollaborationSessionView;
|
||||
import com.raytheon.uf.viz.collaboration.ui.session.PeerToPeerView;
|
||||
|
@ -157,6 +159,8 @@ public class CollaborationGroupView extends ViewPart implements IPartListener {
|
|||
|
||||
private Action removeUserAction;
|
||||
|
||||
private Action changeStatusMessageAction;
|
||||
|
||||
private Action changeStatusAction;
|
||||
|
||||
private Action changePasswordAction;
|
||||
|
@ -324,12 +328,12 @@ public class CollaborationGroupView extends ViewPart implements IPartListener {
|
|||
};
|
||||
selectGroups.setEnabled(false);
|
||||
|
||||
changeStatusAction = new Action("Change Status...") {
|
||||
changeStatusMessageAction = new Action("Change Status Message...") {
|
||||
public void run() {
|
||||
changeStatus();
|
||||
changeStatusMessage();
|
||||
};
|
||||
};
|
||||
changeStatusAction.setEnabled(false);
|
||||
changeStatusMessageAction.setEnabled(false);
|
||||
|
||||
changePasswordAction = new Action("Change password...") {
|
||||
public void run() {
|
||||
|
@ -338,12 +342,13 @@ public class CollaborationGroupView extends ViewPart implements IPartListener {
|
|||
};
|
||||
changePasswordAction.setEnabled(false);
|
||||
|
||||
// changeStatusAction = new Action("Change Status",
|
||||
// Action.AS_DROP_DOWN_MENU) {
|
||||
// public void run() {
|
||||
// System.out.println("Change Status here to: " + getId());
|
||||
// };
|
||||
// };
|
||||
changeStatusAction = new Action("Change Status",
|
||||
Action.AS_DROP_DOWN_MENU) {
|
||||
public void run() {
|
||||
changeStatus(getId());
|
||||
};
|
||||
};
|
||||
changeStatusAction.setEnabled(false);
|
||||
|
||||
// refreshActiveSessionsAction = new Action("Refresh") {
|
||||
// public void run() {
|
||||
|
@ -364,30 +369,30 @@ public class CollaborationGroupView extends ViewPart implements IPartListener {
|
|||
collapseAllAction.setImageDescriptor(IconUtil.getImageDescriptor(
|
||||
bundle, "collapseall.gif"));
|
||||
|
||||
// IMenuCreator creator = new IMenuCreator() {
|
||||
//
|
||||
// Menu menu;
|
||||
//
|
||||
// @Override
|
||||
// public Menu getMenu(Menu parent) {
|
||||
// menu = new Menu(parent);
|
||||
// fillStatusMenu(menu);
|
||||
// return menu;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Menu getMenu(Control parent) {
|
||||
// menu = new Menu(parent);
|
||||
// fillStatusMenu(menu);
|
||||
// return menu;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void dispose() {
|
||||
// menu.dispose();
|
||||
// }
|
||||
// };
|
||||
// changeStatusAction.setMenuCreator(creator);
|
||||
IMenuCreator creator = new IMenuCreator() {
|
||||
|
||||
Menu menu;
|
||||
|
||||
@Override
|
||||
public Menu getMenu(Menu parent) {
|
||||
menu = new Menu(parent);
|
||||
fillStatusMenu(menu);
|
||||
return menu;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Menu getMenu(Control parent) {
|
||||
menu = new Menu(parent);
|
||||
fillStatusMenu(menu);
|
||||
return menu;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
menu.dispose();
|
||||
}
|
||||
};
|
||||
changeStatusAction.setMenuCreator(creator);
|
||||
|
||||
removeGroupAction = new Action("Remove Group") {
|
||||
public void run() {
|
||||
|
@ -421,7 +426,7 @@ public class CollaborationGroupView extends ViewPart implements IPartListener {
|
|||
}
|
||||
}
|
||||
|
||||
private void changeStatus() {
|
||||
private void changeStatusMessage() {
|
||||
ChangeStatusDialog dialog = new ChangeStatusDialog(Display.getCurrent()
|
||||
.getActiveShell());
|
||||
dialog.open();
|
||||
|
@ -432,6 +437,19 @@ public class CollaborationGroupView extends ViewPart implements IPartListener {
|
|||
}
|
||||
}
|
||||
|
||||
private void changeStatus(String status) {
|
||||
CollaborationDataManager manager = CollaborationDataManager
|
||||
.getInstance();
|
||||
LoginData loginData = manager.getLoginData();
|
||||
int index = Integer.parseInt(status);
|
||||
IPresence.Mode mode = CollaborationUtils.statusModes[index];
|
||||
if (mode != loginData.getMode()) {
|
||||
loginData.setMode(mode);
|
||||
manager.fireModifiedPresence();
|
||||
LoginDialog.saveUserLoginData(loginData);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This displays a warning dialog then closes all collaboration views and
|
||||
* disconnects from the server.
|
||||
|
@ -500,29 +518,29 @@ public class CollaborationGroupView extends ViewPart implements IPartListener {
|
|||
|
||||
}
|
||||
|
||||
// private void fillStatusMenu(Menu menu) {
|
||||
// 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(IconUtil.getImageDescriptor(Activator
|
||||
// .getDefault().getBundle(), type.name().toLowerCase()
|
||||
// + ".gif"));
|
||||
// item.fill(menu, -1);
|
||||
// }
|
||||
// }
|
||||
private void fillStatusMenu(Menu menu) {
|
||||
System.out.println("fillStatusMenu");
|
||||
for (int index = 0; index < CollaborationUtils.statusModes.length; ++index) {
|
||||
IPresence.Mode mode = CollaborationUtils.statusModes[index];
|
||||
Action action = new Action(mode.getMode()) {
|
||||
public void run() {
|
||||
changeStatusAction.setId(getId());
|
||||
changeStatusAction.run();
|
||||
};
|
||||
};
|
||||
action.setId(Integer.toString(index));
|
||||
ActionContributionItem item = new ActionContributionItem(action);
|
||||
action.setImageDescriptor(IconUtil.getImageDescriptor(Activator
|
||||
.getDefault().getBundle(), mode.name().toLowerCase()
|
||||
+ ".gif"));
|
||||
item.fill(menu, -1);
|
||||
}
|
||||
}
|
||||
|
||||
private void createToolbar() {
|
||||
IToolBarManager mgr = getViewSite().getActionBars().getToolBarManager();
|
||||
// mgr.add(joinCollaborationAction);
|
||||
mgr.add(createSessionAction);
|
||||
mgr.add(collapseAllAction);
|
||||
// mgr.add(privateChatAction);
|
||||
mgr.add(linkToEditorAction);
|
||||
}
|
||||
|
||||
|
@ -544,8 +562,8 @@ public class CollaborationGroupView extends ViewPart implements IPartListener {
|
|||
mgr.add(addUserAction);
|
||||
mgr.add(selectGroups);
|
||||
mgr.add(new Separator());
|
||||
// mgr.add(changeStatusAction);
|
||||
mgr.add(changeStatusAction);
|
||||
mgr.add(changeStatusMessageAction);
|
||||
mgr.add(changePasswordAction);
|
||||
mgr.add(new Separator());
|
||||
if (CollaborationDataManager.getInstance().isConnected()) {
|
||||
|
@ -576,7 +594,7 @@ public class CollaborationGroupView extends ViewPart implements IPartListener {
|
|||
if (result.isCollaborationSession()) {
|
||||
createCollaborationView(result);
|
||||
} else {
|
||||
createPrivateView(result);
|
||||
createTextOnlyView(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -626,7 +644,12 @@ public class CollaborationGroupView extends ViewPart implements IPartListener {
|
|||
}
|
||||
}
|
||||
|
||||
private void createPrivateView(CreateSessionData result) {
|
||||
/**
|
||||
* Generate a view for text only session.
|
||||
*
|
||||
* @param result
|
||||
*/
|
||||
private void createTextOnlyView(CreateSessionData result) {
|
||||
String sessionId = result.getSessionId();
|
||||
try {
|
||||
PlatformUI
|
||||
|
@ -682,6 +705,12 @@ public class CollaborationGroupView extends ViewPart implements IPartListener {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a view to for messages to/from a user via a Peer to Peer
|
||||
* connection.
|
||||
*
|
||||
* @param user
|
||||
*/
|
||||
private void createP2PChat(String user) {
|
||||
System.err.println("createPrivateChat with " + user);
|
||||
try {
|
||||
|
@ -696,6 +725,11 @@ public class CollaborationGroupView extends ViewPart implements IPartListener {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Genearte the Tree View component and add tooltip tracking.
|
||||
*
|
||||
* @param parent
|
||||
*/
|
||||
private void createUsersTree(Composite parent) {
|
||||
Composite child = new Composite(parent, SWT.NONE);
|
||||
child.setLayout(new GridLayout(1, false));
|
||||
|
@ -850,6 +884,9 @@ public class CollaborationGroupView extends ViewPart implements IPartListener {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get entries for all part of the Tree Viewer and enable actions.
|
||||
*/
|
||||
protected void populateTree() {
|
||||
CollaborationDataManager manager = CollaborationDataManager
|
||||
.getInstance();
|
||||
|
@ -860,7 +897,7 @@ public class CollaborationGroupView extends ViewPart implements IPartListener {
|
|||
addGroupAction.setEnabled(false);
|
||||
addUserAction.setEnabled(false);
|
||||
selectGroups.setEnabled(false);
|
||||
changeStatusAction.setEnabled(false);
|
||||
changeStatusMessageAction.setEnabled(false);
|
||||
changePasswordAction.setEnabled(false);
|
||||
return;
|
||||
}
|
||||
|
@ -868,6 +905,7 @@ public class CollaborationGroupView extends ViewPart implements IPartListener {
|
|||
addUserAction.setEnabled(true);
|
||||
selectGroups.setEnabled(true);
|
||||
changeStatusAction.setEnabled(true);
|
||||
changeStatusMessageAction.setEnabled(true);
|
||||
changePasswordAction.setEnabled(true);
|
||||
|
||||
LoginUser user = new LoginUser(manager.getLoginId());
|
||||
|
@ -891,10 +929,13 @@ public class CollaborationGroupView extends ViewPart implements IPartListener {
|
|||
// usersTreeViewer.refresh(activeSessionGroup, true);
|
||||
// }
|
||||
|
||||
/**
|
||||
* Clears and repopulates the Tree Viewer's active session node.
|
||||
*/
|
||||
private void populateActiveSessions() {
|
||||
activeSessionGroup.removeChildren();
|
||||
Collection<IVenueInfo> venuList = CollaborationDataManager
|
||||
.getInstance().getSessionManager().getVenueInfo();
|
||||
// Collection<IVenueInfo> venuList = CollaborationDataManager
|
||||
// .getInstance().getSessionManager().getVenueInfo();
|
||||
// for (IVenueInfo venu : venuList) {
|
||||
// // SessionGroup gp = new SessionGroup(CollaborationDataManager
|
||||
// // .getInstance().venueIdToSessionId(venu.getVenueID()));
|
||||
|
@ -925,6 +966,9 @@ public class CollaborationGroupView extends ViewPart implements IPartListener {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear and populate the groups from the roster manager entries.
|
||||
*/
|
||||
private void populateGroups() {
|
||||
for (CollaborationNode node : topLevel.getChildren()) {
|
||||
if (!(node instanceof LoginUser || node instanceof SessionGroup)) {
|
||||
|
@ -1008,16 +1052,16 @@ public class CollaborationGroupView extends ViewPart implements IPartListener {
|
|||
}
|
||||
}
|
||||
|
||||
private LoginUser getLoginUser() {
|
||||
LoginUser loginUser = null;
|
||||
for (CollaborationNode node : topLevel.getChildren()) {
|
||||
if (node instanceof LoginUser) {
|
||||
loginUser = (LoginUser) node;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return loginUser;
|
||||
}
|
||||
// private LoginUser getLoginUser() {
|
||||
// LoginUser loginUser = null;
|
||||
// for (CollaborationNode node : topLevel.getChildren()) {
|
||||
// if (node instanceof LoginUser) {
|
||||
// loginUser = (LoginUser) node;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// return loginUser;
|
||||
// }
|
||||
|
||||
/**
|
||||
* @return
|
||||
|
@ -1027,7 +1071,8 @@ public class CollaborationGroupView extends ViewPart implements IPartListener {
|
|||
}
|
||||
|
||||
/**
|
||||
* Get a unique set of selected users that have a Type of AVAILABLE.
|
||||
* Get a unique set of selected users that have a Type of AVAILABLE. This
|
||||
* does a recursive search so will work even when groups contain groups.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
@ -1053,6 +1098,13 @@ public class CollaborationGroupView extends ViewPart implements IPartListener {
|
|||
return selectedUsers;
|
||||
}
|
||||
|
||||
/**
|
||||
* This recursively searches group Node and returns all users with Type
|
||||
* AVAILABLE.
|
||||
*
|
||||
* @param groupNode
|
||||
* @return users
|
||||
*/
|
||||
private Set<CollaborationUser> getSelectedUsers(CollaborationGroup groupNode) {
|
||||
CollaborationDataManager manger = CollaborationDataManager
|
||||
.getInstance();
|
||||
|
@ -1252,8 +1304,14 @@ public class CollaborationGroupView extends ViewPart implements IPartListener {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Refresh the labels on the View Tree to reflect presence change.
|
||||
*
|
||||
* @param rosterEntry
|
||||
*/
|
||||
@Subscribe
|
||||
public void handleModifiedPresence(IRosterEntry rosterEntry) {
|
||||
// Assumes the Data Manager has already update
|
||||
System.out.println("group view roster entry for:"
|
||||
+ rosterEntry.getUser().getFQName() + " "
|
||||
+ rosterEntry.getPresence().getMode() + "/"
|
||||
|
|
Loading…
Add table
Reference in a new issue