Issue #444 cleanup and fix numerous small errors
Change-Id: Idc7862a20a3d3a95103bd58ab9417e002ffaced9 Former-commit-id: efcfbbc302ede49acffcf85a792a80dc9862a0b8
This commit is contained in:
parent
217ee506e1
commit
ff6cd0bd75
8 changed files with 41 additions and 202 deletions
|
@ -184,8 +184,10 @@ public class CollaborationDataManager {
|
|||
return linkCollaboration;
|
||||
}
|
||||
|
||||
public void editorCreated(String sessionId, CollaborationEditor editor) {
|
||||
editorsMap.put(sessionId, editor);
|
||||
public void editorCreated(ISharedDisplaySession session,
|
||||
CollaborationEditor editor) {
|
||||
editorsMap.put(session.getSessionId(), editor);
|
||||
editor.setTabTitle(((IVenueSession) session).getSubject());
|
||||
}
|
||||
|
||||
public CollaborationEditor getEditor(String sessionId) {
|
||||
|
@ -327,12 +329,14 @@ public class CollaborationDataManager {
|
|||
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);
|
||||
IWorkbenchPage page = PlatformUI.getWorkbench()
|
||||
.getActiveWorkbenchWindow().getActivePage();
|
||||
if (page != null) {
|
||||
for (IEditorReference ref : page.getEditorReferences()) {
|
||||
if (editor == ref.getEditor(false)) {
|
||||
PlatformUI.getWorkbench().getActiveWorkbenchWindow()
|
||||
.getActivePage().hideEditor(ref);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@ package com.raytheon.uf.viz.collaboration.data;
|
|||
import com.raytheon.uf.viz.collaboration.comm.identity.IPresence;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.IPresence.Type;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.user.IChatID;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.user.ParticipantRole;
|
||||
|
||||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
|
@ -75,26 +74,6 @@ public class CollaborationUser extends CollaborationNode implements
|
|||
return "contact_disabled";
|
||||
}
|
||||
|
||||
public ParticipantRole[] getRoles() {
|
||||
return CollaborationDataManager.getInstance().getUser(id)
|
||||
.getSessionRoles(session);
|
||||
}
|
||||
|
||||
public void addRole(ParticipantRole role) {
|
||||
CollaborationDataManager.getInstance().getUser(id)
|
||||
.addSessionRole(session, role);
|
||||
}
|
||||
|
||||
public void removeRole(ParticipantRole role) {
|
||||
CollaborationDataManager.getInstance().getUser(id)
|
||||
.removeSessionRole(session, role);
|
||||
}
|
||||
|
||||
public void removeSession(String session) {
|
||||
CollaborationDataManager.getInstance().getUser(id)
|
||||
.removeSession(session);
|
||||
}
|
||||
|
||||
public IPresence.Mode getMode() {
|
||||
return CollaborationDataManager.getInstance().getUser(id).mode;
|
||||
}
|
||||
|
|
|
@ -19,16 +19,12 @@
|
|||
**/
|
||||
package com.raytheon.uf.viz.collaboration.data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.IPresence;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.IPresence.Mode;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.IPresence.Type;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.user.ParticipantRole;
|
||||
|
||||
/**
|
||||
* A Data class that contains all the user information needed for the current
|
||||
|
@ -62,13 +58,6 @@ public class DataUser {
|
|||
|
||||
String statusMessage;
|
||||
|
||||
Map<String, List<ParticipantRole>> roleMap;
|
||||
|
||||
/**
|
||||
* Unique id for the usersData.
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* The groups being tracked that user belongs to.
|
||||
*/
|
||||
|
@ -85,84 +74,10 @@ public class DataUser {
|
|||
* @param id
|
||||
*/
|
||||
DataUser(String id) {
|
||||
this.id = id;
|
||||
groupsMap = new HashMap<String, DataGroup>();
|
||||
sessionsMap = new HashMap<String, String>();
|
||||
mode = Mode.EXTENDED_AWAY;
|
||||
type = Type.UNKNOWN;
|
||||
roleMap = new HashMap<String, List<ParticipantRole>>();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param sessionId
|
||||
* @return
|
||||
*/
|
||||
ParticipantRole[] getSessionRoles(String sessionId) {
|
||||
ParticipantRole[] result = null;
|
||||
List<ParticipantRole> roleList = roleMap.get(sessionId);
|
||||
if (roleList == null) {
|
||||
result = new ParticipantRole[0];
|
||||
} else {
|
||||
result = new ParticipantRole[roleList.size()];
|
||||
roleList.toArray(result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param sessionId
|
||||
* @param role
|
||||
*/
|
||||
public void addSessionRole(final String sessionId,
|
||||
final ParticipantRole role) {
|
||||
List<ParticipantRole> roleList = roleMap.get(sessionId);
|
||||
if (roleList == null) {
|
||||
roleList = new ArrayList<ParticipantRole>();
|
||||
roleMap.put(sessionId, roleList);
|
||||
}
|
||||
|
||||
if (role == ParticipantRole.PARTICIPANT) {
|
||||
roleList.clear();
|
||||
roleList.add(role);
|
||||
} else {
|
||||
boolean insertRole = true;
|
||||
Iterator<ParticipantRole> iter = roleList.iterator();
|
||||
while (iter.hasNext()) {
|
||||
ParticipantRole r = iter.next();
|
||||
if (r == role) {
|
||||
insertRole = false;
|
||||
}
|
||||
if (r == ParticipantRole.PARTICIPANT) {
|
||||
iter.remove();
|
||||
}
|
||||
}
|
||||
if (insertRole) {
|
||||
// Keep order Leader then provider.
|
||||
if (role == ParticipantRole.SESSION_LEADER) {
|
||||
roleList.add(0, role);
|
||||
} else {
|
||||
roleList.add(role);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param sessionId
|
||||
* @param role
|
||||
*/
|
||||
public void removeSessionRole(String sessionId, ParticipantRole role) {
|
||||
List<ParticipantRole> roleList = roleMap.get(sessionId);
|
||||
if (roleList != null) {
|
||||
roleList.remove(role);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param sessionId
|
||||
*/
|
||||
void removeSession(String sessionId) {
|
||||
roleMap.remove(sessionId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -23,7 +23,6 @@ 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.collaboration.ui.editor.event.CollaborationInputHandler;
|
||||
import com.raytheon.uf.viz.core.rsc.IInputHandler;
|
||||
|
@ -133,15 +132,7 @@ public class CollaborationEditor extends AbstractEditor implements
|
|||
*/
|
||||
@Override
|
||||
public void partOpened(IWorkbenchPart part) {
|
||||
if (this == part) {
|
||||
CollaborationDataManager manager = CollaborationDataManager
|
||||
.getInstance();
|
||||
String sessionId = manager.getSessionId(this);
|
||||
IVenueSession session = manager.getSession(sessionId);
|
||||
String name = (session == null) ? sessionId : session.getVenue()
|
||||
.getInfo().getVenueDescription();
|
||||
setPartName(name);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -87,8 +87,8 @@ public class ParticipantEventController extends AbstractRoleEventController {
|
|||
}
|
||||
initializeResources(editor.getActiveDisplayPane()
|
||||
.getDescriptor());
|
||||
CollaborationDataManager.getInstance().editorCreated(
|
||||
session.getSessionId(), editor);
|
||||
CollaborationDataManager.getInstance().editorCreated(session,
|
||||
editor);
|
||||
}
|
||||
});
|
||||
super.activateTelestrator(); // TODO should this be elsewhere?
|
||||
|
|
|
@ -46,7 +46,6 @@ import org.eclipse.ui.part.ViewPart;
|
|||
import org.eclipse.ui.progress.IWorkbenchSiteProgressService;
|
||||
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.IMessage;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.user.ParticipantRole;
|
||||
import com.raytheon.uf.viz.collaboration.ui.Activator;
|
||||
import com.raytheon.uf.viz.collaboration.ui.SessionColorManager;
|
||||
import com.raytheon.uf.viz.core.icon.IconUtil;
|
||||
|
@ -297,17 +296,6 @@ public abstract class AbstractSessionView extends ViewPart implements
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of Participant roles the user is assigned for the session.
|
||||
* This sets up a default list of user as a PARTICIPANT.
|
||||
*
|
||||
* @param userId
|
||||
* @return roles
|
||||
*/
|
||||
protected ParticipantRole[] getRoles(String userId) {
|
||||
return new ParticipantRole[] { ParticipantRole.PARTICIPANT };
|
||||
}
|
||||
|
||||
/**
|
||||
* Place holder must override to do something.
|
||||
*/
|
||||
|
|
|
@ -21,7 +21,6 @@ package com.raytheon.uf.viz.collaboration.ui.session;
|
|||
**/
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.jface.action.Action;
|
||||
import org.eclipse.jface.action.ActionContributionItem;
|
||||
|
@ -75,6 +74,8 @@ public class CollaborationSessionView extends SessionView {
|
|||
|
||||
private Action switchToAction;
|
||||
|
||||
private ISharedDisplaySession session;
|
||||
|
||||
protected void createActions() {
|
||||
super.createActions();
|
||||
switchToAction = new Action("Transfer Role...",
|
||||
|
@ -92,8 +93,6 @@ public class CollaborationSessionView extends SessionView {
|
|||
if (menu == null || menu.isDisposed()) {
|
||||
menu = new Menu(parent);
|
||||
}
|
||||
ISharedDisplaySession session = (ISharedDisplaySession) CollaborationDataManager
|
||||
.getInstance().getSession(sessionId);
|
||||
if (session.hasRole(ParticipantRole.SESSION_LEADER)) {
|
||||
Action leaderAction = new Action("Session Leader") {
|
||||
public void run() {
|
||||
|
@ -154,17 +153,8 @@ public class CollaborationSessionView extends SessionView {
|
|||
Tools.parseHost(fqname));
|
||||
trc.setUser(vp);
|
||||
trc.setRole(ParticipantRole.SESSION_LEADER);
|
||||
ISharedDisplaySession session = (ISharedDisplaySession) CollaborationDataManager
|
||||
.getInstance().getSession(this.sessionId);
|
||||
try {
|
||||
session.sendObjectToVenue(trc);
|
||||
CollaborationDataManager.getInstance().getUser(vp.getFQName())
|
||||
.addSessionRole(sessionId, ParticipantRole.SESSION_LEADER);
|
||||
CollaborationDataManager
|
||||
.getInstance()
|
||||
.getUser(session.getUserID().getFQName())
|
||||
.removeSessionRole(sessionId,
|
||||
ParticipantRole.SESSION_LEADER);
|
||||
} catch (CollaborationException e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Unable to send message to transfer role", e);
|
||||
|
@ -176,38 +166,15 @@ public class CollaborationSessionView extends SessionView {
|
|||
return COLLABORATION_SESSION_IMAGE_NAME;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.viz.collaboration.ui.session.AbstractSessionView#getRoles
|
||||
* (java.lang.String)
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
protected ParticipantRole[] getRoles(String userId) {
|
||||
for (CollaborationUser u : ((List<CollaborationUser>) usersTable
|
||||
.getInput())) {
|
||||
if (userId.equals(u.getId())) {
|
||||
return u.getRoles();
|
||||
}
|
||||
}
|
||||
return new ParticipantRole[] { ParticipantRole.PARTICIPANT };
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String buildParticipantTooltip(CollaborationUser user) {
|
||||
StringBuilder builder = new StringBuilder(
|
||||
super.buildParticipantTooltip(user));
|
||||
ISharedDisplaySession session = (ISharedDisplaySession) CollaborationDataManager
|
||||
.getInstance().getSession(sessionId);
|
||||
// TODO these should be smarter ifs
|
||||
boolean isSessionLeader = Tools.parseName(user.getId()).equals(
|
||||
session.getCurrentSessionLeader().getName());
|
||||
boolean isDataProvider = Tools.parseName(user.getId()).equals(
|
||||
session.getCurrentSessionLeader().getName());
|
||||
System.out.println(isSessionLeader);
|
||||
System.out.println(isDataProvider);
|
||||
if (isSessionLeader || isDataProvider) {
|
||||
builder.append("-- Roles --");
|
||||
if (isSessionLeader) {
|
||||
|
@ -250,11 +217,11 @@ public class CollaborationSessionView extends SessionView {
|
|||
String message = getComposedMessage();
|
||||
if (message.length() > 0) {
|
||||
try {
|
||||
CollaborationDataManager.getInstance().getSession(sessionId)
|
||||
.sendTextMessage(message);
|
||||
((IVenueSession) session).sendTextMessage(message);
|
||||
} catch (CollaborationException e) {
|
||||
// TODO Auto-generated catch block. Please revise as
|
||||
// appropriate.
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -269,8 +236,6 @@ public class CollaborationSessionView extends SessionView {
|
|||
@Override
|
||||
protected void fillContextMenu(IMenuManager manager) {
|
||||
super.fillContextMenu(manager);
|
||||
ISharedDisplaySession session = (ISharedDisplaySession) CollaborationDataManager
|
||||
.getInstance().getSession(this.sessionId);
|
||||
if (session.hasRole(ParticipantRole.DATA_PROVIDER)
|
||||
|| session.hasRole(ParticipantRole.SESSION_LEADER)) {
|
||||
IStructuredSelection selection = (IStructuredSelection) usersTable
|
||||
|
@ -294,16 +259,21 @@ public class CollaborationSessionView extends SessionView {
|
|||
protected void setMessageLabel(Composite comp) {
|
||||
Label label = new Label(comp, SWT.NONE);
|
||||
StringBuilder labelInfo = new StringBuilder();
|
||||
IVenueSession session = CollaborationDataManager.getInstance()
|
||||
.getSession(sessionId);
|
||||
if (session != null) {
|
||||
IVenueInfo info = session.getVenue().getInfo();
|
||||
IVenueInfo info = ((IVenueSession) session).getVenue().getInfo();
|
||||
labelInfo.append(info.getVenueSubject());
|
||||
label.setToolTipText(info.getVenueSubject());
|
||||
}
|
||||
label.setText(labelInfo.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setSession(String sessionId) {
|
||||
super.setSession(sessionId);
|
||||
this.session = (ISharedDisplaySession) CollaborationDataManager
|
||||
.getInstance().getSession(this.sessionId);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
|
|
|
@ -102,6 +102,8 @@ public class SessionView extends AbstractSessionView {
|
|||
|
||||
protected String sessionId;
|
||||
|
||||
private IVenueSession session;
|
||||
|
||||
private Image downArrow;
|
||||
|
||||
private Image rightArrow;
|
||||
|
@ -226,8 +228,6 @@ public class SessionView extends AbstractSessionView {
|
|||
@Override
|
||||
protected void createListeners() {
|
||||
super.createListeners();
|
||||
IVenueSession session = CollaborationDataManager.getInstance()
|
||||
.getSession(sessionId);
|
||||
// if (session != null) {
|
||||
// session.registerEventHandler(this);
|
||||
// }
|
||||
|
@ -352,8 +352,6 @@ public class SessionView extends AbstractSessionView {
|
|||
}
|
||||
});
|
||||
|
||||
IVenueSession session = CollaborationDataManager.getInstance()
|
||||
.getSession(sessionId);
|
||||
List<CollaborationUser> users = new ArrayList<CollaborationUser>();
|
||||
if (session != null) {
|
||||
for (IVenueParticipant participant : session.getVenue()
|
||||
|
@ -416,12 +414,8 @@ public class SessionView extends AbstractSessionView {
|
|||
public void sendMessage() {
|
||||
String message = getComposedMessage();
|
||||
if (message.length() > 0) {
|
||||
// CollaborationDataManager.getInstance().getSession(sessionId)
|
||||
// .sendTextMessage(message);
|
||||
|
||||
try {
|
||||
CollaborationDataManager.getInstance().getSession(sessionId)
|
||||
.sendTextMessage(message);
|
||||
session.sendTextMessage(message);
|
||||
} catch (CollaborationException e) {
|
||||
// TODO Auto-generated catch block. Please revise as
|
||||
// appropriate.
|
||||
|
@ -450,10 +444,8 @@ public class SessionView extends AbstractSessionView {
|
|||
public void partClosed(IWorkbenchPart part) {
|
||||
super.partClosed(part);
|
||||
if (this == part) {
|
||||
CollaborationDataManager manager = CollaborationDataManager
|
||||
.getInstance();
|
||||
manager.getSession(sessionId).unRegisterEventHandler(this);
|
||||
manager.unRegisterEventHandler(this);
|
||||
session.unRegisterEventHandler(this);
|
||||
CollaborationDataManager.getInstance().unRegisterEventHandler(this);
|
||||
CollaborationDataManager.getInstance().closeSession(sessionId);
|
||||
}
|
||||
}
|
||||
|
@ -470,10 +462,8 @@ public class SessionView extends AbstractSessionView {
|
|||
// TODO Auto-generated method stub
|
||||
super.partOpened(part);
|
||||
if (this == part) {
|
||||
CollaborationDataManager manager = CollaborationDataManager
|
||||
.getInstance();
|
||||
manager.getSession(sessionId).registerEventHandler(this);
|
||||
manager.registerEventHandler(this);
|
||||
session.registerEventHandler(this);
|
||||
CollaborationDataManager.getInstance().registerEventHandler(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -538,8 +528,6 @@ public class SessionView extends AbstractSessionView {
|
|||
protected void setMessageLabel(Composite comp) {
|
||||
Label label = new Label(comp, SWT.WRAP);
|
||||
StringBuilder labelInfo = new StringBuilder();
|
||||
IVenueSession session = CollaborationDataManager.getInstance()
|
||||
.getSession(sessionId);
|
||||
if (session != null) {
|
||||
IVenueInfo info = session.getVenue().getInfo();
|
||||
labelInfo.append(info.getVenueSubject());
|
||||
|
@ -556,15 +544,19 @@ public class SessionView extends AbstractSessionView {
|
|||
*/
|
||||
@Override
|
||||
protected String getSessionName() {
|
||||
sessionId = getViewSite().getSecondaryId();
|
||||
IVenueSession session = CollaborationDataManager.getInstance()
|
||||
.getSession(sessionId);
|
||||
setSession(getViewSite().getSecondaryId());
|
||||
if (session == null) {
|
||||
return sessionId;
|
||||
}
|
||||
return session.getVenue().getInfo().getVenueDescription();
|
||||
}
|
||||
|
||||
protected void setSession(String sessionId) {
|
||||
this.sessionId = sessionId;
|
||||
this.session = CollaborationDataManager.getInstance().getSession(
|
||||
this.sessionId);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void participantHandler(IVenueParticipantEvent event)
|
||||
throws Exception {
|
||||
|
|
Loading…
Add table
Reference in a new issue