From 4e48f2c00765539b915520f723c752eed18b6e87 Mon Sep 17 00:00:00 2001 From: Roger Ferrel Date: Fri, 30 Mar 2012 10:45:26 -0500 Subject: [PATCH] Issue #244 Send and accept invites now works. Change-Id: I8d2c5e04f0d7dab6eb81a7321130533e5cfd6148 Former-commit-id: 108ac66214ceb2db01edbcafd426407a85617e9c [formerly 22fff3a4b8f1a8d9576195e5ed9b415b8bc3a3de [formerly 6929e4f068cc397d253b3fabd712e093c4c16dbe]] Former-commit-id: 22fff3a4b8f1a8d9576195e5ed9b415b8bc3a3de Former-commit-id: dc50eb06d7962c766f2c62e92643cd914138e8ac --- .../META-INF/MANIFEST.MF | 2 +- .../data/CollaborationDataManager.java | 114 +++++++++++++----- .../ui/CollaborationGroupView.java | 17 ++- .../collaboration/ui/login/LoginDialog.java | 4 - 4 files changed, 103 insertions(+), 34 deletions(-) diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/META-INF/MANIFEST.MF b/cave/com.raytheon.uf.viz.collaboration.ui/META-INF/MANIFEST.MF index 60c3baa8d0..22abbe53ed 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/META-INF/MANIFEST.MF +++ b/cave/com.raytheon.uf.viz.collaboration.ui/META-INF/MANIFEST.MF @@ -16,7 +16,7 @@ Require-Bundle: com.raytheon.viz.ui, com.raytheon.uf.viz.core;bundle-version="1.12.1174", org.geotools;bundle-version="2.6.4", com.google.guava;bundle-version="1.0.0", - com.raytheon.viz.core;bundle-version="1.12.1174" + com.raytheon.viz.core;bundle-version="1.12.1174", com.raytheon.uf.viz.drawing;bundle-version="1.0.0" Import-Package: com.raytheon.uf.common.status, com.raytheon.uf.viz.core.maps.display, diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/data/CollaborationDataManager.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/data/CollaborationDataManager.java index 66212aa22d..39e2546083 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/data/CollaborationDataManager.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/data/CollaborationDataManager.java @@ -30,8 +30,11 @@ import org.eclipse.ui.IEditorReference; import org.eclipse.ui.IViewReference; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchListener; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.PartInitException; import org.eclipse.ui.PlatformUI; +import com.google.common.eventbus.Subscribe; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; @@ -39,6 +42,8 @@ import com.raytheon.uf.viz.collaboration.comm.identity.CollaborationException; import com.raytheon.uf.viz.collaboration.comm.identity.IPresence.Type; import com.raytheon.uf.viz.collaboration.comm.identity.ISharedDisplaySession; import com.raytheon.uf.viz.collaboration.comm.identity.IVenueSession; +import com.raytheon.uf.viz.collaboration.comm.identity.event.IVenueInvitationEvent; +import com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID; import com.raytheon.uf.viz.collaboration.comm.provider.session.SessionManager; import com.raytheon.uf.viz.collaboration.ui.editor.CollaborationEditor; import com.raytheon.uf.viz.collaboration.ui.login.LoginData; @@ -46,6 +51,7 @@ import com.raytheon.uf.viz.collaboration.ui.login.LoginDialog; import com.raytheon.uf.viz.collaboration.ui.role.AbstractRoleEventController; import com.raytheon.uf.viz.collaboration.ui.role.DataProviderEventController; import com.raytheon.uf.viz.collaboration.ui.role.ParticipantEventController; +import com.raytheon.uf.viz.collaboration.ui.session.CollaborationSessionView; import com.raytheon.uf.viz.core.VizApp; /** @@ -77,6 +83,8 @@ public class CollaborationDataManager { String loginId; + Shell shell; + /** * Created when connection made. Used to clean up connection when CAVE shuts * down. @@ -169,7 +177,7 @@ public class CollaborationDataManager { @Override public void run() { - Shell shell = Display.getDefault().getActiveShell(); + shell = Display.getDefault().getActiveShell(); if (shell == null) { return; } @@ -192,34 +200,7 @@ public class CollaborationDataManager { user.setMode(loginData.getMode()); user.type = Type.AVAILABLE; user.statusMessage = loginData.getModeMessage(); - wbListener = new IWorkbenchListener() { - - @Override - public boolean preShutdown( - IWorkbench workbench, boolean forced) { - return true; - } - - @Override - public void postShutdown(IWorkbench workbench) { - if (manager != null) { - manager.closeManager(); - manager = null; - } - } - }; - PlatformUI.getWorkbench().addWorkbenchListener( - wbListener); } catch (Exception e) { - if (manager != null) { - manager.closeManager(); - manager = null; - } - if (wbListener != null) { - PlatformUI.getWorkbench() - .removeWorkbenchListener(wbListener); - wbListener = null; - } statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e); MessageBox box = new MessageBox(shell, SWT.ERROR); @@ -231,12 +212,37 @@ public class CollaborationDataManager { } } }); + + if (isConnected()) { + // Register handlers and events for the new manager. + manager.registerEventHandler(this); + wbListener = new IWorkbenchListener() { + + @Override + public boolean preShutdown(IWorkbench workbench, + boolean forced) { + return true; + } + + @Override + public void postShutdown(IWorkbench workbench) { + if (manager != null) { + manager.unRegisterEventHandler(this); + manager.closeManager(); + manager = null; + } + } + }; + PlatformUI.getWorkbench().addWorkbenchListener(wbListener); + } } + return manager; } synchronized public void closeManager() { if (manager != null) { + manager.unRegisterEventHandler(this); manager.closeManager(); manager = null; } @@ -392,6 +398,58 @@ public class CollaborationDataManager { return manager != null; } + @Subscribe + public void handleInvitationEvent(IVenueInvitationEvent event) { + final IVenueInvitationEvent invitation = event; + System.out.println("==== handleInvitationEvent sessionId: " + + invitation.getSessionId()); + System.out.println("==== handleInvitationEvent inviter: " + + invitation.getInviter()); + VizApp.runSync(new Runnable() { + + @Override + public void run() { + IQualifiedID inviter = invitation.getInviter(); + IQualifiedID room = invitation.getRoomId(); + MessageBox box = new MessageBox(shell, SWT.ICON_QUESTION + | SWT.OK | SWT.CANCEL); + box.setText("Invitation"); + StringBuilder sb = new StringBuilder(); + sb.append("You are invited to a collaboration.\n"); + sb.append("Inviter: ").append(inviter.getName()).append("\n"); + sb.append("Room: ").append(room.getName()).append("\n"); + sb.append("Subject: ").append(invitation.getSubject()); + box.setMessage(sb.toString()); + if (SWT.OK != box.open()) { + return; + } + try { + IVenueSession session = manager + .joinCollaborationVenue(invitation); + String sessionId = session.getSessionId(); + sessionsMap.put(sessionId, session); + PlatformUI + .getWorkbench() + .getActiveWorkbenchWindow() + .getActivePage() + .showView(CollaborationSessionView.ID, sessionId, + IWorkbenchPage.VIEW_ACTIVATE); + + } catch (CollaborationException e) { + // TODO Auto-generated catch block. Please revise as + // appropriate. + statusHandler.handle(Priority.PROBLEM, + e.getLocalizedMessage(), e); + } catch (PartInitException e) { + // TODO Auto-generated catch block. Please revise as + // appropriate. + statusHandler.handle(Priority.PROBLEM, + e.getLocalizedMessage(), e); + } + } + }); + } + public String joinCollaborationSession(String venueName, String sessionId) { String result = sessionId; if (sessionsMap.get(sessionId) == null) { 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 ed7befe17c..7ebc2afe2c 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 @@ -20,8 +20,10 @@ package com.raytheon.uf.viz.collaboration.ui; * further licensing information. **/ +import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; +import java.util.List; import java.util.Map; import java.util.Set; @@ -243,7 +245,20 @@ public class CollaborationGroupView extends ViewPart { String sessionId = getId(); IVenueSession session = CollaborationDataManager.getInstance() .getSession(sessionId); - // session.sendInvitation(invitation) + List ids = new ArrayList(); + for (CollaborationUser user : getSelectedUsers()) { + String id = user.getId(); + if (!ids.contains(id)) { + System.out.println("Add Selected User: " + id); + ids.add(id); + } + } + IVenueInfo info = session.getVenue().getInfo(); + System.out.println("room: " + info.getVenueName()); + System.out.println("subject: " + + session.getVenue().getInfo().getVenueSubject()); + session.sendInvitation(info.getVenueName(), ids, session + .getVenue().getInfo().getVenueSubject(), "body"); }; }; inviteAction.setImageDescriptor(IconUtil.getImageDescriptor(bundle, diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/login/LoginDialog.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/login/LoginDialog.java index f42acd3de8..cbbca5da04 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/login/LoginDialog.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/login/LoginDialog.java @@ -109,10 +109,6 @@ public class LoginDialog extends CaveSWTDialog { setText("Collaboration Server Log On"); } - // public void setLoginData(LoginData loginData) { - // this.loginData = loginData; - // } - private Control createDialogArea(Composite parent) { GridData gd = null; Composite body = new Composite(parent, SWT.NONE);