Issue #244 Active Sessions node only displays rooms the user is in.

Change-Id: I2a0ba28e4519102fe26498eb578e83c4a92163a4

Former-commit-id: fac1db8b37 [formerly 442500aeae] [formerly 232df64e22 [formerly 17c8ca27316951cb97c48c8172d669cc65bbd6cd]]
Former-commit-id: 232df64e22
Former-commit-id: 21b19df9db
This commit is contained in:
Roger Ferrel 2012-03-30 15:06:35 -05:00
parent ae115263ce
commit a8b643dc2a
4 changed files with 205 additions and 76 deletions

View file

@ -320,7 +320,7 @@ public class CollaborationDataManager {
} }
} }
public String getSessinId(CollaborationEditor editor) { public String getSessionId(CollaborationEditor editor) {
String sessionId = null; String sessionId = null;
for (String key : editorsMap.keySet()) { for (String key : editorsMap.keySet()) {
if (editor == editorsMap.get(key)) { if (editor == editorsMap.get(key)) {

View file

@ -84,7 +84,7 @@ public class CollaborationGroup extends CollaborationNode {
public void removeChildren() { public void removeChildren() {
for (CollaborationNode child : children) { for (CollaborationNode child : children) {
if (child instanceof CollaborationNode) { if (child instanceof CollaborationGroup) {
CollaborationGroup groupNode = (CollaborationGroup) child; CollaborationGroup groupNode = (CollaborationGroup) child;
groupNode.removeChildren(); groupNode.removeChildren();
} }

View file

@ -64,9 +64,11 @@ import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.TreeItem; import org.eclipse.swt.widgets.TreeItem;
import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IEditorReference; import org.eclipse.ui.IEditorReference;
import org.eclipse.ui.IPartListener;
import org.eclipse.ui.IViewPart; import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IViewReference; import org.eclipse.ui.IViewReference;
import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchPage;
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 org.eclipse.ui.part.ViewPart; import org.eclipse.ui.part.ViewPart;
@ -76,6 +78,7 @@ 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.IPresence; import com.raytheon.uf.viz.collaboration.comm.identity.IPresence;
import com.raytheon.uf.viz.collaboration.comm.identity.IPresence.Type;
import com.raytheon.uf.viz.collaboration.comm.identity.ISession; import com.raytheon.uf.viz.collaboration.comm.identity.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;
@ -116,7 +119,7 @@ import com.raytheon.viz.ui.perspectives.VizPerspectiveListener;
* @author rferrel * @author rferrel
* @version 1.0 * @version 1.0
*/ */
public class CollaborationGroupView extends ViewPart { public class CollaborationGroupView extends ViewPart implements IPartListener {
public static final String ID = "com.raytheon.uf.viz.collaboration.ui.CollaborationGroupView"; public static final String ID = "com.raytheon.uf.viz.collaboration.ui.CollaborationGroupView";
private static final transient IUFStatusHandler statusHandler = UFStatus private static final transient IUFStatusHandler statusHandler = UFStatus
@ -181,12 +184,13 @@ public class CollaborationGroupView extends ViewPart {
createToolbar(); createToolbar();
createMenubar(); createMenubar();
getViewSite().getWorkbenchWindow().getPartService()
.addPartListener(this);
createUsersTree(parent); createUsersTree(parent);
addDoubleClickListeners(); addDoubleClickListeners();
createContextMenu(); createContextMenu();
if (CollaborationDataManager.getInstance().isConnected()) { if (CollaborationDataManager.getInstance().isConnected() == false) {
populateTree();
} else {
usersTreeViewer.getTree().setEnabled(false); usersTreeViewer.getTree().setEnabled(false);
} }
@ -352,16 +356,16 @@ public class CollaborationGroupView extends ViewPart {
}; };
}; };
refreshActiveSessionsAction = new Action("Refresh") { // refreshActiveSessionsAction = new Action("Refresh") {
public void run() { // public void run() {
System.out.println("Refresh Active Sessions"); // System.out.println("Refresh Active Sessions");
refreshActiveSessions(); // refreshActiveSessions();
} // }
}; // };
refreshActiveSessionsAction.setImageDescriptor(IconUtil // refreshActiveSessionsAction.setImageDescriptor(IconUtil
.getImageDescriptor(bundle, "refresh.gif")); // .getImageDescriptor(bundle, "refresh.gif"));
refreshActiveSessionsAction // refreshActiveSessionsAction
.setToolTipText("Refresh the Active Sessions Entries."); // .setToolTipText("Refresh the Active Sessions Entries.");
collapseAllAction = new Action("Collapse All") { collapseAllAction = new Action("Collapse All") {
public void run() { public void run() {
@ -585,7 +589,7 @@ public class CollaborationGroupView extends ViewPart {
System.out.println("sessionId - Invite: " + user.getId()); System.out.println("sessionId - Invite: " + user.getId());
} }
} }
refreshActiveSessions(); // refreshActiveSessions();
} catch (PartInitException e) { } catch (PartInitException e) {
statusHandler.handle(Priority.PROBLEM, statusHandler.handle(Priority.PROBLEM,
"Unable to open collaboation sesson", e); "Unable to open collaboation sesson", e);
@ -625,7 +629,7 @@ public class CollaborationGroupView extends ViewPart {
System.out.println("sessionId - Invite: " + user.getId()); System.out.println("sessionId - Invite: " + user.getId());
} }
} }
refreshActiveSessions(); // refreshActiveSessions();
} catch (PartInitException e) { } catch (PartInitException e) {
statusHandler.handle(Priority.PROBLEM, statusHandler.handle(Priority.PROBLEM,
"Unable to open collaboation sesson", e); "Unable to open collaboation sesson", e);
@ -641,17 +645,12 @@ public class CollaborationGroupView extends ViewPart {
for (Object node : nodes) { for (Object node : nodes) {
if (node instanceof SessionGroup) { if (node instanceof SessionGroup) {
SessionGroup sg = (SessionGroup) node; SessionGroup sg = (SessionGroup) node;
System.out.println("Join: " + sg.getId()); // System.out.println("Join: " + sg.getId());
CollaborationDataManager manager = CollaborationDataManager CollaborationDataManager manager = CollaborationDataManager
.getInstance(); .getInstance();
String sessionId = manager.joinCollaborationSession( String sessionId = manager.joinCollaborationSession(
sg.getText(), sg.getId()); sg.getText(), sg.getId());
sg.setId(sessionId); sg.setId(sessionId);
// ParticipantEventController controller = new
// ParticipantEventController(
// (VenueSession) manager.getSession(sessionId));
// manager.setDisplaySession(sessionId, controller);
// controller.startup();
try { try {
IViewPart part = PlatformUI IViewPart part = PlatformUI
.getWorkbench() .getWorkbench()
@ -744,6 +743,22 @@ public class CollaborationGroupView extends ViewPart {
builder.append("Message: \"") builder.append("Message: \"")
.append(user.getStatusMessage()) .append(user.getStatusMessage())
.append("\"\n"); .append("\"\n");
} else if (node instanceof SessionGroup
&& ((SessionGroup) node).isSessionRoot() == false) {
IVenueInfo info = CollaborationDataManager
.getInstance().getSession(node.getId())
.getVenue().getInfo();
builder.append("VenueName: ")
.append(info.getVenueName())
.append("\n");
// builder.append("VenueID: ")
// .append(info.getVenueID()).append("\n");
builder.append("Subject: ")
.append(info.getVenueSubject())
.append("\n");
builder.append("ParticipantCount: ")
.append(info.getParticipantCount())
.append("\n");
} }
usersTreeViewer.getTree().setToolTipText( usersTreeViewer.getTree().setToolTipText(
builder.toString()); builder.toString());
@ -788,7 +803,7 @@ public class CollaborationGroupView extends ViewPart {
SessionGroup sessionGroup = (SessionGroup) o; SessionGroup sessionGroup = (SessionGroup) o;
if (sessionGroup.isSessionRoot()) { if (sessionGroup.isSessionRoot()) {
manager.add(createSessionAction); manager.add(createSessionAction);
manager.add(refreshActiveSessionsAction); // manager.add(refreshActiveSessionsAction);
} else { } else {
manager.add(joinAction); manager.add(joinAction);
} }
@ -797,43 +812,46 @@ public class CollaborationGroupView extends ViewPart {
if (o instanceof CollaborationUser) { if (o instanceof CollaborationUser) {
CollaborationUser user = (CollaborationUser) o; CollaborationUser user = (CollaborationUser) o;
MenuManager inviteManager = new MenuManager("Invite to..."); if (user.getType() == Type.AVAILABLE) {
// get current open chats MenuManager inviteManager = new MenuManager("Invite to...");
Map<String, IVenueSession> sessions = CollaborationDataManager // get current open chats
.getInstance().getSessions(); Map<String, IVenueSession> sessions = CollaborationDataManager
for (String name : sessions.keySet()) { .getInstance().getSessions();
final ISession session = sessions.get(name); for (String name : sessions.keySet()) {
if (session != null) { final ISession session = sessions.get(name);
final IVenueInfo info = sessions.get(name).getVenue() if (session != null) {
.getInfo(); final IVenueInfo info = sessions.get(name).getVenue()
if (info != null) { .getInfo();
System.out.println("Add to Invite To menu: " if (info != null) {
+ info.getVenueDescription()); System.out.println("Add to Invite To menu: "
Action action = new Action(info.getVenueDescription()) { + info.getVenueDescription());
/* Action action = new Action(
* (non-Javadoc) info.getVenueDescription()) {
* /*
* @see org.eclipse.jface.action.Action#run() * (non-Javadoc)
*/ *
@Override * @see org.eclipse.jface.action.Action#run()
public void run() { */
inviteAction.setId(session.getSessionId()); @Override
inviteAction.run(); public void run() {
} inviteAction.setId(session.getSessionId());
}; inviteAction.run();
action.setId(info.getVenueID()); }
inviteManager.add(action); };
action.setId(info.getVenueID());
inviteManager.add(action);
}
} }
} }
} manager.add(inviteManager);
manager.add(inviteManager); manager.add(peerToPeerChatAction);
manager.add(peerToPeerChatAction); peerToPeerChatAction.setId(user.getId());
peerToPeerChatAction.setId(user.getId()); if (user.isLocal()) {
if (user.isLocal()) { manager.add(addUserAction);
manager.add(addUserAction); manager.add(addGroupAction);
manager.add(addGroupAction); manager.add(removeUserAction);
manager.add(removeUserAction); manager.add(removeGroupAction);
manager.add(removeGroupAction); }
} }
} else if (o instanceof CollaborationGroup) { } else if (o instanceof CollaborationGroup) {
CollaborationGroup group = (CollaborationGroup) o; CollaborationGroup group = (CollaborationGroup) o;
@ -873,25 +891,42 @@ public class CollaborationGroupView extends ViewPart {
createSessionAction.setEnabled(true); createSessionAction.setEnabled(true);
} }
private void refreshActiveSessions() { // private void refreshActiveSessions() {
populateActiveSessions(); // populateActiveSessions();
usersTreeViewer.refresh(activeSessionGroup, true); // usersTreeViewer.refresh(activeSessionGroup, true);
} // }
private void populateActiveSessions() { private void populateActiveSessions() {
activeSessionGroup.removeChildren(); activeSessionGroup.removeChildren();
Collection<IVenueInfo> venuList = CollaborationDataManager Collection<IVenueInfo> venuList = CollaborationDataManager
.getInstance().getSessionManager().getVenueInfo(); .getInstance().getSessionManager().getVenueInfo();
for (IVenueInfo venu : venuList) { // for (IVenueInfo venu : venuList) {
// SessionGroup gp = new SessionGroup(CollaborationDataManager // // SessionGroup gp = new SessionGroup(CollaborationDataManager
// .getInstance().venueIdToSessionId(venu.getVenueID())); // // .getInstance().venueIdToSessionId(venu.getVenueID()));
SessionGroup gp = new SessionGroup(null); // SessionGroup gp = new SessionGroup(null);
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);
// }
try {
CollaborationDataManager manager = CollaborationDataManager
.getInstance();
for (IViewReference ref : getViewSite().getWorkbenchWindow()
.getActivePage().getViewReferences()) {
IViewPart viewPart = ref.getView(false);
if (viewPart instanceof SessionView) {
String sessionId = viewPart.getViewSite().getSecondaryId();
SessionGroup child = new SessionGroup(sessionId);
child.setText(manager.getSession(sessionId).getVenue()
.getInfo().getVenueDescription());
activeSessionGroup.addChild(child);
}
} }
activeSessionGroup.addChild(gp); } catch (NullPointerException e) {
// Ignore happens when creating view when starting CAVE.
} }
} }
@ -1041,14 +1076,22 @@ public class CollaborationGroupView extends ViewPart {
return result; return result;
} }
/**
* Get the list of selected users that have a Type of AVAILABLE.
*
* @return
*/
private Set<CollaborationUser> getSelectedUsers() { private Set<CollaborationUser> getSelectedUsers() {
Set<CollaborationUser> selectedUsers = new HashSet<CollaborationUser>(); Set<CollaborationUser> selectedUsers = new HashSet<CollaborationUser>();
IStructuredSelection selection = (IStructuredSelection) usersTreeViewer IStructuredSelection selection = (IStructuredSelection) usersTreeViewer
.getSelection(); .getSelection();
Object[] nodes = selection.toArray(); Object[] nodes = selection.toArray();
for (Object node : nodes) { for (Object node : nodes) {
if (node instanceof CollaborationUser) { if (node instanceof CollaborationUser) {
if ((node instanceof LoginUser) == false) { CollaborationUser user = (CollaborationUser) node;
if ((user instanceof LoginUser) == false
&& user.getType() == Type.AVAILABLE) {
selectedUsers.add((CollaborationUser) node); selectedUsers.add((CollaborationUser) node);
} }
} else if ((node instanceof SessionGroup) == false) { } else if ((node instanceof SessionGroup) == false) {
@ -1113,4 +1156,90 @@ public class CollaborationGroupView extends ViewPart {
System.out.println("Disposing: " + getClass().getName()); System.out.println("Disposing: " + getClass().getName());
super.dispose(); super.dispose();
} }
/*
* (non-Javadoc)
*
* @see
* org.eclipse.ui.IPartListener#partActivated(org.eclipse.ui.IWorkbenchPart)
*/
@Override
public void partActivated(IWorkbenchPart part) {
// TODO Auto-generated method stub
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.ui.IPartListener#partBroughtToTop(org.eclipse.ui.IWorkbenchPart
* )
*/
@Override
public void partBroughtToTop(IWorkbenchPart part) {
// TODO Auto-generated method stub
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.ui.IPartListener#partClosed(org.eclipse.ui.IWorkbenchPart)
*/
@Override
public void partClosed(IWorkbenchPart part) {
if (part instanceof SessionView) {
SessionView sessionView = (SessionView) part;
String sessionId = sessionView.getViewSite().getSecondaryId();
System.out.println("partClosed remove sessionId: " + sessionId);
for (CollaborationNode node : activeSessionGroup.getChildren()) {
if (sessionId.equals(node.getId())) {
activeSessionGroup.removeChild(node);
usersTreeViewer.refresh(activeSessionGroup);
break;
}
}
} else if (part == this) {
getViewSite().getWorkbenchWindow().getPartService()
.removePartListener(this);
}
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.ui.IPartListener#partDeactivated(org.eclipse.ui.IWorkbenchPart
* )
*/
@Override
public void partDeactivated(IWorkbenchPart part) {
// TODO Auto-generated method stub
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.ui.IPartListener#partOpened(org.eclipse.ui.IWorkbenchPart)
*/
@Override
public void partOpened(IWorkbenchPart part) {
if (part instanceof SessionView) {
SessionView sessionView = (SessionView) part;
String sessionId = sessionView.getViewSite().getSecondaryId();
System.out.println("partOpen add sessionId: " + sessionId);
SessionGroup child = new SessionGroup(sessionId);
child.setText(CollaborationDataManager.getInstance()
.getSession(sessionId).getVenue().getInfo()
.getVenueDescription());
activeSessionGroup.addChild(child);
usersTreeViewer.refresh(activeSessionGroup);
} else if (part == this) {
populateTree();
}
}
} }

View file

@ -74,7 +74,7 @@ public class CollaborationEditor extends AbstractEditor implements
if (this == part) { if (this == part) {
CollaborationDataManager manager = CollaborationDataManager CollaborationDataManager manager = CollaborationDataManager
.getInstance(); .getInstance();
String sessionId = manager.getSessinId(this); String sessionId = manager.getSessionId(this);
manager.viewBringToTop(sessionId); manager.viewBringToTop(sessionId);
} }
} }
@ -130,7 +130,7 @@ public class CollaborationEditor extends AbstractEditor implements
if (this == part) { if (this == part) {
CollaborationDataManager manager = CollaborationDataManager CollaborationDataManager manager = CollaborationDataManager
.getInstance(); .getInstance();
String sessionId = manager.getSessinId(this); String sessionId = manager.getSessionId(this);
IVenueSession session = manager.getSession(sessionId); IVenueSession session = manager.getSession(sessionId);
String name = (session == null) ? sessionId : session.getVenue() String name = (session == null) ? sessionId : session.getVenue()
.getInfo().getVenueDescription(); .getInfo().getVenueDescription();