diff --git a/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/identity/IVenueSession.java b/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/identity/IVenueSession.java index e67ef23361..effa00e188 100644 --- a/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/identity/IVenueSession.java +++ b/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/identity/IVenueSession.java @@ -26,6 +26,7 @@ import org.jivesoftware.smack.packet.Presence; 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; +import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueId; import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueParticipant; /** @@ -55,6 +56,7 @@ import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueParticipant; * Jan 30, 2014 2698 bclement changed UserId to VenueParticipant * Mar 06, 2014 2751 bclement added isAdmin() * Mar 07, 2014 2848 bclement added getVenueName() and hasOtherParticipants() + * Oct 08, 2014 3705 bclement added getVenueId() * * * @@ -76,6 +78,11 @@ public interface IVenueSession extends ISession { */ public String getVenueName(); + /** + * @return qualified id of venue on server + */ + public VenueId getVenueId(); + /** * Send a chat message. * diff --git a/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/provider/connection/CollaborationConnection.java b/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/provider/connection/CollaborationConnection.java index 5e71f11fef..696d6a52ca 100644 --- a/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/provider/connection/CollaborationConnection.java +++ b/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/provider/connection/CollaborationConnection.java @@ -21,8 +21,11 @@ package com.raytheon.uf.viz.collaboration.comm.provider.connection; import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; +import java.util.List; import java.util.Map; import java.util.Map.Entry; +import java.util.TreeSet; import java.util.concurrent.ConcurrentHashMap; import org.apache.commons.lang.StringUtils; @@ -35,6 +38,9 @@ import org.jivesoftware.smack.packet.Message; import org.jivesoftware.smack.packet.Presence; import org.jivesoftware.smack.packet.XMPPError; import org.jivesoftware.smack.provider.ProviderManager; +import org.jivesoftware.smackx.bookmark.BookmarkManager; +import org.jivesoftware.smackx.bookmark.BookmarkedConference; +import org.jivesoftware.smackx.muc.HostedRoom; import org.jivesoftware.smackx.muc.MultiUserChat; import org.jivesoftware.smackx.pubsub.PubSubElementType; import org.jivesoftware.smackx.pubsub.packet.PubSubNamespace; @@ -62,6 +68,8 @@ import com.raytheon.uf.viz.collaboration.comm.packet.SessionPayload; import com.raytheon.uf.viz.collaboration.comm.packet.SessionPayloadProvider; import com.raytheon.uf.viz.collaboration.comm.provider.account.AccountManager; import com.raytheon.uf.viz.collaboration.comm.provider.account.ClientAuthManager; +import com.raytheon.uf.viz.collaboration.comm.provider.event.BookmarkEvent; +import com.raytheon.uf.viz.collaboration.comm.provider.event.BookmarkEvent.Type; import com.raytheon.uf.viz.collaboration.comm.provider.event.VenueUserEvent; import com.raytheon.uf.viz.collaboration.comm.provider.session.CreateSessionData; import com.raytheon.uf.viz.collaboration.comm.provider.session.FeedVenueConfigManager; @@ -126,6 +134,7 @@ import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueParticipant; * May 09, 2014 3107 bclement added ability for packet timeout to be set via system properties * May 19, 2014 3180 bclement added getJoinedVenueSessions() * Jun 16, 2014 3288 bclement feed venue configuration changes + * Oct 08, 2014 3705 bclement added bookmarks, joinTextOnlyVenue() and getPublicRooms() * * * @@ -556,6 +565,27 @@ public class CollaborationConnection implements IEventPublisher { return session; } + /** + * Join existing chat room with provided handle + * + * @param venueId + * @param handle + * @return + * @throws CollaborationException + */ + public VenueSession joinTextOnlyVenue(VenueId venueId, String handle) + throws CollaborationException { + VenueSession session = createTextOnlyVenue(venueId, handle); + try { + session.configureVenue(); + postEvent(session); + return session; + } catch (CollaborationException e) { + removeSession(session); + throw e; + } + } + /** * Check if venue exists on server * @@ -625,6 +655,29 @@ public class CollaborationConnection implements IEventPublisher { return sessions.values(); } + /** + * @return list of public chat rooms on server + */ + public Collection getPublicRooms() { + XMPPConnection conn = getXmppConnection(); + String mucService = VenueId.DEFAULT_SUBDOMAIN + "." + + conn.getServiceName(); + Collection results; + try { + results = MultiUserChat.getHostedRooms(conn, mucService); + } catch (XMPPException e) { + statusHandler.error("Problem getting public room list from server", + e); + results = Collections.emptyList(); + } + Collection rval = new TreeSet<>(); + for (HostedRoom room : results) { + rval.add(new VenueId(room.getJid())); + } + + return rval; + } + /** * @return all IVenueSessions that this user is a participant in */ @@ -682,4 +735,82 @@ public class CollaborationConnection implements IEventPublisher { return statusHandler; } + /** + * @return collection of chat rooms bookmarked by user + * @throws CollaborationException + */ + public Collection getBookmarkedRooms() + throws CollaborationException { + Collection bookmarkedConferences; + try { + BookmarkManager bmkManager = BookmarkManager + .getBookmarkManager(getXmppConnection()); + bookmarkedConferences = bmkManager.getBookmarkedConferences(); + } catch (XMPPException e) { + throw new CollaborationException( + "Unable to get list of bookmarked rooms from server", e); + } + List rval = new ArrayList<>(bookmarkedConferences.size()); + for (BookmarkedConference conf : bookmarkedConferences) { + rval.add(new VenueId(conf.getJid())); + } + return rval; + } + + /** + * Bookmark room on server + * + * @param room + * @throws CollaborationException + */ + public void bookmarkRoom(VenueId room) throws CollaborationException { + try { + BookmarkManager bmkManager = BookmarkManager + .getBookmarkManager(getXmppConnection()); + bmkManager.addBookmarkedConference(room.getName(), + room.getFQName(), false, null, null); + postEvent(new BookmarkEvent(Type.ADDED, room)); + } catch (XMPPException e) { + throw new CollaborationException("Unable to bookmark room: " + + room.getFQName(), e); + } + } + + /** + * Remove bookmark for room from server + * + * @param room + * @throws CollaborationException + */ + public void removeBookmark(VenueId room) throws CollaborationException { + try { + BookmarkManager bmkManager = BookmarkManager + .getBookmarkManager(getXmppConnection()); + bmkManager.removeBookmarkedConference(room.getFQName()); + postEvent(new BookmarkEvent(Type.REMOVED, room)); + } catch (XMPPException e) { + throw new CollaborationException( + "Unable to remove bookmark for room: " + room.getFQName(), + e); + } + } + + /** + * Find session this user is joined to by venue id + * + * @param room + * @return null if not joined to room + */ + public IVenueSession getJoinedVenueSession(VenueId room) { + IVenueSession rval = null; + Collection joinedRooms = getJoinedVenueSessions(); + for (IVenueSession session : joinedRooms) { + VenueId vid = session.getVenueId(); + if (room.equals(vid)) { + rval = session; + break; + } + } + return rval; + } } diff --git a/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/provider/event/BookmarkEvent.java b/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/provider/event/BookmarkEvent.java new file mode 100644 index 0000000000..bbeb32669a --- /dev/null +++ b/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/provider/event/BookmarkEvent.java @@ -0,0 +1,72 @@ +/** + * 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.comm.provider.event; + +import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueId; + +/** + * Event triggered when the user adds or removes a bookmark for a chat room + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Oct 8, 2014  3705      bclement     Initial creation
+ * 
+ * 
+ * + * @author bclement + * @version 1.0 + */ +public class BookmarkEvent { + + public static enum Type { + ADDED, REMOVED + }; + + private final Type type; + + private final VenueId room; + + /** + * + */ + public BookmarkEvent(Type type, VenueId room) { + this.type = type; + this.room = room; + } + + /** + * @return the type + */ + public Type getType() { + return type; + } + + /** + * @return the room + */ + public VenueId getRoom() { + return room; + } + +} diff --git a/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/provider/session/VenueSession.java b/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/provider/session/VenueSession.java index 04ecaca107..edecaf14ad 100644 --- a/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/provider/session/VenueSession.java +++ b/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/provider/session/VenueSession.java @@ -113,6 +113,7 @@ import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueParticipant; * Apr 29, 2014 3061 bclement moved invite payload to shared display session * May 09, 2014 3107 bclement removed catch from isRoomOwner() so callers know about errors * Jun 16, 2014 3288 bclement changed String venueName to VenueId venueId, added createVenueId() + * Oct 08, 2014 3705 bclement aded getVenueId() * * * @@ -1004,4 +1005,16 @@ public class VenueSession extends BaseSession implements IVenueSession { venueName); } + /* + * (non-Javadoc) + * + * @see + * com.raytheon.uf.viz.collaboration.comm.identity.IVenueSession#getVenueId + * () + */ + @Override + public VenueId getVenueId() { + return venueId; + } + } diff --git a/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/provider/user/VenueId.java b/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/provider/user/VenueId.java index 965b17b438..7c3e5b17d1 100644 --- a/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/provider/user/VenueId.java +++ b/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/provider/user/VenueId.java @@ -19,6 +19,8 @@ **/ package com.raytheon.uf.viz.collaboration.comm.provider.user; +import org.jivesoftware.smack.util.StringUtils; + import com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID; import com.raytheon.uf.viz.collaboration.comm.provider.Tools; @@ -35,6 +37,7 @@ import com.raytheon.uf.viz.collaboration.comm.provider.Tools; * Feb 13, 2014 2751 bclement removed resource, fixed getFQN * May 19, 2014 3180 bclement added isSameVenue() fromString() and hashcode/equals * Jun 16, 2014 3288 bclement added constructors, default subdomain + * Oct 08, 2014 3705 bclement added single string constructor, compareTo() * * * @@ -42,7 +45,7 @@ import com.raytheon.uf.viz.collaboration.comm.provider.Tools; * @version 1.0 */ -public class VenueId implements IQualifiedID { +public class VenueId implements IQualifiedID, Comparable { public static final String DEFAULT_SUBDOMAIN = "conference"; @@ -56,6 +59,11 @@ public class VenueId implements IQualifiedID { public VenueId() { } + public VenueId(String jid) { + this.name = StringUtils.parseName(jid); + this.host = StringUtils.parseServer(jid); + } + /** * @param host * @param name @@ -189,4 +197,30 @@ public class VenueId implements IQualifiedID { rval.setHost(Tools.parseHost(venueId)); return rval; } + + /* + * (non-Javadoc) + * + * @see java.lang.Comparable#compareTo(java.lang.Object) + */ + @Override + public int compareTo(VenueId o) { + int rval; + if (o == null) { + rval = 1; + } else if (this.name == null) { + if (o.name == null) { + rval = 0; + } else { + rval = -1; + } + } else { + if (o.name == null) { + rval = 1; + } else { + rval = this.name.compareTo(o.name); + } + } + return rval; + } } 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 7ee887f548..ea3fa4323d 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 @@ -87,12 +87,14 @@ import com.raytheon.uf.viz.collaboration.comm.identity.IVenueSession; import com.raytheon.uf.viz.collaboration.comm.identity.event.IRosterChangeEvent; import com.raytheon.uf.viz.collaboration.comm.identity.event.RosterChangeType; import com.raytheon.uf.viz.collaboration.comm.provider.connection.CollaborationConnection; +import com.raytheon.uf.viz.collaboration.comm.provider.event.BookmarkEvent; import com.raytheon.uf.viz.collaboration.comm.provider.event.UserPresenceChangedEvent; import com.raytheon.uf.viz.collaboration.comm.provider.user.ContactsManager; import com.raytheon.uf.viz.collaboration.comm.provider.user.ContactsManager.GroupListener; import com.raytheon.uf.viz.collaboration.comm.provider.user.IDConverter; import com.raytheon.uf.viz.collaboration.comm.provider.user.SharedGroup; import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId; +import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueId; import com.raytheon.uf.viz.collaboration.ui.actions.AddNotifierAction; import com.raytheon.uf.viz.collaboration.ui.actions.AddToGroupAction; import com.raytheon.uf.viz.collaboration.ui.actions.ArchiveViewerAction; @@ -106,10 +108,12 @@ import com.raytheon.uf.viz.collaboration.ui.actions.CreateSessionAction; import com.raytheon.uf.viz.collaboration.ui.actions.DeleteGroupAction; import com.raytheon.uf.viz.collaboration.ui.actions.DisplayFeedAction; import com.raytheon.uf.viz.collaboration.ui.actions.InviteAction; +import com.raytheon.uf.viz.collaboration.ui.actions.JoinRoomAction; import com.raytheon.uf.viz.collaboration.ui.actions.LinkToEditorAction; import com.raytheon.uf.viz.collaboration.ui.actions.LoginAction; import com.raytheon.uf.viz.collaboration.ui.actions.LogoutAction; import com.raytheon.uf.viz.collaboration.ui.actions.PeerToPeerChatAction; +import com.raytheon.uf.viz.collaboration.ui.actions.RemoveBookmarkAction; import com.raytheon.uf.viz.collaboration.ui.actions.RemoveFromGroupAction; import com.raytheon.uf.viz.collaboration.ui.actions.RemoveFromRosterAction; import com.raytheon.uf.viz.collaboration.ui.actions.SendSubReqAction; @@ -117,6 +121,7 @@ import com.raytheon.uf.viz.collaboration.ui.actions.ShowVenueAction; import com.raytheon.uf.viz.collaboration.ui.actions.UserSearchAction; import com.raytheon.uf.viz.collaboration.ui.data.AlertWordWrapper; import com.raytheon.uf.viz.collaboration.ui.data.CollaborationGroupContainer; +import com.raytheon.uf.viz.collaboration.ui.data.PublicRoomContainer; import com.raytheon.uf.viz.collaboration.ui.data.SessionGroupContainer; import com.raytheon.uf.viz.collaboration.ui.notifier.NotifierTools; import com.raytheon.uf.viz.collaboration.ui.prefs.CollabPrefConstants; @@ -154,6 +159,7 @@ import com.raytheon.viz.ui.views.CaveWorkbenchPageManager; * Apr 11, 2014 2903 bclement login action changes, removed server disconnect listener, * added static utility method to show view * May 19, 2014 3180 bclement fixed inviting multiple users to session + * Oct 08, 2014 3705 bclement added room search and bookmarking * * * @@ -192,6 +198,8 @@ public class CollaborationGroupView extends CaveFloatingView implements private LogoutAction logOut; + private Action roomSearchAction; + /** * @param parent */ @@ -307,6 +315,15 @@ public class CollaborationGroupView extends CaveFloatingView implements // this is either on or off, so it is a toggle displayFeedAction = new DisplayFeedAction(); + roomSearchAction = new Action("Public Room Search...", + IconUtil.getImageDescriptor(Activator.getDefault().getBundle(), + "spyglass.gif")) { + public void run() { + new RoomSearchDialog(Display.getCurrent().getActiveShell()) + .open(); + }; + }; + this.disableOrEnableToolbarActions(); } @@ -341,6 +358,7 @@ public class CollaborationGroupView extends CaveFloatingView implements private void createMenu(IMenuManager mgr) { mgr.add(new UserSearchAction()); + mgr.add(roomSearchAction); mgr.add(new Separator()); mgr.add(new ChangeFontAction()); mgr.add(new ChangeStatusAction()); @@ -413,6 +431,9 @@ public class CollaborationGroupView extends CaveFloatingView implements if (o instanceof SessionGroupContainer) { manager.add(createSessionAction); return; + } else if (o instanceof PublicRoomContainer){ + manager.add(roomSearchAction); + return; } else if (o instanceof IVenueSession) { manager.add(new ShowVenueAction((IVenueSession) o)); manager.add(new ArchiveViewerAction((IVenueSession) o)); @@ -458,6 +479,11 @@ public class CollaborationGroupView extends CaveFloatingView implements renameAction.setId(group.getName()); manager.add(renameAction); } + } else if (o instanceof VenueId) { + VenueId venue = (VenueId) o; + manager.add(new JoinRoomAction(venue, false)); + manager.add(new JoinRoomAction(venue, true)); + manager.add(new RemoveBookmarkAction(venue)); } } @@ -515,6 +541,8 @@ public class CollaborationGroupView extends CaveFloatingView implements new PeerToPeerChatAction(user).run(); } else if (o instanceof IVenueSession) { new ShowVenueAction((IVenueSession) o).run(); + } else if (o instanceof VenueId) { + new JoinRoomAction((VenueId) o, false).run(); } } }); @@ -913,6 +941,11 @@ public class CollaborationGroupView extends CaveFloatingView implements refreshUsersTreeViewerAsync(topLevel.getSessionGroup()); } + @Subscribe + public void handleBookmarkEvent(BookmarkEvent event) { + refreshUsersTreeViewerAsync(topLevel.getPublicRoomGroup()); + } + /** * Enables or disables the toolbar buttons based on whether or not the user * is connected to the xmpp server. diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/RoomSearchDialog.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/RoomSearchDialog.java new file mode 100644 index 0000000000..3d2b94abc1 --- /dev/null +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/RoomSearchDialog.java @@ -0,0 +1,183 @@ +/** + * 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.ui; + +import java.util.Collection; + +import org.eclipse.jface.action.IMenuListener; +import org.eclipse.jface.action.IMenuManager; +import org.eclipse.jface.action.MenuManager; +import org.eclipse.jface.layout.TableColumnLayout; +import org.eclipse.jface.viewers.ColumnWeightData; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.RowData; +import org.eclipse.swt.layout.RowLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Menu; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.TableColumn; +import org.eclipse.swt.widgets.TableItem; + +import com.raytheon.uf.viz.collaboration.comm.provider.connection.CollaborationConnection; +import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueId; +import com.raytheon.uf.viz.collaboration.ui.actions.AddBookmarkAction; +import com.raytheon.uf.viz.collaboration.ui.actions.JoinRoomAction; +import com.raytheon.viz.ui.dialogs.CaveSWTDialog; + +/** + * Dialog for finding public chat rooms on server + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Oct 8, 2014  3705      bclement     Initial creation
+ * 
+ * 
+ * + * @author bclement + * @version 1.0 + */ +public class RoomSearchDialog extends CaveSWTDialog { + + private Table resultTable; + + /** + * @param parentShell + */ + public RoomSearchDialog(Shell parentShell) { + super(parentShell); + setText("Room Search"); + } + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#initializeComponents(org + * .eclipse.swt.widgets.Shell) + */ + @Override + protected void initializeComponents(Shell shell) { + initializeResultsTable(shell); + initializeButtonBar(shell); + } + + private void initializeResultsTable(Shell shell) { + Composite tableComp = new Composite(shell, SWT.NONE); + GridData gridData = new GridData(500, 200); + gridData.horizontalAlignment = SWT.FILL; + gridData.verticalAlignment = SWT.FILL; + gridData.grabExcessHorizontalSpace = true; + gridData.grabExcessVerticalSpace = true; + tableComp.setLayoutData(gridData); + resultTable = new Table(tableComp, SWT.BORDER | SWT.V_SCROLL + | SWT.H_SCROLL | SWT.MULTI | SWT.FULL_SELECTION); + resultTable.setHeaderVisible(true); + resultTable.setLinesVisible(true); + TableColumn nameColumn = new TableColumn(resultTable, SWT.LEFT); + nameColumn.setText("Room Name"); + TableColumn idColumn = new TableColumn(resultTable, SWT.LEFT); + idColumn.setText("Service"); + + TableColumnLayout tcl = new TableColumnLayout(); + tableComp.setLayout(tcl); + tcl.setColumnData(nameColumn, new ColumnWeightData(40)); + tcl.setColumnData(idColumn, new ColumnWeightData(60)); + + MenuManager menuMgr = new MenuManager(); + menuMgr.setRemoveAllWhenShown(true); + menuMgr.addMenuListener(new IMenuListener() { + + @Override + public void menuAboutToShow(IMenuManager manager) { + fillContextMenu(manager); + } + + }); + Menu menu = menuMgr.createContextMenu(resultTable); + resultTable.setMenu(menu); + search(); + } + + private void initializeButtonBar(Shell shell) { + Composite buttonComp = new Composite(shell, SWT.NONE); + buttonComp.setLayoutData(new GridData(SWT.RIGHT, SWT.NONE, false, + false, 1, 1)); + RowLayout layout = new RowLayout(SWT.HORIZONTAL); + layout.pack = false; + buttonComp.setLayout(layout); + + Button closeButton = new Button(buttonComp, SWT.PUSH); + closeButton.setText("Close"); + closeButton.addSelectionListener(new SelectionAdapter() { + + @Override + public void widgetSelected(SelectionEvent e) { + close(); + } + + }); + closeButton.setLayoutData(new RowData(90, SWT.DEFAULT)); + } + + private void fillContextMenu(IMenuManager manager) { + TableItem[] selection = resultTable.getSelection(); + if (selection == null || selection.length == 0) { + return; + } + VenueId[] rooms = new VenueId[selection.length]; + for (int i = 0; i < rooms.length; i += 1) { + rooms[i] = (VenueId) selection[i].getData(); + } + if (rooms.length == 1) { + manager.add(new JoinRoomAction(rooms[0], false)); + manager.add(new JoinRoomAction(rooms[0], true)); + } + manager.add(new AddBookmarkAction(rooms)); + } + + private void search() { + CollaborationConnection conn = CollaborationConnection.getConnection(); + Collection results = conn.getPublicRooms(); + resultTable.removeAll(); + if (results.size() > 0) { + for (VenueId room : results) { + TableItem ti = new TableItem(resultTable, SWT.NONE); + ti.setText(0, room.getName()); + ti.setText(1, room.getHost()); + ti.setData(room); + } + resultTable.setEnabled(true); + } else { + TableItem ti = new TableItem(resultTable, SWT.NONE); + ti.setText("No rooms found."); + resultTable.setEnabled(false); + } + } + +} 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 a17c4b8e84..254c7297ae 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 @@ -35,7 +35,7 @@ import com.raytheon.uf.viz.collaboration.comm.provider.connection.CollaborationC import com.raytheon.uf.viz.collaboration.comm.provider.user.SharedGroup; import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId; import com.raytheon.uf.viz.collaboration.ui.data.CollaborationGroupContainer; -import com.raytheon.uf.viz.collaboration.ui.data.SessionGroupContainer; +import com.raytheon.uf.viz.collaboration.ui.data.TreeObjectContainer; /** * Provides access to contacts list tree @@ -51,6 +51,7 @@ import com.raytheon.uf.viz.collaboration.ui.data.SessionGroupContainer; * Jan 24, 2014 2701 bclement removed local groups, added shared groups * Jan 27, 2014 2700 bclement added support roster entries * Apr 24, 2014 3070 bclement removed check for hasInteraction() from group entries + * Oct 08, 2014 3705 bclement replaced checks for SessionGroupContainer with TreeObjectContainer * * * @@ -93,9 +94,9 @@ public class UsersTreeContentProvider implements ITreeContentProvider { */ @Override public Object[] getElements(Object inputElement) { - if (inputElement instanceof SessionGroupContainer) { - SessionGroupContainer group = (SessionGroupContainer) inputElement; - return group.getObjects().toArray(); + if (inputElement instanceof TreeObjectContainer) { + TreeObjectContainer cont = (TreeObjectContainer) inputElement; + return cont.getObjects(); } else if (inputElement instanceof CollaborationGroupContainer) { CollaborationGroupContainer cont = (CollaborationGroupContainer) inputElement; return cont.getObjects().toArray(); @@ -115,9 +116,9 @@ public class UsersTreeContentProvider implements ITreeContentProvider { public Object[] getChildren(Object parentElement) { // 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(); + if (parentElement instanceof TreeObjectContainer) { + TreeObjectContainer cont = (TreeObjectContainer) parentElement; + return cont.getObjects(); } else if (parentElement instanceof RosterGroup) { RosterGroup group = (RosterGroup) parentElement; return getRosterChildren(group.getEntries()); @@ -177,9 +178,9 @@ public class UsersTreeContentProvider implements ITreeContentProvider { } else if (element instanceof SharedGroup) { SharedGroup group = (SharedGroup) element; hasChildren = rosterHasChildren(group.getEntries()); - } else if (element instanceof SessionGroupContainer) { - SessionGroupContainer cont = (SessionGroupContainer) element; - if (cont.getObjects() != null && cont.getObjects().size() > 0) { + } else if (element instanceof TreeObjectContainer) { + TreeObjectContainer cont = (TreeObjectContainer) element; + if (cont.getObjects() != null && cont.getObjects().length > 0) { hasChildren = true; } else { hasChildren = false; 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 21e6ad134a..61a5abfce7 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 @@ -43,7 +43,8 @@ import com.raytheon.uf.viz.collaboration.comm.provider.user.ContactsManager; import com.raytheon.uf.viz.collaboration.comm.provider.user.IDConverter; import com.raytheon.uf.viz.collaboration.comm.provider.user.SharedGroup; import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId; -import com.raytheon.uf.viz.collaboration.ui.data.SessionGroupContainer; +import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueId; +import com.raytheon.uf.viz.collaboration.ui.data.TreeObjectContainer; /** * Provides contacts list UI elements with icons, text, tooltips, etc @@ -64,6 +65,7 @@ import com.raytheon.uf.viz.collaboration.ui.data.SessionGroupContainer; * Feb 17, 2014 2751 bclement added block image logic to userLabelProvider * Mar 06, 2014 2848 bclement get venueName directly from session * Jun 12, 2014 3267 bclement fixed missing null-check for outdated UI info + * Oct 08, 2014 3705 bclement replaced checks for SessionGroupContainer with TreeObjectContainer * * * @@ -164,9 +166,9 @@ public class UsersTreeLabelProvider extends ColumnLabelProvider { key = "shared_group"; } else if (element instanceof IVenueSession) { // key = "session_group"; - } else if (element instanceof SessionGroupContainer) { - key = "session_group"; - } + } else if (element instanceof TreeObjectContainer) { + key = ((TreeObjectContainer) element).getIcon(); + } if (imageMap.get(key) == null && !key.equals("")) { imageMap.put(key, CollaborationUtils.getNodeImage(key)); @@ -182,8 +184,8 @@ public class UsersTreeLabelProvider extends ColumnLabelProvider { return ((SharedGroup) element).getName(); } else if (element instanceof RosterEntry) { return userLabelProvider.getText((RosterEntry) element); - } else if (element instanceof SessionGroupContainer) { - return "Active Sessions"; + } else if (element instanceof TreeObjectContainer) { + return ((TreeObjectContainer) element).getLabel(); } else if (element instanceof UserId) { UserId user = (UserId) element; String fullname = userLabelProvider.getText(element); @@ -201,6 +203,8 @@ public class UsersTreeLabelProvider extends ColumnLabelProvider { return null; } return venue.getVenueName(); + } else if (element instanceof VenueId) { + return ((VenueId) element).getName(); } return null; } @@ -208,7 +212,7 @@ public class UsersTreeLabelProvider extends ColumnLabelProvider { @Override public Font getFont(Object element) { if (element instanceof RosterGroup || element instanceof SharedGroup - || element instanceof SessionGroupContainer) { + || element instanceof TreeObjectContainer) { // for this case do nothing, as it is not the top level of // session groups if (boldFont == 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 57330d5a25..bdd794b44c 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 @@ -28,6 +28,8 @@ import org.jivesoftware.smack.RosterGroup; import com.raytheon.uf.viz.collaboration.comm.identity.IVenueSession; import com.raytheon.uf.viz.collaboration.comm.provider.user.SharedGroup; import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId; +import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueId; +import com.raytheon.uf.viz.collaboration.ui.data.PublicRoomContainer; import com.raytheon.uf.viz.collaboration.ui.data.SessionGroupContainer; /** @@ -42,6 +44,7 @@ import com.raytheon.uf.viz.collaboration.ui.data.SessionGroupContainer; * Mar 1, 2012 rferrel Initial creation * Dec 6, 2013 2561 bclement removed ECF * Jan 24, 2014 2701 bclement removed local groups, added shared groups + * Oct 08, 2014 3705 bclement added public rooms (venue ids) * * * @@ -74,6 +77,15 @@ public class UsersTreeViewerSorter extends ViewerSorter { return 1; } + /* bookmarked rooms next */ + if (e1 instanceof PublicRoomContainer) { + if ((e2 instanceof PublicRoomContainer) == false) { + return -1; + } + } else if (e2 instanceof PublicRoomContainer) { + return 1; + } + // Groups before users. if (e1 instanceof SharedGroup) { if (!(e2 instanceof SharedGroup)) { @@ -129,6 +141,10 @@ public class UsersTreeViewerSorter extends ViewerSorter { ((RosterGroup) e2).getName()); } + if (e1 instanceof VenueId && e2 instanceof VenueId) { + return ((VenueId) e1).compareTo((VenueId) e2); + } + return 0; } } diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/actions/AddBookmarkAction.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/actions/AddBookmarkAction.java new file mode 100644 index 0000000000..0ab921b0aa --- /dev/null +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/actions/AddBookmarkAction.java @@ -0,0 +1,78 @@ +/** + * 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.ui.actions; + +import org.eclipse.jface.action.Action; + +import com.raytheon.uf.viz.collaboration.comm.identity.CollaborationException; +import com.raytheon.uf.viz.collaboration.comm.provider.connection.CollaborationConnection; +import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueId; +import com.raytheon.uf.viz.collaboration.ui.Activator; + +/** + * Adds bookmarks for public chatrooms + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Oct 8, 2014  3705      bclement     Initial creation
+ * 
+ * 
+ * + * @author bclement + * @version 1.0 + */ +public class AddBookmarkAction extends Action { + + private final VenueId[] rooms; + + /** + * + */ + public AddBookmarkAction(VenueId... rooms) { + super("Add Bookmark"); + this.rooms = rooms; + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.action.Action#run() + */ + @Override + public void run() { + CollaborationConnection connection = CollaborationConnection + .getConnection(); + if (connection != null) { + for (VenueId room : rooms) { + try { + connection.bookmarkRoom(room); + } catch (CollaborationException e) { + Activator.statusHandler.error("Unable to bookmark room: " + + room.getFQName(), e); + } + } + } + } + +} diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/actions/DisplayFeedAction.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/actions/DisplayFeedAction.java index 6e004472a5..1d3efe65ae 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/actions/DisplayFeedAction.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/actions/DisplayFeedAction.java @@ -71,6 +71,7 @@ import com.raytheon.viz.ui.views.CaveWorkbenchPageManager; * Apr 10, 2014 2937 bgonzale Connect to the venue after the feed view is available * to display messages. * Jun 16, 2014 3288 bclement feed venue configuration changes + * Oct 08, 2014 3705 bclement moved venue joining code to CollaborationConnection * * * @@ -133,14 +134,11 @@ public class DisplayFeedAction extends Action { String defaultHandle = HandleUtil.getDefaultHandle(); FeedVenueConfig config = FeedVenueConfigManager.getConfig(); VenueId venueId = createVenueId(config); - VenueSession session = connection.createTextOnlyVenue(venueId, - defaultHandle); try { - session.configureVenue(); - connection.postEvent(session); + VenueSession session = connection.joinTextOnlyVenue(venueId, + defaultHandle); return session; } catch (CollaborationException e) { - connection.removeSession(session); final String msg = e.getLocalizedMessage() + "\n\nDefault handle options can be set in the Collaboration Preferences page."; VizApp.runAsync(new Runnable() { diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/actions/JoinRoomAction.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/actions/JoinRoomAction.java new file mode 100644 index 0000000000..04e43262b0 --- /dev/null +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/actions/JoinRoomAction.java @@ -0,0 +1,136 @@ +/** + * 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.ui.actions; + +import org.eclipse.jface.action.Action; +import org.eclipse.jface.dialogs.InputDialog; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.window.Window; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.PartInitException; + +import com.raytheon.uf.common.status.IUFStatusHandler; +import com.raytheon.uf.common.status.UFStatus; +import com.raytheon.uf.viz.collaboration.comm.identity.CollaborationException; +import com.raytheon.uf.viz.collaboration.comm.identity.IVenueSession; +import com.raytheon.uf.viz.collaboration.comm.provider.connection.CollaborationConnection; +import com.raytheon.uf.viz.collaboration.comm.provider.session.VenueSession; +import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueId; +import com.raytheon.uf.viz.collaboration.ui.prefs.HandleUtil; +import com.raytheon.uf.viz.collaboration.ui.session.SessionView; +import com.raytheon.viz.ui.views.CaveWorkbenchPageManager; + +/** + * Action for joining a public chat room on server + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Oct 8, 2014  3705      bclement     Initial creation
+ * 
+ * 
+ * + * @author bclement + * @version 1.0 + */ +public class JoinRoomAction extends Action { + + private static final IUFStatusHandler log = UFStatus + .getHandler(JoinRoomAction.class); + + private final boolean promptForHandle; + + private final VenueId room; + + /** + * + */ + public JoinRoomAction(VenueId room, boolean promptForHandle) { + super(promptForHandle ? "Join with Custom Handle" + : "Join with Default Handle"); + this.promptForHandle = promptForHandle; + this.room = room; + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.action.Action#run() + */ + @Override + public void run() { + CollaborationConnection connection = CollaborationConnection + .getConnection(); + IVenueSession joinedVenueSession = connection + .getJoinedVenueSession(room); + if (joinedVenueSession != null) { + openExistingSession(joinedVenueSession); + return; + } + String handle = HandleUtil.getDefaultHandle(); + if (promptForHandle) { + Shell shell = new Shell(Display.getCurrent()); + InputDialog dlg = new InputDialog(shell, "Join Room", + "Enter handle for room: " + room.getName(), handle, null); + if (dlg.open() == Window.OK) { + handle = dlg.getValue(); + } else { + /* user cancelled the dialog, abort joining the room */ + return; + } + } + + if (connection != null) { + try { + VenueSession session = connection.joinTextOnlyVenue(room, + handle); + CaveWorkbenchPageManager page = CaveWorkbenchPageManager + .getActiveInstance(); + page.showView(SessionView.ID, session.getSessionId(), + IWorkbenchPage.VIEW_ACTIVATE); + session.connectToRoom(); + } catch (CollaborationException | PartInitException e) { + log.error("Unable to join room " + room.getFQName(), e); + } + } + } + + private void openExistingSession(IVenueSession session) { + if (promptForHandle) { + Shell shell = new Shell(Display.getCurrent()); + /* we are already in the room, prompt user before continuing */ + if (!MessageDialog.openQuestion(shell, "Already In Room", + "Already joined to room '" + room.getName() + + "' with handle '" + + session.getUserID().getHandle() + + "'. Open Session?")) { + /* user aborted */ + return; + } + } + new ShowVenueAction(session).run(); + } + +} diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/actions/RemoveBookmarkAction.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/actions/RemoveBookmarkAction.java new file mode 100644 index 0000000000..b474715eb4 --- /dev/null +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/actions/RemoveBookmarkAction.java @@ -0,0 +1,79 @@ +/** + * 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.ui.actions; + +import org.eclipse.jface.action.Action; + +import com.raytheon.uf.viz.collaboration.comm.identity.CollaborationException; +import com.raytheon.uf.viz.collaboration.comm.provider.connection.CollaborationConnection; +import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueId; +import com.raytheon.uf.viz.collaboration.ui.Activator; + +/** + * Remove bookmark for public chat room on server + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Oct 8, 2014  3705      bclement     Initial creation
+ * 
+ * 
+ * + * @author bclement + * @version 1.0 + */ +public class RemoveBookmarkAction extends Action { + + private final VenueId[] rooms; + + /** + * + */ + public RemoveBookmarkAction(VenueId... rooms) { + super("Remove Bookmark"); + this.rooms = rooms; + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.action.Action#run() + */ + @Override + public void run() { + CollaborationConnection connection = CollaborationConnection + .getConnection(); + if (connection != null) { + for (VenueId room : rooms) { + try { + connection.removeBookmark(room); + } catch (CollaborationException e) { + Activator.statusHandler.error( + "Unable to remove bookmark for room: " + + room.getFQName(), e); + } + } + } + } + +} diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/data/CollaborationGroupContainer.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/data/CollaborationGroupContainer.java index a202f9221d..f51f6fddb8 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/data/CollaborationGroupContainer.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/data/CollaborationGroupContainer.java @@ -39,6 +39,7 @@ import com.raytheon.uf.viz.collaboration.comm.provider.user.ContactsManager; * Apr 23, 2012 mnash Initial creation * Dec 20, 2013 2563 bclement added items from server roster not in groups * Jan 24, 2014 2701 bclement removed local groups, added shared groups + * Oct 08, 2014 3705 bclement added public room group * * * @@ -48,7 +49,9 @@ import com.raytheon.uf.viz.collaboration.comm.provider.user.ContactsManager; public class CollaborationGroupContainer { - private SessionGroupContainer sessionGroup = new SessionGroupContainer(); + private final SessionGroupContainer sessionGroup = new SessionGroupContainer(); + + private final PublicRoomContainer publicRoomGroup = new PublicRoomContainer(); public CollaborationGroupContainer() { } @@ -67,6 +70,7 @@ public class CollaborationGroupContainer { List result = new ArrayList(); result.add(connection.getUser()); result.add(sessionGroup); + result.add(publicRoomGroup); ContactsManager contactsManager = connection.getContactsManager(); result.addAll(contactsManager.getSharedGroups()); result.addAll(contactsManager.getGroups()); @@ -83,4 +87,11 @@ public class CollaborationGroupContainer { return sessionGroup; } + /** + * @return the publicRoomGroup + */ + public PublicRoomContainer getPublicRoomGroup() { + return publicRoomGroup; + } + } diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/data/PublicRoomContainer.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/data/PublicRoomContainer.java new file mode 100644 index 0000000000..e5fba1c82e --- /dev/null +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/data/PublicRoomContainer.java @@ -0,0 +1,68 @@ +/** + * 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.ui.data; + +import java.util.Collection; +import java.util.Collections; + +import com.raytheon.uf.viz.collaboration.comm.identity.CollaborationException; +import com.raytheon.uf.viz.collaboration.comm.provider.connection.CollaborationConnection; +import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueId; +import com.raytheon.uf.viz.collaboration.ui.Activator; + +/** + * Contributes bookmarked public rooms to the group view + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Oct 8, 2014  3705      bclement     Initial creation
+ * 
+ * 
+ * + * @author bclement + * @version 1.0 + */ +public class PublicRoomContainer extends TreeObjectContainer { + + public PublicRoomContainer() { + super("Bookmarked Rooms", "session_group"); + } + + public Object[] getObjects() { + CollaborationConnection connection = CollaborationConnection + .getConnection(); + if (connection == null) { + return new Object[0]; + } + Collection bookmarkedRooms; + try { + bookmarkedRooms = connection.getBookmarkedRooms(); + } catch (CollaborationException e) { + Activator.statusHandler.error( + "Unable to get bookmarked rooms from server", e); + bookmarkedRooms = Collections.emptyList(); + } + return bookmarkedRooms.toArray(new Object[0]); + } +} diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/data/SessionGroupContainer.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/data/SessionGroupContainer.java index be76a02631..82e0943723 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/data/SessionGroupContainer.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/data/SessionGroupContainer.java @@ -21,7 +21,6 @@ package com.raytheon.uf.viz.collaboration.ui.data; import java.util.ArrayList; import java.util.Collection; -import java.util.Collections; import java.util.List; import com.raytheon.uf.viz.collaboration.comm.identity.ISession; @@ -39,19 +38,24 @@ import com.raytheon.uf.viz.collaboration.comm.provider.connection.CollaborationC * ------------ ---------- ----------- -------------------------- * Mar 6, 2012 rferrel Initial creation * Jan 28, 2014 2698 bclement removed venue info + * Oct 08, 2014 3705 bclement extends TreeObjectContainer * * * * @author rferrel * @version 1.0 */ -public class SessionGroupContainer { +public class SessionGroupContainer extends TreeObjectContainer { - public List getObjects() { + public SessionGroupContainer() { + super("Active Sessions", "session_group"); + } + + public Object[] getObjects() { CollaborationConnection connection = CollaborationConnection .getConnection(); if (connection == null) { - return Collections.emptyList(); + return new Object[0]; } Collection sessions = connection.getSessions(); List result = new ArrayList(); @@ -60,7 +64,7 @@ public class SessionGroupContainer { result.add(session); } } - return result; + return result.toArray(); } } diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/data/TreeObjectContainer.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/data/TreeObjectContainer.java new file mode 100644 index 0000000000..4539e89cd2 --- /dev/null +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/data/TreeObjectContainer.java @@ -0,0 +1,66 @@ +/** + * 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.ui.data; + +/** + * Base class for containers that contribute groups to the collaboration group + * view + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Oct 8, 2014  3705      bclement     Initial creation
+ * 
+ * 
+ * + * @author bclement + * @version 1.0 + */ +public abstract class TreeObjectContainer { + + private final String label; + + private final String icon; + + public TreeObjectContainer(String label, String icon) { + this.label = label; + this.icon = icon; + } + + public abstract Object[] getObjects(); + + /** + * @return the label + */ + public String getLabel() { + return label; + } + + /** + * @return the icon + */ + public String getIcon() { + return icon; + } + +}