From 01f852004b09875fa3524bc36dc915e96a074d29 Mon Sep 17 00:00:00 2001 From: Matt Nash Date: Fri, 11 May 2012 16:29:27 -0500 Subject: [PATCH] Issue #444 add further capability of transferring session leader Former-commit-id: b2621eb89e910a0443ee23cc25b2024c5d73f207 [formerly 49a19d4b6a56252e4e17f4563cdd4f94ef0ab3cc] Former-commit-id: 746fd1464ca27fae972fc56e7c5a6cac31240cb2 --- .../comm/provider/session/VenueSession.java | 1 - .../comm/provider/user/IDConverter.java | 5 +++- .../ui/CollaborationGroupView.java | 11 +++++---- .../ui/UsersTreeLabelProvider.java | 3 ++- .../ui/actions/ChatRoomAction.java | 4 ++-- .../ui/role/AbstractRoleEventController.java | 2 +- .../ui/session/CollaborationSessionView.java | 24 +++++++++++++++---- .../ui/session/ParticipantsLabelProvider.java | 12 ++++++---- .../collaboration/ui/session/SessionView.java | 17 +++++++------ .../CollaborationDrawingLayer.java | 15 +++++++++++- .../telestrator/CollaborationPathToolbar.java | 11 +++++---- .../META-INF/MANIFEST.MF | 1 + .../raytheon/uf/viz/drawing/PathToolbar.java | 11 +++++++++ 13 files changed, 84 insertions(+), 33 deletions(-) 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 8eb690ec08..1eef1528b9 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 @@ -402,7 +402,6 @@ public class VenueSession extends BaseSession implements IVenueSession { } }; venueContainer.addMessageListener(intListener); - } } catch (Exception e) { throw new CollaborationException( diff --git a/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/provider/user/IDConverter.java b/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/provider/user/IDConverter.java index fec6cf1544..b573664e27 100644 --- a/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/provider/user/IDConverter.java +++ b/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/provider/user/IDConverter.java @@ -49,7 +49,10 @@ public class IDConverter { String name = Tools.parseName(id.getName()); String host = Tools.parseHost(id.getName()); String rsc = Tools.parseResource(id.getName()); - return new UserId(name, host, rsc); + + UserId uid = new UserId(name, host, rsc); + uid.setId(id); + return uid; } /** 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 3210ae83aa..974608517b 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 @@ -114,9 +114,9 @@ import com.raytheon.uf.viz.collaboration.ui.session.AbstractSessionView; import com.raytheon.uf.viz.collaboration.ui.session.CollaborationSessionView; import com.raytheon.uf.viz.collaboration.ui.session.PeerToPeerView; import com.raytheon.uf.viz.collaboration.ui.session.SessionView; +import com.raytheon.uf.viz.collaboration.ui.telestrator.CollaborationPathToolbar; import com.raytheon.uf.viz.core.VizApp; import com.raytheon.uf.viz.core.icon.IconUtil; -import com.raytheon.uf.viz.drawing.PathToolbar; import com.raytheon.viz.ui.VizWorkbenchManager; /** @@ -314,11 +314,11 @@ public class CollaborationGroupView extends ViewPart implements IPartListener { // loop through all the views so that we can bring the one // that // was selected to the top... + IVenueSession session = (IVenueSession) selection + .getFirstElement(); for (IViewReference ref : getViewSite() .getWorkbenchWindow().getActivePage() .getViewReferences()) { - IVenueSession session = (IVenueSession) selection - .getFirstElement(); if (session.getSessionId().equals(ref.getSecondaryId())) { PlatformUI.getWorkbench() .getActiveWorkbenchWindow().getActivePage() @@ -468,7 +468,7 @@ public class CollaborationGroupView extends ViewPart implements IPartListener { drawToolbarAction = new Action("Drawing Toolbar") { @Override public void run() { - PathToolbar.getToolbar().open(); + CollaborationPathToolbar.getToolbar().open(); } }; drawToolbarAction.setImageDescriptor(IconUtil.getImageDescriptor( @@ -671,7 +671,8 @@ public class CollaborationGroupView extends ViewPart implements IPartListener { // the user, both the logged in user as well as his buddies if (o instanceof IRosterEntry) { IRosterEntry user = (IRosterEntry) o; - if (user.getPresence().getType() == Type.AVAILABLE) { + if (user.getPresence() != null + && user.getPresence().getType() == Type.AVAILABLE) { MenuManager inviteManager = new MenuManager("Invite to..."); // get current open chats Map sessions = CollaborationDataManager 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 5ba06f15d7..20829d7d35 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 @@ -164,7 +164,8 @@ public class UsersTreeLabelProvider extends ColumnLabelProvider { builder.append("ID: ").append( IDConverter.convertFrom(user.getUser()).getFQName()); builder.append("\nStatus: "); - if (user.getPresence().getType() == Type.UNAVAILABLE) { + if (user.getPresence() == null + || user.getPresence().getType() == Type.UNAVAILABLE) { builder.append("Offline"); } else { builder.append(CollaborationUtils.formatMode(user.getPresence() 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 index ce274b2622..d15d93c0ad 100644 --- 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 @@ -57,8 +57,8 @@ public class ChatRoomAction extends AbstractHandler { PlatformUI.getWorkbench().getActiveWorkbenchWindow() .getActivePage().showView(SessionView.ID); } catch (PartInitException e) { - statusHandler.handle(Priority.PROBLEM, - "Unable to open product browser", 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/role/AbstractRoleEventController.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/role/AbstractRoleEventController.java index 87fd979cc1..bde45a9da3 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/role/AbstractRoleEventController.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/role/AbstractRoleEventController.java @@ -86,7 +86,7 @@ public abstract class AbstractRoleEventController implements protected void deactivateTelestrator() { // TODO this must be handled better - PathToolbar.getToolbar().close(); + CollaborationPathToolbar.getToolbar().close(); if (tool != null) { tool.deactivate(); session.unRegisterEventHandler(tool); diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/CollaborationSessionView.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/CollaborationSessionView.java index 3244c119ad..60c69f0966 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/CollaborationSessionView.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/CollaborationSessionView.java @@ -23,6 +23,7 @@ package com.raytheon.uf.viz.collaboration.ui.session; import java.util.Collection; import org.eclipse.ecf.presence.roster.IRosterEntry; +import org.eclipse.ecf.presence.roster.RosterEntry; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.ActionContributionItem; import org.eclipse.jface.action.IMenuCreator; @@ -48,6 +49,7 @@ import com.raytheon.uf.viz.collaboration.comm.identity.IVenueSession; import com.raytheon.uf.viz.collaboration.comm.identity.info.IVenueInfo; import com.raytheon.uf.viz.collaboration.comm.identity.user.SharedDisplayRole; import com.raytheon.uf.viz.collaboration.comm.provider.TransferRoleCommand; +import com.raytheon.uf.viz.collaboration.comm.provider.user.IDConverter; import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId; import com.raytheon.uf.viz.collaboration.data.CollaborationDataManager; import com.raytheon.uf.viz.collaboration.data.SharedDisplaySessionMgr; @@ -122,8 +124,14 @@ public class CollaborationSessionView extends SessionView { .getSelection(); IRosterEntry selectedUser = (IRosterEntry) selection .getFirstElement(); - switchLeader((UserId) selectedUser.getUser()); - usersTable.refresh(); + usersTable.remove(selectedUser); + UserId id = IDConverter.convertFrom(selectedUser + .getUser()); + selectedUser = new RosterEntry( + selectedUser.getParent(), id, + selectedUser.getPresence()); + switchLeader(id); + usersTable.refresh(selectedUser); }; }; ActionContributionItem leaderItem = new ActionContributionItem( @@ -138,8 +146,14 @@ public class CollaborationSessionView extends SessionView { .getSelection(); IRosterEntry selectedUser = (IRosterEntry) selection .getFirstElement(); - switchDataProvider((UserId) selectedUser.getUser()); - usersTable.refresh(); + usersTable.remove(selectedUser); + UserId id = IDConverter.convertFrom(selectedUser + .getUser()); + selectedUser = new RosterEntry( + selectedUser.getParent(), id, + selectedUser.getPresence()); + switchDataProvider(id); + usersTable.refresh(selectedUser); }; }; ActionContributionItem dataProviderItem = new ActionContributionItem( @@ -171,7 +185,7 @@ public class CollaborationSessionView extends SessionView { .getSelection(); IRosterEntry entry = (IRosterEntry) selection.getFirstElement(); ColorChangeEvent event = new ColorChangeEvent( - (UserId) entry.getUser(), rgb); + IDConverter.convertFrom(entry.getUser()), rgb); try { session.sendObjectToVenue(event); } catch (CollaborationException e) { 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 663219a423..b396179184 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 @@ -255,7 +255,7 @@ public class ParticipantsLabelProvider extends ColumnLabelProvider { } } - return boldFont; + return null; } @Override @@ -349,10 +349,12 @@ public class ParticipantsLabelProvider extends ColumnLabelProvider { IVenueSession session = CollaborationDataManager.getInstance() .getSession(sessionId); if (session instanceof SharedDisplaySession) { - boolean isSessionLeader = user.getUser().equals( - ((SharedDisplaySession) session).getCurrentSessionLeader()); - boolean isDataProvider = user.getUser().equals( - ((SharedDisplaySession) session).getCurrentDataProvider()); + UserId id = IDConverter.convertFrom(user.getUser()); + boolean isSessionLeader = id + .equals(((SharedDisplaySession) session) + .getCurrentSessionLeader()); + boolean isDataProvider = id.equals(((SharedDisplaySession) session) + .getCurrentDataProvider()); if (isSessionLeader || isDataProvider) { if (isSessionLeader) { builder.append("\nSession Leader"); 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 1bb10189fa..d8eac0d8f2 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 @@ -363,7 +363,6 @@ public class SessionView extends AbstractSessionView { ColumnViewerToolTipSupport.enableFor(usersTable, ToolTip.RECREATE); List users = new ArrayList(); if (session != null) { - session.getVenue().getParticipants(); Map usersMap = session.getConnection() .getContactsManager().getUsersMap(); for (UserId participant : session.getVenue().getParticipants()) { @@ -373,7 +372,8 @@ public class SessionView extends AbstractSessionView { RosterEntry rEntry = new RosterEntry(session .getConnection().getRosterManager().getRoster(), participant, CollaborationDataManager.getInstance() - .getCollaborationConnection(true).getPresence()); + .getCollaborationConnection(true) + .getPresence()); users.add(rEntry); } else if (entry != null) { users.add(usersMap.get(participant)); @@ -416,7 +416,8 @@ public class SessionView extends AbstractSessionView { session.unRegisterEventHandler(this); CollaborationDataManager mgr = CollaborationDataManager.getInstance(); mgr.closeSession(sessionId); - mgr.getCollaborationConnection(true).getEventPublisher().unregister(this); + mgr.getCollaborationConnection(true).getEventPublisher() + .unregister(this); super.dispose(); } @@ -664,10 +665,12 @@ public class SessionView extends AbstractSessionView { // TODO Keep as a place holder for now since it may be needed to set // leader/provider roles. List users = (List) usersTable.getInput(); - for (IRosterEntry entry : users) { - if (entry.getUser().equals(participant)) { - ((RosterEntry) entry).setPresence(presence); - usersTable.refresh(entry); + if (users != null) { + for (IRosterEntry entry : users) { + if (entry.getUser().equals(participant)) { + ((RosterEntry) entry).setPresence(presence); + usersTable.refresh(entry); + } } } } diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/telestrator/CollaborationDrawingLayer.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/telestrator/CollaborationDrawingLayer.java index 1d0d0a967c..b334647019 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/telestrator/CollaborationDrawingLayer.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/telestrator/CollaborationDrawingLayer.java @@ -33,6 +33,8 @@ 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.event.IVenueParticipantEvent; +import com.raytheon.uf.viz.collaboration.comm.identity.event.ParticipantEventType; import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId; import com.raytheon.uf.viz.collaboration.data.CollaborationDataManager; import com.raytheon.uf.viz.collaboration.data.SharedDisplaySessionMgr; @@ -164,7 +166,7 @@ public class CollaborationDrawingLayer extends DrawingLayer { for (ShapeContainer sh : collaboratorShapes.get(userName)) { if (sh != null) { RGB col = colorManager.getColors().get(userName); - if (sh.getShape() != null) { + if (sh.getShape() != null && col != null) { target.drawWireframeShape(sh.getShape(), col, outline.getOutlineWidth(), outline.getLineStyle(), imaging.getAlpha()); @@ -185,6 +187,17 @@ public class CollaborationDrawingLayer extends DrawingLayer { issueRefresh(); } + @Subscribe + public void participantChanged(IVenueParticipantEvent event) { + if (event.getEventType().equals(ParticipantEventType.DEPARTED)) { + System.out + .println(event.getParticipant().getFQName() + " departed"); + resetTemp(); + clearSelfShapes(event.getParticipant()); + issueRefresh(); + } + } + @Subscribe public void handle(CollaborationDrawingEvent event) { switch (event.getType()) { diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/telestrator/CollaborationPathToolbar.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/telestrator/CollaborationPathToolbar.java index 715394dd21..79301de3e7 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/telestrator/CollaborationPathToolbar.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/telestrator/CollaborationPathToolbar.java @@ -65,6 +65,7 @@ public class CollaborationPathToolbar extends PathToolbar { */ protected CollaborationPathToolbar(Shell parentShell) { super(parentShell); + setText("Collaboration Drawing"); } public static PathToolbar getToolbar() { @@ -98,8 +99,8 @@ public class CollaborationPathToolbar extends PathToolbar { public void run() { if (event instanceof CollaborationDrawingEvent) { CollaborationDrawingEvent cde = (CollaborationDrawingEvent) event; - if (!cde.getUserName().equals( - CollaborationDataManager.getInstance() + if (!cde.getUserName() + .equals(CollaborationDataManager.getInstance() .getCollaborationConnection(true).getUser())) { if (cde.getType() == CollaborationEventType.DISABLE) { disableAll(); @@ -128,7 +129,7 @@ public class CollaborationPathToolbar extends PathToolbar { .getSessionContainer(sessionId).getSession(); if (session != null && !session.hasRole(SharedDisplayRole.SESSION_LEADER) - && leaderOnly != null) { + && leaderOnly != null && !leaderOnly.isDisposed()) { leaderOnly.setEnabled(false); } } @@ -159,7 +160,9 @@ public class CollaborationPathToolbar extends PathToolbar { } public void disableAll() { - toolbar.setEnabled(!toolbar.getEnabled()); + if (toolbar != null && !toolbar.isDisposed()) { + toolbar.setEnabled(!toolbar.getEnabled()); + } } } diff --git a/cave/com.raytheon.uf.viz.drawing/META-INF/MANIFEST.MF b/cave/com.raytheon.uf.viz.drawing/META-INF/MANIFEST.MF index f83d26efb7..c03943b10f 100644 --- a/cave/com.raytheon.uf.viz.drawing/META-INF/MANIFEST.MF +++ b/cave/com.raytheon.uf.viz.drawing/META-INF/MANIFEST.MF @@ -21,5 +21,6 @@ Import-Package: com.raytheon.uf.common.time, com.raytheon.viz.ui.cmenu, com.vividsolutions.jts.geom Export-Package: com.raytheon.uf.viz.drawing, + com.raytheon.uf.viz.drawing.actions, com.raytheon.uf.viz.drawing.events, com.raytheon.uf.viz.drawing.tools diff --git a/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/PathToolbar.java b/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/PathToolbar.java index 5283e5fc98..ab41748e28 100644 --- a/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/PathToolbar.java +++ b/cave/com.raytheon.uf.viz.drawing/src/com/raytheon/uf/viz/drawing/PathToolbar.java @@ -283,6 +283,17 @@ public class PathToolbar extends CaveSWTDialog { updateToolbar(); } + /* + * (non-Javadoc) + * + * @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#disposed() + */ + @Override + protected void disposed() { + super.disposed(); + pathToolbar = null; + } + public void updateToolbar() { if (this.isDisposed()) { return;