diff --git a/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/provider/info/Venue.java b/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/provider/info/Venue.java index 9b462a8807..e735c5df89 100644 --- a/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/provider/info/Venue.java +++ b/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/provider/info/Venue.java @@ -21,10 +21,8 @@ package com.raytheon.uf.viz.collaboration.comm.provider.info; import java.util.ArrayList; import java.util.Collection; -import java.util.HashMap; import java.util.Iterator; import java.util.List; -import java.util.Map; import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.packet.Presence; @@ -51,6 +49,7 @@ import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueParticipant; * Jan 28, 2014 2698 bclement removed getInfo, added methods to replace * Jan 30, 2014 2698 bclement changed UserId to VenueParticipant, getSubject never returns null * Feb 13, 2014 2751 bclement changed to use VenueParticipant handle instead of alias + * Mar 05, 2014 2798 mpduff Get Presence from MUC. * * * @@ -61,8 +60,6 @@ public class Venue implements IVenue { private final MultiUserChat muc; - private Map presenceMap = new HashMap(); - public Venue(XMPPConnection conn, MultiUserChat muc) { this.muc = muc; } @@ -80,7 +77,7 @@ public class Venue implements IVenue { @Override public Presence getPresence(VenueParticipant user) { - Presence presence = presenceMap.get(user.getHandle()); + Presence presence = muc.getOccupantPresence(user.getFQName()); if (presence == null) { presence = new Presence(Type.unavailable); presence.setMode(Mode.away); @@ -88,10 +85,6 @@ public class Venue implements IVenue { return presence; } - public void handlePresenceUpdated(VenueParticipant fromID, Presence presence) { - presenceMap.put(fromID.getHandle(), presence); - } - /* * (non-Javadoc) * diff --git a/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/provider/session/VenueSession.java b/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/provider/session/VenueSession.java index f2e77b9bd8..cad4723291 100644 --- a/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/provider/session/VenueSession.java +++ b/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/provider/session/VenueSession.java @@ -100,6 +100,7 @@ import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueParticipant; * Feb 18, 2014 2751 bclement Fixed history message 'from' type * Feb 18, 2014 2751 bclement log privilege changes instead of spamming chat window * Feb 24, 2014 2751 bclement added isRoomOwner() + * Mar 05, 2014 2798 mpduff Don't handle Presence, get from MUC instead.. * * * @@ -107,7 +108,6 @@ import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueParticipant; * @version 1.0 * @see com.raytheon.uf.viz.collaboration.comm.identity.event.IVenueParticipantEvent * @see com.raytheon.uf.viz.collaboration.comm.provider.TextMessage - * @see com.raytheon.uf.viz.collaboration.comm.provider.CollaborationMessage */ public class VenueSession extends BaseSession implements IVenueSession { @@ -519,7 +519,7 @@ public class VenueSession extends BaseSession implements IVenueSession { logParticipantEvent(participant, ParticipantEventType.UPDATED, "is now an admin."); } - + private void logParticipantEvent(String participant, ParticipantEventType type, String desciption) { StringBuilder builder = new StringBuilder(); @@ -537,6 +537,7 @@ public class VenueSession extends BaseSession implements IVenueSession { VenueParticipantEvent event = new VenueParticipantEvent(user, type); event.setEventDescription(desciption); + postEvent(event); } @@ -551,7 +552,6 @@ public class VenueSession extends BaseSession implements IVenueSession { String fromID = p.getFrom(); VenueParticipant user = IDConverter.convertFromRoom(muc, fromID); - venue.handlePresenceUpdated(user, p); postEvent(new VenueParticipantEvent(user, p, ParticipantEventType.PRESENCE_UPDATED)); } diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/CollaborationGroupView.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/CollaborationGroupView.java index 346d296f9d..6be31ead13 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/CollaborationGroupView.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/CollaborationGroupView.java @@ -146,6 +146,7 @@ import com.raytheon.viz.ui.views.CaveFloatingView; * Feb 12, 2014 2799 bclement fixed double click chat not working for roster entries * Feb 24, 2014 2632 mpduff Add Notifier actions. * Mar 05, 2014 2837 bclement separate rename action for groups, added more icons + * Mar 05, 2014 2798 mpduff Add getter for displayFeedAction. * * * @@ -950,4 +951,11 @@ public class CollaborationGroupView extends CaveFloatingView implements } }); } + + /** + * @return the displayFeedAction + */ + public DisplayFeedAction getDisplayFeedAction() { + return displayFeedAction; + } } diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/actions/CollaborationGroupAction.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/actions/CollaborationGroupAction.java index 3ec54b0106..3362de86e8 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/actions/CollaborationGroupAction.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/actions/CollaborationGroupAction.java @@ -43,7 +43,8 @@ import com.raytheon.viz.ui.views.CaveWorkbenchPageManager; * * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Mar 1, 2012 rferrel Initial creation + * Mar 1, 2012 rferrel Initial creation + * Mar 05, 2014 2798 mpduff Don't create a new DisplayFeedAction * * * @@ -58,6 +59,9 @@ public class CollaborationGroupAction extends AbstractHandler { public Object execute(ExecutionEvent event) throws ExecutionException { // this opens the collaboration group view try { + // If connection is null then user has not logged in + boolean initialExecutionFlag = CollaborationConnection + .getConnection() == null; new LoginAction().run(); CollaborationConnection connection = CollaborationConnection .getConnection(); @@ -66,15 +70,18 @@ public class CollaborationGroupAction extends AbstractHandler { return event; } - CaveWorkbenchPageManager.getActiveInstance().showView( - CollaborationGroupView.ID); + CollaborationGroupView view = (CollaborationGroupView) CaveWorkbenchPageManager + .getActiveInstance().showView(CollaborationGroupView.ID); - // if autojoin is selected (to join the default room) - if (Activator.getDefault().getPreferenceStore() - .getBoolean(CollabPrefConstants.AUTO_JOIN)) { - DisplayFeedAction displayFeed = new DisplayFeedAction(); - displayFeed.setChecked(true); - displayFeed.run(); + // Is this is the first log in + if (initialExecutionFlag) { + // if autojoin is selected (to join the default room) + if (Activator.getDefault().getPreferenceStore() + .getBoolean(CollabPrefConstants.AUTO_JOIN)) { + DisplayFeedAction action = view.getDisplayFeedAction(); + action.setChecked(true); + action.run(); + } } } catch (PartInitException e) { statusHandler.handle(Priority.PROBLEM, 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 1f21fe89a3..455c747a08 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,7 +20,10 @@ 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; import org.eclipse.jface.action.IMenuManager; @@ -66,6 +69,7 @@ import com.raytheon.uf.viz.core.icon.IconUtil; * Feb 13, 2014 2751 bclement VenueParticipant refactor * Feb 18, 2014 2631 mpduff Add processJoinAlert() * Feb 19, 2014 2751 bclement add change color icon, fix NPE when user cancels change color + * Mar 05, 2014 2798 mpduff Changed how messages are processed for the feed view. * * * @@ -91,6 +95,12 @@ public class SessionFeedView extends SessionView { private List colors; + /** + * Set of users logged in. + */ + private final Set enabledUsers = Collections + .newSetFromMap(new ConcurrentHashMap()); + /** * */ @@ -382,17 +392,7 @@ public class SessionFeedView extends SessionView { @Override protected void sendParticipantSystemMessage(VenueParticipant participant, String message) { - Presence presence = session.getVenue().getPresence(participant); - Object siteObj = presence.getProperty(SiteConfigInformation.SITE_NAME); - String siteName = siteObj == null ? "" : siteObj.toString(); - // only show sites you care about - if (enabledSites.contains(siteName) - || userEnabledSites.contains(siteName)) { - super.sendParticipantSystemMessage(participant, message); - } else { - usersTable.setInput(session.getVenue().getParticipants()); - usersTable.refresh(); - } + super.sendParticipantSystemMessage(participant, message); } /* @@ -406,8 +406,56 @@ public class SessionFeedView extends SessionView { @Override protected void participantPresenceUpdated(VenueParticipant participant, Presence presence) { - setColorForSite(participant, presence); - super.participantPresenceUpdated(participant, presence); + usersTable.refresh(); + + // Verify we have properties + if (!presence.getPropertyNames().contains( + SiteConfigInformation.SITE_NAME)) { + return; + } + + Object roleObj = presence.getProperty(SiteConfigInformation.ROLE_NAME); + String roleName = roleObj == null ? "" : roleObj.toString(); + Object siteObj = presence.getProperty(SiteConfigInformation.SITE_NAME); + String siteName = siteObj == null ? "" : siteObj.toString(); + String user = participant.getName(); + + // 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); + setColorForSite(participant, presence); + sendSystemMessage(message); + processJoinAlert(); + } + } + } + + /** + * No operation for Session Feed View + */ + @Override + protected void participantArrived(VenueParticipant participant, + String description) { + usersTable.setInput(session.getVenue().getParticipants()); + usersTable.refresh(); + } + + /** + * {@inheritDoc} + */ + @Override + protected void participantDeparted(VenueParticipant participant, + String description) { + if (enabledUsers.remove(participant.getName())) { + super.participantDeparted(participant, description); + } } /* diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/SessionView.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/SessionView.java index 1255d765eb..aa10d3662a 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/SessionView.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/SessionView.java @@ -102,6 +102,8 @@ import com.raytheon.viz.ui.views.CaveWorkbenchPageManager; * Feb 13, 2014 2751 bclement VenueParticipant refactor * Feb 18, 2014 2631 mpduff Add processJoinAlert() * Feb 24, 2014 2632 mpduff Move playSound to CollaborationUtils + * Mar 05, 2014 2798 mpduff Moved processJoinAlert() call from participantHandler + * to participantArrived. * * * @@ -632,7 +634,6 @@ public class SessionView extends AbstractSessionView switch (type) { case ARRIVED: participantArrived(participant, description); - processJoinAlert(); break; case DEPARTED: participantDeparted(participant, description); @@ -671,6 +672,7 @@ public class SessionView extends AbstractSessionView String message = description != null ? description : "has entered the room."; sendParticipantSystemMessage(participant, message); + processJoinAlert(); } /** @@ -728,7 +730,6 @@ public class SessionView extends AbstractSessionView protected SessionMsgArchive createMessageArchive() { String sessionName = getSessionName(); UserId me = CollaborationConnection.getConnection().getUser(); - // UserId me = session.getUserID(); return new SessionMsgArchive(me.getHost(), me.getName(), sessionName); }