Issue #432 In Collaboration Session View roles now properly update the icon.
Change-Id: I970cd006464359acae17dc71705d76e0083c016e Former-commit-id:cca947d3ec
[formerly4266d74fb4
[formerly 7ad908ac8ef6d276c3294e4c7590e07972b0fd79]] Former-commit-id:4266d74fb4
Former-commit-id:c47521f4b9
This commit is contained in:
parent
5fd1dfbe50
commit
6a1ae6a396
3 changed files with 69 additions and 45 deletions
|
@ -731,7 +731,12 @@ public class CollaborationDataManager implements IRosterEventSubscriber {
|
||||||
break;
|
break;
|
||||||
case MODIFY:
|
case MODIFY:
|
||||||
// Assume only the presence needs to be updated.
|
// Assume only the presence needs to be updated.
|
||||||
user.setPresence(rosterEntry.getPresence());
|
IPresence precsence = rosterEntry.getPresence();
|
||||||
|
if (precsence == null) {
|
||||||
|
// Nothing to do don't bother doing eventBus post.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
user.setPresence(precsence);
|
||||||
break;
|
break;
|
||||||
// case PRESENCE:
|
// case PRESENCE:
|
||||||
// System.out.println("\tIgnore assume only presence change");
|
// System.out.println("\tIgnore assume only presence change");
|
||||||
|
|
|
@ -60,6 +60,8 @@ public class CollaborationUtils {
|
||||||
public static final IPresence.Mode[] statusModes = { Mode.AVAILABLE,
|
public static final IPresence.Mode[] statusModes = { Mode.AVAILABLE,
|
||||||
Mode.DND, Mode.AWAY };
|
Mode.DND, Mode.AWAY };
|
||||||
|
|
||||||
|
private static final String PREFIX_CONFERENCE = "conference.";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the statusModes' index for desired mode.
|
* Get the statusModes' index for desired mode.
|
||||||
*
|
*
|
||||||
|
@ -111,9 +113,13 @@ public class CollaborationUtils {
|
||||||
StringBuilder sb = new StringBuilder(participant.getName());
|
StringBuilder sb = new StringBuilder(participant.getName());
|
||||||
sb.append(Tools.NAME_DELIM);
|
sb.append(Tools.NAME_DELIM);
|
||||||
int start = sb.length();
|
int start = sb.length();
|
||||||
// Assume participant's host is conference.site
|
|
||||||
sb.append(participant.getHost());
|
String host = participant.getHost();
|
||||||
sb.replace(start, start + "conference.".length(), "");
|
|
||||||
|
sb.append(host);
|
||||||
|
if (host.startsWith(PREFIX_CONFERENCE)) {
|
||||||
|
sb.replace(start, start + PREFIX_CONFERENCE.length(), "");
|
||||||
|
}
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
package com.raytheon.uf.viz.collaboration.ui.session;
|
package com.raytheon.uf.viz.collaboration.ui.session;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -36,12 +35,14 @@ import org.eclipse.swt.graphics.GC;
|
||||||
import org.eclipse.swt.graphics.Image;
|
import org.eclipse.swt.graphics.Image;
|
||||||
import org.eclipse.swt.widgets.Display;
|
import org.eclipse.swt.widgets.Display;
|
||||||
|
|
||||||
|
import com.raytheon.uf.viz.collaboration.comm.identity.ISharedDisplaySession;
|
||||||
import com.raytheon.uf.viz.collaboration.comm.identity.user.ParticipantRole;
|
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.CollaborationUser;
|
import com.raytheon.uf.viz.collaboration.data.CollaborationUser;
|
||||||
import com.raytheon.uf.viz.collaboration.ui.CollaborationUtils;
|
import com.raytheon.uf.viz.collaboration.ui.CollaborationUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO Add Description
|
* Generate the Participant's label and icon image.
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
*
|
*
|
||||||
|
@ -60,9 +61,9 @@ import com.raytheon.uf.viz.collaboration.ui.CollaborationUtils;
|
||||||
public class ParticipantsLabelProvider implements ITableColorProvider,
|
public class ParticipantsLabelProvider implements ITableColorProvider,
|
||||||
ITableFontProvider, ITableLabelProvider {
|
ITableFontProvider, ITableLabelProvider {
|
||||||
|
|
||||||
private static int COLOR_DATA_PROVIDER = SWT.COLOR_GREEN;
|
private static int COLOR_SESSION_LEADER = SWT.COLOR_GREEN;
|
||||||
|
|
||||||
private static int COLOR_SESSION_LEADER = SWT.COLOR_RED;
|
private static int COLOR_DATA_PROVIDER = SWT.COLOR_RED;
|
||||||
|
|
||||||
private List<ILabelProviderListener> listeners;
|
private List<ILabelProviderListener> listeners;
|
||||||
|
|
||||||
|
@ -89,8 +90,6 @@ public class ParticipantsLabelProvider implements ITableColorProvider,
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isLabelProperty(Object element, String property) {
|
public boolean isLabelProperty(Object element, String property) {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
System.out.println("isLabelProperty");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,12 +112,27 @@ public class ParticipantsLabelProvider implements ITableColorProvider,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// TODO Determine user's role and then test getModifier.
|
|
||||||
if (image != null) {
|
if (image != null) {
|
||||||
ParticipantRole[] types = new ParticipantRole[] {
|
CollaborationDataManager.getInstance().getSession(sessionId);
|
||||||
ParticipantRole.SESSION_LEADER,
|
ISharedDisplaySession sdSession = CollaborationDataManager
|
||||||
ParticipantRole.DATA_PROVIDER };
|
.getInstance().getSession(sessionId)
|
||||||
image = getModifier(types, user);
|
.spawnSharedDisplaySession();
|
||||||
|
String userId = user.getId();
|
||||||
|
String sessionLeaderId = CollaborationUtils.makeUserId(sdSession
|
||||||
|
.getCurrentSessionLeader());
|
||||||
|
String dataProviderId = CollaborationUtils.makeUserId(sdSession
|
||||||
|
.getCurrentDataProvider());
|
||||||
|
List<ParticipantRole> roleList = new ArrayList<ParticipantRole>();
|
||||||
|
if (userId.equals(sessionLeaderId)) {
|
||||||
|
roleList.add(ParticipantRole.SESSION_LEADER);
|
||||||
|
}
|
||||||
|
if (userId.equals(dataProviderId)) {
|
||||||
|
roleList.add(ParticipantRole.DATA_PROVIDER);
|
||||||
|
}
|
||||||
|
if (roleList.size() > 0) {
|
||||||
|
image = getModifier(roleList, user);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
@ -126,27 +140,21 @@ public class ParticipantsLabelProvider implements ITableColorProvider,
|
||||||
@Override
|
@Override
|
||||||
public String getColumnText(Object element, int columnIndex) {
|
public String getColumnText(Object element, int columnIndex) {
|
||||||
CollaborationUser user = (CollaborationUser) element;
|
CollaborationUser user = (CollaborationUser) element;
|
||||||
// RoleType[] roles = user.getRoles(sessionId);
|
|
||||||
return user.getText();
|
return user.getText();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Font getFont(Object element, int columnIndex) {
|
public Font getFont(Object element, int columnIndex) {
|
||||||
// System.out.println("getFont");
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Color getForeground(Object element, int columnIndex) {
|
public Color getForeground(Object element, int columnIndex) {
|
||||||
// CollaborationUser user = (CollaborationUser) element;
|
|
||||||
// System.out.println("getForeground");
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Color getBackground(Object element, int columnIndex) {
|
public Color getBackground(Object element, int columnIndex) {
|
||||||
// System.out.println("getBackground");
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,17 +173,26 @@ public class ParticipantsLabelProvider implements ITableColorProvider,
|
||||||
return sessionId;
|
return sessionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Image getModifier(ParticipantRole[] types, CollaborationUser user) {
|
/**
|
||||||
|
* Modify image image to indicate Session Leader and/or DataProvider.
|
||||||
|
*
|
||||||
|
* @param roles
|
||||||
|
* - non-empty list indicate the role(s)
|
||||||
|
* @param user
|
||||||
|
* -
|
||||||
|
* @return image - modified with indicator(s)
|
||||||
|
*/
|
||||||
|
private Image getModifier(List<ParticipantRole> roles,
|
||||||
|
CollaborationUser user) {
|
||||||
String key = user.getImageKey();
|
String key = user.getImageKey();
|
||||||
StringBuilder modKey = new StringBuilder(key);
|
StringBuilder modKey = new StringBuilder(key);
|
||||||
List<ParticipantRole> t = Arrays.asList(types);
|
|
||||||
int roleCnt = 0;
|
int roleCnt = 0;
|
||||||
if (t.contains(ParticipantRole.SESSION_LEADER)) {
|
if (roles.contains(ParticipantRole.SESSION_LEADER)) {
|
||||||
++roleCnt;
|
++roleCnt;
|
||||||
modKey.append(":")
|
modKey.append(":")
|
||||||
.append(ParticipantRole.SESSION_LEADER.toString());
|
.append(ParticipantRole.SESSION_LEADER.toString());
|
||||||
}
|
}
|
||||||
if (t.contains(ParticipantRole.DATA_PROVIDER)) {
|
if (roles.contains(ParticipantRole.DATA_PROVIDER)) {
|
||||||
++roleCnt;
|
++roleCnt;
|
||||||
modKey.append(":").append(ParticipantRole.DATA_PROVIDER.toString());
|
modKey.append(":").append(ParticipantRole.DATA_PROVIDER.toString());
|
||||||
}
|
}
|
||||||
|
@ -184,30 +201,26 @@ public class ParticipantsLabelProvider implements ITableColorProvider,
|
||||||
if (image == null) {
|
if (image == null) {
|
||||||
image = CollaborationUtils.getNodeImage(user);
|
image = CollaborationUtils.getNodeImage(user);
|
||||||
// original image is 16x16
|
// original image is 16x16
|
||||||
if (roleCnt > 0) {
|
GC gc = new GC(image, SWT.LEFT_TO_RIGHT);
|
||||||
GC gc = new GC(image, SWT.LEFT_TO_RIGHT);
|
int topColor = -1;
|
||||||
System.err.println("Creating icon: " + modKey.toString());
|
int bottomColor = -1;
|
||||||
int topColor = -1;
|
if (roleCnt == 1) {
|
||||||
int bottomColor = -1;
|
if (roles.contains(ParticipantRole.SESSION_LEADER)) {
|
||||||
if (roleCnt == 1) {
|
topColor = COLOR_SESSION_LEADER;
|
||||||
if (t.contains(ParticipantRole.SESSION_LEADER)) {
|
bottomColor = COLOR_SESSION_LEADER;
|
||||||
topColor = COLOR_SESSION_LEADER;
|
|
||||||
bottomColor = COLOR_SESSION_LEADER;
|
|
||||||
} else {
|
|
||||||
topColor = COLOR_DATA_PROVIDER;
|
|
||||||
bottomColor = COLOR_DATA_PROVIDER;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
topColor = COLOR_DATA_PROVIDER;
|
topColor = COLOR_DATA_PROVIDER;
|
||||||
bottomColor = COLOR_SESSION_LEADER;
|
bottomColor = COLOR_DATA_PROVIDER;
|
||||||
}
|
}
|
||||||
gc.setBackground(Display.getCurrent().getSystemColor(topColor));
|
} else {
|
||||||
gc.fillRectangle(0, 0, 16, 8);
|
topColor = COLOR_SESSION_LEADER;
|
||||||
gc.setBackground(Display.getCurrent().getSystemColor(
|
bottomColor = COLOR_DATA_PROVIDER;
|
||||||
bottomColor));
|
|
||||||
gc.fillRectangle(0, 8, 8, 8);
|
|
||||||
gc.dispose();
|
|
||||||
}
|
}
|
||||||
|
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();
|
image.getImageData();
|
||||||
imageMap.put(modKey.toString(), image);
|
imageMap.put(modKey.toString(), image);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue