From fc1cc39479f3fe3034f2b1d7162cd03fa69f9f01 Mon Sep 17 00:00:00 2001 From: Mike Duff Date: Wed, 12 Mar 2014 10:20:32 -0500 Subject: [PATCH] Issue #2632 - Don't execute notifier on null presence, fix bug with group in UI when deleting last user in group, property change to handle String and Boolean. Change-Id: I533e0831529038cb4205e38e706369ca74f4f824 Former-commit-id: 8068c9aa835ace0cec684921f78e7739649141f1 [formerly 8068c9aa835ace0cec684921f78e7739649141f1 [formerly 13f134bafc5331939e23ce0e14d350593bb7c2e1]] Former-commit-id: e01c5c35348b1710cc80a944ae50f8a5c6517e82 Former-commit-id: 832dd498fc33991520e77cf93eef6a15a9b9eb97 --- .../ui/CollaborationGroupView.java | 18 +++++++++++++++- .../ui/notifier/NotifierTools.java | 5 +++++ .../prefs/AutoSubscribePropertyListener.java | 21 +++++++++++++------ 3 files changed, 37 insertions(+), 7 deletions(-) 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 6be31ead13..facbba4747 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 @@ -84,6 +84,7 @@ import org.osgi.framework.Bundle; import com.google.common.eventbus.Subscribe; import com.raytheon.uf.viz.collaboration.comm.identity.IVenueSession; import com.raytheon.uf.viz.collaboration.comm.identity.event.IRosterChangeEvent; +import com.raytheon.uf.viz.collaboration.comm.identity.event.RosterChangeType; import com.raytheon.uf.viz.collaboration.comm.provider.event.ServerDisconnectEvent; import com.raytheon.uf.viz.collaboration.comm.provider.event.UserPresenceChangedEvent; import com.raytheon.uf.viz.collaboration.comm.provider.session.CollaborationConnection; @@ -147,6 +148,7 @@ import com.raytheon.viz.ui.views.CaveFloatingView; * 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. + * Mar 12, 2014 2632 mpduff Force group deletes from UI if last user is removed. * * * @@ -877,11 +879,25 @@ public class CollaborationGroupView extends CaveFloatingView implements @Subscribe public void handleRosterChangeEvent(IRosterChangeEvent rosterChangeEvent) { + /* + * If a user is deleted and that user is the only user in a group the + * group does not get removed from the UI even though the group was + * deleted within XMPP. Force the delete here. + */ + if (rosterChangeEvent.getType() == RosterChangeType.DELETE) { + ContactsManager contacts = CollaborationConnection.getConnection() + .getContactsManager(); + for (RosterGroup group : contacts.getGroups()) { + if (group.getEntryCount() == 0) { + groupDeleted(group); + } + } + } + // Refresh the whole tree since there can be instances of the same user // elsewhere that might not .equals this one. refreshUsersTreeViewerAsync(usersTreeViewer.getInput()); NotifierTools.processNotifiers(rosterChangeEvent.getPresence()); - } @Subscribe diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/notifier/NotifierTools.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/notifier/NotifierTools.java index a519c50f4d..072491c1cb 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/notifier/NotifierTools.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/notifier/NotifierTools.java @@ -62,6 +62,7 @@ import com.raytheon.uf.viz.core.sounds.SoundUtil; * ------------ ---------- ----------- -------------------------- * Feb 24, 2014 2632 mpduff Initial creation. * Mar 05, 2014 2632 mpduff Removed unused field. + * Mar 12, 2014 2632 mpduff Don't process the notifier if the presence is null. * * * @@ -92,6 +93,10 @@ public class NotifierTools { * The updated Presence */ public static void processNotifiers(Presence presence) { + if (presence == null) { + return; + } + UserId userId = IDConverter.convertFrom(presence.getFrom()); NotifierTask task = NotifierTools.getNotifierTask(userId.getName()); if (task != null && task.getUserName().equals(userId.getName())) { diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/prefs/AutoSubscribePropertyListener.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/prefs/AutoSubscribePropertyListener.java index 832c379b3e..42a0aa2224 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/prefs/AutoSubscribePropertyListener.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/prefs/AutoSubscribePropertyListener.java @@ -52,6 +52,7 @@ import com.raytheon.uf.viz.core.VizApp; * Jan 24, 2014 2700 bclement Initial creation * Feb 3, 2014 2699 bclement fixed assumption that username search was exact * Feb 13, 2014 2755 bclement added user input for which group to add contact to + * Mar 12, 2014 2632 mpduff Property change to handle String and Boolean * * * @@ -114,7 +115,15 @@ public class AutoSubscribePropertyListener implements IPropertyChangeListener { if (event.getProperty().equals( CollabPrefConstants.AUTO_ACCEPT_SUBSCRIBE) && accountManager != null) { - updateManager((Boolean) event.getNewValue()); + + // The HierarchicalPreferenceStore store sometimes returns a string + Object valueObject = event.getNewValue(); + + if (valueObject instanceof Boolean) { + updateManager((Boolean) valueObject); + } else { + updateManager(Boolean.valueOf(valueObject.toString())); + } } } @@ -153,7 +162,7 @@ public class AutoSubscribePropertyListener implements IPropertyChangeListener { */ private ISubscriptionResponder newResponder() { return new ISubscriptionResponder() { - + private final UserSearch search = connection.createSearch(); @Override @@ -170,14 +179,14 @@ public class AutoSubscribePropertyListener implements IPropertyChangeListener { String displayName = getDisplayName(fromID); StringBuilder builder = new StringBuilder(); builder.append(fromID.getFQName()); - if ( displayName != null){ - builder.append(" (").append(displayName).append(")"); + if (displayName != null) { + builder.append(" (").append(displayName).append(")"); } builder.append(" wants to add you to his or her contacts list."); final String msg = builder.toString(); final SubscriptionResponse rval = new SubscriptionResponse(); VizApp.runSync(new Runnable() { - + @Override public void run() { Shell shell = new Shell(Display.getCurrent()); @@ -192,7 +201,7 @@ public class AutoSubscribePropertyListener implements IPropertyChangeListener { return rval; } - + /** * Get display name for user from server *