From d497c533e611f198784c8214798403bcfd87730a Mon Sep 17 00:00:00 2001 From: Mike Duff Date: Tue, 25 Mar 2014 11:18:09 -0500 Subject: [PATCH] Issue #2938 - Show status message for site/role changes, but not return from away Change-Id: I30f6e1122e813d70b1c3fbee5e0b0f6ce9107dd2 Former-commit-id: 1e42d8a30dc3bb0d642698f76c3067f5b6ff05e4 [formerly 666a354d6f676b899bd14371517bce9de88192d2] Former-commit-id: a06f058ea9dfcf69743cb7661ff8811aca050746 --- .../ui/session/SessionFeedView.java | 52 ++++++++++++++----- 1 file changed, 39 insertions(+), 13 deletions(-) diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/SessionFeedView.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/SessionFeedView.java index 1e00d10b4e..6a7ad7bc3e 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/SessionFeedView.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/SessionFeedView.java @@ -20,9 +20,7 @@ package com.raytheon.uf.viz.collaboration.ui.session; import java.util.ArrayList; -import java.util.Collections; import java.util.List; -import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import org.eclipse.jface.action.Action; @@ -74,6 +72,7 @@ import com.raytheon.uf.viz.core.icon.IconUtil; * Mar 18, 2014 2798 mpduff Fixed issue with user changing site and participant list not * having the color update to reflect the change. * Mar 24, 2014 2936 mpduff Remove join alerts from feed view. + * Mar 25, 2014 2938 mpduff Show status message for site and role changes. * * * @@ -102,8 +101,7 @@ public class SessionFeedView extends SessionView { /** * Set of users logged in. */ - private final Set enabledUsers = Collections - .newSetFromMap(new ConcurrentHashMap()); + private final ConcurrentHashMap enabledUsers = new ConcurrentHashMap(); /** * @@ -425,14 +423,25 @@ public class SessionFeedView extends SessionView { // only show sites you care about if (enabledSites.contains(siteName) || userEnabledSites.contains(siteName)) { - if (!enabledUsers.contains(user) && presence.isAvailable()) { - // New user - enabledUsers.add(user); - StringBuilder message = new StringBuilder(); - message.append(user); - message.append(" ").append(roleName).append(" ") - .append(siteName); - sendSystemMessage(message); + if (!enabledUsers.containsKey(user)) { + // Add user + enabledUsers.put(user, presence); + if (!presence.isAway()) { + // Send message + StringBuilder message = getMessage(roleName, siteName, user); + sendSystemMessage(message); + } + } else if (!presence.isAway()) { + Presence prev = enabledUsers.get(user); + if (!prev.getProperty(SiteConfigInformation.ROLE_NAME) + .toString().equals(roleName) + || !prev.getProperty(SiteConfigInformation.SITE_NAME) + .toString().equals(siteName)) { + // Send message + StringBuilder message = getMessage(roleName, siteName, user); + sendSystemMessage(message); + enabledUsers.put(user, presence); + } } } @@ -444,6 +453,23 @@ public class SessionFeedView extends SessionView { refreshParticipantList(); } + /** + * Get the status message. + * + * @param roleName + * @param siteName + * @param user + * + * @return The StringBuilder instance holding the message + */ + private StringBuilder getMessage(String roleName, String siteName, + String user) { + StringBuilder message = new StringBuilder(); + message.append(user); + message.append(" ").append(roleName).append(" ").append(siteName); + return message; + } + /** * No operation for Session Feed View */ @@ -459,7 +485,7 @@ public class SessionFeedView extends SessionView { @Override protected void participantDeparted(VenueParticipant participant, String description) { - if (enabledUsers.remove(participant.getName())) { + if (enabledUsers.remove(participant.getName()) != null) { super.participantDeparted(participant, description); } }