diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/data/CollaborationDataManager.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/data/CollaborationDataManager.java index 7006043632..58317f6ef2 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/data/CollaborationDataManager.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/data/CollaborationDataManager.java @@ -60,6 +60,7 @@ import com.raytheon.uf.viz.collaboration.comm.identity.invite.SharedDisplayVenue import com.raytheon.uf.viz.collaboration.comm.identity.roster.IRoster; import com.raytheon.uf.viz.collaboration.comm.identity.roster.IRosterEntry; import com.raytheon.uf.viz.collaboration.comm.identity.roster.IRosterGroup; +import com.raytheon.uf.viz.collaboration.comm.identity.roster.IRosterItem; import com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID; import com.raytheon.uf.viz.collaboration.comm.identity.user.SharedDisplayRole; import com.raytheon.uf.viz.collaboration.comm.provider.Presence; @@ -67,7 +68,6 @@ import com.raytheon.uf.viz.collaboration.comm.provider.TextMessage; import com.raytheon.uf.viz.collaboration.comm.provider.roster.RosterEntry; import com.raytheon.uf.viz.collaboration.comm.provider.session.CollaborationConnection; import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId; -import com.raytheon.uf.viz.collaboration.ui.CollaborationUtils; import com.raytheon.uf.viz.collaboration.ui.SessionColorManager; import com.raytheon.uf.viz.collaboration.ui.editor.CollaborationEditor; import com.raytheon.uf.viz.collaboration.ui.login.LoginData; @@ -104,7 +104,7 @@ public class CollaborationDataManager implements IRosterEventSubscriber { */ private CollaborationConnection sessionManager; - String loginId; + private UserId loginId; private LoginData loginData; @@ -119,9 +119,9 @@ public class CollaborationDataManager implements IRosterEventSubscriber { /** * User information such as sessions and groups user is in. */ - Map usersMap; + Map usersMap; - Set groupsSet; + Set groups; private boolean linkCollaboration; @@ -159,36 +159,25 @@ public class CollaborationDataManager implements IRosterEventSubscriber { */ private CollaborationDataManager() { linkCollaboration = false; - groupsSet = new HashSet(); - usersMap = new HashMap(); + groups = new HashSet(); + usersMap = new HashMap(); sessionsMap = new HashMap(); eventBus = new EventBus(); } private void populateGroups() { IRoster roster = sessionManager.getRosterManager().getRoster(); - System.out.println("rosterManager Name " + roster.getUser().getName() - + ": group size " + roster.getGroups().size() + ": entry size " - + roster.getEntries().size()); - - groupsSet.clear(); for (IRosterGroup rosterGroup : roster.getGroups()) { - String groupName = rosterGroup.getName(); - DataGroup group = new DataGroup(groupName); - groupsSet.add(group); + groups.add(rosterGroup); for (IRosterEntry rosterEntry : rosterGroup.getEntries()) { - DataUser user = getUser(CollaborationUtils - .makeUserId(rosterEntry)); - user.addGroup(groupName); - user.setPresence(rosterEntry.getPresence()); + usersMap.put(rosterEntry.getUser(), rosterEntry); } } // Orphan users not in any group. for (IRosterEntry rosterEntry : roster.getEntries()) { - DataUser user = getUser(CollaborationUtils.makeUserId(rosterEntry)); - user.setPresence(rosterEntry.getPresence()); + usersMap.put(rosterEntry.getUser(), rosterEntry); } } @@ -200,29 +189,23 @@ public class CollaborationDataManager implements IRosterEventSubscriber { * display. * @return groups */ - public List getGroups(boolean allGroups) { - List result = new ArrayList(); + public List getGroups(boolean allGroups) { + List result = new ArrayList(); if (allGroups) { - for (DataGroup dataGroup : groupsSet) { - result.add(dataGroup.getId()); - } - } else { - for (DataGroup dataGroup : groupsSet) { - if (dataGroup.isDisplay()) { - result.add(dataGroup.getId()); - } + for (IRosterGroup dataGroup : groups) { + result.add(dataGroup); } } return result; } - public List getUsersInGroup(String groupId) { - List userList = new ArrayList(); - for (String userId : usersMap.keySet()) { - DataUser user = usersMap.get(userId); - for (String group : user.groups) { + public List getUsersInGroup(IRosterItem groupId) { + List userList = new ArrayList(); + for (UserId userId : usersMap.keySet()) { + IRosterEntry user = usersMap.get(userId); + for (IRosterGroup group : user.getGroups()) { if (groupId.equals(group)) { - userList.add(userId); + userList.add(user); break; } } @@ -232,39 +215,14 @@ public class CollaborationDataManager implements IRosterEventSubscriber { public boolean displayGroup(String groupId) { boolean display = true; - for (DataGroup group : groupsSet) { - if (groupId.equals(group.getId())) { - display = group.isDisplay(); - break; - } - } + // TODO maybe need to make this displayGroup function do something return display; } - public List getOrphanUsers() { - List orphanList = new ArrayList(); - for (String userId : usersMap.keySet()) { - DataUser user = usersMap.get(userId); - if (user.groups.size() == 0 && userId.equals(loginId) == false) { - orphanList.add(userId); - } - } - return orphanList; - } - - public String getLoginId() { + public UserId getLoginId() { return loginId; } - public DataUser getUser(String id) { - DataUser user = usersMap.get(id); - if (user == null) { - user = new DataUser(id); - usersMap.put(id, user); - } - return usersMap.get(id); - } - public void setLinkCollaboration(boolean state) { this.linkCollaboration = state; } @@ -287,7 +245,7 @@ public class CollaborationDataManager implements IRosterEventSubscriber { * * @return sessionManager or null if unable to get connection. */ - synchronized public CollaborationConnection getSessionManager() { + synchronized public CollaborationConnection getCollaborationConnection() { // Get user's server account information and make connection. if (isConnected() == false) { VizApp.runSync(new Runnable() { @@ -495,7 +453,7 @@ public class CollaborationDataManager implements IRosterEventSubscriber { */ public String createCollaborationSession(String venue, String subject) throws CollaborationException { - CollaborationConnection sessionManager = getSessionManager(); + CollaborationConnection sessionManager = getCollaborationConnection(); IVenueSession session = null; String sessionId = null; // try { @@ -517,7 +475,7 @@ public class CollaborationDataManager implements IRosterEventSubscriber { public String createTextOnlySession(String venueName, String subject) throws CollaborationException { - CollaborationConnection sessionManager = getSessionManager(); + CollaborationConnection sessionManager = getCollaborationConnection(); IVenueSession session = null; String sessionId = null; session = sessionManager.createTextOnlyVenue(venueName, subject); @@ -683,10 +641,8 @@ public class CollaborationDataManager implements IRosterEventSubscriber { @Subscribe public void handleModifiedPresence(IRosterEntry entry) { final IRosterEntry rosterEntry = entry; - String userId = CollaborationUtils.makeUserId(rosterEntry); - DataUser user = usersMap.get(userId); + IRosterEntry user = usersMap.get(entry.getUser()); if (user != null) { - user.setPresence(rosterEntry.getPresence()); // Assumes only UI updates will be registered. VizApp.runAsync(new Runnable() { @@ -709,10 +665,6 @@ public class CollaborationDataManager implements IRosterEventSubscriber { final IRosterChangeEvent rosterChangeEvent = event; // TODO update the event's user groups here for the desired type IRosterEntry rosterEntry = rosterChangeEvent.getEntry(); - String userId = CollaborationUtils.makeUserId(rosterEntry); - DataUser user = getUser(userId); - System.out.println("=== RosterChangeEvent<" + event.getType() + ">: " - + userId); IPresence presence = rosterChangeEvent.getEntry().getPresence(); if (presence != null) { System.out.println("\t" + presence.getMode() + "/" @@ -722,39 +674,39 @@ public class CollaborationDataManager implements IRosterEventSubscriber { Collection userGroups = rosterEntry.getGroups(); switch (rosterChangeEvent.getType()) { case ADD: - user.clearGroups(); for (IRosterGroup group : userGroups) { - String groupName = group.getName(); - user.addGroup(groupName); - DataGroup dataGroup = null; - for (DataGroup dGroup : groupsSet) { - if (groupName.equals(dGroup.getId())) { - dataGroup = dGroup; + boolean matched = false; + for (IRosterGroup dGroup : groups) { + if (dGroup.getName().equals(group.getName())) { + dGroup = group; + matched = true; break; } } - if (dataGroup == null) { - groupsSet.add(new DataGroup(groupName)); + if (!matched) { + groups.add(group); } } break; case DELETE: // Assume user no longer exists and remove. - usersMap.remove(user); + usersMap.remove(rosterEntry); break; case MODIFY: // Assume only the presence needs to be updated. - IPresence precsence = rosterEntry.getPresence(); - if (precsence == null) { + if (presence == null) { // Nothing to do don't bother doing eventBus post. return; } - user.setPresence(precsence); + for (UserId id : usersMap.keySet()) { + if (rosterEntry.getUser().equals(id)) { + usersMap.put(id, rosterEntry); + break; + } + } + break; + case PRESENCE: break; - // case PRESENCE: - // System.out.println("\tIgnore assume only presence change"); - // return; - // break; default: statusHandler.handle(Priority.PROBLEM, "Unhandled type: " + rosterChangeEvent.getType()); @@ -771,6 +723,13 @@ public class CollaborationDataManager implements IRosterEventSubscriber { }); } + /** + * @return the usersMap + */ + public Map getUsersMap() { + return usersMap; + } + public void registerEventHandler(Object handler) { eventBus.register(handler); } diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/data/CollaborationGroup.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/data/CollaborationGroup.java deleted file mode 100644 index 7fae512811..0000000000 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/data/CollaborationGroup.java +++ /dev/null @@ -1,105 +0,0 @@ -/** - * This software was developed and / or modified by Raytheon Company, - * pursuant to Contract DG133W-05-CQ-1067 with the US Government. - * - * U.S. EXPORT CONTROLLED TECHNICAL DATA - * This software product contains export-restricted data whose - * export/transfer/disclosure is restricted by U.S. law. Dissemination - * to non-U.S. persons whether in the United States or abroad requires - * an export license or other authorization. - * - * Contractor Name: Raytheon Company - * Contractor Address: 6825 Pine Street, Suite 340 - * Mail Stop B8 - * Omaha, NE 68106 - * 402.291.0100 - * - * See the AWIPS II Master Rights File ("Master Rights File.pdf") for - * further licensing information. - **/ -package com.raytheon.uf.viz.collaboration.data; - -import java.util.ArrayList; -import java.util.List; - -/** - * TODO Add Description - * - *
- * 
- * SOFTWARE HISTORY
- * 
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * Feb 22, 2012            mnash     Initial creation
- * 
- * 
- * - * @author mnash - * @version 1.0 - */ - -public class CollaborationGroup extends CollaborationNode { - protected boolean modifiable; - - protected List children; - - public CollaborationGroup(String id) { - super(id); - children = new ArrayList(); - } - - /** - * @param modifiable - * the modifiable to set - */ - public void setModifiable(boolean modifiable) { - this.modifiable = modifiable; - } - - public boolean getModifiable() { - return modifiable; - } - - public void addChild(CollaborationNode child) { - children.add(child); - } - - /** - * @return the users - */ - public List getChildren() { - return children; - } - - public void removeChild(CollaborationNode child) { - if (children.contains(child)) { - if (child instanceof CollaborationGroup) { - CollaborationGroup groupNode = (CollaborationGroup) child; - groupNode.removeChildren(); - } - children.remove(child); - } - } - - public void removeChildren() { - for (CollaborationNode child : children) { - if (child instanceof CollaborationGroup) { - CollaborationGroup groupNode = (CollaborationGroup) child; - groupNode.removeChildren(); - } - } - children.clear(); - } - - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.viz.collaboration.data.CollaborationNode#getImageKey() - */ - @Override - public String getImageKey() { - return "group"; - } -} diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/data/SessionGroup.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/data/CollaborationGroupContainer.java similarity index 59% rename from cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/data/SessionGroup.java rename to cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/data/CollaborationGroupContainer.java index 7326914e42..ab564a8baf 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/data/SessionGroup.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/data/CollaborationGroupContainer.java @@ -19,6 +19,9 @@ **/ package com.raytheon.uf.viz.collaboration.data; +import java.util.ArrayList; +import java.util.List; + /** * TODO Add Description * @@ -28,42 +31,48 @@ package com.raytheon.uf.viz.collaboration.data; * * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Mar 6, 2012 rferrel Initial creation + * Apr 23, 2012 mnash Initial creation * * * - * @author rferrel + * @author mnash * @version 1.0 */ -public class SessionGroup extends CollaborationGroup { - boolean sessionRoot; +public class CollaborationGroupContainer { + private List objects; - public SessionGroup(String id) { - super(id); - this.sessionRoot = false; - } - - public boolean isSessionRoot() { - return sessionRoot; - } - - public void setSessionRoot(boolean sessionRoot) { - this.sessionRoot = sessionRoot; - } - - public void setId(String id) { - this.id = id; - } - - /* - * (non-Javadoc) + /** * - * @see - * com.raytheon.uf.viz.collaboration.data.CollaborationNode#getImageKey() */ - @Override - public String getImageKey() { - return "session_group"; + public CollaborationGroupContainer() { + objects = new ArrayList(); + } + + /** + * @param objects + * the objects to set + */ + public void setObjects(List objects) { + this.objects = objects; + } + + /** + * @return the objects + */ + public List getObjects() { + return objects; + } + + public void addObject(Object o) { + objects.add(o); + } + + public void removeObject(Object o) { + objects.remove(o); + } + + public void clear() { + objects.clear(); } } diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/data/CollaborationNode.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/data/CollaborationNode.java deleted file mode 100644 index 146da69d64..0000000000 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/data/CollaborationNode.java +++ /dev/null @@ -1,99 +0,0 @@ -/** - * This software was developed and / or modified by Raytheon Company, - * pursuant to Contract DG133W-05-CQ-1067 with the US Government. - * - * U.S. EXPORT CONTROLLED TECHNICAL DATA - * This software product contains export-restricted data whose - * export/transfer/disclosure is restricted by U.S. law. Dissemination - * to non-U.S. persons whether in the United States or abroad requires - * an export license or other authorization. - * - * Contractor Name: Raytheon Company - * Contractor Address: 6825 Pine Street, Suite 340 - * Mail Stop B8 - * Omaha, NE 68106 - * 402.291.0100 - * - * See the AWIPS II Master Rights File ("Master Rights File.pdf") for - * further licensing information. - **/ -package com.raytheon.uf.viz.collaboration.data; - -/** - * TODO Add Description - * - *
- * 
- * SOFTWARE HISTORY
- * 
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * Feb 22, 2012            mnash     Initial creation
- * 
- * 
- * - * @author mnash - * @version 1.0 - */ - -public class CollaborationNode implements Comparable { - - private String text; - - private boolean local; - - String id; - - public CollaborationNode(String id) { - super(); - this.id = id; - } - - public String getId() { - return id; - } - - public String getImageKey() { - return null; - } - - /** - * @return the name - */ - public String getText() { - return text; - } - - /** - * @param name - * the name to set - */ - public void setText(String text) { - this.text = text; - } - - /** - * @return the buddy - */ - public boolean isLocal() { - return local; - } - - /** - * @param buddy - * the buddy to set - */ - public void setLocal(boolean local) { - this.local = local; - } - - /* - * (non-Javadoc) - * - * @see java.lang.Comparable#compareTo(java.lang.Object) - */ - @Override - public int compareTo(CollaborationNode o) { - return id.compareTo(o.id); - } -} diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/data/CollaborationUser.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/data/CollaborationUser.java deleted file mode 100644 index bcde202ee1..0000000000 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/data/CollaborationUser.java +++ /dev/null @@ -1,118 +0,0 @@ -package com.raytheon.uf.viz.collaboration.data; - -import com.raytheon.uf.viz.collaboration.comm.identity.IPresence; -import com.raytheon.uf.viz.collaboration.comm.identity.IPresence.Type; -import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId; - -/** - * This software was developed and / or modified by Raytheon Company, - * pursuant to Contract DG133W-05-CQ-1067 with the US Government. - * - * U.S. EXPORT CONTROLLED TECHNICAL DATA - * This software product contains export-restricted data whose - * export/transfer/disclosure is restricted by U.S. law. Dissemination - * to non-U.S. persons whether in the United States or abroad requires - * an export license or other authorization. - * - * Contractor Name: Raytheon Company - * Contractor Address: 6825 Pine Street, Suite 340 - * Mail Stop B8 - * Omaha, NE 68106 - * 402.291.0100 - * - * See the AWIPS II Master Rights File ("Master Rights File.pdf") for - * further licensing information. - **/ - -/** - * TODO Add Description - * - *
- * 
- * SOFTWARE HISTORY
- * 
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * Mar 1, 2012            rferrel     Initial creation
- * 
- * 
- * - * @author rferrel - * @version 1.0 - */ -public class CollaborationUser extends CollaborationNode { - - String session; - - UserId iChatID; - - public CollaborationUser(String id) { - super(id); - this.session = null; - // this.roles = new ArrayList(); - // this.status = DataUser.StatusType.NOT_ON_LINE; - // this.statusMessage = ""; - } - - public CollaborationUser(String id, String session) { - super(id); - this.session = session; - } - - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.viz.collaboration.data.CollaborationNode#getImageKey() - */ - @Override - public String getImageKey() { - if (getType() == Type.AVAILABLE) { - return getMode().toString(); - } - return "contact_disabled"; - } - - public IPresence.Mode getMode() { - return CollaborationDataManager.getInstance().getUser(id).mode; - } - - public IPresence.Type getType() { - return CollaborationDataManager.getInstance().getUser(id).type; - } - - public void setPresence(IPresence presence) { - CollaborationDataManager.getInstance().getUser(id) - .setPresence(presence); - } - - // public void setMode(IPresence.Mode mode) { - // CollaborationDataManager.getInstance().getUser(id).mode = mode; - // } - // - // public void setType(IPresence.Type type) { - // CollaborationDataManager.getInstance().getUser(id).type = type; - // } - - // public void setStatus(IPresence.Mode mode) { - // if (mode.getMode().equals(Mode.AWAY)) { - // CollaborationDataManager.getInstance().getUser(id).mode = - // StatusType.AWAY; - // } else if (mode.getMode().equals(Mode.DND)) { - // CollaborationDataManager.getInstance().getUser(id).mode = - // StatusType.DO_NOT_DISTURB; - // } else if (mode.getMode().equals(Mode.AVAILABLE)) { - // CollaborationDataManager.getInstance().getUser(id).mode = - // StatusType.AVAILABLE; - // } - // } - - public String getStatusMessage() { - return CollaborationDataManager.getInstance().getUser(id).statusMessage; - } - - // public void setStatusMessage(String statusMessage) { - // CollaborationDataManager.getInstance().getUser(id).statusMessage = - // statusMessage; - // } -} diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/data/DataGroup.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/data/DataGroup.java deleted file mode 100644 index 7125ebcd95..0000000000 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/data/DataGroup.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * This software was developed and / or modified by Raytheon Company, - * pursuant to Contract DG133W-05-CQ-1067 with the US Government. - * - * U.S. EXPORT CONTROLLED TECHNICAL DATA - * This software product contains export-restricted data whose - * export/transfer/disclosure is restricted by U.S. law. Dissemination - * to non-U.S. persons whether in the United States or abroad requires - * an export license or other authorization. - * - * Contractor Name: Raytheon Company - * Contractor Address: 6825 Pine Street, Suite 340 - * Mail Stop B8 - * Omaha, NE 68106 - * 402.291.0100 - * - * See the AWIPS II Master Rights File ("Master Rights File.pdf") for - * further licensing information. - **/ -package com.raytheon.uf.viz.collaboration.data; - -/** - * TODO Add Description - * - *
- * 
- * SOFTWARE HISTORY
- * 
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * Mar 1, 2012            rferrel     Initial creation
- * 
- * 
- * - * @author rferrel - * @version 1.0 - */ -public class DataGroup { - /** - * The fully qualified group name. When a subgroup the name should contain - * all the groups ancestors. For example if "C" is a subgroup of "B" which - * is a subgroup of "A" then C's id would be "A.B.C". - */ - String id; - - /** - * Indicates if the user wants to display the groups information. - */ - boolean display; - - /** - * Only allow classes in the package to use the constructor. - * - * @param id - */ - DataGroup(String id) { - this.id = id; - this.display = true; - } - - /** - * @return display - */ - public boolean isDisplay() { - return display; - } - - public void setDisplay(boolean display) { - this.display = display; - } - - public String getId() { - return id; - } -} diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/data/DataUser.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/data/DataUser.java deleted file mode 100644 index 57efba073b..0000000000 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/data/DataUser.java +++ /dev/null @@ -1,136 +0,0 @@ -/** - * This software was developed and / or modified by Raytheon Company, - * pursuant to Contract DG133W-05-CQ-1067 with the US Government. - * - * U.S. EXPORT CONTROLLED TECHNICAL DATA - * This software product contains export-restricted data whose - * export/transfer/disclosure is restricted by U.S. law. Dissemination - * to non-U.S. persons whether in the United States or abroad requires - * an export license or other authorization. - * - * Contractor Name: Raytheon Company - * Contractor Address: 6825 Pine Street, Suite 340 - * Mail Stop B8 - * Omaha, NE 68106 - * 402.291.0100 - * - * See the AWIPS II Master Rights File ("Master Rights File.pdf") for - * further licensing information. - **/ -package com.raytheon.uf.viz.collaboration.data; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import com.raytheon.uf.viz.collaboration.comm.identity.IPresence; -import com.raytheon.uf.viz.collaboration.comm.identity.IPresence.Mode; -import com.raytheon.uf.viz.collaboration.comm.identity.IPresence.Type; - -/** - * A Data class that contains all the user information needed for the current - * instance of CAVE. - * - *
- * 
- * SOFTWARE HISTORY
- * 
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * Mar 1, 2012             rferrel     Initial creation
- * 
- * 
- * - * @author rferrel - * @version 1.0 - */ - -public class DataUser { - private static final Map modeMap = new HashMap(); - static { - for (Mode mode : Mode.values()) { - modeMap.put(mode.name(), mode); - } - } - - IPresence.Mode mode; - - IPresence.Type type; - - String statusMessage; - - /** - * The groups being tracked that user belongs to. - */ - Set groups; - - /** - * The active sessions the user is in. - */ - private Map sessionsMap; - - /** - * Only allow classes in the package to use the constructor. - * - * @param id - */ - DataUser(String id) { - groups = new HashSet(); - sessionsMap = new HashMap(); - mode = Mode.EXTENDED_AWAY; - type = Type.UNKNOWN; - } - - public void addGroup(String group) { - groups.add(group); - } - - public Set getGroups() { - return groups; - } - - public void clearGroups() { - groups.clear(); - } - - public String getSessString(String key) { - return sessionsMap.get(key); - } - - public void setPresence(IPresence presence) { - type = presence.getType(); - mode = presence.getMode(); - statusMessage = presence.getStatusMessage(); - if (statusMessage == null) { - statusMessage = ""; - } - } - - // /** - // * @param mode - // * the mode to set - // */ - // public void setMode(Mode status) { - // this.mode = status; - // } - // - // public void setMode(String name) { - // this.mode = modeMap.get(name); - // } - - /** - * @return the mode - */ - public Mode getMode() { - return mode; - } - - public Type getType() { - return type; - } - - // public void setType(Type type) { - // this.type = type; - // } -} diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/data/OrphanGroup.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/data/OrphanGroup.java deleted file mode 100644 index 906eac56d6..0000000000 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/data/OrphanGroup.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * This software was developed and / or modified by Raytheon Company, - * pursuant to Contract DG133W-05-CQ-1067 with the US Government. - * - * U.S. EXPORT CONTROLLED TECHNICAL DATA - * This software product contains export-restricted data whose - * export/transfer/disclosure is restricted by U.S. law. Dissemination - * to non-U.S. persons whether in the United States or abroad requires - * an export license or other authorization. - * - * Contractor Name: Raytheon Company - * Contractor Address: 6825 Pine Street, Suite 340 - * Mail Stop B8 - * Omaha, NE 68106 - * 402.291.0100 - * - * See the AWIPS II Master Rights File ("Master Rights File.pdf") for - * further licensing information. - **/ -package com.raytheon.uf.viz.collaboration.data; - -/** - * A special group to places users not in any group. - * - *
- * 
- * SOFTWARE HISTORY
- * 
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * Apr 11, 2012            rferrel     Initial creation
- * 
- * 
- * - * @author rferrel - * @version 1.0 - */ - -public class OrphanGroup extends CollaborationGroup { - - /** - * @param id - */ - public OrphanGroup(String id) { - super(id); - } - -} diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/data/LoginUser.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/data/SessionGroupContainer.java similarity index 91% rename from cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/data/LoginUser.java rename to cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/data/SessionGroupContainer.java index 52929bb56d..f7ed6334f5 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/data/LoginUser.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/data/SessionGroupContainer.java @@ -36,8 +36,6 @@ package com.raytheon.uf.viz.collaboration.data; * @version 1.0 */ -public class LoginUser extends CollaborationUser { - public LoginUser(String id) { - super(id); - } +public class SessionGroupContainer extends CollaborationGroupContainer { + } diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/ChangePasswordDialog.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/ChangePasswordDialog.java index 3d5fed2541..183e2935d1 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/ChangePasswordDialog.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/ChangePasswordDialog.java @@ -37,6 +37,7 @@ import org.eclipse.swt.widgets.MessageBox; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; +import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId; import com.raytheon.uf.viz.collaboration.data.CollaborationDataManager; import com.raytheon.viz.ui.dialogs.CaveSWTDialog; @@ -72,7 +73,7 @@ public class ChangePasswordDialog extends CaveSWTDialog { private Control createDialogArea(Composite parent) { CollaborationDataManager manager = CollaborationDataManager .getInstance(); - String user = manager.getLoginId(); + UserId user = manager.getLoginId(); Composite body = new Composite(parent, SWT.NONE); body.setLayout(new GridLayout(2, false)); // body.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL @@ -83,7 +84,7 @@ public class ChangePasswordDialog extends CaveSWTDialog { gd = new GridData(SWT.FILL, SWT.FILL, true, true); gd.horizontalSpan = 2; userLabel.setLayoutData(gd); - userLabel.setText(user); + userLabel.setText(user.getFQName()); label = new Label(body, SWT.NONE); label.setText("New Password: "); 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 e3d4070313..42ff820ffa 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 @@ -41,6 +41,8 @@ import org.eclipse.jface.viewers.TreeSelection; import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.TreeEditor; +import org.eclipse.swt.events.FocusAdapter; +import org.eclipse.swt.events.FocusEvent; import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.events.MouseEvent; @@ -84,18 +86,15 @@ import com.raytheon.uf.viz.collaboration.comm.identity.invite.SharedDisplayVenue import com.raytheon.uf.viz.collaboration.comm.identity.invite.VenueInvite; import com.raytheon.uf.viz.collaboration.comm.identity.roster.IRosterEntry; import com.raytheon.uf.viz.collaboration.comm.identity.roster.IRosterGroup; +import com.raytheon.uf.viz.collaboration.comm.identity.roster.IRosterItem; import com.raytheon.uf.viz.collaboration.comm.identity.roster.IRosterManager; import com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID; -import com.raytheon.uf.viz.collaboration.comm.provider.Tools; import com.raytheon.uf.viz.collaboration.comm.provider.session.CollaborationConnection; import com.raytheon.uf.viz.collaboration.comm.provider.user.IDConverter; +import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId; import com.raytheon.uf.viz.collaboration.data.CollaborationDataManager; -import com.raytheon.uf.viz.collaboration.data.CollaborationGroup; -import com.raytheon.uf.viz.collaboration.data.CollaborationNode; -import com.raytheon.uf.viz.collaboration.data.CollaborationUser; -import com.raytheon.uf.viz.collaboration.data.LoginUser; -import com.raytheon.uf.viz.collaboration.data.OrphanGroup; -import com.raytheon.uf.viz.collaboration.data.SessionGroup; +import com.raytheon.uf.viz.collaboration.data.CollaborationGroupContainer; +import com.raytheon.uf.viz.collaboration.data.SessionGroupContainer; import com.raytheon.uf.viz.collaboration.data.SharedDisplaySessionMgr; import com.raytheon.uf.viz.collaboration.ui.editor.CollaborationEditor; import com.raytheon.uf.viz.collaboration.ui.login.ChangeStatusDialog; @@ -131,15 +130,11 @@ public class CollaborationGroupView extends ViewPart implements IPartListener { private static final transient IUFStatusHandler statusHandler = UFStatus .getHandler(CollaborationGroupView.class); - private static String ORPHAN_GROUP_ID = "Orphan Users"; - - private SessionGroup activeSessionGroup; + private SessionGroupContainer activeSessionGroup; private TreeViewer usersTreeViewer; - CollaborationGroup topLevel; - - Map groupMap; + private CollaborationGroupContainer topLevel; private Action createSessionAction; @@ -149,8 +144,6 @@ public class CollaborationGroupView extends ViewPart implements IPartListener { private Action joinAction; - private Action joinCollaborationAction; - private Action peerToPeerChatAction; private Action logonAction; @@ -159,18 +152,12 @@ public class CollaborationGroupView extends ViewPart implements IPartListener { private Action aliasAction; - private Action renameAction; - private Action addGroupAction; private Action addUserAction; private Action selectGroups; - private Action removeGroupAction; - - private Action removeUserAction; - private Action changeStatusMessageAction; private Action changeStatusAction; @@ -179,8 +166,6 @@ public class CollaborationGroupView extends ViewPart implements IPartListener { private Action drawToolbarAction; - // private Action refreshActiveSessionsAction; - private Action collapseAllAction; private TreeEditor treeEditor; @@ -245,10 +230,10 @@ public class CollaborationGroupView extends ViewPart implements IPartListener { .getSession(sessionId); String roomName = session.getVenue().getInfo() .getVenueDescription(); - List ids = new ArrayList(); + List ids = new ArrayList(); - for (CollaborationUser user : getSelectedUsers()) { - String id = user.getId(); + for (IRosterEntry user : getSelectedUsers()) { + UserId id = user.getUser(); System.out.println("Add Selected User: " + id); ids.add(id); } @@ -280,7 +265,8 @@ public class CollaborationGroupView extends ViewPart implements IPartListener { joinAction = new Action("Join Session") { @Override public void run() { - createJoinCollaboration(); + // TODO, maybe need to switch tab to the session here?, or is + // this even needed since we are already part of the session? } }; @@ -316,18 +302,9 @@ public class CollaborationGroupView extends ViewPart implements IPartListener { @Override public void run() { aliasItem(); - System.out.println("Alias"); }; }; - renameAction = new Action("Rename") { - @Override - public void run() { - System.out.println("Rename action"); - nyiFeature("Rename"); - } - }; - addUserAction = new Action("Add User") { public void run() { // addUsersToGroup(); @@ -422,15 +399,6 @@ public class CollaborationGroupView extends ViewPart implements IPartListener { }; changeStatusAction.setMenuCreator(creator); - removeGroupAction = new Action("Remove Group") { - public void run() { - }; - }; - removeUserAction = new Action("Remove User") { - public void run() { - }; - }; - drawToolbarAction = new Action("Drawing Toolbar") { @Override public void run() { @@ -443,7 +411,6 @@ public class CollaborationGroupView extends ViewPart implements IPartListener { } private void changePassword() { - System.out.println("Change password here"); ChangePasswordDialog dialog = new ChangePasswordDialog(Display .getCurrent().getActiveShell()); dialog.open(); @@ -452,14 +419,12 @@ public class CollaborationGroupView extends ViewPart implements IPartListener { if (result != null) { char[] password = result.toString().toCharArray(); CollaborationConnection sessionManager = CollaborationDataManager - .getInstance().getSessionManager(); + .getInstance().getCollaborationConnection(); try { sessionManager.getAccountManager().changePassword(password); } catch (CollaborationException e) { - // TODO Auto-generated catch block. Please revise as - // appropriate. - statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), - e); + statusHandler.handle(Priority.PROBLEM, + "Unable to change password", e); } } } @@ -538,17 +503,30 @@ public class CollaborationGroupView extends ViewPart implements IPartListener { } TreeSelection selection = (TreeSelection) usersTreeViewer .getSelection(); - selection.getFirstElement(); + final IRosterEntry entry = (IRosterEntry) selection.getFirstElement(); Text newEditor = new Text(usersTreeViewer.getTree(), SWT.NONE); - newEditor.setText(((CollaborationNode) selection.getFirstElement()) - .getId()); newEditor.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { Text text = (Text) treeEditor.getEditor(); treeEditor.getItem().setText(text.getText()); } }); + newEditor.addFocusListener(new FocusAdapter() { + /* + * (non-Javadoc) + * + * @see + * org.eclipse.swt.events.FocusAdapter#focusLost(org.eclipse.swt + * .events.FocusEvent) + */ + @Override + public void focusLost(FocusEvent e) { + entry.getUser().setAlias(treeEditor.getItem().getText()); + // TODO, persist this back to the xmpp server so that the alias + // is used next time you login + } + }); newEditor.selectAll(); newEditor.setFocus(); treeEditor.setEditor(newEditor, usersTreeViewer.getTree() @@ -557,7 +535,6 @@ public class CollaborationGroupView extends ViewPart implements IPartListener { } private void fillStatusMenu(Menu menu) { - System.out.println("fillStatusMenu"); for (int index = 0; index < CollaborationUtils.statusModes.length; ++index) { IPresence.Mode mode = CollaborationUtils.statusModes[index]; Action action = new Action(mode.getMode()) { @@ -575,6 +552,9 @@ public class CollaborationGroupView extends ViewPart implements IPartListener { } } + /** + * Create the toolbar on top of the group view + */ private void createToolbar() { IToolBarManager mgr = getViewSite().getActionBars().getToolBarManager(); mgr.add(createSessionAction); @@ -582,6 +562,10 @@ public class CollaborationGroupView extends ViewPart implements IPartListener { mgr.add(linkToEditorAction); } + /** + * Create the menu bar that is shown when the user clicks the down arrow + * next to the toolbar + */ private void createMenubar() { IMenuManager mgr = getViewSite().getActionBars().getMenuManager(); createMenu(mgr); @@ -618,14 +602,13 @@ public class CollaborationGroupView extends ViewPart implements IPartListener { private void createSession() { CollaborationDataManager manager = CollaborationDataManager .getInstance(); - CollaborationConnection sessionManager = manager.getSessionManager(); + CollaborationConnection sessionManager = manager + .getCollaborationConnection(); if (sessionManager == null) { System.err.println("Unable to get session manager"); return; } - // TODO determine invite based on if any users/groups selected. - CreateSessionDialog dialog = new CreateSessionDialog(Display .getCurrent().getActiveShell(), usersSelected()); dialog.open(); @@ -643,9 +626,9 @@ public class CollaborationGroupView extends ViewPart implements IPartListener { if (result.isInviteUsers()) { IVenueSession session = CollaborationDataManager .getInstance().getSession(result.getSessionId()); - List usersList = new ArrayList(); - for (CollaborationUser user : getSelectedUsers()) { - usersList.add(user.getId()); + List usersList = new ArrayList(); + for (IRosterEntry user : getSelectedUsers()) { + usersList.add(user.getUser()); } String b = result.getInviteMessage(); @@ -660,7 +643,8 @@ public class CollaborationGroupView extends ViewPart implements IPartListener { session.sendInvitation(usersList, invite); } } catch (Exception e) { - statusHandler.error("Error sending invitation", e); + statusHandler.handle(Priority.ERROR, + "Error sending invitation", e); } } } @@ -730,39 +714,6 @@ public class CollaborationGroupView extends ViewPart implements IPartListener { } } - @Deprecated - private void createJoinCollaboration() { - // IStructuredSelection selection = (IStructuredSelection) - // usersTreeViewer - // .getSelection(); - // Object[] nodes = selection.toArray(); - // for (Object node : nodes) { - // if (node instanceof SessionGroup) { - // SessionGroup sg = (SessionGroup) node; - // // System.out.println("Join: " + sg.getId()); - // CollaborationDataManager manager = CollaborationDataManager - // .getInstance(); - // String sessionId = manager.joinCollaborationSession( - // sg.getText(), sg.getId()); - // sg.setId(sessionId); - // try { - // IViewPart part = PlatformUI - // .getWorkbench() - // .getActiveWorkbenchWindow() - // .getActivePage() - // .showView(CollaborationSessionView.ID, sessionId, - // IWorkbenchPage.VIEW_ACTIVATE); - // } catch (PartInitException e) { - // statusHandler.handle(Priority.PROBLEM, - // "Unable to open collaboation sesson", e); - // } catch (Exception e) { - // statusHandler.handle(Priority.ERROR, "Unexpected excepton", - // e); - // } - // } - // } - } - /** * Generate a view to for messages to/from a user via a Peer to Peer * connection. @@ -802,7 +753,7 @@ public class CollaborationGroupView extends ViewPart implements IPartListener { usersTreeViewer.setContentProvider(new UsersTreeContentProvider()); usersTreeViewer.setLabelProvider(new UsersTreeLabelProvider()); usersTreeViewer.setSorter(new UsersTreeViewerSorter()); - topLevel = new CollaborationGroup("kickstart"); + topLevel = new CollaborationGroupContainer(); usersTreeViewer.setInput(topLevel); treeEditor = new TreeEditor(usersTreeViewer.getTree()); @@ -813,42 +764,47 @@ public class CollaborationGroupView extends ViewPart implements IPartListener { TreeItem item = usersTreeViewer.getTree().getItem( new Point(e.x, e.y)); if (item != null) { - CollaborationNode node = (CollaborationNode) item - .getData(); + Object node = item.getData(); StringBuilder builder = new StringBuilder(); - if (node instanceof CollaborationUser) { - builder.append("ID: ").append(node.getId()); - CollaborationUser user = (CollaborationUser) node; + if (node instanceof IRosterEntry) { + IRosterEntry user = (IRosterEntry) node; + builder.append("ID: ").append( + user.getUser().getFQName()); builder.append("\nStatus: "); - if (user.getType() == Type.UNAVAILABLE) { + if (user.getPresence().getType() == Type.UNAVAILABLE) { builder.append("Offline"); } else { - builder.append(user.getMode().getMode()); + builder.append(user.getPresence().getMode() + .getMode()); // builder.append("Type: ").append(user.getType()) // .append("\n"); - String message = user.getStatusMessage(); + String message = user.getPresence() + .getStatusMessage(); if (message != null && message.length() > 0) { builder.append("\n"); builder.append("Message: \"").append( - user.getStatusMessage() + "\""); + user.getPresence() + .getStatusMessage() + + "\""); } } - } else if (node instanceof SessionGroup - && ((SessionGroup) node).isSessionRoot() == false) { - builder.append("ID: ").append(node.getId()); - IVenueInfo info = CollaborationDataManager - .getInstance().getSession(node.getId()) - .getVenue().getInfo(); - builder.append("\nVenueName: ") - .append(info.getVenueName()) + } + // builds the tooltip text for the session group + // portion of the view + else if (node instanceof IVenueSession) { + IVenueSession sessGroup = (IVenueSession) node; + IVenueInfo info = sessGroup.getVenue() + .getInfo(); + builder.append("ID: ") + .append(info.getVenueID()); + builder.append("\nName: ") + .append(info.getVenueDescription()) .append("\n"); - // builder.append("VenueID: ") - // .append(info.getVenueID()).append("\n"); builder.append("Subject: ") .append(info.getVenueSubject()) .append("\n"); - builder.append("ParticipantCount: ").append( + builder.append("Participants: ").append( info.getParticipantCount()); } usersTreeViewer.getTree().setToolTipText( @@ -885,25 +841,23 @@ public class CollaborationGroupView extends ViewPart implements IPartListener { IStructuredSelection selection = (IStructuredSelection) usersTreeViewer .getSelection(); Object o = selection.getFirstElement(); - if (o instanceof LoginUser) { + + // handle the session group portion of the group view + if (o instanceof SessionGroupContainer) { + manager.add(createSessionAction); + return; + } else if (o instanceof IVenueSession) { + manager.add(joinAction); + return; + } else if (o instanceof UserId) { createMenu(manager); return; } - if (o instanceof SessionGroup) { - SessionGroup sessionGroup = (SessionGroup) o; - if (sessionGroup.isSessionRoot()) { - manager.add(createSessionAction); - // manager.add(refreshActiveSessionsAction); - } else { - manager.add(joinAction); - } - return; - } - - if (o instanceof CollaborationUser) { - CollaborationUser user = (CollaborationUser) o; - if (user.getType() == Type.AVAILABLE) { + // the user, both the logged in user as well as his buddies + if (o instanceof IRosterEntry) { + IRosterEntry user = (IRosterEntry) o; + if (user.getPresence().getType() == Type.AVAILABLE) { MenuManager inviteManager = new MenuManager("Invite to..."); // get current open chats Map sessions = CollaborationDataManager @@ -914,8 +868,6 @@ public class CollaborationGroupView extends ViewPart implements IPartListener { final IVenueInfo info = sessions.get(name).getVenue() .getInfo(); if (info != null) { - System.out.println("Add to Invite To menu: " - + info.getVenueDescription()); Action action = new Action( info.getVenueDescription()) { /* @@ -936,25 +888,15 @@ public class CollaborationGroupView extends ViewPart implements IPartListener { } manager.add(inviteManager); manager.add(peerToPeerChatAction); - peerToPeerChatAction.setId(user.getId()); - if (user.isLocal()) { - manager.add(addUserAction); - manager.add(addGroupAction); - manager.add(removeUserAction); - manager.add(removeGroupAction); - } + // use the fq name so that we know who we need to chat with + peerToPeerChatAction.setId(user.getUser().getFQName()); manager.add(new Separator()); manager.add(createSessionAction); } - } else if (o instanceof CollaborationGroup) { - CollaborationGroup group = (CollaborationGroup) o; + manager.add(aliasAction); + } else if (o instanceof IRosterGroup) { + IRosterGroup group = (IRosterGroup) o; manager.add(createSessionAction); - if (group.isLocal()) { - manager.add(addUserAction); - manager.add(addGroupAction); - manager.add(removeGroupAction); - manager.add(renameAction); - } } } @@ -964,8 +906,10 @@ public class CollaborationGroupView extends ViewPart implements IPartListener { protected void populateTree() { CollaborationDataManager manager = CollaborationDataManager .getInstance(); - CollaborationConnection sessionManager = manager.getSessionManager(); - topLevel.removeChildren(); + CollaborationConnection sessionManager = manager + .getCollaborationConnection(); + topLevel.clear(); + // set all the menu actions to false to start with if (sessionManager == null) { usersTreeViewer.getTree().setEnabled(false); addGroupAction.setEnabled(false); @@ -977,6 +921,8 @@ public class CollaborationGroupView extends ViewPart implements IPartListener { changePasswordAction.setEnabled(false); return; } + + // enable all the actions addGroupAction.setEnabled(true); addUserAction.setEnabled(true); selectGroups.setEnabled(true); @@ -985,16 +931,22 @@ public class CollaborationGroupView extends ViewPart implements IPartListener { changeStatusMessageAction.setEnabled(true); changePasswordAction.setEnabled(true); - LoginUser user = new LoginUser(manager.getLoginId()); - topLevel.addChild(user); - activeSessionGroup = new SessionGroup("Active Sessions"); - activeSessionGroup.setSessionRoot(true); - topLevel.addChild(activeSessionGroup); + // make the first thing to show up in the list, which happens to be the + // user's name and gives the user options to modify status and other + // things + UserId user = manager.getLoginId(); + topLevel.addObject(user); + activeSessionGroup = new SessionGroupContainer(); + topLevel.addObject(activeSessionGroup); + + // populates the sessions that the user currently is involved with populateActiveSessions(); + // populates the groups that the user is a part of populateGroups(); + // enable the tree, and then refresh it just to be safe usersTreeViewer.getTree().setEnabled(true); usersTreeViewer.refresh(topLevel, true); createSessionAction.setEnabled(true); @@ -1004,7 +956,7 @@ public class CollaborationGroupView extends ViewPart implements IPartListener { * Clears and populates the Tree Viewer's active session node. */ private void populateActiveSessions() { - activeSessionGroup.removeChildren(); + activeSessionGroup.clear(); try { CollaborationDataManager manager = CollaborationDataManager .getInstance(); @@ -1013,14 +965,14 @@ public class CollaborationGroupView extends ViewPart implements IPartListener { IViewPart viewPart = ref.getView(false); if (viewPart instanceof SessionView) { String sessionId = viewPart.getViewSite().getSecondaryId(); - SessionGroup child = new SessionGroup(sessionId); - child.setText(manager.getSession(sessionId).getVenue() - .getInfo().getVenueDescription()); - activeSessionGroup.addChild(child); + activeSessionGroup.addObject(manager.getSession(sessionId)); } } } catch (NullPointerException e) { // Ignore happens when creating view when starting CAVE. + // TODO bad to ignore, need to take care of + statusHandler.handle(Priority.ERROR, + "Unable to populate active sessions", e); } } @@ -1030,28 +982,21 @@ public class CollaborationGroupView extends ViewPart implements IPartListener { private void populateGroups() { CollaborationDataManager manager = CollaborationDataManager .getInstance(); - for (CollaborationNode node : topLevel.getChildren()) { - if (!(node instanceof LoginUser || node instanceof SessionGroup)) { - topLevel.removeChild(node); - } + + // go through and clear out everything above the groups (my user, the + // sessions) + List obs = new ArrayList(); + obs.addAll(topLevel.getObjects()); + for (IRosterGroup node : manager.getCollaborationConnection() + .getRosterManager().getRoster().getGroups()) { + topLevel.addObject(node); + } + for (IRosterEntry node : manager.getCollaborationConnection() + .getRosterManager().getRoster().getEntries()) { + topLevel.addObject(node); } - for (String groupId : manager.getGroups(false)) { - CollaborationGroup child = new CollaborationGroup(groupId); - for (String userId : manager.getUsersInGroup(groupId)) { - CollaborationUser user = new CollaborationUser(userId); - child.addChild(user); - } - topLevel.addChild(child); - } - List orphanList = manager.getOrphanUsers(); - if (orphanList.size() > 0) { - OrphanGroup orphanGroup = new OrphanGroup(ORPHAN_GROUP_ID); - for (String userId : orphanList) { - orphanGroup.addChild(new CollaborationUser(userId)); - } - topLevel.addChild(orphanGroup); - } + // topLevel.addObject(orphans); } /** @@ -1067,22 +1012,20 @@ public class CollaborationGroupView extends ViewPart implements IPartListener { * * @return */ - private Set getSelectedUsers() { - Set selectedUsers = new HashSet(); + private Set getSelectedUsers() { + Set selectedUsers = new HashSet(); IStructuredSelection selection = (IStructuredSelection) usersTreeViewer .getSelection(); Object[] nodes = selection.toArray(); for (Object node : nodes) { - if (node instanceof CollaborationUser) { - CollaborationUser user = (CollaborationUser) node; - if ((user instanceof LoginUser) == false - && user.getType() == Type.AVAILABLE) { - selectedUsers.add((CollaborationUser) node); + if (node instanceof IRosterEntry) { + IRosterEntry user = (IRosterEntry) node; + if (user.getPresence().getType() == Type.AVAILABLE) { + selectedUsers.add(user); } - } else if ((node instanceof SessionGroup) == false) { - selectedUsers - .addAll(getSelectedUsers((CollaborationGroup) node)); + } else if (node instanceof IRosterGroup) { + selectedUsers.addAll(getSelectedUsers((IRosterGroup) node)); } } @@ -1096,19 +1039,16 @@ public class CollaborationGroupView extends ViewPart implements IPartListener { * @param groupNode * @return users */ - private Set getSelectedUsers(CollaborationGroup groupNode) { - CollaborationDataManager manger = CollaborationDataManager - .getInstance(); - Set selectedUsers = new HashSet(); - for (CollaborationNode node : groupNode.getChildren()) { - if (node instanceof CollaborationUser) { - CollaborationNode user = (CollaborationUser) node; - if (manger.getUser(user.getId()).getType() == Type.AVAILABLE) { - selectedUsers.add((CollaborationUser) node); + private Set getSelectedUsers(IRosterGroup groupNode) { + Set selectedUsers = new HashSet(); + for (IRosterItem node : groupNode.getEntries()) { + if (node instanceof IRosterEntry) { + IRosterEntry user = (IRosterEntry) node; + if (user.getPresence().getType() == Type.AVAILABLE) { + selectedUsers.add((IRosterEntry) node); } - } else if (node instanceof CollaborationGroup) { - selectedUsers - .addAll(getSelectedUsers((CollaborationGroup) node)); + } else if (node instanceof IRosterGroup) { + selectedUsers.addAll(getSelectedUsers((IRosterGroup) node)); } } return selectedUsers; @@ -1120,42 +1060,30 @@ public class CollaborationGroupView extends ViewPart implements IPartListener { nyiFeature("Add user is not yet implemented"); return; } - Set users = getSelectedUsers(); + Set users = getSelectedUsers(); IStructuredSelection selection = (IStructuredSelection) usersTreeViewer .getSelection(); Object[] nodes = selection.toArray(); System.out.println("Add User: " + users.size()); IRosterManager rosterManager = CollaborationDataManager.getInstance() - .getSessionManager().getRosterManager(); + .getCollaborationConnection().getRosterManager(); for (Object node : nodes) { - if (node instanceof CollaborationUser) { - CollaborationUser user = (CollaborationUser) node; + if (node instanceof IRosterEntry) { + IRosterEntry user = (IRosterEntry) node; try { - String account = user.getId(); - String nickname = Tools.parseName(account); - // String[] groups = new String[] { "rogerTestGroup" }; + UserId account = user.getUser(); + String nickname = account.getAlias(); + if (nickname == null || nickname.isEmpty()) { + nickname = account.getName(); + } + String[] groups = null; - rosterManager.sendRosterAdd(account, nickname, groups); - // rosterManager.sendRosterRemove(userId) + rosterManager.sendRosterAdd(account, groups); } catch (CollaborationException e) { - // TODO Auto-generated catch block. Please revise as - // appropriate. statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e); } } - // for (CollaborationUser user : users) { - // try { - // String account = user.getId(); - // String nickname = account.substring(0, account.indexOf('@')); - // rosterManager.sendRosterAdd(account, nickname, - // new String[] { "rogertestgroup" }); - // } catch (CollaborationException e) { - // // TODO Auto-generated catch block. Please revise as - // // appropriate. - // statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), - // e); - // } } } @@ -1185,22 +1113,20 @@ public class CollaborationGroupView extends ViewPart implements IPartListener { usersTreeViewer.addDoubleClickListener(new IDoubleClickListener() { @Override public void doubleClick(DoubleClickEvent event) { - System.out.println("Double click"); TreeSelection selection = (TreeSelection) event.getSelection(); - CollaborationNode node = (CollaborationNode) selection - .getFirstElement(); - if (node instanceof SessionGroup) { + Object node = selection.getFirstElement(); + if (node instanceof SessionGroupContainer) { // SessionGroup group = (SessionGroup) node; // if (!group.isSessionRoot()) { // createJoinCollaboration(); // } - } else if (node instanceof CollaborationUser) { - CollaborationUser user = (CollaborationUser) node; - if (user.getType() == Type.AVAILABLE) { - String loginUserId = CollaborationDataManager + } else if (node instanceof IRosterEntry) { + IRosterEntry user = (IRosterEntry) node; + if (user.getPresence().getType() == Type.AVAILABLE) { + UserId loginUserId = CollaborationDataManager .getInstance().getLoginId(); - if (loginUserId.equals(node.getId()) == false) { - createP2PChat(IDConverter.convertFrom(node.getId())); + if (loginUserId.equals(user) == false) { + createP2PChat(user.getUser()); } } } @@ -1236,8 +1162,6 @@ public class CollaborationGroupView extends ViewPart implements IPartListener { */ @Override public void partBroughtToTop(IWorkbenchPart part) { - // TODO Auto-generated method stub - } /* @@ -1251,10 +1175,10 @@ public class CollaborationGroupView extends ViewPart implements IPartListener { if (part instanceof SessionView) { SessionView sessionView = (SessionView) part; String sessionId = sessionView.getViewSite().getSecondaryId(); - System.out.println("partClosed remove sessionId: " + sessionId); - for (CollaborationNode node : activeSessionGroup.getChildren()) { - if (sessionId.equals(node.getId())) { - activeSessionGroup.removeChild(node); + for (Object node : activeSessionGroup.getObjects()) { + IVenueSession group = (IVenueSession) node; + if (sessionId.equals(group.getVenue().getInfo().getVenueID())) { + activeSessionGroup.removeObject(node); usersTreeViewer.refresh(activeSessionGroup); break; } @@ -1275,8 +1199,6 @@ public class CollaborationGroupView extends ViewPart implements IPartListener { */ @Override public void partDeactivated(IWorkbenchPart part) { - // TODO Auto-generated method stub - } /* @@ -1290,12 +1212,8 @@ public class CollaborationGroupView extends ViewPart implements IPartListener { if (part instanceof SessionView) { SessionView sessionView = (SessionView) part; String sessionId = sessionView.getViewSite().getSecondaryId(); - System.out.println("partOpen add sessionId: " + sessionId); - SessionGroup child = new SessionGroup(sessionId); - child.setText(CollaborationDataManager.getInstance() - .getSession(sessionId).getVenue().getInfo() - .getVenueDescription()); - activeSessionGroup.addChild(child); + activeSessionGroup.addObject(CollaborationDataManager.getInstance() + .getSession(sessionId)); usersTreeViewer.refresh(activeSessionGroup); } else if (part == this) { CollaborationDataManager.getInstance().registerEventHandler(this); @@ -1317,18 +1235,21 @@ public class CollaborationGroupView extends ViewPart implements IPartListener { + rosterEntry.getUser().getHost() + " " + rosterEntry.getPresence().getMode() + "/" + rosterEntry.getPresence().getType()); - refreshUser(CollaborationUtils.makeUserId(rosterEntry), topLevel); + + for (IRosterGroup group : rosterEntry.getGroups()) { + refreshUser(rosterEntry.getUser(), group); + } usersTreeViewer.refresh(topLevel, true); } - private void refreshUser(String userId, CollaborationGroup groupNode) { - for (CollaborationNode child : groupNode.getChildren()) { - if (child instanceof CollaborationUser) { - if (userId.equals(child.getId())) { + private void refreshUser(UserId userId, IRosterGroup group) { + for (Object child : group.getEntries()) { + if (child instanceof IRosterEntry) { + if (userId.equals(((IRosterEntry) child).getUser())) { usersTreeViewer.refresh(child, true); } - } else if (child instanceof CollaborationGroup) { - refreshUser(userId, (CollaborationGroup) child); + } else if (child instanceof IRosterGroup) { + refreshUser(userId, (IRosterGroup) child); } } } @@ -1341,7 +1262,7 @@ public class CollaborationGroupView extends ViewPart implements IPartListener { + rosterChangeEvent.getType() + ">: " + rosterChangeEvent.getEntry().getUser().getFQName()); IRosterEntry rosterEntry = rosterChangeEvent.getEntry(); - String userId = CollaborationUtils.makeUserId(rosterEntry); + UserId userId = rosterEntry.getUser(); List groupIds = new ArrayList(); for (IRosterGroup rosterGroup : rosterEntry.getGroups()) { groupIds.add(rosterGroup.getName()); @@ -1349,142 +1270,124 @@ public class CollaborationGroupView extends ViewPart implements IPartListener { switch (rosterChangeEvent.getType()) { case ADD: // Should be a rare event after initial population. - OrphanGroup orphanGroup = null; - if (groupIds.size() == 0) { - // remove from all groups and add to Orphans. - for (CollaborationNode node : topLevel.getChildren()) { - if (node instanceof OrphanGroup) { - CollaborationUser user = null; - orphanGroup = (OrphanGroup) node; - for (CollaborationNode child : orphanGroup - .getChildren()) { - if (userId.equals(child.getId())) { - user = (CollaborationUser) child; - break; - } - } - if (user == null) { - orphanGroup.addChild(new CollaborationUser(userId)); - usersTreeViewer.refresh(orphanGroup); - } - } else if (node instanceof CollaborationGroup - && !(node instanceof SessionGroup)) { - CollaborationGroup groupNode = (CollaborationGroup) node; - for (CollaborationNode child : groupNode.getChildren()) { - if (userId.equals(child.getId())) { - if (!groupIds.contains(groupNode.getId())) { - groupNode.removeChild(child); - usersTreeViewer.refresh(groupNode); - break; - } - } - } - } - } - if (orphanGroup == null) { - orphanGroup = new OrphanGroup(ORPHAN_GROUP_ID); - orphanGroup.addChild(new CollaborationUser(userId)); - topLevel.addChild(orphanGroup); - usersTreeViewer.refresh(); - } - } else { - // TODO add user to groups and remove from others including - // orphan group. - for (CollaborationNode node : topLevel.getChildren()) { - if (node instanceof CollaborationGroup - && !(node instanceof SessionGroup)) { - CollaborationGroup group = (CollaborationGroup) node; - if (group instanceof OrphanGroup) { - orphanGroup = (OrphanGroup) group; - } - boolean addUser = groupIds.contains(group.getId()); - for (CollaborationNode child : group.getChildren()) { - if (userId.equals(child.getId())) { - if (addUser) { - // User already in the group no need to - // add. - groupIds.remove(group.getId()); - addUser = false; - } else { - // User no longer in this group. - group.removeChild(child); - usersTreeViewer.refresh(group); - } - break; - } - } - if (addUser) { - group.addChild(new CollaborationUser(userId)); - groupIds.remove(group.getId()); - } - } - } - - boolean refreshTopLevel = false; - if (orphanGroup != null - && orphanGroup.getChildren().size() == 0) { - topLevel.removeChild(orphanGroup); - refreshTopLevel = true; - } - - // groups now contains new groups. See if they are on the - // display list. - if (groupIds.size() > 0) { - CollaborationDataManager manager = CollaborationDataManager - .getInstance(); - for (String groupId : groupIds) { - if (manager.displayGroup(groupId)) { - CollaborationGroup groupNode = new CollaborationGroup( - groupId); - topLevel.addChild(groupNode); - groupNode.addChild(new CollaborationUser(userId)); - } - } - refreshTopLevel = true; - } - if (refreshTopLevel) { - usersTreeViewer.refresh(topLevel); - } - } - break; - case DELETE: - // Should be a rare event. - for (CollaborationNode node : topLevel.getChildren()) { - if (node instanceof CollaborationGroup - && !(node instanceof SessionGroup)) { - CollaborationGroup groupNode = (CollaborationGroup) node; - for (CollaborationNode child : groupNode.getChildren()) { - if (userId.equals(child.getId())) { - groupNode.removeChild(child); - usersTreeViewer.refresh(groupNode); - break; - } - } - } - } - break; - case MODIFY: - // Assume this only changes the presence of a user in the - // desired - // groups. - // Since this is handled by the handleModifiedPresence nothing - // needs - // to be done. - // for (String groupId : groups) { + // OrphanGroup orphanGroup = null; + // if (groupIds.size() == 0) { + // // remove from all groups and add to Orphans. // for (CollaborationNode node : topLevel.getChildren()) { - // if (node instanceof CollaborationGroup - // && !(node instanceof SessionGroup) - // && groupId.equals(node.getId())) { - // CollaborationGroup groupNode = (CollaborationGroup) node; + // if (node instanceof OrphanGroup) { + // CollaborationUser user = null; + // orphanGroup = (OrphanGroup) node; + // for (CollaborationNode child : orphanGroup + // .getChildren()) { + // if (userId.equals(child.getId())) { + // user = (IRosterEntry) child; + // break; + // } + // } + // } else if (node instanceof IRosterGroup + // && !(node instanceof SessionGroup)) { + // IRosterGroup groupNode = (IRosterGroup) node; // for (CollaborationNode child : groupNode.getChildren()) { // if (userId.equals(child.getId())) { - // usersTreeViewer.refresh(child, true); + // if (!groupIds.contains(groupNode.getId())) { + // groupNode.removeChild(child); + // usersTreeViewer.refresh(groupNode); // break; // } // } // } // } // } + // if (orphanGroup == null) { + // orphanGroup = new OrphanGroup(ORPHAN_GROUP_ID); + // orphanGroup.addChild(new CollaborationUser(rosterEntry + // .getUser())); + // topLevel.addChild(orphanGroup); + // usersTreeViewer.refresh(); + // } + // } else { + // // TODO add user to groups and remove from others including + // // orphan group. + // for (Object node : topLevel.getObjects()) { + // if (node instanceof IRosterGroup + // && !(node instanceof SessionGroup)) { + // IRosterGroup group = (IRosterGroup) node; + // if (group instanceof OrphanGroup) { + // orphanGroup = (OrphanGroup) group; + // } + // boolean addUser = groupIds.contains(group.getId()); + // for (CollaborationNode child : group.getChildren()) { + // if (userId.equals(child.getId())) { + // if (addUser) { + // // User already in the group no need to + // // add. + // groupIds.remove(group.getId()); + // addUser = false; + // } else { + // // User no longer in this group. + // group.removeChild(child); + // usersTreeViewer.refresh(group); + // } + // break; + // } + // } + // if (addUser) { + // group.addChild(new CollaborationUser(userId)); + // groupIds.remove(group.getId()); + // } + // } + // } + // + // boolean refreshTopLevel = false; + // if (orphanGroup != null + // && orphanGroup.getChildren().size() == 0) { + // topLevel.removeChild(orphanGroup); + // refreshTopLevel = true; + // } + // + // // groups now contains new groups. See if they are on the + // // display list. + // if (groupIds.size() > 0) { + // CollaborationDataManager manager = CollaborationDataManager + // .getInstance(); + // for (String groupId : groupIds) { + // if (manager.displayGroup(groupId)) { + // IRosterGroup groupNode = new IRosterGroup(groupId); + // topLevel.addObject(groupNode); + // groupNode.addChild(new CollaborationUser(userId)); + // } + // } + // refreshTopLevel = true; + // } + // if (refreshTopLevel) { + // usersTreeViewer.refresh(topLevel); + // } + // } + break; + case DELETE: + // Should be a rare event. + // for (Object node : topLevel.getObjects()) { + // if (node instanceof IRosterGroup + // && !(node instanceof SessionGroup)) { + // IRosterGroup groupNode = (IRosterGroup) node; + // for (IRosterEntry child : groupNode.getEntries()) { + // if (userId.equals(child.getUser())) { + // groupNode.removeObject(child); + // usersTreeViewer.refresh(groupNode); + // break; + // } + // } + // } + // } + break; + case MODIFY: + // TODO, remove this case if nothing is done + // Assume this only changes the presence of a user in the + // desired + // groups. + // Since this is handled by the handleModifiedPresence nothing + // needs + // to be done. break; default: statusHandler.handle(Priority.PROBLEM, "Unknown type: " diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/CollaborationUtils.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/CollaborationUtils.java index 9b3c9beac3..e893ec5843 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/CollaborationUtils.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/CollaborationUtils.java @@ -28,10 +28,6 @@ import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.viz.collaboration.comm.identity.IPresence; import com.raytheon.uf.viz.collaboration.comm.identity.IPresence.Mode; -import com.raytheon.uf.viz.collaboration.comm.identity.roster.IRosterEntry; -import com.raytheon.uf.viz.collaboration.comm.provider.Tools; -import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId; -import com.raytheon.uf.viz.collaboration.data.CollaborationNode; import com.raytheon.uf.viz.core.icon.IconUtil; /** @@ -82,44 +78,9 @@ public class CollaborationUtils { * @param node * @return image */ - public static Image getNodeImage(CollaborationNode node) { - String name = node.getImageKey().toLowerCase() + ".gif"; + public static Image getNodeImage(String name) { return IconUtil.getImageDescriptor(Activator.getDefault().getBundle(), - name).createImage(); - } - - /** - * Make userId of the form username@site; using the information in the - * Roster Entry. - * - * @param rosterEntry - * @return userId - */ - public static String makeUserId(IRosterEntry rosterEntry) { - UserId chatId = rosterEntry.getUser(); - String userId = chatId.getName() + Tools.NAME_DELIM + chatId.getHost(); - return userId; - } - - /** - * Make userId of the form username@site; using the information in the Venue - * Participant. - * - * @param participant - * @return userId - */ - public static String makeUserId(UserId participant) { - StringBuilder sb = new StringBuilder(participant.getName()); - sb.append(Tools.NAME_DELIM); - int start = sb.length(); - - String host = participant.getHost(); - - sb.append(host); - if (host.startsWith(PREFIX_CONFERENCE)) { - sb.replace(start, start + PREFIX_CONFERENCE.length(), ""); - } - return sb.toString(); + name.toLowerCase() + ".gif").createImage(); } public static void sendChatMessage(List ids, String message) { diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/CreateSessionDialog.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/CreateSessionDialog.java index b5c0b5e914..0e0560a540 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/CreateSessionDialog.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/CreateSessionDialog.java @@ -325,7 +325,7 @@ public class CreateSessionDialog extends CaveSWTDialog { err = "Name contains invalid characters."; } else { Collection info = CollaborationDataManager - .getInstance().getSessionManager().getVenueInfo(); + .getInstance().getCollaborationConnection().getVenueInfo(); for (IVenueInfo i : info) { if (name.equals(i.getVenueName())) { err = "Session already exists. Pick a different name."; diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/UsersTreeContentProvider.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/UsersTreeContentProvider.java index 37391fdec6..e161fc0cac 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/UsersTreeContentProvider.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/UsersTreeContentProvider.java @@ -23,7 +23,9 @@ package com.raytheon.uf.viz.collaboration.ui; import org.eclipse.jface.viewers.ITreeContentProvider; import org.eclipse.jface.viewers.Viewer; -import com.raytheon.uf.viz.collaboration.data.CollaborationGroup; +import com.raytheon.uf.viz.collaboration.comm.identity.roster.IRosterGroup; +import com.raytheon.uf.viz.collaboration.data.CollaborationGroupContainer; +import com.raytheon.uf.viz.collaboration.data.SessionGroupContainer; /** * TODO Add Description @@ -42,12 +44,6 @@ import com.raytheon.uf.viz.collaboration.data.CollaborationGroup; * @version 1.0 */ public class UsersTreeContentProvider implements ITreeContentProvider { - // UsersTree rootNode; - // - // public UsersTreeContentProvider(UsersTree rootNode) { - // this.rootNode = rootNode; - // } - /* * (non-Javadoc) * @@ -80,19 +76,22 @@ public class UsersTreeContentProvider implements ITreeContentProvider { */ @Override public Object[] getElements(Object inputElement) { - // if (rootNode != null) { - // if (rootNode.getChildren() != null) { - // return rootNode.getChildren().toArray(); - // } - // } - // return new Object[0]; - CollaborationGroup group = (CollaborationGroup) inputElement; - if (group.getChildren() != null) { - return group.getChildren().toArray(); + if (inputElement instanceof IRosterGroup) { + IRosterGroup group = (IRosterGroup) inputElement; + if (group.getEntries() != null) { + return group.getEntries().toArray(); + } else { + return new Object[0]; + } + } else if (inputElement instanceof SessionGroupContainer) { + SessionGroupContainer group = (SessionGroupContainer) inputElement; + return group.getObjects().toArray(); + } else if (inputElement instanceof CollaborationGroupContainer) { + CollaborationGroupContainer cont = (CollaborationGroupContainer) inputElement; + return cont.getObjects().toArray(); } else { return new Object[0]; } - } /* @@ -104,18 +103,16 @@ public class UsersTreeContentProvider implements ITreeContentProvider { */ @Override public Object[] getChildren(Object parentElement) { - // if (parentElement instanceof UsersTree) { - // UsersTree parent = (UsersTree) parentElement; - // List children = parent.getChildren(); - // if (children != null) { - // return children.toArray(); - // } else { - // return new Object[0]; - // } - // } - // return null; - CollaborationGroup group = (CollaborationGroup) parentElement; - return group.getChildren().toArray(); + // the only things that can have children are the sessions item or the + // groups items + if (parentElement instanceof SessionGroupContainer) { + SessionGroupContainer cont = (SessionGroupContainer) parentElement; + return cont.getObjects().toArray(); + } else if (parentElement instanceof IRosterGroup) { + IRosterGroup group = (IRosterGroup) parentElement; + return group.getEntries().toArray(); + } + return null; } /* @@ -140,25 +137,22 @@ public class UsersTreeContentProvider implements ITreeContentProvider { */ @Override public boolean hasChildren(Object element) { - // if (element instanceof UsersTree) { - // UsersTree elem = (UsersTree) element; - // return elem.hasChildren(); - // } - // return false; - if (element instanceof CollaborationGroup) { - CollaborationGroup group = (CollaborationGroup) element; - if (group.getChildren().size() <= 0) { + if (element instanceof IRosterGroup) { + IRosterGroup group = (IRosterGroup) element; + if (group.getEntries().size() <= 0) { return false; } else { return true; } + } else if (element instanceof SessionGroupContainer) { + SessionGroupContainer cont = (SessionGroupContainer) element; + if (cont.getObjects() != null && cont.getObjects().size() > 0) { + return true; + } else { + return false; + } } else { return false; } } - - // public Object findItem(String text) { - // UsersTree item = rootNode.findChildByText(text); - // return item; - // } } diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/UsersTreeLabelProvider.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/UsersTreeLabelProvider.java index 16d27581c0..59b0b36d4a 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/UsersTreeLabelProvider.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/UsersTreeLabelProvider.java @@ -35,9 +35,13 @@ import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.widgets.Display; -import com.raytheon.uf.viz.collaboration.data.CollaborationGroup; -import com.raytheon.uf.viz.collaboration.data.CollaborationNode; -import com.raytheon.uf.viz.collaboration.data.SessionGroup; +import com.raytheon.uf.viz.collaboration.comm.identity.IPresence.Type; +import com.raytheon.uf.viz.collaboration.comm.identity.IVenueSession; +import com.raytheon.uf.viz.collaboration.comm.identity.roster.IRosterEntry; +import com.raytheon.uf.viz.collaboration.comm.identity.roster.IRosterGroup; +import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId; +import com.raytheon.uf.viz.collaboration.data.CollaborationDataManager; +import com.raytheon.uf.viz.collaboration.data.SessionGroupContainer; /** * TODO Add Description @@ -78,11 +82,13 @@ public class UsersTreeLabelProvider implements ITableLabelProvider, for (String key : imageMap.keySet()) { imageMap.get(key).dispose(); } + if (boldFont != null && !boldFont.isDisposed()) { + boldFont.dispose(); + } } @Override public boolean isLabelProperty(Object element, String property) { - // TODO Auto-generated method stub return false; } @@ -96,30 +102,55 @@ public class UsersTreeLabelProvider implements ITableLabelProvider, if (Activator.getDefault() == null) { return null; } - Image image = null; - if (element instanceof CollaborationNode) { - CollaborationNode node = (CollaborationNode) element; - String key = node.getImageKey(); - if (key != null) { - image = imageMap.get(key); - if (image == null) { - image = CollaborationUtils.getNodeImage(node); - if (image != null) { - imageMap.put(key, image); - } - } + String key = ""; + if (element instanceof UserId) { + String mode = CollaborationDataManager.getInstance() + .getCollaborationConnection().getPresence().getMode() + .toString(); + key = mode; + } else if (element instanceof IRosterEntry) { + IRosterEntry entry = (IRosterEntry) element; + if (entry.getPresence().getType() == Type.AVAILABLE) { + key = entry.getPresence().getMode().toString(); + } else { + key = "contact_disabled"; } + } else if (element instanceof IRosterGroup) { + key = "group"; + } else if (element instanceof IVenueSession) { + // key = "session_group"; + } else if (element instanceof SessionGroupContainer) { + key = "session_group"; } - return image; + + if (imageMap.get(key) == null && !key.equals("")) { + imageMap.put(key, CollaborationUtils.getNodeImage(key)); + } + + return imageMap.get(key); } @Override public String getColumnText(Object element, int index) { - CollaborationNode elem = (CollaborationNode) element; - if (elem.getText() == null) { - return elem.getId(); + if (element instanceof IRosterEntry) { + IRosterEntry entry = (IRosterEntry) element; + if (entry.getUser().getAlias() == null) { + return entry.getUser().getName(); + } else { + return entry.getUser().getAlias(); + } + } else if (element instanceof IRosterGroup) { + return ((IRosterGroup) element).getName(); + } else if (element instanceof SessionGroupContainer) { + return "Active Sessions"; + } else if (element instanceof UserId) { + return ((UserId) element).getName() + " - " + + ((UserId) element).getHost(); + } else if (element instanceof IVenueSession) { + return ((IVenueSession) element).getVenue().getInfo() + .getVenueDescription(); } - return elem.getText(); + return null; } /* @@ -157,20 +188,16 @@ public class UsersTreeLabelProvider implements ITableLabelProvider, */ @Override public Font getFont(Object element, int columnIndex) { - if (element instanceof CollaborationGroup) { - if (element instanceof SessionGroup - && !((SessionGroup) element).isSessionRoot()) { - // for this case do nothing, as it is not the top level of - // session groups - } else { - if (boldFont == null) { - Font currFont = Display.getCurrent().getSystemFont(); - boldFont = new Font(Display.getCurrent(), - currFont.toString(), - currFont.getFontData()[0].getHeight(), SWT.BOLD); - } - return boldFont; + if (element instanceof IRosterGroup + || element instanceof SessionGroupContainer) { + // for this case do nothing, as it is not the top level of + // session groups + if (boldFont == null) { + Font currFont = Display.getCurrent().getSystemFont(); + boldFont = new Font(Display.getCurrent(), currFont.toString(), + currFont.getFontData()[0].getHeight(), SWT.BOLD); } + return boldFont; } return null; } diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/UsersTreeViewerSorter.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/UsersTreeViewerSorter.java index 6e6419ce25..c2d86498b0 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/UsersTreeViewerSorter.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/UsersTreeViewerSorter.java @@ -23,11 +23,10 @@ package com.raytheon.uf.viz.collaboration.ui; import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.viewers.ViewerSorter; -import com.raytheon.uf.viz.collaboration.data.CollaborationGroup; -import com.raytheon.uf.viz.collaboration.data.CollaborationNode; -import com.raytheon.uf.viz.collaboration.data.LoginUser; -import com.raytheon.uf.viz.collaboration.data.OrphanGroup; -import com.raytheon.uf.viz.collaboration.data.SessionGroup; +import com.raytheon.uf.viz.collaboration.comm.identity.roster.IRosterGroup; +import com.raytheon.uf.viz.collaboration.comm.identity.roster.IRosterItem; +import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId; +import com.raytheon.uf.viz.collaboration.data.SessionGroupContainer; /** * TODO Add Description @@ -54,40 +53,34 @@ public class UsersTreeViewerSorter extends ViewerSorter { } // Make login user top node - if (e1 instanceof LoginUser) { + if (e1 instanceof UserId) { return -1; } - if (e2 instanceof LoginUser) { + + if (e2 instanceof UserId) { return 1; } // session group before all other types but login user. - if (e1 instanceof SessionGroup) { - if ((e2 instanceof SessionGroup) == false) { + if (e1 instanceof SessionGroupContainer) { + if ((e2 instanceof SessionGroupContainer) == false) { return -1; } - } else if (e2 instanceof SessionGroup) { + } else if (e2 instanceof SessionGroupContainer) { return 1; } - // OrpahGroup always at the bottom - if (e1 instanceof OrphanGroup) { - return 1; - } - if (e2 instanceof OrphanGroup) { - return -1; - } - // Groups before users. - if (e1 instanceof CollaborationGroup) { - if (!(e2 instanceof CollaborationGroup)) { + if (e1 instanceof IRosterGroup) { + if (!(e2 instanceof IRosterGroup)) { return -1; } - } else if (e1 instanceof CollaborationGroup) { + } else if (e1 instanceof IRosterGroup) { return 1; } // Either both are groups or both are users. - return ((CollaborationNode) e1).compareTo((CollaborationNode) e2); + return ((IRosterItem) e1).getName().compareTo( + ((IRosterItem) e2).getName()); } } diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/login/ChangeStatusDialog.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/login/ChangeStatusDialog.java index 7232fcbab6..c0705fe382 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/login/ChangeStatusDialog.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/login/ChangeStatusDialog.java @@ -122,7 +122,7 @@ public class ChangeStatusDialog extends CaveSWTDialog { super.preOpened(); LoginData loginData = CollaborationDataManager.getInstance() .getLoginData(); - userLabel.setText(loginData.getAccount()); + userLabel.setText(loginData.getAccount().getFQName()); statusCombo.select(CollaborationUtils.statusModesIndex(loginData .getMode())); statusCombo.select(CollaborationUtils.statusModesIndex(loginData diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/login/LoginData.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/login/LoginData.java index 7cdcf400b5..cf3fd4f035 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/login/LoginData.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/login/LoginData.java @@ -7,6 +7,7 @@ import javax.xml.bind.annotation.XmlRootElement; import com.raytheon.uf.common.serialization.ISerializableObject; import com.raytheon.uf.viz.collaboration.comm.identity.IPresence; +import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId; /** * This software was developed and / or modified by Raytheon Company, @@ -94,8 +95,8 @@ public class LoginData implements ISerializableObject { return modeMessage; } - public String getAccount() { - return user + "@" + server; + public UserId getAccount() { + return new UserId(user, server); } public void setUser(String user) { diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/login/LoginDialog.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/login/LoginDialog.java index 2d524c23b5..b24b09992c 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/login/LoginDialog.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/login/LoginDialog.java @@ -56,8 +56,6 @@ import com.raytheon.uf.common.status.UFStatus.Priority; import com.raytheon.uf.viz.collaboration.comm.identity.IPresence; import com.raytheon.uf.viz.collaboration.comm.identity.event.IRosterEventSubscriber; import com.raytheon.uf.viz.collaboration.comm.provider.session.CollaborationConnection; -import com.raytheon.uf.viz.collaboration.data.CollaborationDataManager; -import com.raytheon.uf.viz.collaboration.data.DataUser; import com.raytheon.uf.viz.collaboration.ui.CollaborationUtils; import com.raytheon.uf.viz.core.localization.LocalizationManager; import com.raytheon.viz.ui.dialogs.CaveSWTDialog; @@ -378,18 +376,12 @@ public class LoginDialog extends CaveSWTDialog { // .getSelectionIndex()], messageTF // .getText().trim()); try { - sessionManager = new CollaborationConnection(loginData - .getAccount(), loginData.getPassword(), + sessionManager = new CollaborationConnection( + loginData.getAccount(), loginData + .getPassword(), rosterEventSubscriber); - DataUser dUser = CollaborationDataManager - .getInstance().getUser( - loginData.getAccount()); - // // TODO set mode and message here. - // dUser.setMode(loginData.getMode()); - // dUser.type = Type.AVAILABLE; - // dUser.statusMessage = loginData.getModeMessage(); setReturnValue(loginData); - LoginDialog.this.getShell().dispose(); + close(); } catch (Exception e) { if (focusField == null) { focusField = passwordTF; diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/AbstractSessionView.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/AbstractSessionView.java index 871f521896..73749dbe6e 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/AbstractSessionView.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/AbstractSessionView.java @@ -85,14 +85,10 @@ public abstract class AbstractSessionView extends ViewPart implements private StyledText composeText; - // protected Action chatAction; - protected abstract String getSessionImageName(); protected abstract String getSessionName(); - // protected abstract void populateSashForm(SashForm sashForm); - public abstract void sendMessage(); protected abstract void setMessageLabel(Composite comp); @@ -142,7 +138,6 @@ public abstract class AbstractSessionView extends ViewPart implements Composite messagesComp = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(1, false); messagesComp.setLayout(layout); - // TODO, wrap label in view setMessageLabel(messagesComp); messagesText = new StyledText(messagesComp, SWT.MULTI | SWT.WRAP | SWT.READ_ONLY | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); @@ -216,23 +211,21 @@ public abstract class AbstractSessionView extends ViewPart implements */ public void appendMessage(IMessage message) { UserId userId = (UserId) message.getFrom(); - String name = message.getFrom().getName(); long timestamp = message.getTimeStamp(); String body = message.getBody(); - appendMessage(userId, name, timestamp, body); + appendMessage(userId, timestamp, body); } - public void appendMessage(UserId userId, String name, long timestamp, - String body) { + public void appendMessage(UserId userId, long timestamp, String body) { IWorkbenchSiteProgressService service = (IWorkbenchSiteProgressService) getSite() .getAdapter(IWorkbenchSiteProgressService.class); service.warnOfContentChange(); - // String fqName = message.getFrom().getFQName(); - // String name = message.getFrom().getName(); - if (name == null) { - name = userId.getFQName().substring(0, - userId.getFQName().indexOf("@")); + String name = null; + if (userId.getAlias() == null || userId.getAlias().isEmpty()) { + name = userId.getName(); + } else { + name = userId.getAlias(); } Calendar cal = Calendar.getInstance(); cal.setTimeInMillis(timestamp); diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/CollaborationSessionView.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/CollaborationSessionView.java index ca588b25bf..1114d1d5df 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/CollaborationSessionView.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/CollaborationSessionView.java @@ -41,12 +41,11 @@ import com.raytheon.uf.viz.collaboration.comm.identity.CollaborationException; import com.raytheon.uf.viz.collaboration.comm.identity.ISharedDisplaySession; import com.raytheon.uf.viz.collaboration.comm.identity.IVenueSession; import com.raytheon.uf.viz.collaboration.comm.identity.info.IVenueInfo; +import com.raytheon.uf.viz.collaboration.comm.identity.roster.IRosterEntry; import com.raytheon.uf.viz.collaboration.comm.identity.user.SharedDisplayRole; -import com.raytheon.uf.viz.collaboration.comm.provider.Tools; import com.raytheon.uf.viz.collaboration.comm.provider.TransferRoleCommand; import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId; import com.raytheon.uf.viz.collaboration.data.CollaborationDataManager; -import com.raytheon.uf.viz.collaboration.data.CollaborationUser; /** * TODO Add Description @@ -98,9 +97,9 @@ public class CollaborationSessionView extends SessionView { public void run() { IStructuredSelection selection = (IStructuredSelection) usersTable .getSelection(); - CollaborationUser selectedUser = (CollaborationUser) selection + IRosterEntry selectedUser = (IRosterEntry) selection .getFirstElement(); - switchLeader(selectedUser.getId()); + switchLeader(selectedUser.getUser()); }; }; ActionContributionItem leaderItem = new ActionContributionItem( @@ -113,9 +112,9 @@ public class CollaborationSessionView extends SessionView { public void run() { IStructuredSelection selection = (IStructuredSelection) usersTable .getSelection(); - CollaborationUser selectedUser = (CollaborationUser) selection + IRosterEntry selectedUser = (IRosterEntry) selection .getFirstElement(); - switchDataProvider(selectedUser.getId()); + switchDataProvider(selectedUser.getUser()); }; }; ActionContributionItem dataProviderItem = new ActionContributionItem( @@ -138,20 +137,20 @@ public class CollaborationSessionView extends SessionView { switchToAction.setMenuCreator(creator); } - private void switchDataProvider(String fqname) { - System.out.println("Send switchDataProvider request. " + fqname); + private void switchDataProvider(UserId userId) { + System.out.println("Send switchDataProvider request. " + + userId.getFQName()); // TODO need to send invite/request for transfer, and then if successful // deactivate the local ones since we won't receive the message } - private void switchLeader(String fqname) { - System.out.println("Send switchLeader request. " + fqname); + private void switchLeader(UserId userId) { + System.out.println("Send switchLeader request. " + userId.getFQName()); // TODO need to send invite/request for transfer, and then if successful // deactivate the local ones since we won't receive the message TransferRoleCommand trc = new TransferRoleCommand(); - UserId vp = new UserId(Tools.parseName(fqname), Tools.parseHost(fqname)); - trc.setUser(vp); - session.setCurrentSessionLeader(vp); + trc.setUser(userId); + session.setCurrentSessionLeader(userId); trc.setRole(SharedDisplayRole.SESSION_LEADER); try { session.sendObjectToVenue(trc); @@ -167,14 +166,14 @@ public class CollaborationSessionView extends SessionView { } @Override - protected String buildParticipantTooltip(CollaborationUser user) { + protected String buildParticipantTooltip(IRosterEntry user) { StringBuilder builder = new StringBuilder( super.buildParticipantTooltip(user)); // TODO these should be smarter ifs - boolean isSessionLeader = Tools.parseName(user.getId()).equals( - session.getCurrentSessionLeader().getName()); - boolean isDataProvider = Tools.parseName(user.getId()).equals( - session.getCurrentDataProvider().getName()); + boolean isSessionLeader = user.getUser().equals( + session.getCurrentSessionLeader()); + boolean isDataProvider = user.getUser().equals( + session.getCurrentDataProvider()); if (isSessionLeader || isDataProvider) { builder.append("\n-- Roles --"); if (isSessionLeader) { @@ -219,9 +218,8 @@ public class CollaborationSessionView extends SessionView { try { ((IVenueSession) session).sendChatMessage(message); } catch (CollaborationException e) { - // TODO Auto-generated catch block. Please revise as - // appropriate. - e.printStackTrace(); + statusHandler.handle(Priority.ERROR, + "Unable to send chat message", e); } } } @@ -240,10 +238,9 @@ public class CollaborationSessionView extends SessionView { || session.hasRole(SharedDisplayRole.SESSION_LEADER)) { IStructuredSelection selection = (IStructuredSelection) usersTable .getSelection(); - CollaborationUser selectedUser = (CollaborationUser) selection + IRosterEntry selectedUser = (IRosterEntry) selection .getFirstElement(); - String selectedUserName = Tools.parseName(selectedUser.getId()); - if (!selectedUserName.equals(session.getUserID().getName())) { + if (!selectedUser.getUser().equals(session.getUserID())) { manager.add(switchToAction); } } diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/ParticipantsLabelProvider.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/ParticipantsLabelProvider.java index 3d467e53a9..73e634d6b1 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/ParticipantsLabelProvider.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/ParticipantsLabelProvider.java @@ -35,9 +35,9 @@ import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.widgets.Display; import com.raytheon.uf.viz.collaboration.comm.identity.IVenueSession; +import com.raytheon.uf.viz.collaboration.comm.identity.roster.IRosterEntry; import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId; import com.raytheon.uf.viz.collaboration.data.CollaborationDataManager; -import com.raytheon.uf.viz.collaboration.data.CollaborationUser; import com.raytheon.uf.viz.collaboration.data.SharedDisplaySessionMgr; import com.raytheon.uf.viz.collaboration.ui.CollaborationUtils; @@ -111,13 +111,13 @@ public class ParticipantsLabelProvider implements ITableColorProvider, return null; } - CollaborationUser user = (CollaborationUser) element; + IRosterEntry user = (IRosterEntry) element; Image image = null; - String key = user.getImageKey(); + String key = user.getPresence().getMode().toString(); if (key != null) { image = imageMap.get(key); if (image == null) { - image = CollaborationUtils.getNodeImage(user); + image = CollaborationUtils.getNodeImage(key); if (image != null) { imageMap.put(key, image); } @@ -129,8 +129,8 @@ public class ParticipantsLabelProvider implements ITableColorProvider, @Override public String getColumnText(Object element, int columnIndex) { - CollaborationUser user = (CollaborationUser) element; - return user.getText(); + IRosterEntry user = (IRosterEntry) element; + return user.getName(); } @Override @@ -143,20 +143,9 @@ public class ParticipantsLabelProvider implements ITableColorProvider, if (colors == null) { colors = new HashMap(); } - // String host = ((CollaborationUser) element). - String id = ((CollaborationUser) element).getId(); - String[] uid = null; - if (id != null) { - uid = ((CollaborationUser) element).getId().split("@"); - } - UserId userId = new UserId(uid[0], uid[1]); + UserId userId = ((IRosterEntry) element).getUser(); RGB color = SharedDisplaySessionMgr.getSessionContainer(sessionId) .getColorManager().getColors().get(userId); - if (color == null) { - userId.setHost("conference." + uid[1]); - color = SharedDisplaySessionMgr.getSessionContainer(sessionId) - .getColorManager().getColors().get(userId); - } // add to map so we can dispose if (color == null) { diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/PeerToPeerView.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/PeerToPeerView.java index 109780a8fc..a88b931ce3 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/PeerToPeerView.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/PeerToPeerView.java @@ -22,7 +22,6 @@ package com.raytheon.uf.viz.collaboration.ui.session; import java.util.List; -import org.eclipse.jface.action.IMenuManager; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.SashForm; import org.eclipse.swt.custom.StyleRange; @@ -89,71 +88,6 @@ public class PeerToPeerView extends AbstractSessionView { sashForm.setWeights(new int[] { 20, 5 }); } - protected void createActions() { - // TODO create peer-to-peer chat action here - // chatAction = new Action("Chat") { - // @Override - // public void run() { - // try { - // CollaborationDataManager dataManager = CollaborationDataManager - // .getInstance(); - // CollaborationUser user = (CollaborationUser) ((IStructuredSelection) - // usersTable - // .getSelection()).getFirstElement(); - // String session = dataManager.createCollaborationSession( - // user.getId(), "Chatting..."); - // PlatformUI - // .getWorkbench() - // .getActiveWorkbenchWindow() - // .getActivePage() - // .showView(CollaborationSessionView.ID, session, - // IWorkbenchPage.VIEW_ACTIVATE); - // // } - // } catch (PartInitException e) { - // statusHandler.handle(Priority.PROBLEM, - // "Unable to open chat", e); - // } - // } - // }; - } - - // /** - // * - // */ - // private void createContextMenu() { - // MenuManager menuManager = new MenuManager(); - // menuManager.setRemoveAllWhenShown(true); - // menuManager.addMenuListener(new IMenuListener() { - // /* - // * (non-Javadoc) - // * - // * @see - // * org.eclipse.jface.action.IMenuListener#menuAboutToShow(org.eclipse - // * .jface.action.IMenuManager) - // */ - // @Override - // public void menuAboutToShow(IMenuManager manager) { - // fillContextMenu(manager); - // } - // }); - // // Menu menu = menuManager.createContextMenu(usersTable.getControl()); - // // usersTable.getControl().setMenu(menu); - // // PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() - // // .getActivePart().getSite() - // // .registerContextMenu(menuManager, usersTable); - // // usersTable.getTable().setMenu(menu); - // } - - protected void fillContextMenu(IMenuManager manager) { - // IStructuredSelection selection = (IStructuredSelection) usersTable - // .getSelection(); - // do something here! - // Object ob = selection.getFirstElement(); - // System.out.println(ob.toString()); - // manager.add(chatAction); - // manager.add(new Separator()); - } - /* * (non-Javadoc) * @@ -178,16 +112,14 @@ public class PeerToPeerView extends AbstractSessionView { try { CollaborationDataManager manager = CollaborationDataManager .getInstance(); - IPeerToPeer p2p = (IPeerToPeer) manager.getSessionManager() - .getPeerToPeerSession(); + IPeerToPeer p2p = (IPeerToPeer) manager + .getCollaborationConnection().getPeerToPeerSession(); p2p.sendPeerToPeer(peer, message); - appendMessage((UserId) peer, manager.getLoginId(), - System.currentTimeMillis(), message); + appendMessage(manager.getLoginId(), System.currentTimeMillis(), + message); } catch (CollaborationException e) { - // TODO Auto-generated catch block. Please revise as - // appropriate. - statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), - e); + statusHandler.handle(Priority.PROBLEM, + "Unable to send message to " + peer.getName(), e); } } } @@ -195,11 +127,10 @@ public class PeerToPeerView extends AbstractSessionView { protected void styleAndAppendText(StringBuilder sb, int offset, String name, UserId userId, List ranges) { Color color = null; - if (!userId.getFQName().equals( - CollaborationDataManager.getInstance().getLoginId())) { - color = userColor; - } else { + if (!userId.equals(CollaborationDataManager.getInstance().getLoginId())) { color = chatterColor; + } else { + color = userColor; } StyleRange range = new StyleRange(messagesText.getCharCount(), offset, color, null, SWT.NORMAL); 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 a50879d9e5..931415e4ef 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 @@ -64,21 +64,16 @@ import com.raytheon.uf.common.status.UFStatus.Priority; import com.raytheon.uf.viz.collaboration.comm.identity.CollaborationException; import com.raytheon.uf.viz.collaboration.comm.identity.IMessage; import com.raytheon.uf.viz.collaboration.comm.identity.IPresence; -import com.raytheon.uf.viz.collaboration.comm.identity.IPresence.Mode; -import com.raytheon.uf.viz.collaboration.comm.identity.IPresence.Type; import com.raytheon.uf.viz.collaboration.comm.identity.ISession; import com.raytheon.uf.viz.collaboration.comm.identity.IVenueSession; import com.raytheon.uf.viz.collaboration.comm.identity.event.IVenueParticipantEvent; import com.raytheon.uf.viz.collaboration.comm.identity.event.ParticipantEventType; import com.raytheon.uf.viz.collaboration.comm.identity.info.IVenueInfo; import com.raytheon.uf.viz.collaboration.comm.identity.roster.IRosterEntry; -import com.raytheon.uf.viz.collaboration.comm.provider.Presence; import com.raytheon.uf.viz.collaboration.comm.provider.session.CollaborationConnection; import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId; import com.raytheon.uf.viz.collaboration.data.CollaborationDataManager; -import com.raytheon.uf.viz.collaboration.data.CollaborationUser; import com.raytheon.uf.viz.collaboration.data.SharedDisplaySessionMgr; -import com.raytheon.uf.viz.collaboration.ui.CollaborationUtils; import com.raytheon.uf.viz.collaboration.ui.SessionColorManager; import com.raytheon.uf.viz.core.VizApp; @@ -156,7 +151,7 @@ public class SessionView extends AbstractSessionView { public void run() { try { CollaborationConnection sessionManager = CollaborationDataManager - .getInstance().getSessionManager(); + .getInstance().getCollaborationConnection(); ISession session = sessionManager.getPeerToPeerSession(); // TODO this doesn't seem right to use the session's // sessionId @@ -346,9 +341,10 @@ public class SessionView extends AbstractSessionView { usersTable.setLabelProvider(labelProvider); usersTable.setSorter(new ViewerSorter() { public int compare(Viewer viewer, Object e1, Object e2) { - CollaborationUser c1 = (CollaborationUser) e1; - CollaborationUser c2 = (CollaborationUser) e1; - return c1.compareTo(c2); + IRosterEntry c1 = (IRosterEntry) e1; + IRosterEntry c2 = (IRosterEntry) e1; + return c1.getUser().getFQName() + .compareTo(c2.getUser().getFQName()); } }); @@ -358,7 +354,7 @@ public class SessionView extends AbstractSessionView { TableItem item = usersTable.getTable().getItem( new Point(e.x, e.y)); if (item != null) { - CollaborationUser user = (CollaborationUser) item.getData(); + IRosterEntry user = (IRosterEntry) item.getData(); usersTable.getTable().setToolTipText( buildParticipantTooltip(user)); } else { @@ -367,21 +363,15 @@ public class SessionView extends AbstractSessionView { } }); - List users = new ArrayList(); + List users = new ArrayList(); if (session != null) { for (UserId participant : session.getVenue().getParticipants()) { - - String userId = CollaborationUtils.makeUserId(participant); - CollaborationUser user = new CollaborationUser(userId, - sessionId); - if (user.getType() == Type.UNKNOWN) { - // Unknown user assume mode/type - user.setPresence(new Presence(Mode.AVAILABLE, - Type.AVAILABLE, "")); + CollaborationDataManager manager = CollaborationDataManager + .getInstance(); + IRosterEntry entry = manager.getUsersMap().get(participant); + if (entry != null) { + users.add(manager.getUsersMap().get(participant)); } - - user.setText(participant.getFQName()); - users.add(user); } } else { participantsLabel.setEnabled(false); @@ -393,11 +383,12 @@ public class SessionView extends AbstractSessionView { ((GridData) usersComp.getLayoutData()).exclude = true; } - protected String buildParticipantTooltip(CollaborationUser user) { + protected String buildParticipantTooltip(IRosterEntry user) { StringBuilder builder = new StringBuilder(); - builder.append("Status : ").append(user.getMode().getMode()) - .append("\n"); - builder.append("Message : \"").append(user.getStatusMessage()); + builder.append("Status : ") + .append(user.getPresence().getMode().getMode()).append("\n"); + builder.append("Message : \"").append( + user.getPresence().getStatusMessage()); return builder.toString(); } @@ -640,28 +631,20 @@ public class SessionView extends AbstractSessionView { @SuppressWarnings("unchecked") private void participantArrived(UserId participant) { - List users = (List) usersTable - .getInput(); - String name = participant.getFQName(); - String userId = CollaborationUtils.makeUserId(participant); - for (CollaborationUser user : users) { - if (userId.equals(user.getId())) { - return; - } - } - CollaborationUser user = new CollaborationUser(userId, sessionId); - user.setText(name); + List users = (List) usersTable.getInput(); + IRosterEntry user = CollaborationDataManager.getInstance() + .getUsersMap().get(participant); users.add(user); usersTable.refresh(); } @SuppressWarnings("unchecked") private void participantDeparted(UserId participant) { - String userId = CollaborationUtils.makeUserId(participant); - List users = (List) usersTable - .getInput(); + System.out.println("++++ handle departed here: " + + participant.getName() + ", " + participant.getFQName()); + List users = (List) usersTable.getInput(); for (int i = 0; i < users.size(); ++i) { - if (userId.equals(users.get(i).getId())) { + if (participant.equals(users.get(i).getUser())) { users.remove(i); usersTable.refresh(); break; @@ -679,9 +662,6 @@ public class SessionView extends AbstractSessionView { // Ignore the presence's mode/type. May not be the same as the user's. // TODO Keep as a place holder for now since it may be needed to set // leader/provider roles. - List users = (List) usersTable - .getInput(); - String name = participant.getFQName(); - String userId = CollaborationUtils.makeUserId(participant); + List users = (List) usersTable.getInput(); } } diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/SharedDisplayParticipantsLabelProvider.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/SharedDisplayParticipantsLabelProvider.java index 46e99e4027..528da344f1 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/SharedDisplayParticipantsLabelProvider.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/SharedDisplayParticipantsLabelProvider.java @@ -25,8 +25,9 @@ import java.util.List; import org.eclipse.swt.graphics.Image; import com.raytheon.uf.viz.collaboration.comm.identity.ISharedDisplaySession; +import com.raytheon.uf.viz.collaboration.comm.identity.roster.IRosterEntry; import com.raytheon.uf.viz.collaboration.comm.identity.user.SharedDisplayRole; -import com.raytheon.uf.viz.collaboration.data.CollaborationUser; +import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId; import com.raytheon.uf.viz.collaboration.data.SharedDisplaySessionMgr; import com.raytheon.uf.viz.collaboration.ui.CollaborationUtils; @@ -56,12 +57,10 @@ public class SharedDisplayParticipantsLabelProvider extends if (image != null) { ISharedDisplaySession sdSession = SharedDisplaySessionMgr .getSessionContainer(sessionId).getSession(); - CollaborationUser user = (CollaborationUser) element; - String userId = user.getId(); - String sessionLeaderId = CollaborationUtils.makeUserId(sdSession - .getCurrentSessionLeader()); - String dataProviderId = CollaborationUtils.makeUserId(sdSession - .getCurrentDataProvider()); + IRosterEntry user = (IRosterEntry) element; + UserId userId = user.getUser(); + UserId sessionLeaderId = sdSession.getCurrentSessionLeader(); + UserId dataProviderId = sdSession.getCurrentDataProvider(); List roleList = new ArrayList(); if (userId.equals(sessionLeaderId)) { roleList.add(SharedDisplayRole.SESSION_LEADER); @@ -86,24 +85,25 @@ public class SharedDisplayParticipantsLabelProvider extends * - * @return image - modified with indicator(s) */ - private Image getModifier(List roles, - CollaborationUser user) { - String key = user.getImageKey(); + private Image getModifier(List roles, IRosterEntry user) { + // String key = user.getImageKey(); + String key = ""; StringBuilder modKey = new StringBuilder(key); int roleCnt = 0; if (roles.contains(SharedDisplayRole.SESSION_LEADER)) { ++roleCnt; - modKey.append(":") - .append(SharedDisplayRole.SESSION_LEADER.toString()); + modKey.append(":").append( + SharedDisplayRole.SESSION_LEADER.toString()); } if (roles.contains(SharedDisplayRole.DATA_PROVIDER)) { ++roleCnt; - modKey.append(":").append(SharedDisplayRole.DATA_PROVIDER.toString()); + modKey.append(":").append( + SharedDisplayRole.DATA_PROVIDER.toString()); } Image image = imageMap.get(modKey.toString()); if (image == null) { - image = CollaborationUtils.getNodeImage(user); + image = CollaborationUtils.getNodeImage(key); // original image is 16x16 image.getImageData(); imageMap.put(modKey.toString(), image); diff --git a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/identity/IVenueSession.java b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/identity/IVenueSession.java index eacb121203..e14d693843 100644 --- a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/identity/IVenueSession.java +++ b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/identity/IVenueSession.java @@ -23,6 +23,7 @@ import java.util.List; import com.raytheon.uf.viz.collaboration.comm.identity.info.IVenue; import com.raytheon.uf.viz.collaboration.comm.identity.invite.VenueInvite; +import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId; /** * @@ -81,7 +82,7 @@ public interface IVenueSession extends ISession { * The intended subject of the venue conversation. * @return */ - public void sendInvitation(String id, VenueInvite invite) + public void sendInvitation(UserId id, VenueInvite invite) throws CollaborationException; /** @@ -93,7 +94,7 @@ public interface IVenueSession extends ISession { * Any text that the user may wish to include. * @return */ - public void sendInvitation(List ids, VenueInvite invite) + public void sendInvitation(List ids, VenueInvite invite) throws CollaborationException; } diff --git a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/identity/roster/IRoster.java b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/identity/roster/IRoster.java index d8bc0f6148..0acebb59f0 100644 --- a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/identity/roster/IRoster.java +++ b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/identity/roster/IRoster.java @@ -139,7 +139,7 @@ public interface IRoster { * @param nickName * @param groups */ - void sendRosterAdd(String account, String nickName, String[] groups) + void sendRosterAdd(UserId account, String[] groups) throws CollaborationException; /** diff --git a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/identity/roster/IRosterManager.java b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/identity/roster/IRosterManager.java index 7b09d928a6..54c8cb11eb 100644 --- a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/identity/roster/IRosterManager.java +++ b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/identity/roster/IRosterManager.java @@ -81,7 +81,7 @@ public interface IRosterManager { * @param nickName * @param groups */ - void sendRosterAdd(String account, String nickName, String[] groups) + void sendRosterAdd(UserId account, String[] groups) throws CollaborationException; /** diff --git a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/roster/Roster.java b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/roster/Roster.java index 0e2d2e0b5e..63118c5997 100644 --- a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/roster/Roster.java +++ b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/roster/Roster.java @@ -231,7 +231,6 @@ public class Roster extends RosterItem implements IRoster { // so update with the presence. RosterEntry ret = (RosterEntry) re; ret.setPresence(entry.getPresence()); - } else { } } else { // nothing to do. And this shouldn't happen! @@ -257,9 +256,9 @@ public class Roster extends RosterItem implements IRoster { * @param groups */ @Override - public void sendRosterAdd(String account, String nickName, String[] groups) + public void sendRosterAdd(UserId account, String[] groups) throws CollaborationException { - rosterManager.sendRosterAdd(account, nickName, groups); + rosterManager.sendRosterAdd(account, groups); } /** @@ -340,5 +339,4 @@ public class Roster extends RosterItem implements IRoster { System.out .println("##########################################################################"); } - } diff --git a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/roster/RosterManager.java b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/roster/RosterManager.java index 95db51356f..d80b6b2edf 100644 --- a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/roster/RosterManager.java +++ b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/roster/RosterManager.java @@ -19,7 +19,9 @@ **/ package com.raytheon.uf.viz.collaboration.comm.provider.roster; +import java.util.ArrayList; import java.util.Collection; +import java.util.List; import org.eclipse.ecf.core.identity.ID; import org.eclipse.ecf.core.util.ECFException; @@ -31,6 +33,7 @@ import com.raytheon.uf.viz.collaboration.comm.identity.IPresence; import com.raytheon.uf.viz.collaboration.comm.identity.listener.IRosterListener; import com.raytheon.uf.viz.collaboration.comm.identity.roster.IRoster; import com.raytheon.uf.viz.collaboration.comm.identity.roster.IRosterEntry; +import com.raytheon.uf.viz.collaboration.comm.identity.roster.IRosterGroup; import com.raytheon.uf.viz.collaboration.comm.identity.roster.IRosterManager; import com.raytheon.uf.viz.collaboration.comm.provider.Presence; import com.raytheon.uf.viz.collaboration.comm.provider.session.CollaborationConnection; @@ -127,7 +130,7 @@ public class RosterManager implements IRosterManager { * @param groups */ @Override - public void sendRosterAdd(String account, String nickName, String[] groups) + public void sendRosterAdd(UserId account, String[] groups) throws CollaborationException { org.eclipse.ecf.presence.roster.IRosterManager manager = baseRoster .getPresenceContainerAdapter().getRosterManager(); @@ -136,7 +139,8 @@ public class RosterManager implements IRosterManager { .getRosterSubscriptionSender(); try { - sender.sendRosterAdd(account, nickName, groups); + sender.sendRosterAdd(account.getFQName(), account.getAlias(), + groups); } catch (ECFException e) { throw new CollaborationException(); } @@ -157,7 +161,7 @@ public class RosterManager implements IRosterManager { IRosterSubscriptionSender sender = manager .getRosterSubscriptionSender(); - ID id = sessionManager.createID(userId.getFQName()); + ID id = sessionManager.createID(userId); try { sender.sendRosterRemove(id); } catch (ECFException e) { @@ -189,6 +193,22 @@ public class RosterManager implements IRosterManager { */ public void updateEntry(IRosterEntry entry) { IRosterEntry modified = roster.modifyRosterEntry(entry); + IPresenceContainerAdapter adapter = baseRoster + .getPresenceContainerAdapter(); + org.eclipse.ecf.presence.roster.IRosterManager manager = adapter + .getRosterManager(); + List groups = new ArrayList(); + for (IRosterGroup grp : entry.getGroups()) { + groups.add(grp.getName()); + } + try { + manager.getRosterSubscriptionSender().sendRosterAdd( + entry.getUser().getFQName(), entry.getUser().getAlias(), + groups.toArray(new String[0])); + } catch (ECFException e) { + // TODO handle better + e.printStackTrace(); + } if (modified != null) { sessionManager.getEventPublisher().post(entry); } diff --git a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/CollaborationConnection.java b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/CollaborationConnection.java index 9d8333ba9b..65fde32fe9 100644 --- a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/CollaborationConnection.java +++ b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/CollaborationConnection.java @@ -120,7 +120,7 @@ public class CollaborationConnection implements IEventPublisher { private Map sessions; - private String account; + private UserId account; private String password; @@ -156,7 +156,7 @@ public class CollaborationConnection implements IEventPublisher { * @throws ContainerCreateException * */ - public CollaborationConnection(String account, String password) + public CollaborationConnection(UserId account, String password) throws CollaborationException { this(account, password, (IRosterEventSubscriber) null); } @@ -172,7 +172,7 @@ public class CollaborationConnection implements IEventPublisher { * @throws ContainerCreateException * */ - public CollaborationConnection(String account, String password, + public CollaborationConnection(UserId account, String password, IPresence initialPresence) throws Exception { this(account, password, (IRosterEventSubscriber) null); if (accountManager != null) { @@ -194,7 +194,7 @@ public class CollaborationConnection implements IEventPublisher { * A roster event subscriber. * @throws CollaborationException */ - public CollaborationConnection(String account, String password, + public CollaborationConnection(UserId account, String password, IRosterEventSubscriber rosterEventSubscriber) throws CollaborationException { eventBus = new EventBus(); @@ -315,7 +315,7 @@ public class CollaborationConnection implements IEventPublisher { * * @return The account string. */ - public String getAccount() { + public UserId getAccount() { return account; } @@ -422,10 +422,7 @@ public class CollaborationConnection implements IEventPublisher { if (session != null) { session.joinVenue(venueName); - String name = Tools.parseName(account); - String host = Tools.parseHost(account); - UserId me = new UserId(name, host); - session.setUserId(me); + session.setUserId(account); if (invitation.getInvite() instanceof SharedDisplayVenueInvite) { SharedDisplayVenueInvite invite = (SharedDisplayVenueInvite) invitation .getInvite(); @@ -455,14 +452,9 @@ public class CollaborationConnection implements IEventPublisher { session = new SharedDisplaySession(container, eventBus, this); session.createVenue(venueName, subject); - String name = Tools.parseName(account); - String host = Tools.parseHost(account); - - UserId me = new UserId(name, host); - - session.setCurrentSessionLeader(me); - session.setCurrentDataProvider(me); - session.setUserId(me); + session.setCurrentSessionLeader(account); + session.setCurrentDataProvider(account); + session.setUserId(account); sessions.put(session.getSessionId(), session); return session; @@ -741,11 +733,12 @@ public class CollaborationConnection implements IEventPublisher { * @param name * @return */ - public ID createID(String name) throws CollaborationException { + public ID createID(UserId name) throws CollaborationException { ID id = null; try { if (connectionNamespace != null) { - id = IDFactory.getDefault().createID(connectionNamespace, name); + id = IDFactory.getDefault().createID(connectionNamespace, + name.getFQName()); } } catch (IDCreateException idce) { throw new CollaborationException("Could not create id"); diff --git a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/VenueSession.java b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/VenueSession.java index 1750393404..8856b9104c 100644 --- a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/VenueSession.java +++ b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/session/VenueSession.java @@ -233,7 +233,7 @@ public class VenueSession extends BaseSession implements IVenueSession { * java.lang.String, java.lang.String, java.lang.String) */ @Override - public void sendInvitation(String id, VenueInvite invite) + public void sendInvitation(UserId id, VenueInvite invite) throws CollaborationException { IChatRoomInvitationSender sender = getConnectionPresenceAdapter() .getChatRoomManager().getInvitationSender(); @@ -241,7 +241,7 @@ public class VenueSession extends BaseSession implements IVenueSession { String msgBody = Tools.marshallData(invite); ID roomId = venueInfo.getConnectedID(); ID userId = IDFactory.getDefault().createID( - getConnectionNamespace(), id); + getConnectionNamespace(), id.getFQName()); try { sender.sendInvitation(roomId, userId, invite.getSubject(), @@ -267,10 +267,10 @@ public class VenueSession extends BaseSession implements IVenueSession { * java.lang.String, java.lang.String, java.lang.String) */ @Override - public void sendInvitation(List ids, VenueInvite invite) + public void sendInvitation(List ids, VenueInvite invite) throws CollaborationException { if (ids != null) { - for (String id : ids) { + for (UserId id : ids) { sendInvitation(id, invite); } } @@ -450,8 +450,8 @@ public class VenueSession extends BaseSession implements IVenueSession { String name = Tools.parseName(from.getName()); - String account = getSessionManager().getAccount(); - String aName = Tools.parseName(account); + UserId account = getSessionManager().getAccount(); + String aName = account.getFQName(); if (aName.equals(name)) { acceptMessage = false; } diff --git a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/user/UserId.java b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/user/UserId.java index 3c5bfa9a42..5735b64930 100644 --- a/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/user/UserId.java +++ b/cave/com.raytheon.uf.viz.collaboration/src/com/raytheon/uf/viz/collaboration/comm/provider/user/UserId.java @@ -83,7 +83,7 @@ public class UserId implements IQualifiedID { public UserId(String userName, String hostName, String resource, String alias) { this.name = userName; - this.host = hostName; + setHost(hostName); this.resource = resource; this.alias = alias; } @@ -112,8 +112,11 @@ public class UserId implements IQualifiedID { * @see com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID#setHostName(java.lang.String) */ @Override - public void setHost(String hostName) { - host = hostName; + public void setHost(String hostname) { + if (hostname.startsWith(CONF_ID)) { + hostname = hostname.substring(CONF_ID.length()); + } + host = hostname; } /** @@ -155,11 +158,7 @@ public class UserId implements IQualifiedID { public String getFQName() { StringBuilder sb = new StringBuilder(name); sb.append("@"); - String hostname = host; - if (hostname.startsWith(CONF_ID)) { - hostname = hostname.substring(CONF_ID.length()); - } - sb.append(hostname); + sb.append(host); sb.append("/"); if (resource != null) { sb.append(resource);