Issue #244 Clean up and Link editor to chat now works.

Change-Id: I23b12fa44b8908b6a0c5ce79ca79ad73ff26df9d

Former-commit-id: 5d95a69f39 [formerly 5d95a69f39 [formerly 51e85606ad7d7462ce84bb14bd4df0c792997a59]]
Former-commit-id: dc2f3316e6
Former-commit-id: 9712ba2751
This commit is contained in:
Roger Ferrel 2012-03-28 11:23:24 -05:00
parent 64be5deba5
commit a5b05aeebd
9 changed files with 297 additions and 76 deletions

View file

@ -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">
</editor>
</extension>

View file

@ -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<String, DataUser> usersMap;
private boolean linkCollaboration;
/**
* Mapping for all active chat sessions.
*/
Map<String, IVenueSession> sessionsMap;
Map<String, AbstractRoleEventController> displaySessionsMap = new HashMap<String, AbstractRoleEventController>();
private Map<String, AbstractRoleEventController> roleEventControllersMap;
Map<String, CollaborationEditor> editorsMap = new HashMap<String, CollaborationEditor>();
Map<String, CollaborationEditor> 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<String, DataUser>();
sessionsMap = new HashMap<String, IVenueSession>();
// displaySessionsMap = new HashMap<String, ISharedDisplaySession>();
roleEventControllersMap = new HashMap<String, AbstractRoleEventController>();
editorsMap = new HashMap<String, CollaborationEditor>();
}
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;
}
}

View file

@ -52,6 +52,10 @@ public class SessionGroup extends CollaborationGroup {
this.sessionRoot = sessionRoot;
}
public void setId(String id) {
this.id = id;
}
/*
* (non-Javadoc)
*

View file

@ -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<IVenueInfo> 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) {

View file

@ -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);
}
}
}

View file

@ -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

View file

@ -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);
}
}
/*

View file

@ -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);
}
}
}

View file

@ -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);
}
}