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: bb2b251cd0 [formerly 6444131768] [formerly 8068c9aa83] [formerly e01c5c3534 [formerly 8068c9aa83 [formerly 13f134bafc5331939e23ce0e14d350593bb7c2e1]]]
Former-commit-id: e01c5c3534
Former-commit-id: ea4a4997b336401081920b43fb91017011502ca3 [formerly 832dd498fc]
Former-commit-id: 4fddc0c631
This commit is contained in:
Mike Duff 2014-03-12 10:20:32 -05:00
parent 054d624717
commit cbc15d479a
3 changed files with 37 additions and 7 deletions

View file

@ -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.
*
* </pre>
*
@ -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

View file

@ -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.
*
* </pre>
*
@ -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())) {

View file

@ -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
*
* </pre>
*
@ -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
*