Issue #437 But fix in group View enent handler, improved tooltip

Change-Id: Ibb6fc5f312f09d72df988c591408fc41e39ad674

Former-commit-id: 8ab764e56c [formerly 55ab473fd6 [formerly 47c81c08d9a90c271873cfa50525fb40c26db508]]
Former-commit-id: 55ab473fd6
Former-commit-id: 41e4666d55
This commit is contained in:
Roger Ferrel 2012-04-13 15:51:41 -05:00
parent b79ae6a022
commit 1907f26a0d
7 changed files with 147 additions and 221 deletions

View file

@ -30,7 +30,7 @@
id="com.raytheon.uf.viz.collaboration.ui.CollaborationGroupView"
icon="icons/browser.gif"
name="Collaboration Information"
restorable="true"/>
restorable="false"/>
</extension>
<extension
point="org.eclipse.ui.commands">

View file

@ -704,6 +704,12 @@ public class CollaborationDataManager implements IRosterEventSubscriber {
}
}
/**
* This updates the Data Manager's information then informs and UI of the
* change.
*
* @param event
*/
@Subscribe
public void handleRosterChangeEvent(IRosterChangeEvent event) {
final IRosterChangeEvent rosterChangeEvent = event;
@ -746,31 +752,24 @@ public class CollaborationDataManager implements IRosterEventSubscriber {
// Assume only the presence needs to be updated.
user.setPresence(rosterEntry.getPresence());
break;
case PRESENCE:
System.out.println("\tIgnore assume only presence change");
return;
// break;
// case PRESENCE:
// System.out.println("\tIgnore assume only presence change");
// return;
// break;
default:
statusHandler.handle(Priority.PROBLEM, "Unknown type: "
statusHandler.handle(Priority.PROBLEM, "Unhandled type: "
+ rosterChangeEvent.getType());
return;
}
// synchronized (registerCnt) {
// if (registerCnt.compareAndSet(0, 0)) {
// System.out.println("post delayed");
// rosterChangeEventQueue.add(event);
// } else {
// Assume only views to be updated will register.
System.out.println("post now");
// Assume only UI updates are registered.
VizApp.runAsync(new Runnable() {
@Override
public void run() {
eventBus.post(rosterChangeEvent);
}
});
// }
// }
}
@Deprecated

View file

@ -36,7 +36,7 @@ package com.raytheon.uf.viz.collaboration.data;
* @version 1.0
*/
public class CollaborationNode {
public class CollaborationNode implements Comparable<CollaborationNode> {
private String text;
@ -86,4 +86,14 @@ public class CollaborationNode {
public void setLocal(boolean local) {
this.local = local;
}
/*
* (non-Javadoc)
*
* @see java.lang.Comparable#compareTo(java.lang.Object)
*/
@Override
public int compareTo(CollaborationNode o) {
return id.compareTo(o.id);
}
}

View file

@ -40,8 +40,7 @@ import com.raytheon.uf.viz.collaboration.comm.identity.user.IChatID;
* @author rferrel
* @version 1.0
*/
public class CollaborationUser extends CollaborationNode implements
Comparable<CollaborationUser> {
public class CollaborationUser extends CollaborationNode {
String session;
@ -116,10 +115,4 @@ public class CollaborationUser extends CollaborationNode implements
// CollaborationDataManager.getInstance().getUser(id).statusMessage =
// statusMessage;
// }
@Override
public int compareTo(CollaborationUser o) {
return getId().compareToIgnoreCase(o.getId());
}
}

View file

@ -317,7 +317,8 @@ public class CollaborationGroupView extends ViewPart implements IPartListener {
addUserAction = new Action("Add User") {
public void run() {
addUsersToGroup();
// addUsersToGroup();
nyiFeature("Add User to a Group");
};
};
addUserAction.setImageDescriptor(IconUtil.getImageDescriptor(bundle,
@ -625,14 +626,11 @@ public class CollaborationGroupView extends ViewPart implements IPartListener {
createTextOnlyView(result);
}
}
}
private void createCollaborationView(CreateSessionData result) {
String sessionId = result.getSessionId();
try {
if (result.isInviteUsers()) {
IVenueSession session = CollaborationDataManager.getInstance()
.getSession(sessionId);
.getSession(result.getSessionId());
List<String> usersList = new ArrayList<String>();
for (CollaborationUser user : getSelectedUsers()) {
usersList.add(user.getId());
@ -642,12 +640,11 @@ public class CollaborationGroupView extends ViewPart implements IPartListener {
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (sessionId == null) {
return;
}
}
}
private void createCollaborationView(CreateSessionData result) {
String sessionId = result.getSessionId();
try {
PlatformUI
.getWorkbench()
@ -655,18 +652,9 @@ public class CollaborationGroupView extends ViewPart implements IPartListener {
.getActivePage()
.showView(CollaborationSessionView.ID, sessionId,
IWorkbenchPage.VIEW_ACTIVATE);
if (result.isInviteUsers()) {
// TODO send invites to the users
Set<CollaborationUser> selectedUsers = getSelectedUsers();
for (CollaborationUser user : selectedUsers) {
System.out.println("sessionId - Invite: " + user.getId());
}
}
// refreshActiveSessions();
} catch (PartInitException e) {
statusHandler.handle(Priority.PROBLEM,
"Unable to open collaboation sesson", e);
"Unable to open collaboration sesson", e);
} catch (Exception e) {
statusHandler.handle(Priority.ERROR, "Unexpected excepton", e);
}
@ -686,17 +674,9 @@ public class CollaborationGroupView extends ViewPart implements IPartListener {
.getActivePage()
.showView(SessionView.ID, sessionId,
IWorkbenchPage.VIEW_ACTIVATE);
if (result.isInviteUsers()) {
// TODO send invites to the users
Set<CollaborationUser> selectedUsers = getSelectedUsers();
for (CollaborationUser user : selectedUsers) {
System.out.println("sessionId - Invite: " + user.getId());
}
}
} catch (PartInitException e) {
statusHandler.handle(Priority.PROBLEM,
"Unable to open collaboation sesson", e);
"Unable to open text only chat session", e);
} catch (Exception e) {
statusHandler.handle(Priority.ERROR, "Unexpected exception", e);
}
@ -754,7 +734,7 @@ public class CollaborationGroupView extends ViewPart implements IPartListener {
}
/**
* Genearte the Tree View component and add tooltip tracking.
* Generate the Tree View component and add tooltip tracking.
*
* @param parent
*/
@ -789,13 +769,21 @@ public class CollaborationGroupView extends ViewPart implements IPartListener {
if (node instanceof CollaborationUser) {
builder.append("ID: ").append(node.getId());
CollaborationUser user = (CollaborationUser) node;
builder.append("\nMode: ")
.append(user.getMode().getMode())
.append("\n");
builder.append("Type: ").append(user.getType())
.append("\n");
builder.append("Message: \"").append(
user.getStatusMessage() + "\"");
builder.append("\nStatus: ");
if (user.getType() == Type.UNAVAILABLE) {
builder.append("Off Line");
} else {
builder.append(user.getMode().getMode());
builder.append("\n");
// builder.append("Type: ").append(user.getType())
// .append("\n");
String message = user.getStatusMessage();
if (message != null && message.length() > 0) {
builder.append("Message: \"").append(
user.getStatusMessage() + "\"");
}
}
} else if (node instanceof SessionGroup
&& ((SessionGroup) node).isSessionRoot() == false) {
builder.append("ID: ").append(node.getId());
@ -935,6 +923,7 @@ public class CollaborationGroupView extends ViewPart implements IPartListener {
selectGroups.setEnabled(false);
changeStatusAction.setEnabled(false);
drawToolbarAction.setEnabled(false);
changeStatusMessageAction.setEnabled(false);
changePasswordAction.setEnabled(false);
return;
}
@ -943,6 +932,7 @@ public class CollaborationGroupView extends ViewPart implements IPartListener {
selectGroups.setEnabled(true);
changeStatusAction.setEnabled(true);
drawToolbarAction.setEnabled(true);
changeStatusMessageAction.setEnabled(true);
changePasswordAction.setEnabled(true);
LoginUser user = new LoginUser(manager.getLoginId());
@ -955,35 +945,16 @@ public class CollaborationGroupView extends ViewPart implements IPartListener {
populateGroups();
// usersTreeViewer.setInput(topLevel);
usersTreeViewer.getTree().setEnabled(true);
usersTreeViewer.refresh(topLevel, true);
createSessionAction.setEnabled(true);
}
// private void refreshActiveSessions() {
// populateActiveSessions();
// usersTreeViewer.refresh(activeSessionGroup, true);
// }
/**
* Clears and repopulates the Tree Viewer's active session node.
* Clears and populates the Tree Viewer's active session node.
*/
private void populateActiveSessions() {
activeSessionGroup.removeChildren();
// Collection<IVenueInfo> venuList = CollaborationDataManager
// .getInstance().getSessionManager().getVenueInfo();
// for (IVenueInfo venu : venuList) {
// // SessionGroup gp = new SessionGroup(CollaborationDataManager
// // .getInstance().venueIdToSessionId(venu.getVenueID()));
// SessionGroup gp = new SessionGroup(null);
// gp.setText(venu.getVenueName());
//
// if (venu.getParticipantCount() > 0) {
// // TODO add current participants of the venu here?
// }
// activeSessionGroup.addChild(gp);
// }
try {
CollaborationDataManager manager = CollaborationDataManager
.getInstance();
@ -1009,7 +980,6 @@ public class CollaborationGroupView extends ViewPart implements IPartListener {
private void populateGroups() {
CollaborationDataManager manager = CollaborationDataManager
.getInstance();
for (CollaborationNode node : topLevel.getChildren()) {
if (!(node instanceof LoginUser || node instanceof SessionGroup)) {
topLevel.removeChild(node);
@ -1034,104 +1004,6 @@ public class CollaborationGroupView extends ViewPart implements IPartListener {
}
}
// private void populateGroups() {
// for (CollaborationNode node : topLevel.getChildren()) {
// if (!(node instanceof LoginUser || node instanceof SessionGroup)) {
// topLevel.removeChild(node);
// }
// }
//
// // CollaborationDataManager.getInstance().repopulateGroups();
//
// IRosterManager rosterManager = CollaborationDataManager.getInstance()
// .getSessionManager().getRosterManager();
//
// IRoster roster = rosterManager.getRoster();
//
// String name = null;
// int rsize = -1;
// int gsize = -1;
// if (roster != null) {
// // TODO remove DEBUG start
// if (roster.getUser() != null) {
// name = roster.getUser().getName();
// }
// if (roster.getEntries() != null) {
// rsize = roster.getEntries().size();
// }
// if (roster.getGroups() != null) {
// gsize = roster.getGroups().size();
// }
// System.out.println("rosterManager Name " + name + ": group size "
// + gsize + ": entry size " + rsize);
// // TODO DEBUG end remove
// for (IRosterGroup rosterGroup : roster.getGroups()) {
// if (rosterGroup != null) {
// populateGroup(topLevel, rosterGroup);
// }
// }
//
// // add users not in a group to an orphan group.
// if (roster.getEntries() != null && roster.getEntries().size() > 0) {
// CollaborationGroup groupNode = new OrphanGroup(ORPHAN_GROUP_ID);
// for (IRosterEntry e : roster.getEntries()) {
// System.out.println(name + " entry: "
// + e.getUser().getName() + "@"
// + e.getUser().getHost() + "/"
// + e.getUser().getResource());
// String userId = CollaborationUtils.makeUserId(e);
// CollaborationUser child = new CollaborationUser(userId);
// child.setPresence(e.getPresence());
// groupNode.addChild(child);
// }
// topLevel.addChild(groupNode);
// } else {
// // TODO test do not check in with this else
// CollaborationGroup groupNode = new OrphanGroup(
// "a test of Orphan Users");
// String userId = "foo@bar.com";
// CollaborationUser child = new CollaborationUser(userId);
// child.setPresence(new Presence(Mode.AWAY, Type.UNAVAILABLE,
// "R.I.P."));
// groupNode.addChild(child);
// topLevel.addChild(groupNode);
// }
// }
// }
/**
* 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(false);
groupNode.setModifiable(false);
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()) {
String userId = CollaborationUtils.makeUserId(e);
CollaborationUser child = new CollaborationUser(userId);
child.setPresence(e.getPresence());
groupNode.addChild(child);
}
}
/**
* @return
*/
@ -1168,7 +1040,7 @@ public class CollaborationGroupView extends ViewPart implements IPartListener {
}
/**
* This recursively searches group Node and returns all users with Type
* This recursively searches group Nodes and returns all users with Type
* AVAILABLE.
*
* @param groupNode
@ -1423,7 +1295,6 @@ public class CollaborationGroupView extends ViewPart implements IPartListener {
switch (rosterChangeEvent.getType()) {
case ADD:
// Should be a rare event after initial population.
// User should only be in enter on list in groups.
OrphanGroup orphanGroup = null;
if (groups.size() == 0) {
// remove from all groups and add to Orphans.
@ -1463,16 +1334,23 @@ public class CollaborationGroupView extends ViewPart implements IPartListener {
usersTreeViewer.refresh();
}
} else {
// TODO add user to all in groups and remove from others.
// TODO add user to groups and remove from others including
// orphan group.
for (CollaborationNode node : topLevel.getChildren()) {
if (node instanceof CollaborationGroup
&& !(node instanceof SessionGroup)) {
CollaborationGroup group = (CollaborationGroup) node;
if (group instanceof OrphanGroup) {
orphanGroup = (OrphanGroup) group;
}
boolean addUser = groups.contains(group.getId());
for (CollaborationNode child : group.getChildren()) {
if (userId.equals(child.getId())) {
if (groups.contains(group.getId())) {
// User already in the group no need to add.
// User already in the group no need to
// add.
groups.remove(group.getId());
addUser = false;
} else {
// User no longer in this group.
group.removeChild(child);
@ -1481,9 +1359,20 @@ public class CollaborationGroupView extends ViewPart implements IPartListener {
break;
}
}
if (addUser) {
group.addChild(new CollaborationUser(userId));
groups.remove(group.getClass());
}
}
}
boolean refreshTopLevel = false;
if (orphanGroup != null
&& orphanGroup.getChildren().size() == 0) {
topLevel.removeChild(orphanGroup);
refreshTopLevel = true;
}
// groups now contains new groups. See if they are on the
// display list.
if (groups.size() > 0) {
@ -1491,9 +1380,15 @@ public class CollaborationGroupView extends ViewPart implements IPartListener {
.getInstance();
for (String groupId : groups) {
if (manager.displayGroup(groupId)) {
topLevel.addChild(new CollaborationGroup(groupId));
CollaborationGroup groupNode = new CollaborationGroup(
groupId);
topLevel.addChild(groupNode);
groupNode.addChild(new CollaborationUser(userId));
}
}
refreshTopLevel = true;
}
if (refreshTopLevel) {
usersTreeViewer.refresh(topLevel);
}
}
@ -1515,30 +1410,32 @@ public class CollaborationGroupView extends ViewPart implements IPartListener {
}
break;
case MODIFY:
// Assume this only changes the presence of a user in the desire
// Assume this only changes the presence of a user in the
// desired
// groups.
// Since this is handled by the handleModifiedPresence nothing needs
// Since this is handled by the handleModifiedPresence nothing
// needs
// to be done.
for (String groupId : groups) {
for (CollaborationNode node : topLevel.getChildren()) {
if (node instanceof CollaborationGroup
&& !(node instanceof SessionGroup)
&& groupId.equals(node.getId())) {
CollaborationGroup groupNode = (CollaborationGroup) node;
for (CollaborationNode child : groupNode.getChildren()) {
if (userId.equals(child.getId())) {
usersTreeViewer.refresh(child, true);
break;
}
}
}
}
}
// for (String groupId : groups) {
// for (CollaborationNode node : topLevel.getChildren()) {
// if (node instanceof CollaborationGroup
// && !(node instanceof SessionGroup)
// && groupId.equals(node.getId())) {
// CollaborationGroup groupNode = (CollaborationGroup) node;
// for (CollaborationNode child : groupNode.getChildren()) {
// if (userId.equals(child.getId())) {
// usersTreeViewer.refresh(child, true);
// break;
// }
// }
// }
// }
// }
break;
default:
statusHandler.handle(Priority.PROBLEM, "Unknown type: "
+ rosterChangeEvent.getType());
return;
break;
}
}
}

View file

@ -23,6 +23,8 @@ package com.raytheon.uf.viz.collaboration.ui;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerSorter;
import com.raytheon.uf.viz.collaboration.data.CollaborationGroup;
import com.raytheon.uf.viz.collaboration.data.CollaborationNode;
import com.raytheon.uf.viz.collaboration.data.LoginUser;
import com.raytheon.uf.viz.collaboration.data.OrphanGroup;
import com.raytheon.uf.viz.collaboration.data.SessionGroup;
@ -68,12 +70,24 @@ public class UsersTreeViewerSorter extends ViewerSorter {
return 1;
}
// OrpahGroup always at the bottom
if (e1 instanceof OrphanGroup) {
return 1;
}
if (e2 instanceof OrphanGroup) {
return -1;
}
return super.compare(viewer, e1, e2);
// Groups before users.
if (e1 instanceof CollaborationGroup) {
if (!(e2 instanceof CollaborationGroup)) {
return -1;
}
} else if (e1 instanceof CollaborationGroup) {
return 1;
}
// Either both are groups or both are users.
return ((CollaborationNode) e1).compareTo((CollaborationNode) e2);
}
}

View file

@ -34,13 +34,11 @@ import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
import org.osgi.framework.Bundle;
import org.eclipse.swt.widgets.Display;
import com.raytheon.uf.viz.collaboration.comm.identity.user.ParticipantRole;
import com.raytheon.uf.viz.collaboration.data.CollaborationUser;
import com.raytheon.uf.viz.collaboration.ui.Activator;
import com.raytheon.uf.viz.collaboration.ui.CollaborationUtils;
import com.raytheon.uf.viz.core.icon.IconUtil;
/**
* TODO Add Description
@ -62,6 +60,10 @@ import com.raytheon.uf.viz.core.icon.IconUtil;
public class ParticipantsLabelProvider implements ITableColorProvider,
ITableFontProvider, ITableLabelProvider {
private static int COLOR_DATA_PROVIDER = SWT.COLOR_GREEN;
private static int COLOR_SESSION_LEADER = SWT.COLOR_RED;
private List<ILabelProviderListener> listeners;
private String sessionId = null;
@ -167,36 +169,47 @@ public class ParticipantsLabelProvider implements ITableColorProvider,
String key = user.getImageKey();
StringBuilder modKey = new StringBuilder(key);
List<ParticipantRole> t = Arrays.asList(types);
int roleCnt = 0;
if (t.contains(ParticipantRole.SESSION_LEADER)) {
++roleCnt;
modKey.append(":")
.append(ParticipantRole.SESSION_LEADER.toString());
}
if (t.contains(ParticipantRole.DATA_PROVIDER)) {
++roleCnt;
modKey.append(":").append(ParticipantRole.DATA_PROVIDER.toString());
}
Image image = imageMap.get(modKey.toString());
if (image == null) {
Bundle bundle = Activator.getDefault().getBundle();
image = CollaborationUtils.getNodeImage(user);
// original image is 16x16
GC gc = new GC(image, SWT.LEFT_TO_RIGHT);
if (t.contains(ParticipantRole.SESSION_LEADER)) {
Image im = IconUtil.getImageDescriptor(bundle,
"session_leader.png").createImage();
gc.drawImage(im, 7, 7);
im.dispose();
}
if (t.contains(ParticipantRole.DATA_PROVIDER)) {
Image im = IconUtil.getImageDescriptor(bundle,
"data_provider.png").createImage();
gc.drawImage(im, 0, 16);
im.dispose();
if (roleCnt > 0) {
GC gc = new GC(image, SWT.LEFT_TO_RIGHT);
System.err.println("Creating icon: " + modKey.toString());
int topColor = -1;
int bottomColor = -1;
if (roleCnt == 1) {
if (t.contains(ParticipantRole.SESSION_LEADER)) {
topColor = COLOR_SESSION_LEADER;
bottomColor = COLOR_SESSION_LEADER;
} else {
topColor = COLOR_DATA_PROVIDER;
bottomColor = COLOR_DATA_PROVIDER;
}
} else {
topColor = COLOR_DATA_PROVIDER;
bottomColor = COLOR_SESSION_LEADER;
}
gc.setBackground(Display.getCurrent().getSystemColor(topColor));
gc.fillRectangle(0, 0, 16, 8);
gc.setBackground(Display.getCurrent().getSystemColor(
bottomColor));
gc.fillRectangle(0, 8, 8, 8);
gc.dispose();
}
image.getImageData();
imageMap.put(modKey.toString(), image);
gc.dispose();
}
return image;
}