Issue #244 Invite form Creat Session dialog implementd. Change code to use ParticipantRole enum.

Change-Id: If1c7268bded530312d9c132edacef00cd1dcdfd2

Former-commit-id: 89978ed4bcf7c3b65c6038c6403874ba812f835b
This commit is contained in:
Roger Ferrel 2012-04-02 12:13:26 -05:00
parent 236ae6f26c
commit dbec72645a
7 changed files with 118 additions and 109 deletions

View file

@ -2,6 +2,7 @@ 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.Type; import com.raytheon.uf.viz.collaboration.comm.identity.IPresence.Type;
import com.raytheon.uf.viz.collaboration.comm.identity.user.ParticipantRole;
/** /**
* This software was developed and / or modified by Raytheon Company, * This software was developed and / or modified by Raytheon Company,
@ -71,17 +72,17 @@ public class CollaborationUser extends CollaborationNode implements
return "contact_disabled"; return "contact_disabled";
} }
public DataUser.RoleType[] getRoles() { public ParticipantRole[] getRoles() {
return CollaborationDataManager.getInstance().getUser(id) return CollaborationDataManager.getInstance().getUser(id)
.getSessionRoles(session); .getSessionRoles(session);
} }
public void addRole(DataUser.RoleType role) { public void addRole(ParticipantRole role) {
CollaborationDataManager.getInstance().getUser(id) CollaborationDataManager.getInstance().getUser(id)
.addSessionRole(session, role); .addSessionRole(session, role);
} }
public void removeRole(DataUser.RoleType role) { public void removeRole(ParticipantRole role) {
CollaborationDataManager.getInstance().getUser(id) CollaborationDataManager.getInstance().getUser(id)
.removeSessionRole(session, role); .removeSessionRole(session, role);
} }

View file

@ -28,6 +28,7 @@ import java.util.Map;
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.comm.identity.IPresence.Mode;
import com.raytheon.uf.viz.collaboration.comm.identity.IPresence.Type; import com.raytheon.uf.viz.collaboration.comm.identity.IPresence.Type;
import com.raytheon.uf.viz.collaboration.comm.identity.user.ParticipantRole;
/** /**
* 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
@ -48,22 +49,6 @@ import com.raytheon.uf.viz.collaboration.comm.identity.IPresence.Type;
*/ */
public class DataUser { public class DataUser {
// public static enum StatusType {
// AVAILABLE("Available"), AWAY("Away"), DO_NOT_DISTURB("Do Not Disturb"),
// NOT_ON_LINE(
// "UnAvailable");
//
// private final String value;
//
// StatusType(String value) {
// this.value = value;
// }
//
// public String value() {
// return value;
// }
// }
private static final Map<String, IPresence.Mode> modeMap = new HashMap<String, IPresence.Mode>(); private static final Map<String, IPresence.Mode> modeMap = new HashMap<String, IPresence.Mode>();
static { static {
for (Mode mode : Mode.values()) { for (Mode mode : Mode.values()) {
@ -71,27 +56,13 @@ public class DataUser {
} }
} }
public static enum RoleType {
LEADER("Session Leader"), DATA_PROVIDER("Data Provider"), PARTICIPANT(
"Participant"), UNKNOWN("Unknown");
private final String value;
RoleType(String value) {
this.value = value;
}
public String value() {
return value;
}
}
IPresence.Mode mode; IPresence.Mode mode;
IPresence.Type type; IPresence.Type type;
String statusMessage; String statusMessage;
Map<String, List<RoleType>> roleMap; Map<String, List<ParticipantRole>> roleMap;
/** /**
* Unique id for the usersData. * Unique id for the usersData.
@ -119,48 +90,54 @@ public class DataUser {
sessionsMap = new HashMap<String, String>(); sessionsMap = new HashMap<String, String>();
mode = Mode.EXTENDED_AWAY; mode = Mode.EXTENDED_AWAY;
type = Type.UNKNOWN; type = Type.UNKNOWN;
roleMap = new HashMap<String, List<RoleType>>(); roleMap = new HashMap<String, List<ParticipantRole>>();
} }
RoleType[] getSessionRoles(String session) { /**
RoleType[] result = null; * @param sessionId
List<RoleType> roleList = roleMap.get(session); * @return
*/
ParticipantRole[] getSessionRoles(String sessionId) {
ParticipantRole[] result = null;
List<ParticipantRole> roleList = roleMap.get(sessionId);
if (roleList == null) { if (roleList == null) {
result = new RoleType[0]; result = new ParticipantRole[0];
} else { } else {
result = new RoleType[roleList.size()]; result = new ParticipantRole[roleList.size()];
roleList.toArray(result); roleList.toArray(result);
} }
return result; return result;
} }
void addSessionRole(final String session, final RoleType role) { /**
List<RoleType> roleList = roleMap.get(session); * @param sessionId
* @param role
*/
void addSessionRole(final String sessionId, final ParticipantRole role) {
List<ParticipantRole> roleList = roleMap.get(sessionId);
if (roleList == null) { if (roleList == null) {
roleList = new ArrayList<DataUser.RoleType>(); roleList = new ArrayList<ParticipantRole>();
roleMap.put(session, roleList); roleMap.put(sessionId, roleList);
} }
if (role == DataUser.RoleType.PARTICIPANT if (role == ParticipantRole.PARTICIPANT) {
|| role == DataUser.RoleType.UNKNOWN) {
roleList.clear(); roleList.clear();
roleList.add(role); roleList.add(role);
} else { } else {
boolean insertRole = true; boolean insertRole = true;
Iterator<DataUser.RoleType> iter = roleList.iterator(); Iterator<ParticipantRole> iter = roleList.iterator();
while (iter.hasNext()) { while (iter.hasNext()) {
DataUser.RoleType r = iter.next(); ParticipantRole r = iter.next();
if (r == role) { if (r == role) {
insertRole = false; insertRole = false;
} }
if (r == DataUser.RoleType.PARTICIPANT if (r == ParticipantRole.PARTICIPANT) {
|| r == DataUser.RoleType.UNKNOWN) {
iter.remove(); iter.remove();
} }
} }
if (insertRole) { if (insertRole) {
// Keep order Leader then provider. // Keep order Leader then provider.
if (role == DataUser.RoleType.LEADER) { if (role == ParticipantRole.SESSION_LEADER) {
roleList.add(0, role); roleList.add(0, role);
} else { } else {
roleList.add(role); roleList.add(role);
@ -169,17 +146,28 @@ public class DataUser {
} }
} }
void removeSessionRole(String session, RoleType role) { /**
List<RoleType> roleList = roleMap.get(session); * @param sessionId
* @param role
*/
void removeSessionRole(String sessionId, ParticipantRole role) {
List<ParticipantRole> roleList = roleMap.get(sessionId);
if (roleList != null) { if (roleList != null) {
roleList.remove(role); roleList.remove(role);
} }
} }
void removeSession(String session) { /**
roleMap.remove(session); * @param sessionId
*/
void removeSession(String sessionId) {
roleMap.remove(sessionId);
} }
/**
* @param id
* @return
*/
DataGroup getGroup(String id) { DataGroup getGroup(String id) {
DataGroup group = groupsMap.get(id); DataGroup group = groupsMap.get(id);
if (group == null) { if (group == null) {
@ -211,4 +199,12 @@ public class DataUser {
public Mode getMode() { public Mode getMode() {
return mode; return mode;
} }
public Type getType() {
return type;
}
public void setType(Type type) {
this.type = type;
}
} }

View file

@ -566,6 +566,14 @@ public class CollaborationGroupView extends ViewPart implements IPartListener {
.getInstance(); .getInstance();
sessionId = manager.createCollaborationSession(result.getName(), sessionId = manager.createCollaborationSession(result.getName(),
result.getSubject()); result.getSubject());
if (result.isInviteUsers()) {
List<String> usersList = new ArrayList<String>();
for (CollaborationUser user : getSelectedUsers()) {
usersList.add(user.getId());
}
String b = result.getInviteMessage();
manager.getSession(sessionId).sendInvitation(usersList, b);
}
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} finally { } finally {
@ -575,7 +583,7 @@ public class CollaborationGroupView extends ViewPart implements IPartListener {
} }
try { try {
IViewPart part = PlatformUI PlatformUI
.getWorkbench() .getWorkbench()
.getActiveWorkbenchWindow() .getActiveWorkbenchWindow()
.getActivePage() .getActivePage()
@ -1061,19 +1069,7 @@ public class CollaborationGroupView extends ViewPart implements IPartListener {
* @return * @return
*/ */
private boolean usersSelected() { private boolean usersSelected() {
IStructuredSelection selection = (IStructuredSelection) usersTreeViewer return getSelectedUsers().size() > 0;
.getSelection();
Object[] nodes = selection.toArray();
boolean result = false;
for (Object node : nodes) {
if ((node instanceof LoginUser) == false
&& (node instanceof SessionGroup) == false) {
result = true;
break;
}
}
return result;
} }
/** /**
@ -1103,12 +1099,16 @@ public class CollaborationGroupView extends ViewPart implements IPartListener {
return selectedUsers; return selectedUsers;
} }
private Collection<CollaborationUser> getSelectedUsers( private Set<CollaborationUser> getSelectedUsers(CollaborationGroup groupNode) {
CollaborationGroup groupNode) { CollaborationDataManager manger = CollaborationDataManager
.getInstance();
Set<CollaborationUser> selectedUsers = new HashSet<CollaborationUser>(); Set<CollaborationUser> selectedUsers = new HashSet<CollaborationUser>();
for (CollaborationNode node : groupNode.getChildren()) { for (CollaborationNode node : groupNode.getChildren()) {
if (node instanceof CollaborationUser) { if (node instanceof CollaborationUser) {
selectedUsers.add((CollaborationUser) node); CollaborationNode user = (CollaborationUser) node;
if (manger.getUser(user.getId()).getType() == Type.AVAILABLE) {
selectedUsers.add((CollaborationUser) node);
}
} else if (node instanceof CollaborationGroup) { } else if (node instanceof CollaborationGroup) {
selectedUsers selectedUsers
.addAll(getSelectedUsers((CollaborationGroup) node)); .addAll(getSelectedUsers((CollaborationGroup) node));
@ -1202,6 +1202,11 @@ public class CollaborationGroupView extends ViewPart implements IPartListener {
} }
} }
} else if (part == this) { } else if (part == this) {
// TODO Remove rosterManger handler.
// IRosterManager rosterManager =
// CollaborationDataManager.getInstance()
// .getSessionManager().getRosterManager();
// rosterManager.removeEventHandler(this);
getViewSite().getWorkbenchWindow().getPartService() getViewSite().getWorkbenchWindow().getPartService()
.removePartListener(this); .removePartListener(this);
} }
@ -1239,6 +1244,11 @@ public class CollaborationGroupView extends ViewPart implements IPartListener {
activeSessionGroup.addChild(child); activeSessionGroup.addChild(child);
usersTreeViewer.refresh(activeSessionGroup); usersTreeViewer.refresh(activeSessionGroup);
} else if (part == this) { } else if (part == this) {
// TODO register even handler for
// IRosterManager rosterManager =
// CollaborationDataManager.getInstance()
// .getSessionManager().getRosterManager();
// rosterManager.registerEventHandler(this);
populateTree(); populateTree();
} }
} }

View file

@ -104,7 +104,7 @@ public class CreateSessionDialog extends CaveSWTDialog {
gd = new GridData(SWT.DEFAULT, SWT.DEFAULT, false, false); gd = new GridData(SWT.DEFAULT, SWT.DEFAULT, false, false);
gd.horizontalSpan = 2; gd.horizontalSpan = 2;
publicCollaboration.setLayoutData(gd); publicCollaboration.setLayoutData(gd);
publicCollaboration.setText("Create Public Collaboration"); publicCollaboration.setText("Create Collaboration");
if (showInvite) { if (showInvite) {
inviteUsers = new Button(body, SWT.CHECK); inviteUsers = new Button(body, SWT.CHECK);

View file

@ -36,9 +36,9 @@ import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.Image;
import org.osgi.framework.Bundle; import org.osgi.framework.Bundle;
import com.raytheon.uf.viz.collaboration.comm.identity.user.ParticipantRole;
import com.raytheon.uf.viz.collaboration.data.CollaborationDataManager; import com.raytheon.uf.viz.collaboration.data.CollaborationDataManager;
import com.raytheon.uf.viz.collaboration.data.CollaborationUser; import com.raytheon.uf.viz.collaboration.data.CollaborationUser;
import com.raytheon.uf.viz.collaboration.data.DataUser.RoleType;
import com.raytheon.uf.viz.collaboration.ui.Activator; import com.raytheon.uf.viz.collaboration.ui.Activator;
import com.raytheon.uf.viz.collaboration.ui.CollaborationUtils; import com.raytheon.uf.viz.collaboration.ui.CollaborationUtils;
import com.raytheon.uf.viz.core.icon.IconUtil; import com.raytheon.uf.viz.core.icon.IconUtil;
@ -114,8 +114,9 @@ public class ParticipantsLabelProvider implements ITableColorProvider,
} }
// TODO Determine user's role and then test getModifier. // TODO Determine user's role and then test getModifier.
if (image != null) { if (image != null) {
RoleType[] types = new RoleType[] { RoleType.LEADER, ParticipantRole[] types = new ParticipantRole[] {
RoleType.DATA_PROVIDER }; ParticipantRole.SESSION_LEADER,
ParticipantRole.DATA_PROVIDER };
image = getModifier(types, user); image = getModifier(types, user);
} }
return image; return image;
@ -163,15 +164,16 @@ public class ParticipantsLabelProvider implements ITableColorProvider,
return sessionId; return sessionId;
} }
private Image getModifier(RoleType[] types, CollaborationUser user) { private Image getModifier(ParticipantRole[] types, CollaborationUser user) {
String key = user.getImageKey(); String key = user.getImageKey();
StringBuilder modKey = new StringBuilder(key); StringBuilder modKey = new StringBuilder(key);
List<RoleType> t = Arrays.asList(types); List<ParticipantRole> t = Arrays.asList(types);
if (t.contains(RoleType.LEADER)) { if (t.contains(ParticipantRole.SESSION_LEADER)) {
modKey.append(":").append(RoleType.LEADER.toString()); modKey.append(":")
.append(ParticipantRole.SESSION_LEADER.toString());
} }
if (t.contains(RoleType.DATA_PROVIDER)) { if (t.contains(ParticipantRole.DATA_PROVIDER)) {
modKey.append(":").append(RoleType.DATA_PROVIDER.toString()); modKey.append(":").append(ParticipantRole.DATA_PROVIDER.toString());
} }
Image image = imageMap.get(modKey.toString()); Image image = imageMap.get(modKey.toString());
@ -181,13 +183,13 @@ public class ParticipantsLabelProvider implements ITableColorProvider,
// original image is 16x16 // original image is 16x16
GC gc = new GC(image, SWT.LEFT_TO_RIGHT); GC gc = new GC(image, SWT.LEFT_TO_RIGHT);
if (t.contains(RoleType.LEADER)) { if (t.contains(ParticipantRole.SESSION_LEADER)) {
Image im = IconUtil.getImageDescriptor(bundle, Image im = IconUtil.getImageDescriptor(bundle,
"session_leader.png").createImage(); "session_leader.png").createImage();
gc.drawImage(im, 7, 7); gc.drawImage(im, 7, 7);
im.dispose(); im.dispose();
} }
if (t.contains(RoleType.DATA_PROVIDER)) { if (t.contains(ParticipantRole.DATA_PROVIDER)) {
Image im = IconUtil.getImageDescriptor(bundle, Image im = IconUtil.getImageDescriptor(bundle,
"data_provider.png").createImage(); "data_provider.png").createImage();
gc.drawImage(im, 0, 16); gc.drawImage(im, 0, 16);

View file

@ -26,7 +26,7 @@ import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Display;
import com.raytheon.uf.viz.collaboration.data.DataUser.RoleType; import com.raytheon.uf.viz.collaboration.comm.identity.user.ParticipantRole;
/** /**
* TODO Add Description * TODO Add Description
@ -46,34 +46,34 @@ import com.raytheon.uf.viz.collaboration.data.DataUser.RoleType;
*/ */
public class SessionColorAdvisor { public class SessionColorAdvisor {
private static Map<RoleType, Color> colors = null; private static Map<ParticipantRole, Color> colors = null;
public static Color getColor(RoleType[] type, boolean isSelf) { public static Color getColor(ParticipantRole[] type, boolean isSelf) {
if (colors == null) { if (colors == null) {
colors = new HashMap<RoleType, Color>(); colors = new HashMap<ParticipantRole, Color>();
colors.put(RoleType.LEADER, colors.put(ParticipantRole.SESSION_LEADER, Display.getCurrent()
Display.getCurrent().getSystemColor(SWT.COLOR_BLUE)); .getSystemColor(SWT.COLOR_BLUE));
colors.put(RoleType.DATA_PROVIDER, Display.getCurrent() colors.put(ParticipantRole.DATA_PROVIDER, Display.getCurrent()
.getSystemColor(SWT.COLOR_RED)); .getSystemColor(SWT.COLOR_RED));
colors.put(RoleType.PARTICIPANT, Display.getCurrent() colors.put(ParticipantRole.PARTICIPANT, Display.getCurrent()
.getSystemColor(SWT.COLOR_DARK_GREEN)); .getSystemColor(SWT.COLOR_DARK_GREEN));
} }
if (isSelf) { if (isSelf) {
return Display.getCurrent().getSystemColor(SWT.COLOR_BLACK); return Display.getCurrent().getSystemColor(SWT.COLOR_BLACK);
} }
RoleType rType = null; ParticipantRole rType = null;
if (type == null || type.length == 0) { if (type == null || type.length == 0) {
rType = RoleType.PARTICIPANT; rType = ParticipantRole.PARTICIPANT;
} else if (type.length == 1) { } else if (type.length == 1) {
rType = type[0]; rType = type[0];
} else { } else {
rType = RoleType.PARTICIPANT; rType = ParticipantRole.PARTICIPANT;
for (RoleType rt : type) { for (ParticipantRole rt : type) {
if (rt == RoleType.DATA_PROVIDER) { if (rt == ParticipantRole.DATA_PROVIDER) {
rType = rt; rType = rt;
break; break;
} }
if (rt == RoleType.LEADER) { if (rt == ParticipantRole.SESSION_LEADER) {
rType = rt; rType = rt;
} }
} }

View file

@ -69,10 +69,10 @@ import com.raytheon.uf.viz.collaboration.comm.identity.event.IVenueParticipantEv
import com.raytheon.uf.viz.collaboration.comm.identity.event.ParticipantEventType; 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.user.IVenueParticipant; import com.raytheon.uf.viz.collaboration.comm.identity.user.IVenueParticipant;
import com.raytheon.uf.viz.collaboration.comm.identity.user.ParticipantRole;
import com.raytheon.uf.viz.collaboration.data.CollaborationDataManager; import com.raytheon.uf.viz.collaboration.data.CollaborationDataManager;
import com.raytheon.uf.viz.collaboration.data.CollaborationKeywords; import com.raytheon.uf.viz.collaboration.data.CollaborationKeywords;
import com.raytheon.uf.viz.collaboration.data.CollaborationUser; import com.raytheon.uf.viz.collaboration.data.CollaborationUser;
import com.raytheon.uf.viz.collaboration.data.DataUser.RoleType;
import com.raytheon.uf.viz.core.VizApp; import com.raytheon.uf.viz.core.VizApp;
/** /**
@ -339,12 +339,12 @@ public class SessionView extends AbstractSessionView {
builder.append("type: ").append(user.getType()) builder.append("type: ").append(user.getType())
.append("\n"); .append("\n");
builder.append("-- Roles --"); builder.append("-- Roles --");
for (RoleType type : user.getRoles()) { for (ParticipantRole type : user.getRoles()) {
// TODO fake XXX take this out // TODO fake XXX take this out
if (type == RoleType.UNKNOWN) { // if (type == ParticipantRole.UNKNOWN) {
continue; // continue;
} // }
builder.append("\n" + type.value()); builder.append("\n" + type.toString());
} }
usersTable.getTable().setToolTipText(builder.toString()); usersTable.getTable().setToolTipText(builder.toString());
} else { } else {
@ -365,12 +365,12 @@ public class SessionView extends AbstractSessionView {
user.setMode(Mode.AVAILABLE); user.setMode(Mode.AVAILABLE);
user.setType(Type.AVAILABLE); user.setType(Type.AVAILABLE);
// RoleType[] roles = user.getRoles(sessionId); // ParticipantRole[] roles = user.getRoles(sessionId);
// for (RoleType role : roles) { // for (ParticipantRole role : roles) {
// user.addRole(role); // user.addRole(role);
// } // }
user.addRole(RoleType.DATA_PROVIDER); user.addRole(ParticipantRole.DATA_PROVIDER);
user.addRole(RoleType.LEADER); user.addRole(ParticipantRole.SESSION_LEADER);
user.setText(participant.getFQName()); user.setText(participant.getFQName());
// user.setMode(mode); // user.setMode(mode);
// user.setType(Type.AVAILABLE); // user.setType(Type.AVAILABLE);
@ -458,7 +458,7 @@ public class SessionView extends AbstractSessionView {
} }
} }
RoleType[] type = null; ParticipantRole[] type = null;
for (CollaborationUser u : (List<CollaborationUser>) usersTable for (CollaborationUser u : (List<CollaborationUser>) usersTable
.getInput()) { .getInput()) {
if (name.equals(u.getId())) { if (name.equals(u.getId())) {