From 08c8cd1244eb087b27a644e809d7f0d75f1764e6 Mon Sep 17 00:00:00 2001 From: Roger Ferrel Date: Wed, 28 Mar 2012 11:23:24 -0500 Subject: [PATCH] Issue #244 Clean up and Link editor to chat now works. Change-Id: I23b12fa44b8908b6a0c5ce79ca79ad73ff26df9d Former-commit-id: 2c61bc2a503738a3249115eabfd818cae4910832 [formerly fae15273317e176bfffc168a663f1e6c408accc3] [formerly 5d95a69f393c1c092240ebf5d4dfb7644bce27a7] [formerly 2c61bc2a503738a3249115eabfd818cae4910832 [formerly fae15273317e176bfffc168a663f1e6c408accc3] [formerly 5d95a69f393c1c092240ebf5d4dfb7644bce27a7] [formerly dc2f3316e6a0a75982ad9460f0e2ef3b18f332df [formerly 5d95a69f393c1c092240ebf5d4dfb7644bce27a7 [formerly 51e85606ad7d7462ce84bb14bd4df0c792997a59]]]] Former-commit-id: dc2f3316e6a0a75982ad9460f0e2ef3b18f332df Former-commit-id: f1a9b8265cdc3116ae1a3c922a878a50544bb0fa [formerly d29d2a1c92746ecc15770af8bc6cc60498c26929] [formerly 27bd3129b256af64b1bce9adcab5ca25bc1e9327 [formerly 9712ba275159ebd507a0d732d36ddae12d2a1873]] Former-commit-id: 996507114e4f808d9a2a5758117e98559a4da0d7 [formerly a5b05aeebdc7ff0cd7b9cc94993b776964813a9b] Former-commit-id: dbb7bdf9a8ae7ddc3ae6ff8d52c26bb9b2614dc2 --- .../plugin.xml | 1 + .../data/CollaborationDataManager.java | 113 ++++++++++++++---- .../viz/collaboration/data/SessionGroup.java | 4 + .../ui/CollaborationGroupView.java | 54 +++++---- .../ui/editor/CollaborationEditor.java | 90 +++++++++++++- .../collaboration/ui/editor/EditorSetup.java | 6 + .../ui/session/AbstractSessionView.java | 8 +- .../ui/session/CollaborationSessionView.java | 48 +++++++- .../collaboration/ui/session/SessionView.java | 49 ++++---- 9 files changed, 297 insertions(+), 76 deletions(-) diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/plugin.xml b/cave/com.raytheon.uf.viz.collaboration.ui/plugin.xml index 1e3ddd9ad8..e98e8735e8 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/plugin.xml +++ b/cave/com.raytheon.uf.viz.collaboration.ui/plugin.xml @@ -137,6 +137,7 @@ class="com.raytheon.uf.viz.collaboration.ui.editor.CollaborationEditor" default="true" id="com.raytheon.uf.viz.collaboration.ui.editor.CollaborationEditor" + icon="icons/messages.gif" name="Map"> 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 d855ab8eb4..5d0f215cf9 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 @@ -26,6 +26,8 @@ import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.MessageBox; import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IEditorReference; +import org.eclipse.ui.IViewReference; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchListener; import org.eclipse.ui.PlatformUI; @@ -85,14 +87,16 @@ public class CollaborationDataManager { */ Map usersMap; + private boolean linkCollaboration; + /** * Mapping for all active chat sessions. */ Map sessionsMap; - Map displaySessionsMap = new HashMap(); + private Map roleEventControllersMap; - Map editorsMap = new HashMap(); + Map editorsMap; public static CollaborationDataManager getInstance() { if (instance == null) { @@ -116,9 +120,11 @@ public class CollaborationDataManager { * Private constructor to for singleton class. */ private CollaborationDataManager() { + linkCollaboration = false; usersMap = new HashMap(); sessionsMap = new HashMap(); - // displaySessionsMap = new HashMap(); + roleEventControllersMap = new HashMap(); + editorsMap = new HashMap(); } public String getLoginId() { @@ -134,17 +140,15 @@ public class CollaborationDataManager { return usersMap.get(id); } - public AbstractRoleEventController getDisplaySession(String sessonId) { - return displaySessionsMap.get(sessonId); + public void setLinkCollaboration(boolean state) { + this.linkCollaboration = state; } - public void setDisplaySession(String sessionId, - AbstractRoleEventController controller) { - displaySessionsMap.put(sessionId, controller); + public boolean getLinkCollaboration() { + return linkCollaboration; } - public void editorCreated(String venueId, CollaborationEditor editor) { - String sessionId = venueIdToSessionId(venueId); + public void editorCreated(String sessionId, CollaborationEditor editor) { editorsMap.put(sessionId, editor); } @@ -273,15 +277,75 @@ public class CollaborationDataManager { IVenueSession session = sessionsMap.get(sessionId); if (session != null) { sessionsMap.remove(sessionId); - AbstractRoleEventController controller = displaySessionsMap - .remove(sessionId); - if (controller != null) { - controller.shutdown(); - } session.close(); } } + public void closeEditor(String sessionId) { + CollaborationEditor editor = editorsMap.remove(sessionId); + if (editor != null) { + for (IEditorReference ref : PlatformUI.getWorkbench() + .getActiveWorkbenchWindow().getActivePage() + .getEditorReferences()) { + if (editor == ref.getEditor(false)) { + PlatformUI.getWorkbench().getActiveWorkbenchWindow() + .getActivePage().hideEditor(ref); + } + } + } + + AbstractRoleEventController controller = roleEventControllersMap + .remove(sessionId); + if (controller != null) { + controller.shutdown(); + } + } + + public void editorBringToTop(String sessionId) { + if (linkCollaboration) { + CollaborationEditor editor = CollaborationDataManager.getInstance() + .getEditor(sessionId); + if (editor != null) { + PlatformUI.getWorkbench().getActiveWorkbenchWindow() + .getActivePage().bringToTop(editor); + } + } + } + + public String getSessinId(CollaborationEditor editor) { + String sessionId = null; + for (String key : editorsMap.keySet()) { + if (editor == editorsMap.get(key)) { + sessionId = key; + break; + } + } + return sessionId; + } + + /** + * Bring the view associated with the sessionId to the top. + * + * @param sessionId + */ + public void viewBringToTop(String sessionId) { + if (linkCollaboration) { + for (IViewReference ref : PlatformUI.getWorkbench() + .getActiveWorkbenchWindow().getActivePage() + .getViewReferences()) { + if (sessionId.equals(ref.getSecondaryId())) { + try { + PlatformUI.getWorkbench().getActiveWorkbenchWindow() + .getActivePage().bringToTop(ref.getView(false)); + } catch (NullPointerException ex) { + // Ignore happens during creation of view/editor. + } + break; + } + } + } + } + /** * Generate a new session. * @@ -298,8 +362,9 @@ public class CollaborationDataManager { String sessionId = null; try { session = manager.createCollaborationVenue(venue, subject); - sessionId = venueIdToSessionId(session.getVenue().getInfo() - .getVenueID()); + // sessionId = venueIdToSessionId(session.getVenue().getInfo() + // .getVenueID()); + sessionId = session.getSessionId(); // TODO throw an exception if unable to make connection? if (session.isConnected()) { ISharedDisplaySession displaySession = session @@ -308,7 +373,7 @@ public class CollaborationDataManager { DataProviderEventController dpec = new DataProviderEventController( displaySession); dpec.startup(); - displaySessionsMap.put(sessionId, dpec); + roleEventControllersMap.put(sessionId, dpec); // TODO set displaySession's data provider and session leader. } } catch (CollaborationException e) { @@ -326,19 +391,23 @@ public class CollaborationDataManager { } public String joinCollaborationSession(String venueName, String sessionId) { + String result = sessionId; if (sessionsMap.get(sessionId) == null) { IVenueSession session = null; try { session = getSessionManager().joinCollaborationVenue(venueName); + result = session.getSessionId(); ISharedDisplaySession displaySession = session .spawnSharedDisplaySession(); - sessionsMap.put(sessionId, session); + sessionsMap.put(result, session); ParticipantEventController pec = new ParticipantEventController( displaySession); pec.startup(); - displaySessionsMap.put(sessionId, pec); - // displaySessionsMap.put(sessionId, displaySession); + roleEventControllersMap.put(sessionId, pec); + // TODO test only delete + // SharedEditor editor = EditorSetup.testLoadEditorData(); + // pec.initDataArrived(editor); } catch (CollaborationException e) { // TODO Auto-generated catch block. Please revise as // appropriate. @@ -346,6 +415,6 @@ public class CollaborationDataManager { e); } } - return sessionId; + return result; } } diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/data/SessionGroup.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/data/SessionGroup.java index 44506d8493..7326914e42 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/data/SessionGroup.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/data/SessionGroup.java @@ -52,6 +52,10 @@ public class SessionGroup extends CollaborationGroup { this.sessionRoot = sessionRoot; } + public void setId(String id) { + this.id = id; + } + /* * (non-Javadoc) * 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 cb9e4fd8ac..f5ff14d278 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 @@ -52,6 +52,8 @@ import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Menu; import org.eclipse.swt.widgets.MessageBox; import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.IEditorReference; import org.eclipse.ui.IViewPart; import org.eclipse.ui.IViewReference; import org.eclipse.ui.IWorkbenchPage; @@ -72,15 +74,13 @@ import com.raytheon.uf.viz.collaboration.comm.identity.roster.IRosterEntry; import com.raytheon.uf.viz.collaboration.comm.identity.roster.IRosterGroup; import com.raytheon.uf.viz.collaboration.comm.identity.roster.IRosterManager; import com.raytheon.uf.viz.collaboration.comm.provider.session.SessionManager; -import com.raytheon.uf.viz.collaboration.comm.provider.session.VenueSession; import com.raytheon.uf.viz.collaboration.data.CollaborationDataManager; import com.raytheon.uf.viz.collaboration.data.CollaborationGroup; import com.raytheon.uf.viz.collaboration.data.CollaborationNode; import com.raytheon.uf.viz.collaboration.data.CollaborationUser; import com.raytheon.uf.viz.collaboration.data.LoginUser; import com.raytheon.uf.viz.collaboration.data.SessionGroup; -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.editor.CollaborationEditor; 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; @@ -198,13 +198,15 @@ public class CollaborationGroupView extends ViewPart { Action.AS_CHECK_BOX) { @Override public void run() { - // TODO - System.out.println("Link to editor here"); + CollaborationDataManager.getInstance().setLinkCollaboration( + isChecked()); // createPrivateChat(); } }; linkToEditorAction.setImageDescriptor(CollaborationUtils .getImageDescriptor("link_to_editor.gif")); + linkToEditorAction.setChecked(CollaborationDataManager.getInstance() + .getLinkCollaboration()); inviteAction = new Action("Invite...") { @Override @@ -371,6 +373,7 @@ public class CollaborationGroupView extends ViewPart { + "close all collaboration views\n" + "and editors."); int result = messageBox.open(); if (result == SWT.OK) { + // Close all Session Views PlatformUI.getWorkbench().getActiveWorkbenchWindow() .getActivePage().hideView(this); for (IViewReference ref : PlatformUI.getWorkbench() @@ -382,16 +385,17 @@ public class CollaborationGroupView extends ViewPart { .getActivePage().hideView(view); } } - // TODO close collaboration CAVE editor(s). - // for (IEditorReference ref : - // PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences()) - // { - // IEditorPart editor = ref.getEditor(false); - // if (editor instanceof CollaborationEditor) { - // PlatformUI.getWorkbench().getActiveWorkbenchWindow() - // .getActivePage().hideEditor(ref); - // } - // } + + // Close all Collaboration Editors. + for (IEditorReference ref : PlatformUI.getWorkbench() + .getActiveWorkbenchWindow().getActivePage() + .getEditorReferences()) { + IEditorPart editor = ref.getEditor(false); + if (editor instanceof CollaborationEditor) { + PlatformUI.getWorkbench().getActiveWorkbenchWindow() + .getActivePage().hideEditor(ref); + } + } CollaborationDataManager.getInstance().closeManager(); } } @@ -511,10 +515,6 @@ public class CollaborationGroupView extends ViewPart { .getInstance(); sessionId = manager.createCollaborationSession(result.getName(), result.getSubject()); - DataProviderEventController controller = new DataProviderEventController( - (VenueSession) manager.getSession(sessionId)); - controller.startup(); - manager.setDisplaySession(sessionId, controller); } catch (Exception e) { e.printStackTrace(); } finally { @@ -599,10 +599,12 @@ public class CollaborationGroupView extends ViewPart { .getInstance(); String sessionId = manager.joinCollaborationSession( sg.getText(), sg.getId()); - ParticipantEventController controller = new ParticipantEventController( - (VenueSession) manager.getSession(sessionId)); - manager.setDisplaySession(sessionId, controller); - controller.startup(); + sg.setId(sessionId); + // ParticipantEventController controller = new + // ParticipantEventController( + // (VenueSession) manager.getSession(sessionId)); + // manager.setDisplaySession(sessionId, controller); + // controller.startup(); try { IViewPart part = PlatformUI .getWorkbench() @@ -610,7 +612,6 @@ public class CollaborationGroupView extends ViewPart { .getActivePage() .showView(CollaborationSessionView.ID, sessionId, IWorkbenchPage.VIEW_ACTIVATE); - } catch (PartInitException e) { statusHandler.handle(Priority.PROBLEM, "Unable to open collaboation sesson", e); @@ -806,8 +807,9 @@ public class CollaborationGroupView extends ViewPart { Collection venuList = CollaborationDataManager .getInstance().getSessionManager().getVenueInfo(); for (IVenueInfo venu : venuList) { - SessionGroup gp = new SessionGroup(CollaborationDataManager - .getInstance().venueIdToSessionId(venu.getVenueID())); + // SessionGroup gp = new SessionGroup(CollaborationDataManager + // .getInstance().venueIdToSessionId(venu.getVenueID())); + SessionGroup gp = new SessionGroup(null); gp.setText(venu.getVenueName()); if (venu.getParticipantCount() > 0) { diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/editor/CollaborationEditor.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/editor/CollaborationEditor.java index e55afaf09e..5c708f33d3 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/editor/CollaborationEditor.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/editor/CollaborationEditor.java @@ -19,6 +19,12 @@ **/ package com.raytheon.uf.viz.collaboration.ui.editor; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.ui.IPartListener; +import org.eclipse.ui.IWorkbenchPart; + +import com.raytheon.uf.viz.collaboration.comm.identity.IVenueSession; +import com.raytheon.uf.viz.collaboration.data.CollaborationDataManager; import com.raytheon.uf.viz.core.rsc.IInputHandler.InputPriority; import com.raytheon.viz.ui.editor.AbstractEditor; import com.raytheon.viz.ui.panes.PaneManager; @@ -41,7 +47,8 @@ import com.raytheon.viz.ui.panes.PaneManager; * @version 1.0 */ -public class CollaborationEditor extends AbstractEditor { +public class CollaborationEditor extends AbstractEditor implements + IPartListener { public static final String EDITOR_ID = "com.raytheon.uf.viz.collaboration.ui.editor.CollaborationEditor"; @@ -53,4 +60,85 @@ public class CollaborationEditor extends AbstractEditor { return pm; } + @Override + public void createPartControl(Composite parent) { + super.createPartControl(parent); + getEditorSite().getWorkbenchWindow().getPartService() + .addPartListener(this); + } + + /* + * (non-Javadoc) + * + * @see + * org.eclipse.ui.IPartListener#partActivated(org.eclipse.ui.IWorkbenchPart) + */ + @Override + public void partActivated(IWorkbenchPart part) { + if (this == part) { + CollaborationDataManager manager = CollaborationDataManager + .getInstance(); + String sessionId = manager.getSessinId(this); + manager.viewBringToTop(sessionId); + } + } + + /* + * (non-Javadoc) + * + * @see + * org.eclipse.ui.IPartListener#partBroughtToTop(org.eclipse.ui.IWorkbenchPart + * ) + */ + @Override + public void partBroughtToTop(IWorkbenchPart part) { + // TODO Auto-generated method stub + + } + + /* + * (non-Javadoc) + * + * @see + * org.eclipse.ui.IPartListener#partClosed(org.eclipse.ui.IWorkbenchPart) + */ + @Override + public void partClosed(IWorkbenchPart part) { + if (this == part) { + getEditorSite().getWorkbenchWindow().getPartService() + .removePartListener(this); + } + } + + /* + * (non-Javadoc) + * + * @see + * org.eclipse.ui.IPartListener#partDeactivated(org.eclipse.ui.IWorkbenchPart + * ) + */ + @Override + public void partDeactivated(IWorkbenchPart part) { + // TODO Auto-generated method stub + + } + + /* + * (non-Javadoc) + * + * @see + * org.eclipse.ui.IPartListener#partOpened(org.eclipse.ui.IWorkbenchPart) + */ + @Override + public void partOpened(IWorkbenchPart part) { + if (this == part) { + CollaborationDataManager manager = CollaborationDataManager + .getInstance(); + String sessionId = manager.getSessinId(this); + IVenueSession session = manager.getSession(sessionId); + String name = (session == null) ? sessionId : session.getVenue() + .getInfo().getVenueDescription(); + setPartName(name); + } + } } diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/editor/EditorSetup.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/editor/EditorSetup.java index 1fceb34cce..bc4cc77b8e 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/editor/EditorSetup.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/editor/EditorSetup.java @@ -19,6 +19,7 @@ **/ package com.raytheon.uf.viz.collaboration.ui.editor; +import java.io.File; import java.util.ArrayList; import java.util.Iterator; import java.util.List; @@ -157,6 +158,11 @@ public class EditorSetup { // TODO delete public static SharedEditor testLoadEditorData() { + File file = new File(PATH); + if (!file.exists()) { + testSaveEditorData(); + } + SharedEditor se = null; try { se = (SharedEditor) SerializationUtil diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/AbstractSessionView.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/AbstractSessionView.java index b6d8bae1ae..6234b8c7b4 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/AbstractSessionView.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/AbstractSessionView.java @@ -128,6 +128,8 @@ public abstract class AbstractSessionView extends ViewPart implements } protected void createListeners() { + getViewSite().getWorkbenchWindow().getPartService() + .addPartListener(this); } private void createMessagesComp(Composite parent) { @@ -251,8 +253,10 @@ public abstract class AbstractSessionView extends ViewPart implements */ @Override public void partClosed(IWorkbenchPart part) { - getViewSite().getWorkbenchWindow().getPartService() - .removePartListener(this); + if (this == part) { + getViewSite().getWorkbenchWindow().getPartService() + .removePartListener(this); + } } /* 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 18cd9f78a2..3e80deeec4 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 @@ -27,6 +27,7 @@ import org.eclipse.jface.action.IMenuManager; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Menu; +import org.eclipse.ui.IWorkbenchPart; import com.raytheon.uf.viz.collaboration.comm.identity.CollaborationException; import com.raytheon.uf.viz.collaboration.comm.identity.IVenueSession; @@ -139,7 +140,8 @@ public class CollaborationSessionView extends SessionView { CollaborationDataManager.getInstance().getSession(sessionId) .sendTextMessage(message); } catch (CollaborationException e) { - // TODO Auto-generated catch block. Please revise as appropriate. + // TODO Auto-generated catch block. Please revise as + // appropriate. } } } @@ -177,4 +179,48 @@ public class CollaborationSessionView extends SessionView { } label.setText(labelInfo.toString()); } + + /* + * (non-Javadoc) + * + * @see com.raytheon.uf.viz.collaboration.ui.session.AbstractSessionView# + * partActivated(org.eclipse.ui.IWorkbenchPart) + */ + @Override + public void partActivated(IWorkbenchPart part) { + super.partActivated(part); + if (this == part) { + CollaborationDataManager.getInstance().editorBringToTop(sessionId); + } + } + + @Override + public void partBroughtToTop(IWorkbenchPart part) { + super.partBroughtToTop(part); + } + + @Override + public void partDeactivated(IWorkbenchPart part) { + super.partDeactivated(part); + } + + @Override + public void partOpened(IWorkbenchPart part) { + super.partOpened(part); + } + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.uf.viz.collaboration.ui.session.SessionView#partClosed(org + * .eclipse.ui.IWorkbenchPart) + */ + @Override + public void partClosed(IWorkbenchPart part) { + super.partClosed(part); + if (part == this) { + CollaborationDataManager.getInstance().closeEditor(sessionId); + } + } } 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 ec4e1b9711..a87493ce83 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 @@ -214,10 +214,7 @@ public class SessionView extends AbstractSessionView { */ @Override protected void createListeners() { - // this.getViewSite().getWorkbenchWindow().getPartService() - // .addPartListener(this); super.createListeners(); - // sessionId = getViewSite().getSecondaryId(); IVenueSession session = CollaborationDataManager.getInstance() .getSession(sessionId); if (session != null) { @@ -325,7 +322,6 @@ public class SessionView extends AbstractSessionView { public int compare(Viewer viewer, Object e1, Object e2) { CollaborationUser c1 = (CollaborationUser) e1; CollaborationUser c2 = (CollaborationUser) e1; - // return super.compare(viewer, e1, e2); return c1.compareTo(c2); } }); @@ -340,7 +336,7 @@ public class SessionView extends AbstractSessionView { StringBuilder builder = new StringBuilder("-- Roles --"); for (RoleType type : RoleType.values()) {// user.getRoles(sessionId)) // { - // fake XXX take this out + // TODO fake XXX take this out if (type == RoleType.UNKNOWN) { continue; } @@ -379,15 +375,15 @@ public class SessionView extends AbstractSessionView { @Override public void dispose() { - CollaborationDataManager.getInstance().getSession(sessionId) - .unRegisterEventHandler(this); + // CollaborationDataManager.getInstance().getSession(sessionId) + // .unRegisterEventHandler(this); // dispose of the images first disposeArrow(highlightedDownArrow); disposeArrow(highlightedRightArrow); disposeArrow(downArrow); disposeArrow(rightArrow); - CollaborationDataManager.getInstance().closeSession(sessionId); + // CollaborationDataManager.getInstance().closeSession(sessionId); super.dispose(); } @@ -506,26 +502,31 @@ public class SessionView extends AbstractSessionView { return SESSION_IMAGE_NAME; } - @Override - public void partActivated(IWorkbenchPart part) { - // nothing to do - } - - @Override - public void partBroughtToTop(IWorkbenchPart part) { - // TODO - // if link with editor is on, need to activate the editor - } + // @Override + // public void partActivated(IWorkbenchPart part) { + // // nothing to do + // } + // + // @Override + // public void partBroughtToTop(IWorkbenchPart part) { + // // TODO + // // if link with editor is on, need to activate the editor + // } // @Override + /* + * (non-Javadoc) + * + * @see + * com.raytheon.uf.viz.collaboration.ui.session.AbstractSessionView#partClosed + * (org.eclipse.ui.IWorkbenchPart) + */ public void partClosed(IWorkbenchPart part) { super.partClosed(part); - // TODO - // here you need to end a session that is a temporary session - IVenueSession session = CollaborationDataManager.getInstance() - .getSession(sessionId); - if (session != null) { - session.unRegisterEventHandler(this); + if (this == part) { + CollaborationDataManager.getInstance().getSession(sessionId) + .unRegisterEventHandler(this); + CollaborationDataManager.getInstance().closeSession(sessionId); } }