From d5e3c97d983a176b3c66f8fd0d6386ff2a3c870a Mon Sep 17 00:00:00 2001 From: Matt Nash Date: Mon, 11 Jun 2012 10:24:35 -0500 Subject: [PATCH] Issue #693 add nws_collaborate view, and ability for default on startup or not Former-commit-id: 73da2b1fe8fe65b996508f2402732bc8f3b8e9d2 [formerly b50cfeb8633e2b9a0d2fc7bb848bbcf7d0404321] Former-commit-id: 022e982aae0d3de61ba5f8abdce48e1f035a736f --- .../comm/provider/session/VenueSession.java | 10 +- .../plugin.xml | 24 +- .../ui/CollaborationGroupAction.java | 30 +- .../ui/actions/ChatRoomAction.java | 66 ---- ...CollaborationSiteFilterPreferencePage.java | 220 ------------ .../ui/prefs/CollaborationPreferencePage.java | 20 ++ ...CollaborationSubscribeListPreferences.java | 69 ++++ .../ui/session/ParticipantsLabelProvider.java | 26 +- .../ui/session/SessionFeedView.java | 325 ++++++++++++++++++ .../collaboration/ui/session/SessionView.java | 23 +- ...{SessionAction.java => SubscribeList.java} | 47 ++- 11 files changed, 513 insertions(+), 347 deletions(-) delete mode 100644 cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/actions/ChatRoomAction.java delete mode 100644 cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/feed/CollaborationSiteFilterPreferencePage.java create mode 100644 cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/prefs/CollaborationSubscribeListPreferences.java create mode 100644 cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/SessionFeedView.java rename cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/{SessionAction.java => SubscribeList.java} (50%) 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 1eef1528b9..43615cbae4 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 @@ -294,8 +294,16 @@ public class VenueSession extends BaseSession implements IVenueSession { venueManager = getConnectionPresenceAdapter().getChatRoomManager(); if (venueManager != null) { venueInfo = venueManager.getChatRoomInfo(venueName); - subject = venueInfo.getDescription(); + if (venueInfo == null) { + for (IChatRoomInfo info : venueManager.getChatRoomInfos()) { + System.out.println(info.getName()); + if (info.getName().equals(venueName)) { + venueInfo = info; + } + } + } if (venueInfo != null) { + subject = venueInfo.getDescription(); completeVenueConnection(venueInfo); } } diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/plugin.xml b/cave/com.raytheon.uf.viz.collaboration.ui/plugin.xml index ace6fb80e0..4f540e9180 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/plugin.xml +++ b/cave/com.raytheon.uf.viz.collaboration.ui/plugin.xml @@ -82,6 +82,14 @@ icon="icons/chats.gif" name="Private Session" restorable="false"/> + @@ -100,10 +108,6 @@ id="com.raytheon.uf.viz.collaboration.chatView" name="Collaboration Browser" description="Command category for the Chat Room View"> - - @@ -116,13 +120,6 @@ name="Collaboration Browser"> - - - - - diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/CollaborationGroupAction.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/CollaborationGroupAction.java index 79d2a03fac..8598b53338 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/CollaborationGroupAction.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/CollaborationGroupAction.java @@ -23,15 +23,20 @@ package com.raytheon.uf.viz.collaboration.ui; import org.eclipse.core.commands.AbstractHandler; import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionException; +import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.PartInitException; import org.eclipse.ui.PlatformUI; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; 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.IVenueSession; +import com.raytheon.uf.viz.collaboration.comm.provider.session.CollaborationConnection; +import com.raytheon.uf.viz.collaboration.ui.session.SessionFeedView; /** - * TODO Add Description + * Action to open the group view, as well as the default chat room * *
  * 
@@ -52,9 +57,32 @@ public class CollaborationGroupAction extends AbstractHandler {
 
     @Override
     public Object execute(ExecutionEvent event) throws ExecutionException {
+        // this opens the collaboration group view
         try {
             PlatformUI.getWorkbench().getActiveWorkbenchWindow()
                     .getActivePage().showView(CollaborationGroupView.ID);
+
+            // if autojoin is selected (to join the default room)
+            if (Activator.getDefault().getPreferenceStore()
+                    .getBoolean("autojoin")) {
+                CollaborationConnection connection = CollaborationConnection
+                        .getConnection();
+                try {
+                    // TODO, make this configurable?
+                    IVenueSession session = connection
+                            .joinTextOnlyVenue("nws-collaboration");
+                    PlatformUI
+                            .getWorkbench()
+                            .getActiveWorkbenchWindow()
+                            .getActivePage()
+                            .showView(SessionFeedView.ID,
+                                    session.getSessionId(),
+                                    IWorkbenchPage.VIEW_ACTIVATE);
+                } catch (CollaborationException e) {
+                    statusHandler.handle(Priority.PROBLEM,
+                            "Unable to join the collaboration feed", e);
+                }
+            }
         } catch (PartInitException e) {
             statusHandler.handle(Priority.PROBLEM,
                     "Unable to open collaboration contact list", e);
diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/actions/ChatRoomAction.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/actions/ChatRoomAction.java
deleted file mode 100644
index d15d93c0ad..0000000000
--- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/actions/ChatRoomAction.java
+++ /dev/null
@@ -1,66 +0,0 @@
-package com.raytheon.uf.viz.collaboration.ui.actions;
-
-/**
- * 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.
- **/
-
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-
-import com.raytheon.uf.common.status.IUFStatusHandler;
-import com.raytheon.uf.common.status.UFStatus;
-import com.raytheon.uf.common.status.UFStatus.Priority;
-import com.raytheon.uf.viz.collaboration.ui.session.SessionView;
-
-/**
- * TODO Add Description
- * 
- * 
- * 
- * SOFTWARE HISTORY
- * 
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * Mar 1, 2012            rferrel     Initial creation
- * 
- * 
- * - * @author rferrel - * @version 1.0 - */ -public class ChatRoomAction extends AbstractHandler { - private static final transient IUFStatusHandler statusHandler = UFStatus - .getHandler(ChatRoomAction.class); - - @Override - public Object execute(ExecutionEvent event) throws ExecutionException { - try { - PlatformUI.getWorkbench().getActiveWorkbenchWindow() - .getActivePage().showView(SessionView.ID); - } catch (PartInitException e) { - statusHandler.handle(Priority.PROBLEM, "Unable to open chat room", - e); - } - return event; - } - -} diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/feed/CollaborationSiteFilterPreferencePage.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/feed/CollaborationSiteFilterPreferencePage.java deleted file mode 100644 index b3f02d9112..0000000000 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/feed/CollaborationSiteFilterPreferencePage.java +++ /dev/null @@ -1,220 +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.ui.feed; - -import java.util.List; - -import org.eclipse.jface.preference.ColorFieldEditor; -import org.eclipse.jface.preference.FieldEditorPreferencePage; -import org.eclipse.jface.preference.StringFieldEditor; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.graphics.RGB; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPreferencePage; - -import com.raytheon.uf.viz.collaboration.ui.CollaborationUtils; -import com.raytheon.uf.viz.collaboration.ui.data.AlertWord; -import com.raytheon.uf.viz.collaboration.ui.prefs.CollaborationPreferenceContentProvider; -import com.raytheon.uf.viz.collaboration.ui.prefs.CollaborationPreferencesLabelProvider; - -/** - * TODO Add Description - * - *
- * 
- * SOFTWARE HISTORY
- * 
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * Jun 4, 2012            mnash     Initial creation
- * 
- * 
- * - * @author mnash - * @version 1.0 - */ - -public class CollaborationSiteFilterPreferencePage extends - FieldEditorPreferencePage implements IWorkbenchPreferencePage { - - private TableViewer viewer; - - /** - * - */ - public CollaborationSiteFilterPreferencePage() { - } - - /** - * @param style - */ - public CollaborationSiteFilterPreferencePage(int style) { - super(style); - } - - /** - * @param title - * @param style - */ - public CollaborationSiteFilterPreferencePage(String title, int style) { - super(title, style); - // TODO Auto-generated constructor stub - } - - /** - * @param title - * @param image - * @param style - */ - public CollaborationSiteFilterPreferencePage(String title, - ImageDescriptor image, int style) { - super(title, image, style); - } - - /* - * (non-Javadoc) - * - * @see - * org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors - * () - */ - @Override - protected void createFieldEditors() { - GridData data = new GridData(SWT.FILL, SWT.FILL, true, true); - data.horizontalSpan = 3; - - viewer = new TableViewer(getFieldEditorParent()); - viewer.setContentProvider(new CollaborationPreferenceContentProvider()); - viewer.setLabelProvider(new CollaborationPreferencesLabelProvider()); - viewer.getTable().setLayoutData(data); - - final StringFieldEditor stringEditor = new StringFieldEditor( - "sitename", "Site Name", getFieldEditorParent()) { - @Override - protected void doLoad() { - super.doLoad(); - this.setStringValue(""); - } - }; - this.addField(stringEditor); - - final ColorFieldEditor colorEditor = new ColorFieldEditor( - "coloreditor", "Color", getFieldEditorParent()); - this.addField(colorEditor); - colorEditor.loadDefault(); - - Composite buttonComp = new Composite(getFieldEditorParent(), SWT.NONE); - buttonComp.setLayout(new GridLayout(3, false)); - data = new GridData(SWT.FILL, SWT.FILL, true, true); - data.horizontalSpan = 3; - buttonComp.setLayoutData(data); - - Button saveButton = new Button(buttonComp, SWT.PUSH); - saveButton.setText("Save Current"); - saveButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - if (!stringEditor.getStringValue().isEmpty()) { - AlertWord word = new AlertWord(stringEditor - .getStringValue(), colorEditor.getColorSelector() - .getColorValue()); - int index = viewer.getTable().getSelectionIndex(); - if (index != -1) { - ((List) viewer.getInput()).set(index, word); - } else { - ((List) viewer.getInput()).add(word); - } - viewer.refresh(); - } - } - }); - data = new GridData(SWT.NONE, SWT.NONE, false, true); - saveButton.setLayoutData(data); - - Button addButton = new Button(buttonComp, SWT.PUSH); - addButton.setText("Add New"); - addButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - if (!stringEditor.getStringValue().isEmpty()) { - AlertWord word = new AlertWord(stringEditor - .getStringValue(), colorEditor.getColorSelector() - .getColorValue()); - ((List) viewer.getInput()).add(word); - viewer.refresh(); - } - } - }); - data = new GridData(SWT.NONE, SWT.NONE, false, true); - addButton.setLayoutData(data); - - Button removeButton = new Button(buttonComp, SWT.PUSH); - removeButton.setText("Remove Current"); - removeButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - IStructuredSelection selection = (IStructuredSelection) viewer - .getSelection(); - if (selection != null) { - AlertWord word = (AlertWord) selection.getFirstElement(); - ((List) viewer.getInput()).remove(word); - viewer.refresh(); - } - } - }); - data = new GridData(SWT.NONE, SWT.NONE, false, true); - removeButton.setLayoutData(data); - - viewer.getTable().addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - AlertWord word = (AlertWord) e.item.getData(); - colorEditor.getColorSelector() - .setColorValue( - new RGB(word.getRed(), word.getGreen(), word - .getBlue())); - stringEditor.setStringValue(word.getText()); - } - }); - viewer.setInput(CollaborationUtils.getAlertWords()); - } - - /* - * (non-Javadoc) - * - * @see - * org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench) - */ - @Override - public void init(IWorkbench workbench) { - // TODO Auto-generated method stub - - } - -} diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/prefs/CollaborationPreferencePage.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/prefs/CollaborationPreferencePage.java index fcff1db19c..85c8cd91c2 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/prefs/CollaborationPreferencePage.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/prefs/CollaborationPreferencePage.java @@ -25,6 +25,7 @@ import org.eclipse.jface.preference.FieldEditorPreferencePage; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPreferencePage; +import com.raytheon.uf.viz.collaboration.comm.provider.session.CollaborationConnection; import com.raytheon.uf.viz.collaboration.ui.Activator; /** @@ -75,5 +76,24 @@ public class CollaborationPreferencePage extends FieldEditorPreferencePage FieldEditor notifications = new BooleanFieldEditor("notifications", "Show Notifications", getFieldEditorParent()); this.addField(notifications); + FieldEditor autojoinColl = new BooleanFieldEditor("autojoin", + "Join Discussion On Login", getFieldEditorParent()); + this.addField(autojoinColl); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.preference.FieldEditorPreferencePage#performOk() + */ + @Override + public boolean performOk() { + CollaborationConnection connection = CollaborationConnection + .getConnection(); + if (connection != null && connection.isConnected()) { + CollaborationConnection.getConnection().getEventPublisher() + .post(Activator.getDefault().getPreferenceStore()); + } + return super.performOk(); } } diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/prefs/CollaborationSubscribeListPreferences.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/prefs/CollaborationSubscribeListPreferences.java new file mode 100644 index 0000000000..852b83c59a --- /dev/null +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/prefs/CollaborationSubscribeListPreferences.java @@ -0,0 +1,69 @@ +/** + * 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.prefs; + +import org.eclipse.jface.preference.FieldEditorPreferencePage; + +/** + * TODO Add Description + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Jun 7, 2012            mnash     Initial creation
+ * 
+ * 
+ * + * @author mnash + * @version 1.0 + */ + +public class CollaborationSubscribeListPreferences extends + FieldEditorPreferencePage { + + /** + * + */ + public CollaborationSubscribeListPreferences() { + } + + /** + * @param style + */ + public CollaborationSubscribeListPreferences(int style) { + super(GRID); + } + + /* + * (non-Javadoc) + * + * @see + * org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors + * () + */ + @Override + protected void createFieldEditors() { + // // TODO Auto-generated method stub + // CollaborationConnection.getConnection().getRosterManager().get + } +} 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 733518d806..68511660df 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 @@ -71,6 +71,8 @@ public class ParticipantsLabelProvider extends ColumnLabelProvider { protected Map imageMap; + private List enabledUsers; + protected Map colors; private SessionColorManager manager; @@ -213,6 +215,7 @@ public class ParticipantsLabelProvider extends ColumnLabelProvider { break; } } + return name; } @@ -335,6 +338,10 @@ public class ParticipantsLabelProvider extends ColumnLabelProvider { return new Point(5, 5); } + protected void setEnabledUsers(List enabledUsers) { + this.enabledUsers = enabledUsers; + } + protected String buildParticipantTooltip(IRosterEntry user) { StringBuilder builder = new StringBuilder(); UserId partUser = IDConverter.convertFrom(user.getUser()); @@ -342,13 +349,18 @@ public class ParticipantsLabelProvider extends ColumnLabelProvider { builder.append("Name : ").append(user.getUser().getName()) .append("\n"); } - builder.append("Status : ") - .append(CollaborationUtils.formatMode(user.getPresence() - .getMode())).append("\n"); - builder.append("Message : \"").append(user.getPresence().getStatus()) - .append("\""); - ISession session = CollaborationConnection.getConnection().getSession( - sessionId); + builder.append("Status : ").append( + CollaborationUtils.formatMode(user.getPresence().getMode())); + if (!user.getPresence().getStatus().isEmpty()) { + builder.append("\n").append("Message : \"") + .append(user.getPresence().getStatus()).append("\""); + } + if (user.getPresence().getProperties().containsKey("UserStatus")) { + builder.append("\n").append( + user.getPresence().getProperties().get("UserStatus")); + } + IVenueSession session = (IVenueSession) CollaborationConnection + .getConnection().getSession(sessionId); if (session instanceof SharedDisplaySession) { UserId id = IDConverter.convertFrom(user.getUser()); boolean isSessionLeader = id diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/SessionFeedView.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/SessionFeedView.java new file mode 100644 index 0000000000..8d8ecd7339 --- /dev/null +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/SessionFeedView.java @@ -0,0 +1,325 @@ +/** + * 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.session; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import javax.xml.bind.JAXB; + +import org.eclipse.ecf.core.user.IUser; +import org.eclipse.ecf.presence.Presence; +import org.eclipse.ecf.presence.roster.IRosterEntry; +import org.eclipse.jface.action.Action; +import org.eclipse.jface.action.IMenuManager; +import org.eclipse.jface.action.MenuManager; +import org.eclipse.jface.util.IPropertyChangeListener; +import org.eclipse.jface.util.PropertyChangeEvent; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.RGB; +import org.eclipse.swt.widgets.ColorDialog; +import org.eclipse.swt.widgets.Display; + +import com.google.common.eventbus.Subscribe; +import com.raytheon.uf.common.localization.IPathManager; +import com.raytheon.uf.common.localization.LocalizationContext; +import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel; +import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType; +import com.raytheon.uf.common.localization.LocalizationFile; +import com.raytheon.uf.common.localization.PathManagerFactory; +import com.raytheon.uf.viz.collaboration.comm.identity.IMessage; +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.ui.Activator; +import com.raytheon.uf.viz.core.VizApp; + +/** + * Built for the session in which everyone joins + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Jun 7, 2012            mnash     Initial creation
+ * 
+ * 
+ * + * @author mnash + * @version 1.0 + */ + +public class SessionFeedView extends SessionView { + + public static final String ID = "com.raytheon.uf.viz.collaboration.SessionFeedView"; + + private Action muteAction; + + private Action unMuteAction; + + private Action colorChangeAction; + + private Action autoJoinAction; + + private List enabledUsers; + + /** + * + */ + public SessionFeedView() { + super(); + enabledUsers = readEnabledUsers(); + } + + private List readEnabledUsers() { + LocalizationFile file = getLocalizationFile(); + if (file.exists()) { + SubscribeList list = JAXB.unmarshal(file.getFile(), SubscribeList.class); + return list.getEnabledUsers(); + } + return new ArrayList(); + } + + private void persistEnabledUsers() { + SubscribeList list = new SubscribeList(); + list.setEnabledUsers(enabledUsers); + JAXB.marshal(list, getLocalizationFile().getFile()); + } + + @Subscribe + public void refreshBlockList(SubscribeList list) { + enabledUsers = list.getEnabledUsers(); + } + + private LocalizationFile getLocalizationFile() { + LocalizationFile file = null; + IPathManager pm = PathManagerFactory.getPathManager(); + LocalizationContext context = pm.getContext( + LocalizationType.CAVE_STATIC, LocalizationLevel.USER); + file = PathManagerFactory.getPathManager().getLocalizationFile(context, + "collaboration" + File.separator + "subscribeList.xml"); + return file; + } + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.uf.viz.collaboration.ui.session.SessionView#createActions() + */ + @Override + protected void createActions() { + super.createActions(); + muteAction = new Action("Ignore User") { + @Override + public void run() { + IStructuredSelection selection = (IStructuredSelection) usersTable + .getSelection(); + IRosterEntry entry = (IRosterEntry) selection.getFirstElement(); + UserId id = IDConverter.convertFrom(entry.getUser()); + if (enabledUsers.contains(id.getName())) { + ((Presence) entry.getPresence()).getProperties().put( + "UserStatus", "Ignored"); + usersTable.refresh(entry); + enabledUsers.remove(id.getName()); + } + } + }; + + unMuteAction = new Action("Subcribe User") { + @Override + public void run() { + IStructuredSelection selection = (IStructuredSelection) usersTable + .getSelection(); + IRosterEntry entry = (IRosterEntry) selection.getFirstElement(); + UserId id = IDConverter.convertFrom(entry.getUser()); + if (!enabledUsers.contains(id.getName())) { + ((Presence) entry.getPresence()).getProperties().put( + "UserStatus", "Subscribed"); + usersTable.refresh(entry); + enabledUsers.add(id.getName()); + } + } + }; + + colorChangeAction = new Action("Change Color...") { + @Override + public void run() { + ColorDialog dlg = new ColorDialog(Display.getCurrent() + .getActiveShell()); + RGB rgb = dlg.open(); + IStructuredSelection selection = (IStructuredSelection) usersTable + .getSelection(); + IRosterEntry entry = (IRosterEntry) selection.getFirstElement(); + manager.setColorForUser( + IDConverter.convertFrom(entry.getUser()), rgb); + usersTable.refresh(entry); + } + }; + + autoJoinAction = new Action("Autojoin", SWT.TOGGLE) { + public void run() { + Activator.getDefault().getPreferenceStore() + .setValue("autojoin", autoJoinAction.isChecked()); + }; + }; + + autoJoinAction.setChecked(Activator.getDefault().getPreferenceStore() + .getBoolean("autojoin")); + Activator.getDefault().getPreferenceStore() + .addPropertyChangeListener(new IPropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent event) { + autoJoinAction.setChecked(Activator.getDefault() + .getPreferenceStore().getBoolean("autojoin")); + } + }); + MenuManager manager = (MenuManager) getViewSite().getActionBars() + .getMenuManager(); + manager.add(autoJoinAction); + } + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.uf.viz.collaboration.ui.session.SessionView#fillContextMenu + * (org.eclipse.jface.action.IMenuManager) + */ + @Override + protected void fillContextMenu(IMenuManager manager) { + super.fillContextMenu(manager); + IRosterEntry entry = (IRosterEntry) ((IStructuredSelection) usersTable + .getSelection()).getFirstElement(); + UserId id = IDConverter.convertFrom(entry.getUser()); + if (!id.equals(CollaborationConnection.getConnection().getUser())) { + if (enabledUsers.contains(id.getName())) { + manager.add(muteAction); + } else { + manager.add(unMuteAction); + } + } + manager.add(colorChangeAction); + } + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.uf.viz.collaboration.ui.session.SessionView#setParticipantValues + * (com.raytheon.uf.viz.collaboration.ui.session.ParticipantsLabelProvider) + */ + @Override + protected void setParticipantValues(ParticipantsLabelProvider labelProvider) { + super.setParticipantValues(labelProvider); + labelProvider.setEnabledUsers(enabledUsers); + } + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.uf.viz.collaboration.ui.session.SessionView#handleMessage + * (com.raytheon.uf.viz.collaboration.comm.identity.IMessage) + */ + @Override + public void handleMessage(IMessage message) { + final IMessage msg = message; + // so not to have delay, going to handle messages from yourself + // separately + if (message.getFrom().equals( + CollaborationConnection.getConnection().getUser())) { + return; + } + + if (enabledUsers.contains(message.getFrom().getName())) { + VizApp.runAsync(new Runnable() { + + @Override + public void run() { + appendMessage(msg); + } + }); + } + } + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.uf.viz.collaboration.ui.session.SessionView#participantArrived + * (com.raytheon.uf.viz.collaboration.comm.provider.user.UserId) + */ + @Override + protected void participantArrived(UserId participant) { + List users = (List) usersTable.getInput(); + Map usersMap = session.getConnection() + .getContactsManager().getUsersMap(); + IRosterEntry user = usersMap.get(participant); + if (user != null) { + for (IUser usr : usersMap.keySet()) { + if (usr.getName().equals(participant.getName())) { + user = usersMap.get(usr); + users.add(user); + break; + } + } + } + usersTable.setInput(users); + usersTable.refresh(); + } + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.uf.viz.collaboration.ui.session.SessionView#participantDeparted + * (com.raytheon.uf.viz.collaboration.comm.provider.user.UserId) + */ + @Override + protected void participantDeparted(UserId participant) { + List users = (List) usersTable.getInput(); + for (int i = 0; i < users.size(); ++i) { + UserId otherId = IDConverter.convertFrom(users.get(i).getUser()); + if (users.get(i) == null + || participant.getName().equals(otherId.getName())) { + users.remove(i); + usersTable.refresh(); + break; + } + } + } + + /* + * (non-Javadoc) + * + * @see com.raytheon.uf.viz.collaboration.ui.session.SessionView#dispose() + */ + @Override + public void dispose() { + persistEnabledUsers(); + super.dispose(); + } +} 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 157920e9ee..746621716e 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 @@ -34,7 +34,6 @@ import org.eclipse.jface.action.IMenuListener; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.MenuManager; import org.eclipse.jface.viewers.ColumnViewerToolTipSupport; -import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.TableViewer; import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.viewers.ViewerSorter; @@ -105,7 +104,7 @@ public class SessionView extends AbstractSessionView { protected String sessionId; - private IVenueSession session; + protected IVenueSession session; private Image downArrow; @@ -208,10 +207,6 @@ public class SessionView extends AbstractSessionView { } protected void fillContextMenu(IMenuManager manager) { - IStructuredSelection selection = (IStructuredSelection) usersTable - .getSelection(); - // TODO do something here! - Object ob = selection.getFirstElement(); } @Subscribe @@ -341,8 +336,7 @@ public class SessionView extends AbstractSessionView { ParticipantsContentProvider contentProvider = new ParticipantsContentProvider(); ParticipantsLabelProvider labelProvider = new ParticipantsLabelProvider(); - labelProvider.setSessionId(sessionId); - labelProvider.setManager(manager); + setParticipantValues(labelProvider); usersTable.setContentProvider(contentProvider); usersTable.setLabelProvider(labelProvider); @@ -390,6 +384,11 @@ public class SessionView extends AbstractSessionView { ((GridData) usersComp.getLayoutData()).exclude = true; } + protected void setParticipantValues(ParticipantsLabelProvider labelProvider) { + labelProvider.setSessionId(sessionId); + labelProvider.setManager(manager); + } + @Override public void dispose() { // dispose of the images first @@ -567,6 +566,8 @@ public class SessionView extends AbstractSessionView { @Override protected void setMessageLabel(Composite comp) { Label label = new Label(comp, SWT.WRAP); + GridData data = new GridData(SWT.FILL, SWT.NONE, true, false); + label.setLayoutData(data); StringBuilder labelInfo = new StringBuilder(); if (session != null) { IVenueInfo info = session.getVenue().getInfo(); @@ -637,7 +638,7 @@ public class SessionView extends AbstractSessionView { } @SuppressWarnings("unchecked") - private void participantArrived(UserId participant) { + protected void participantArrived(UserId participant) { List users = (List) usersTable.getInput(); Map usersMap = session.getConnection() .getContactsManager().getUsersMap(); @@ -660,7 +661,7 @@ public class SessionView extends AbstractSessionView { } @SuppressWarnings("unchecked") - private void participantDeparted(UserId participant) { + protected void participantDeparted(UserId participant) { List users = (List) usersTable.getInput(); if (users != null) { for (int i = 0; i < users.size(); ++i) { @@ -685,7 +686,7 @@ public class SessionView extends AbstractSessionView { * @param presence */ @SuppressWarnings("unchecked") - private void participantPresenceUpdated(UserId participant, + protected void participantPresenceUpdated(UserId participant, IPresence presence) { // 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 diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/SessionAction.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/SubscribeList.java similarity index 50% rename from cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/SessionAction.java rename to cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/SubscribeList.java index 291337da28..e8b6d5b43e 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/SessionAction.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/SubscribeList.java @@ -1,5 +1,3 @@ -package com.raytheon.uf.viz.collaboration.ui.session; - /** * This software was developed and / or modified by Raytheon Company, * pursuant to Contract DG133W-05-CQ-1067 with the US Government. @@ -19,16 +17,12 @@ package com.raytheon.uf.viz.collaboration.ui.session; * See the AWIPS II Master Rights File ("Master Rights File.pdf") for * further licensing information. **/ +package com.raytheon.uf.viz.collaboration.ui.session; -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.PlatformUI; +import java.util.List; -import com.raytheon.uf.common.status.IUFStatusHandler; -import com.raytheon.uf.common.status.UFStatus; -import com.raytheon.uf.common.status.UFStatus.Priority; +import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; +import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; /** * TODO Add Description @@ -39,27 +33,30 @@ import com.raytheon.uf.common.status.UFStatus.Priority; * * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Mar 1, 2012 rferrel Initial creation + * Jun 7, 2012 mnash Initial creation * *
* - * @author rferrel + * @author mnash * @version 1.0 */ -public class SessionAction extends AbstractHandler { - private static final transient IUFStatusHandler statusHandler = UFStatus - .getHandler(SessionAction.class); +@DynamicSerialize +public class SubscribeList { + @DynamicSerializeElement + private List enabledUsers; - @Override - public Object execute(ExecutionEvent event) throws ExecutionException { - try { - PlatformUI.getWorkbench().getActiveWorkbenchWindow() - .getActivePage().showView(SessionView.ID); - } catch (PartInitException e) { - statusHandler.handle(Priority.PROBLEM, - "Unable to open product browser", e); - } - return event; + /** + * @return the enabledUsers + */ + public List getEnabledUsers() { + return enabledUsers; } + /** + * @param enabledUsers + * the enabledUsers to set + */ + public void setEnabledUsers(List enabledUsers) { + this.enabledUsers = enabledUsers; + } }