Issue #427 remove login and event subscription code from CollaborationDataManager
Change-Id: I18a2c44a275f5180d828184001fd1c5173ea2f74 Former-commit-id:28f779e7b9
[formerly 2306edfd4e11b512a68320ae7dc4edbcfa474934] Former-commit-id:05389dac56
This commit is contained in:
parent
b6a93f9d41
commit
8d741bc4a1
17 changed files with 466 additions and 383 deletions
|
@ -114,6 +114,8 @@ public class CollaborationConnection implements IEventPublisher {
|
|||
|
||||
private static final String PROVIDER = "ecf.xmpp.smack";
|
||||
|
||||
private static CollaborationConnection instance;
|
||||
|
||||
private Map<String, ISession> sessions;
|
||||
|
||||
private UserId account;
|
||||
|
@ -202,8 +204,8 @@ public class CollaborationConnection implements IEventPublisher {
|
|||
setupP2PComm(presenceAdapter);
|
||||
getPeerToPeerSession();
|
||||
|
||||
userPresence = initialPresence;
|
||||
if (accountManager != null && initialPresence != null) {
|
||||
userPresence = initialPresence;
|
||||
accountManager.sendPresence(initialPresence);
|
||||
}
|
||||
|
||||
|
@ -321,6 +323,7 @@ public class CollaborationConnection implements IEventPublisher {
|
|||
container.dispose();
|
||||
container = null;
|
||||
}
|
||||
instance = null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -670,4 +673,38 @@ public class CollaborationConnection implements IEventPublisher {
|
|||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the currently connected connection or null if it's not connected
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static CollaborationConnection getConnection() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Connects to the collaboration server with the provided credentials.
|
||||
*
|
||||
* @param account
|
||||
* the userid to connect as
|
||||
* @param password
|
||||
* the user's password
|
||||
* @param initialPresence
|
||||
* the initial presence
|
||||
* @return
|
||||
* @throws CollaborationException
|
||||
* when it cannot connect
|
||||
*/
|
||||
public static CollaborationConnection connect(UserId account,
|
||||
String password, IPresence initialPresence)
|
||||
throws CollaborationException {
|
||||
if (instance != null) {
|
||||
throw new CollaborationException("Already connected");
|
||||
} else {
|
||||
instance = new CollaborationConnection(account, password,
|
||||
initialPresence);
|
||||
return getConnection();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,8 +37,8 @@ import org.eclipse.swt.widgets.MessageBox;
|
|||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
|
||||
import com.raytheon.uf.viz.collaboration.comm.provider.session.CollaborationConnection;
|
||||
import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId;
|
||||
import com.raytheon.uf.viz.collaboration.ui.data.CollaborationDataManager;
|
||||
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
||||
|
||||
/**
|
||||
|
@ -71,9 +71,7 @@ public class ChangePasswordDialog extends CaveSWTDialog {
|
|||
}
|
||||
|
||||
private Control createDialogArea(Composite parent) {
|
||||
CollaborationDataManager manager = CollaborationDataManager
|
||||
.getInstance();
|
||||
UserId user = manager.getCollaborationConnection(true).getUser();
|
||||
UserId user = CollaborationConnection.getConnection().getUser();
|
||||
Composite body = new Composite(parent, SWT.NONE);
|
||||
body.setLayout(new GridLayout(2, false));
|
||||
// body.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL
|
||||
|
|
|
@ -52,7 +52,6 @@ public class CollaborationGroupAction extends AbstractHandler {
|
|||
|
||||
@Override
|
||||
public Object execute(ExecutionEvent event) throws ExecutionException {
|
||||
// this opens the product browser view
|
||||
try {
|
||||
PlatformUI.getWorkbench().getActiveWorkbenchWindow()
|
||||
.getActivePage().showView(CollaborationGroupView.ID);
|
||||
|
|
|
@ -73,6 +73,7 @@ import org.eclipse.swt.widgets.Event;
|
|||
import org.eclipse.swt.widgets.Listener;
|
||||
import org.eclipse.swt.widgets.Menu;
|
||||
import org.eclipse.swt.widgets.MessageBox;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
import org.eclipse.swt.widgets.TreeColumn;
|
||||
import org.eclipse.swt.widgets.TreeItem;
|
||||
|
@ -111,6 +112,7 @@ import com.raytheon.uf.viz.collaboration.ui.data.SessionContainer;
|
|||
import com.raytheon.uf.viz.collaboration.ui.data.SessionGroupContainer;
|
||||
import com.raytheon.uf.viz.collaboration.ui.data.SharedDisplaySessionMgr;
|
||||
import com.raytheon.uf.viz.collaboration.ui.login.ChangeStatusDialog;
|
||||
import com.raytheon.uf.viz.collaboration.ui.login.LoginDialog;
|
||||
import com.raytheon.uf.viz.collaboration.ui.prefs.CollabPrefConstants;
|
||||
import com.raytheon.uf.viz.collaboration.ui.session.AbstractSessionView;
|
||||
import com.raytheon.uf.viz.collaboration.ui.session.CollaborationSessionView;
|
||||
|
@ -213,10 +215,27 @@ public class CollaborationGroupView extends CaveFloatingView implements
|
|||
|
||||
// add some actions to the menubar
|
||||
createMenubar();
|
||||
CollaborationConnection connection = CollaborationDataManager
|
||||
.getInstance().getCollaborationConnection(true);
|
||||
CollaborationConnection connection = CollaborationConnection
|
||||
.getConnection();
|
||||
if (connection == null) {
|
||||
return;
|
||||
VizApp.runSync(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Shell shell = Display.getDefault().getActiveShell();
|
||||
if (shell == null) {
|
||||
return;
|
||||
}
|
||||
LoginDialog dlg = new LoginDialog(shell);
|
||||
dlg.open();
|
||||
dlg.close();
|
||||
}
|
||||
});
|
||||
connection = CollaborationConnection.getConnection();
|
||||
if (connection == null) {
|
||||
// user cancelled login
|
||||
return;
|
||||
}
|
||||
}
|
||||
// add a part listener so that we can check when things about the view
|
||||
// change
|
||||
|
@ -226,9 +245,6 @@ public class CollaborationGroupView extends CaveFloatingView implements
|
|||
createUsersTree(parent);
|
||||
addDoubleClickListeners();
|
||||
createContextMenu();
|
||||
if (CollaborationDataManager.getInstance().isConnected() == false) {
|
||||
usersTreeViewer.getTree().setEnabled(false);
|
||||
}
|
||||
|
||||
if (connection != null) {
|
||||
connection.registerEventHandler(this);
|
||||
|
@ -260,8 +276,8 @@ public class CollaborationGroupView extends CaveFloatingView implements
|
|||
@Override
|
||||
public void dispose() {
|
||||
super.dispose();
|
||||
CollaborationConnection connection = CollaborationDataManager
|
||||
.getInstance().getCollaborationConnection(false);
|
||||
CollaborationConnection connection = CollaborationConnection
|
||||
.getConnection();
|
||||
if (connection != null) {
|
||||
connection.unRegisterEventHandler(this);
|
||||
}
|
||||
|
@ -330,9 +346,7 @@ public class CollaborationGroupView extends CaveFloatingView implements
|
|||
|
||||
@Override
|
||||
public void runWithEvent(Event event) {
|
||||
CollaborationConnection conn = CollaborationDataManager
|
||||
.getInstance().getCollaborationConnection(true);
|
||||
UserId user = conn.getUser();
|
||||
UserId user = CollaborationConnection.getConnection().getUser();
|
||||
String logDir = SessionMsgArchive.getLogFilePath(
|
||||
user.getHost(), user.getName(), getSessionName());
|
||||
|
||||
|
@ -433,9 +447,8 @@ public class CollaborationGroupView extends CaveFloatingView implements
|
|||
if (node instanceof IRosterEntry) {
|
||||
IRosterEntry user = (IRosterEntry) node;
|
||||
if (user.getPresence().getType() == Type.AVAILABLE) {
|
||||
UserId loginUserId = CollaborationDataManager
|
||||
.getInstance().getCollaborationConnection(true)
|
||||
.getUser();
|
||||
UserId loginUserId = CollaborationConnection
|
||||
.getConnection().getUser();
|
||||
if (!loginUserId.equals(user)) {
|
||||
createP2PChat(IDConverter.convertFrom(user
|
||||
.getUser()));
|
||||
|
@ -529,7 +542,9 @@ public class CollaborationGroupView extends CaveFloatingView implements
|
|||
|
||||
collapseAllAction = new Action("Collapse All") {
|
||||
public void run() {
|
||||
usersTreeViewer.collapseAll();
|
||||
if (usersTreeViewer != null) {
|
||||
usersTreeViewer.collapseAll();
|
||||
}
|
||||
}
|
||||
};
|
||||
collapseAllAction.setImageDescriptor(IconUtil.getImageDescriptor(
|
||||
|
@ -643,7 +658,7 @@ public class CollaborationGroupView extends CaveFloatingView implements
|
|||
// mgr.add(pgenAction);
|
||||
mgr.add(new Separator());
|
||||
|
||||
if (CollaborationDataManager.getInstance().isConnected()) {
|
||||
if (CollaborationConnection.getConnection() != null) {
|
||||
mgr.add(logoutAction);
|
||||
} else {
|
||||
mgr.add(logonAction);
|
||||
|
@ -671,11 +686,11 @@ public class CollaborationGroupView extends CaveFloatingView implements
|
|||
protected void populateTree() {
|
||||
CollaborationDataManager manager = CollaborationDataManager
|
||||
.getInstance();
|
||||
CollaborationConnection sessionManager = manager
|
||||
.getCollaborationConnection(true);
|
||||
CollaborationConnection connection = CollaborationConnection
|
||||
.getConnection();
|
||||
topLevel.clear();
|
||||
// set all the menu actions to false to start with
|
||||
if (sessionManager == null) {
|
||||
if (connection == null) {
|
||||
usersTreeViewer.getTree().setEnabled(false);
|
||||
addGroupAction.setEnabled(false);
|
||||
addUserAction.setEnabled(false);
|
||||
|
@ -699,7 +714,7 @@ public class CollaborationGroupView extends CaveFloatingView implements
|
|||
// make the first thing to show up in the list, which happens to be the
|
||||
// user's name and gives the user options to modify status and other
|
||||
// things
|
||||
UserId user = manager.getCollaborationConnection(true).getUser();
|
||||
UserId user = connection.getUser();
|
||||
topLevel.addObject(user);
|
||||
|
||||
activeSessionGroup = new SessionGroupContainer();
|
||||
|
@ -893,9 +908,8 @@ public class CollaborationGroupView extends CaveFloatingView implements
|
|||
.getItem().getText());
|
||||
}
|
||||
CollaborationUtils.addAlias();
|
||||
CollaborationDataManager.getInstance()
|
||||
.getCollaborationConnection(true)
|
||||
.getEventPublisher().post(entry.getUser());
|
||||
CollaborationConnection.getConnection().getEventPublisher()
|
||||
.post(entry.getUser());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -941,9 +955,8 @@ public class CollaborationGroupView extends CaveFloatingView implements
|
|||
treeEditor.getItem().getText());
|
||||
}
|
||||
CollaborationUtils.addAlias();
|
||||
CollaborationDataManager.getInstance()
|
||||
.getCollaborationConnection(true)
|
||||
.getEventPublisher().post(entry.getUser());
|
||||
CollaborationConnection.getConnection().getEventPublisher()
|
||||
.post(entry.getUser());
|
||||
break;
|
||||
case SWT.Verify:
|
||||
String newText = modText.getText();
|
||||
|
@ -991,10 +1004,9 @@ public class CollaborationGroupView extends CaveFloatingView implements
|
|||
Object result = dialog.getReturnValue();
|
||||
if (result != null) {
|
||||
char[] password = result.toString().toCharArray();
|
||||
CollaborationConnection sessionManager = CollaborationDataManager
|
||||
.getInstance().getCollaborationConnection(true);
|
||||
try {
|
||||
sessionManager.getAccountManager().changePassword(password);
|
||||
CollaborationConnection.getConnection().getAccountManager()
|
||||
.changePassword(password);
|
||||
} catch (CollaborationException e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Unable to change password", e);
|
||||
|
@ -1023,10 +1035,8 @@ public class CollaborationGroupView extends CaveFloatingView implements
|
|||
}
|
||||
|
||||
private void createSession() {
|
||||
CollaborationDataManager manager = CollaborationDataManager
|
||||
.getInstance();
|
||||
CollaborationConnection sessionManager = manager
|
||||
.getCollaborationConnection(true);
|
||||
CollaborationConnection sessionManager = CollaborationConnection
|
||||
.getConnection();
|
||||
if (sessionManager == null) {
|
||||
System.err.println("Unable to get session manager");
|
||||
return;
|
||||
|
@ -1251,7 +1261,10 @@ public class CollaborationGroupView extends CaveFloatingView implements
|
|||
statusHandler.handle(Priority.WARN,
|
||||
"Unable to save preferences", e);
|
||||
}
|
||||
CollaborationDataManager.getInstance().closeManager();
|
||||
CollaborationConnection connection = CollaborationConnection
|
||||
.getConnection();
|
||||
ConnectionSubscriber.unsubscribe(connection);
|
||||
connection.closeManager();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1328,9 +1341,9 @@ public class CollaborationGroupView extends CaveFloatingView implements
|
|||
+ id.getHost() + " " + rosterEntry.getPresence().getMode()
|
||||
+ "/" + rosterEntry.getPresence().getType());
|
||||
|
||||
((RosterEntry) CollaborationDataManager.getInstance()
|
||||
.getCollaborationConnection(true).getContactsManager()
|
||||
.getUsersMap().get(id)).setPresence(rosterEntry.getPresence());
|
||||
((RosterEntry) CollaborationConnection.getConnection()
|
||||
.getContactsManager().getUsersMap().get(id))
|
||||
.setPresence(rosterEntry.getPresence());
|
||||
VizApp.runAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
@ -1357,8 +1370,8 @@ public class CollaborationGroupView extends CaveFloatingView implements
|
|||
@Subscribe
|
||||
public void handleRosterChangeEvent(IRosterChangeEvent rosterChangeEvent) {
|
||||
final IRosterItem rosterItem = rosterChangeEvent.getItem();
|
||||
CollaborationConnection connection = CollaborationDataManager
|
||||
.getInstance().getCollaborationConnection(true);
|
||||
CollaborationConnection connection = CollaborationConnection
|
||||
.getConnection();
|
||||
switch (rosterChangeEvent.getType()) {
|
||||
case MODIFY:
|
||||
case ADD:
|
||||
|
@ -1452,8 +1465,7 @@ public class CollaborationGroupView extends CaveFloatingView implements
|
|||
* on whether or not the user is connected to the xmpp server.
|
||||
*/
|
||||
private void disableOrEnableSessionAction() {
|
||||
final boolean isSessionEnabled = CollaborationDataManager.getInstance()
|
||||
.isConnected();
|
||||
boolean isSessionEnabled = (CollaborationConnection.getConnection() != null);
|
||||
createSessionAction.setEnabled(isSessionEnabled);
|
||||
}
|
||||
|
||||
|
|
|
@ -53,12 +53,12 @@ import com.raytheon.uf.common.localization.exception.LocalizationOpFailedExcepti
|
|||
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.provider.session.CollaborationConnection;
|
||||
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.comm.provider.user.UserIdWrapper;
|
||||
import com.raytheon.uf.viz.collaboration.ui.data.AlertWord;
|
||||
import com.raytheon.uf.viz.collaboration.ui.data.AlertWordWrapper;
|
||||
import com.raytheon.uf.viz.collaboration.ui.data.CollaborationDataManager;
|
||||
import com.raytheon.uf.viz.core.icon.IconUtil;
|
||||
|
||||
/**
|
||||
|
@ -101,9 +101,8 @@ public class CollaborationUtils {
|
|||
|
||||
public static Collection<Object> readAliases() {
|
||||
UserId[] ids = getIds();
|
||||
Roster roster = (Roster) CollaborationDataManager.getInstance()
|
||||
.getCollaborationConnection(true).getRosterManager()
|
||||
.getRoster();
|
||||
Roster roster = (Roster) CollaborationConnection.getConnection()
|
||||
.getRosterManager().getRoster();
|
||||
Collection<?> rosterObjects = new ArrayList<Object>();
|
||||
rosterObjects.addAll(roster.getItems());
|
||||
for (Object ob : rosterObjects) {
|
||||
|
@ -172,9 +171,8 @@ public class CollaborationUtils {
|
|||
LocalizationFile file = pm.getLocalizationFile(context,
|
||||
"collaboration" + File.separator
|
||||
+ "collaborationAliases.xml");
|
||||
IRoster roster = CollaborationDataManager.getInstance()
|
||||
.getCollaborationConnection(true).getRosterManager()
|
||||
.getRoster();
|
||||
IRoster roster = CollaborationConnection.getConnection()
|
||||
.getRosterManager().getRoster();
|
||||
Set<IUser> ids = new HashSet<IUser>();
|
||||
|
||||
// get the entries that are alone
|
||||
|
|
|
@ -0,0 +1,297 @@
|
|||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* This software product contains export-restricted data whose
|
||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
* to non-U.S. persons whether in the United States or abroad requires
|
||||
* an export license or other authorization.
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address: 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.uf.viz.collaboration.ui;
|
||||
|
||||
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.IViewReference;
|
||||
import org.eclipse.ui.IWorkbench;
|
||||
import org.eclipse.ui.IWorkbenchListener;
|
||||
import org.eclipse.ui.IWorkbenchPage;
|
||||
import org.eclipse.ui.IWorkbenchPart;
|
||||
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;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.CollaborationException;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.ISession;
|
||||
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.IHttpdCollaborationConfigurationEvent;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.event.ITextMessageEvent;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.event.IVenueInvitationEvent;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.invite.SharedDisplayVenueInvite;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.user.SharedDisplayRole;
|
||||
import com.raytheon.uf.viz.collaboration.comm.provider.TextMessage;
|
||||
import com.raytheon.uf.viz.collaboration.comm.provider.session.CollaborationConnection;
|
||||
import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId;
|
||||
import com.raytheon.uf.viz.collaboration.ui.data.CollaborationDataManager;
|
||||
import com.raytheon.uf.viz.collaboration.ui.data.SharedDisplaySessionMgr;
|
||||
import com.raytheon.uf.viz.collaboration.ui.prefs.CollabPrefConstants;
|
||||
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.core.VizApp;
|
||||
|
||||
/**
|
||||
* TODO Add Description
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jun 8, 2012 njensen Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author njensen
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class ConnectionSubscriber {
|
||||
|
||||
private static final transient IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(ConnectionSubscriber.class);
|
||||
|
||||
private static ConnectionSubscriber instance;
|
||||
|
||||
private IWorkbenchListener wbListener;
|
||||
|
||||
private ConnectionSubscriber() {
|
||||
|
||||
}
|
||||
|
||||
public static void subscribe(CollaborationConnection connection) {
|
||||
if (instance == null) {
|
||||
instance = new ConnectionSubscriber();
|
||||
instance.setup(connection);
|
||||
}
|
||||
}
|
||||
|
||||
public static void unsubscribe(CollaborationConnection connection) {
|
||||
if (instance != null) {
|
||||
instance.dispose(connection);
|
||||
}
|
||||
|
||||
instance = null;
|
||||
}
|
||||
|
||||
private void setup(final CollaborationConnection connection) {
|
||||
if (connection != null) {
|
||||
// Register handlers and events for the new sessionManager.
|
||||
connection.registerEventHandler(this);
|
||||
try {
|
||||
ISession p2pSession = connection.getPeerToPeerSession();
|
||||
p2pSession.registerEventHandler(this);
|
||||
} catch (CollaborationException e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Error registering peer to peer handler", e);
|
||||
}
|
||||
// TODO the wblistener should perhaps be elsewhere
|
||||
wbListener = new IWorkbenchListener() {
|
||||
|
||||
@Override
|
||||
public boolean preShutdown(IWorkbench workbench, boolean forced) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postShutdown(IWorkbench workbench) {
|
||||
dispose(connection);
|
||||
if (connection != null) {
|
||||
connection.closeManager();
|
||||
}
|
||||
}
|
||||
};
|
||||
PlatformUI.getWorkbench().addWorkbenchListener(wbListener);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void dispose(CollaborationConnection connection) {
|
||||
if (connection != null) {
|
||||
try {
|
||||
ISession p2pSession = connection.getPeerToPeerSession();
|
||||
p2pSession.unRegisterEventHandler(this);
|
||||
} catch (CollaborationException e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Error unregistering peer to peer handler", e);
|
||||
}
|
||||
connection.unRegisterEventHandler(this);
|
||||
}
|
||||
PlatformUI.getWorkbench().removeWorkbenchListener(wbListener);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void handleInvitationEvent(IVenueInvitationEvent event) {
|
||||
final IVenueInvitationEvent invitation = event;
|
||||
VizApp.runSync(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
IQualifiedID inviter = invitation.getInviter();
|
||||
IQualifiedID room = invitation.getRoomId();
|
||||
Shell shell = new Shell(Display.getCurrent());
|
||||
MessageBox box = new MessageBox(shell, SWT.ICON_QUESTION
|
||||
| SWT.OK | SWT.CANCEL);
|
||||
box.setText("Invitation");
|
||||
StringBuilder sb = new StringBuilder();
|
||||
boolean sharedDisplay = invitation.getInvite() instanceof SharedDisplayVenueInvite;
|
||||
sb.append("You are invited to a ");
|
||||
if (sharedDisplay) {
|
||||
sb.append("collaboration session.\n");
|
||||
} else {
|
||||
sb.append("chat room.\n");
|
||||
}
|
||||
sb.append("Inviter: ").append(inviter.getName()).append("\n");
|
||||
sb.append("Room: ").append(room.getName()).append("\n");
|
||||
sb.append("Subject: ").append(invitation.getSubject());
|
||||
if (invitation.getInvite() != null
|
||||
&& invitation.getInvite().getMessage() != null) {
|
||||
sb.append("\n").append("Message: ")
|
||||
.append(invitation.getInvite().getMessage());
|
||||
}
|
||||
box.setMessage(sb.toString());
|
||||
if (SWT.OK != box.open()) {
|
||||
return;
|
||||
}
|
||||
|
||||
CollaborationConnection connection = CollaborationConnection
|
||||
.getConnection();
|
||||
try {
|
||||
IVenueSession session = connection
|
||||
.joinCollaborationVenue(invitation);
|
||||
String sessionId = session.getSessionId();
|
||||
CollaborationDataManager.getInstance().addSession(
|
||||
sessionId, session);
|
||||
if (sharedDisplay) {
|
||||
ISharedDisplaySession displaySession = (ISharedDisplaySession) session;
|
||||
SessionColorManager man = new SessionColorManager();
|
||||
man.setColors(((SharedDisplayVenueInvite) invitation
|
||||
.getInvite()).getRGBColors());
|
||||
SharedDisplaySessionMgr.joinSession(displaySession,
|
||||
SharedDisplayRole.PARTICIPANT, man);
|
||||
|
||||
PlatformUI
|
||||
.getWorkbench()
|
||||
.getActiveWorkbenchWindow()
|
||||
.getActivePage()
|
||||
.showView(CollaborationSessionView.ID,
|
||||
sessionId, IWorkbenchPage.VIEW_ACTIVATE);
|
||||
} else {
|
||||
PlatformUI
|
||||
.getWorkbench()
|
||||
.getActiveWorkbenchWindow()
|
||||
.getActivePage()
|
||||
.showView(SessionView.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);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* This takes a peer to peer message and displays it in the proper view.
|
||||
*
|
||||
* @param messageEvent
|
||||
*/
|
||||
@Subscribe
|
||||
public void peer2peerMessage(ITextMessageEvent messageEvent) {
|
||||
final TextMessage message = messageEvent.getMessage();
|
||||
VizApp.runAsync(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
IQualifiedID peer = message.getFrom();
|
||||
for (IViewReference ref : PlatformUI.getWorkbench()
|
||||
.getActiveWorkbenchWindow().getActivePage()
|
||||
.getViewReferences()) {
|
||||
IWorkbenchPart part = ref.getPart(false);
|
||||
if (part != null && part instanceof PeerToPeerView) {
|
||||
PeerToPeerView p2pView = (PeerToPeerView) part;
|
||||
if (p2pView.getPeer().equals(peer)) {
|
||||
p2pView.appendMessage(message);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
try {
|
||||
// use the aliased name if there is one
|
||||
String sId = peer.getName();
|
||||
for (UserId id : CollaborationUtils.getIds()) {
|
||||
if (id.equals(peer)) {
|
||||
sId = id.getAlias();
|
||||
}
|
||||
}
|
||||
PeerToPeerView p2pView = (PeerToPeerView) PlatformUI
|
||||
.getWorkbench()
|
||||
.getActiveWorkbenchWindow()
|
||||
.getActivePage()
|
||||
.showView(PeerToPeerView.ID, sId,
|
||||
IWorkbenchPage.VIEW_ACTIVATE);
|
||||
p2pView.setPeer(peer);
|
||||
p2pView.appendMessage(message);
|
||||
} catch (PartInitException e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Error opening peer to peer view", e);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void handleHttpdConfigurationEvent(
|
||||
IHttpdCollaborationConfigurationEvent configurationEvent) {
|
||||
|
||||
// Add the httpd collaboration url to the CAVE configuration.
|
||||
Activator
|
||||
.getDefault()
|
||||
.getPreferenceStore()
|
||||
.setValue(
|
||||
CollabPrefConstants.HttpCollaborationConfiguration.P_HTTP_SESSION_URL,
|
||||
configurationEvent.getHttpdCollaborationURL());
|
||||
Activator
|
||||
.getDefault()
|
||||
.getPreferenceStore()
|
||||
.setValue(
|
||||
CollabPrefConstants.HttpCollaborationConfiguration.P_SESSION_CONFIGURED,
|
||||
true);
|
||||
}
|
||||
|
||||
}
|
|
@ -45,6 +45,7 @@ import org.eclipse.swt.widgets.Text;
|
|||
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.CollaborationException;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.info.IVenueInfo;
|
||||
import com.raytheon.uf.viz.collaboration.comm.provider.session.CollaborationConnection;
|
||||
import com.raytheon.uf.viz.collaboration.ui.data.CollaborationDataManager;
|
||||
import com.raytheon.uf.viz.collaboration.ui.prefs.CollabPrefConstants;
|
||||
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
||||
|
@ -244,7 +245,7 @@ public class CreateSessionDialog extends CaveSWTDialog {
|
|||
Text focusField = null;
|
||||
List<String> errorMessages = new ArrayList<String>();
|
||||
String subject = subjectTF.getText().trim();
|
||||
String err = validateVenuName();
|
||||
String err = validateVenueName();
|
||||
String name = nameTF.getText();
|
||||
if (err != null) {
|
||||
focusField = nameTF;
|
||||
|
@ -315,7 +316,7 @@ public class CreateSessionDialog extends CaveSWTDialog {
|
|||
return button;
|
||||
}
|
||||
|
||||
private String validateVenuName() {
|
||||
private String validateVenueName() {
|
||||
String name = nameTF.getText().trim();
|
||||
nameTF.setText(name);
|
||||
String err = null;
|
||||
|
@ -325,9 +326,8 @@ public class CreateSessionDialog extends CaveSWTDialog {
|
|||
// TODO Above else make it a test for invalid characters.
|
||||
err = "Name contains invalid characters.";
|
||||
} else {
|
||||
Collection<IVenueInfo> info = CollaborationDataManager
|
||||
.getInstance().getCollaborationConnection(true)
|
||||
.getVenueInfo();
|
||||
Collection<IVenueInfo> info = CollaborationConnection
|
||||
.getConnection().getVenueInfo();
|
||||
for (IVenueInfo i : info) {
|
||||
if (name.equals(i.getVenueName())) {
|
||||
err = "Session already exists. Pick a different name.";
|
||||
|
|
|
@ -25,6 +25,7 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.ecf.presence.IPresence;
|
||||
import org.eclipse.ecf.presence.IPresence.Type;
|
||||
import org.eclipse.ecf.presence.roster.IRosterEntry;
|
||||
import org.eclipse.ecf.presence.roster.IRosterGroup;
|
||||
|
@ -38,9 +39,9 @@ import org.eclipse.swt.widgets.Display;
|
|||
|
||||
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.provider.session.CollaborationConnection;
|
||||
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.ui.data.CollaborationDataManager;
|
||||
import com.raytheon.uf.viz.collaboration.ui.data.SessionGroupContainer;
|
||||
|
||||
/**
|
||||
|
@ -78,11 +79,13 @@ public class UsersTreeLabelProvider extends ColumnLabelProvider {
|
|||
}
|
||||
String key = "";
|
||||
if (element instanceof UserId) {
|
||||
String mode = CollaborationDataManager.getInstance()
|
||||
.getCollaborationConnection(true).getPresence().getMode()
|
||||
.toString();
|
||||
mode = mode.replaceAll("\\s+", "_");
|
||||
key = mode;
|
||||
IPresence presence = CollaborationConnection.getConnection()
|
||||
.getPresence();
|
||||
if (presence != null) {
|
||||
String mode = presence.getMode().toString();
|
||||
mode = mode.replaceAll("\\s+", "_");
|
||||
key = mode;
|
||||
}
|
||||
} else if (element instanceof IRosterEntry) {
|
||||
IRosterEntry entry = (IRosterEntry) element;
|
||||
if (entry.getPresence() != null
|
||||
|
|
|
@ -29,44 +29,18 @@ import org.eclipse.ecf.presence.IPresence.Type;
|
|||
import org.eclipse.ecf.presence.Presence;
|
||||
import org.eclipse.ecf.presence.roster.IRosterManager;
|
||||
import org.eclipse.ecf.presence.roster.RosterEntry;
|
||||
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.IViewReference;
|
||||
import org.eclipse.ui.IWorkbench;
|
||||
import org.eclipse.ui.IWorkbenchListener;
|
||||
import org.eclipse.ui.IWorkbenchPage;
|
||||
import org.eclipse.ui.IWorkbenchPart;
|
||||
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;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.CollaborationException;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.ISession;
|
||||
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.IHttpdCollaborationConfigurationEvent;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.event.ITextMessageEvent;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.event.IVenueInvitationEvent;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.invite.SharedDisplayVenueInvite;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.user.SharedDisplayRole;
|
||||
import com.raytheon.uf.viz.collaboration.comm.provider.TextMessage;
|
||||
import com.raytheon.uf.viz.collaboration.comm.provider.session.CollaborationConnection;
|
||||
import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId;
|
||||
import com.raytheon.uf.viz.collaboration.ui.Activator;
|
||||
import com.raytheon.uf.viz.collaboration.ui.CollaborationUtils;
|
||||
import com.raytheon.uf.viz.collaboration.ui.SessionColorManager;
|
||||
import com.raytheon.uf.viz.collaboration.ui.login.LoginDialog;
|
||||
import com.raytheon.uf.viz.collaboration.ui.prefs.CollabPrefConstants;
|
||||
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.core.VizApp;
|
||||
|
||||
/**
|
||||
* A single class that contains all data information.
|
||||
|
@ -122,91 +96,6 @@ public class CollaborationDataManager {
|
|||
sessionsMap = new HashMap<String, IVenueSession>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the session sessionManager and if needed the user/password.
|
||||
*
|
||||
* @return sessionManager or null if unable to get connection.
|
||||
*/
|
||||
synchronized public CollaborationConnection getCollaborationConnection(
|
||||
boolean needsLogin) {
|
||||
// Get user's server account information and make connection.
|
||||
if (isConnected() == false && needsLogin) {
|
||||
VizApp.runSync(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
shell = Display.getDefault().getActiveShell();
|
||||
if (shell == null) {
|
||||
return;
|
||||
}
|
||||
LoginDialog dlg = new LoginDialog(shell);
|
||||
CollaborationConnection newConn = null;
|
||||
newConn = (CollaborationConnection) dlg.open();
|
||||
dlg.close();
|
||||
if (newConn != null) {
|
||||
connection = newConn;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (isConnected()) {
|
||||
// Register handlers and events for the new sessionManager.
|
||||
connection.registerEventHandler(this);
|
||||
try {
|
||||
ISession p2pSession = connection.getPeerToPeerSession();
|
||||
p2pSession.registerEventHandler(this);
|
||||
} catch (CollaborationException e) {
|
||||
// TODO Auto-generated catch block. Please revise as
|
||||
// appropriate.
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
e.getLocalizedMessage(), e);
|
||||
}
|
||||
wbListener = new IWorkbenchListener() {
|
||||
|
||||
@Override
|
||||
public boolean preShutdown(IWorkbench workbench,
|
||||
boolean forced) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postShutdown(IWorkbench workbench) {
|
||||
if (connection != null) {
|
||||
try {
|
||||
ISession p2pSession = connection
|
||||
.getPeerToPeerSession();
|
||||
p2pSession.unRegisterEventHandler(this);
|
||||
} catch (CollaborationException e) {
|
||||
// TODO Auto-generated catch block. Please
|
||||
// revise as appropriate.
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
e.getLocalizedMessage(), e);
|
||||
}
|
||||
connection.unRegisterEventHandler(this);
|
||||
connection.closeManager();
|
||||
connection = null;
|
||||
}
|
||||
}
|
||||
};
|
||||
PlatformUI.getWorkbench().addWorkbenchListener(wbListener);
|
||||
}
|
||||
}
|
||||
|
||||
return connection;
|
||||
}
|
||||
|
||||
synchronized public void closeManager() {
|
||||
if (connection != null) {
|
||||
// The close unRegisters the event handler
|
||||
connection.closeManager();
|
||||
connection = null;
|
||||
}
|
||||
if (wbListener != null) {
|
||||
PlatformUI.getWorkbench().removeWorkbenchListener(wbListener);
|
||||
wbListener = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Venue session associated with the key or any session when key is
|
||||
* null.
|
||||
|
@ -259,11 +148,12 @@ public class CollaborationDataManager {
|
|||
*/
|
||||
public String createCollaborationSession(String venue, String subject)
|
||||
throws CollaborationException {
|
||||
CollaborationConnection sessionManager = getCollaborationConnection(true);
|
||||
CollaborationConnection connection = CollaborationConnection
|
||||
.getConnection();
|
||||
IVenueSession session = null;
|
||||
String sessionId = null;
|
||||
// try {
|
||||
session = sessionManager.createCollaborationVenue(venue, subject);
|
||||
session = connection.createCollaborationVenue(venue, subject);
|
||||
// sessionId = venueIdToSessionId(session.getVenue().getInfo()
|
||||
// .getVenueID());
|
||||
sessionId = session.getSessionId();
|
||||
|
@ -273,7 +163,6 @@ public class CollaborationDataManager {
|
|||
sessionsMap.put(sessionId, session);
|
||||
SharedDisplaySessionMgr.joinSession(displaySession,
|
||||
SharedDisplayRole.DATA_PROVIDER, null);
|
||||
|
||||
}
|
||||
|
||||
return sessionId;
|
||||
|
@ -281,10 +170,11 @@ public class CollaborationDataManager {
|
|||
|
||||
public String createTextOnlySession(String venueName, String subject)
|
||||
throws CollaborationException {
|
||||
CollaborationConnection sessionManager = getCollaborationConnection(true);
|
||||
CollaborationConnection connection = CollaborationConnection
|
||||
.getConnection();
|
||||
IVenueSession session = null;
|
||||
String sessionId = null;
|
||||
session = sessionManager.createTextOnlyVenue(venueName, subject);
|
||||
session = connection.createTextOnlyVenue(venueName, subject);
|
||||
if (session.isConnected()) {
|
||||
sessionId = session.getSessionId();
|
||||
sessionsMap.put(sessionId, session);
|
||||
|
@ -296,132 +186,6 @@ public class CollaborationDataManager {
|
|||
return connection != null && connection.isConnected();
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void handleInvitationEvent(IVenueInvitationEvent event) {
|
||||
final IVenueInvitationEvent invitation = event;
|
||||
VizApp.runSync(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
IQualifiedID inviter = invitation.getInviter();
|
||||
IQualifiedID room = invitation.getRoomId();
|
||||
if (shell.isDisposed()) {
|
||||
shell = new Shell(Display.getCurrent());
|
||||
}
|
||||
MessageBox box = new MessageBox(shell, SWT.ICON_QUESTION
|
||||
| SWT.OK | SWT.CANCEL);
|
||||
box.setText("Invitation");
|
||||
StringBuilder sb = new StringBuilder();
|
||||
boolean sharedDisplay = invitation.getInvite() instanceof SharedDisplayVenueInvite;
|
||||
sb.append("You are invited to a ");
|
||||
if (sharedDisplay) {
|
||||
sb.append("collaboration session.\n");
|
||||
} else {
|
||||
sb.append("chat room.\n");
|
||||
}
|
||||
sb.append("Inviter: ").append(inviter.getName()).append("\n");
|
||||
sb.append("Room: ").append(room.getName()).append("\n");
|
||||
sb.append("Subject: ").append(invitation.getSubject());
|
||||
if (invitation.getInvite() != null
|
||||
&& invitation.getInvite().getMessage() != null) {
|
||||
sb.append("\n").append("Message: ")
|
||||
.append(invitation.getInvite().getMessage());
|
||||
}
|
||||
box.setMessage(sb.toString());
|
||||
if (SWT.OK != box.open()) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
IVenueSession session = connection
|
||||
.joinCollaborationVenue(invitation);
|
||||
String sessionId = session.getSessionId();
|
||||
sessionsMap.put(sessionId, session);
|
||||
if (sharedDisplay) {
|
||||
ISharedDisplaySession displaySession = (ISharedDisplaySession) session;
|
||||
SessionColorManager man = new SessionColorManager();
|
||||
man.setColors(((SharedDisplayVenueInvite) invitation
|
||||
.getInvite()).getRGBColors());
|
||||
SharedDisplaySessionMgr.joinSession(displaySession,
|
||||
SharedDisplayRole.PARTICIPANT, man);
|
||||
|
||||
PlatformUI
|
||||
.getWorkbench()
|
||||
.getActiveWorkbenchWindow()
|
||||
.getActivePage()
|
||||
.showView(CollaborationSessionView.ID,
|
||||
sessionId, IWorkbenchPage.VIEW_ACTIVATE);
|
||||
} else {
|
||||
PlatformUI
|
||||
.getWorkbench()
|
||||
.getActiveWorkbenchWindow()
|
||||
.getActivePage()
|
||||
.showView(SessionView.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);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* This takes a peer to peer message and displays it in the proper view.
|
||||
*
|
||||
* @param messageEvent
|
||||
*/
|
||||
@Subscribe
|
||||
public void peer2peerMessage(ITextMessageEvent messageEvent) {
|
||||
final TextMessage message = messageEvent.getMessage();
|
||||
VizApp.runAsync(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
IQualifiedID peer = message.getFrom();
|
||||
for (IViewReference ref : PlatformUI.getWorkbench()
|
||||
.getActiveWorkbenchWindow().getActivePage()
|
||||
.getViewReferences()) {
|
||||
IWorkbenchPart part = ref.getPart(false);
|
||||
if (part != null && part instanceof PeerToPeerView) {
|
||||
PeerToPeerView p2pView = (PeerToPeerView) part;
|
||||
if (p2pView.getPeer().equals(peer)) {
|
||||
p2pView.appendMessage(message);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
try {
|
||||
// use the aliased name if there is one
|
||||
String sId = peer.getName();
|
||||
for (UserId id : CollaborationUtils.getIds()) {
|
||||
if (id.equals(peer)) {
|
||||
sId = id.getAlias();
|
||||
}
|
||||
}
|
||||
PeerToPeerView p2pView = (PeerToPeerView) PlatformUI
|
||||
.getWorkbench()
|
||||
.getActiveWorkbenchWindow()
|
||||
.getActivePage()
|
||||
.showView(PeerToPeerView.ID, sId,
|
||||
IWorkbenchPage.VIEW_ACTIVATE);
|
||||
p2pView.setPeer(peer);
|
||||
p2pView.appendMessage(message);
|
||||
} catch (PartInitException e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Error opening peer to peer view", e);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void fireModifiedPresence(Mode mode, String msg) {
|
||||
IRosterManager manager = connection.getRosterManager();
|
||||
IPresence presence = new Presence(Type.AVAILABLE, msg, mode);
|
||||
|
@ -441,23 +205,10 @@ public class CollaborationDataManager {
|
|||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void handleHttpdConfigurationEvent(
|
||||
IHttpdCollaborationConfigurationEvent configurationEvent) {
|
||||
|
||||
// Add the httpd collaboration url to the CAVE configuration.
|
||||
Activator
|
||||
.getDefault()
|
||||
.getPreferenceStore()
|
||||
.setValue(
|
||||
CollabPrefConstants.HttpCollaborationConfiguration.P_HTTP_SESSION_URL,
|
||||
configurationEvent.getHttpdCollaborationURL());
|
||||
Activator
|
||||
.getDefault()
|
||||
.getPreferenceStore()
|
||||
.setValue(
|
||||
CollabPrefConstants.HttpCollaborationConfiguration.P_SESSION_CONFIGURED,
|
||||
true);
|
||||
|
||||
// TODO remove as this is temporary to fix a problem and get in a good state
|
||||
public void addSession(String sessionId, IVenueSession session) {
|
||||
sessionsMap.put(sessionId, session);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ public class SharedDisplaySessionMgr {
|
|||
return sharedDisplaySessionMap.keySet();
|
||||
}
|
||||
|
||||
protected static void joinSession(ISharedDisplaySession session,
|
||||
public static void joinSession(ISharedDisplaySession session,
|
||||
SharedDisplayRole initialRole, SessionColorManager colors) {
|
||||
SessionContainer container = new SessionContainer();
|
||||
container.setSessionId(session.getSessionId());
|
||||
|
|
|
@ -54,6 +54,7 @@ import com.raytheon.uf.viz.collaboration.comm.provider.session.CollaborationConn
|
|||
import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId;
|
||||
import com.raytheon.uf.viz.collaboration.ui.Activator;
|
||||
import com.raytheon.uf.viz.collaboration.ui.CollaborationUtils;
|
||||
import com.raytheon.uf.viz.collaboration.ui.ConnectionSubscriber;
|
||||
import com.raytheon.uf.viz.collaboration.ui.prefs.CollabPrefConstants;
|
||||
import com.raytheon.uf.viz.core.VizApp;
|
||||
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
||||
|
@ -97,8 +98,6 @@ public class LoginDialog extends CaveSWTDialog {
|
|||
|
||||
private Control[] withServerList;
|
||||
|
||||
private CollaborationConnection sessionManager;
|
||||
|
||||
private IPersistentPreferenceStore prefStore;
|
||||
|
||||
public LoginDialog(Shell parentShell) {
|
||||
|
@ -364,10 +363,12 @@ public class LoginDialog extends CaveSWTDialog {
|
|||
protected org.eclipse.core.runtime.IStatus run(
|
||||
org.eclipse.core.runtime.IProgressMonitor monitor) {
|
||||
try {
|
||||
sessionManager = new CollaborationConnection(
|
||||
new UserId(usr, srvr), passwd,
|
||||
pres);
|
||||
setReturnValue(sessionManager);
|
||||
CollaborationConnection connection = CollaborationConnection
|
||||
.connect(new UserId(usr, srvr),
|
||||
passwd, pres);
|
||||
setReturnValue(connection);
|
||||
ConnectionSubscriber
|
||||
.subscribe(connection);
|
||||
VizApp.runAsync(new Runnable() {
|
||||
public void run() {
|
||||
close();
|
||||
|
@ -404,9 +405,6 @@ public class LoginDialog extends CaveSWTDialog {
|
|||
}
|
||||
errorMessages.add("Inavlid username or password.");
|
||||
passwordTF.setText("");
|
||||
if (sessionManager != null) {
|
||||
sessionManager.closeManager();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (focusField != null) {
|
||||
|
@ -437,10 +435,4 @@ public class LoginDialog extends CaveSWTDialog {
|
|||
return button;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the sessionManager
|
||||
*/
|
||||
public CollaborationConnection getSessionManager() {
|
||||
return sessionManager;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,7 +55,6 @@ import com.raytheon.uf.viz.collaboration.ui.Activator;
|
|||
import com.raytheon.uf.viz.collaboration.ui.CollaborationUtils;
|
||||
import com.raytheon.uf.viz.collaboration.ui.data.AlertWord;
|
||||
import com.raytheon.uf.viz.collaboration.ui.data.AlertWordWrapper;
|
||||
import com.raytheon.uf.viz.collaboration.ui.data.CollaborationDataManager;
|
||||
|
||||
/**
|
||||
* TODO Add Description
|
||||
|
@ -261,8 +260,8 @@ public class CollaborationAlertWordsPreferencePage extends
|
|||
CollaborationUtils.saveAlertWords(words);
|
||||
AlertWordWrapper wrapper = new AlertWordWrapper();
|
||||
wrapper.setAlertWords(words.toArray(new AlertWord[0]));
|
||||
CollaborationConnection connection = CollaborationDataManager
|
||||
.getInstance().getCollaborationConnection(false);
|
||||
CollaborationConnection connection = CollaborationConnection
|
||||
.getConnection();
|
||||
if (connection != null && connection.isConnected()) {
|
||||
// refresh any open chats or sessions
|
||||
connection.getEventPublisher().post(wrapper);
|
||||
|
|
|
@ -61,11 +61,11 @@ 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.IMessage;
|
||||
import com.raytheon.uf.viz.collaboration.comm.provider.session.CollaborationConnection;
|
||||
import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId;
|
||||
import com.raytheon.uf.viz.collaboration.ui.Activator;
|
||||
import com.raytheon.uf.viz.collaboration.ui.CollaborationUtils;
|
||||
import com.raytheon.uf.viz.collaboration.ui.data.AlertWord;
|
||||
import com.raytheon.uf.viz.collaboration.ui.data.CollaborationDataManager;
|
||||
import com.raytheon.uf.viz.core.VizApp;
|
||||
import com.raytheon.uf.viz.core.icon.IconUtil;
|
||||
import com.raytheon.uf.viz.notification.notifier.PopupNotifier;
|
||||
|
@ -284,8 +284,8 @@ public abstract class AbstractSessionView extends CaveFloatingView {
|
|||
cal.setTimeInMillis(timestamp);
|
||||
String time = String.format("%1$tI:%1$tM:%1$tS %1$Tp", cal);
|
||||
|
||||
UserId myUser = CollaborationDataManager.getInstance()
|
||||
.getCollaborationConnection(true).getUser();
|
||||
UserId myUser = CollaborationConnection.getConnection()
|
||||
.getUser();
|
||||
if (!myUser.equals(userId)
|
||||
&& Activator.getDefault().getPreferenceStore()
|
||||
.getBoolean("notifications")) {
|
||||
|
|
|
@ -53,6 +53,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.session.CollaborationConnection;
|
||||
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.ui.Activator;
|
||||
|
@ -386,8 +387,7 @@ public class CollaborationSessionView extends SessionView implements
|
|||
String message = getComposedMessage();
|
||||
if (message.length() > 0) {
|
||||
try {
|
||||
UserId id = CollaborationDataManager.getInstance()
|
||||
.getCollaborationConnection(true).getUser();
|
||||
UserId id = CollaborationConnection.getConnection().getUser();
|
||||
appendMessage(id, System.currentTimeMillis(), message);
|
||||
((IVenueSession) session).sendChatMessage(message);
|
||||
} catch (CollaborationException e) {
|
||||
|
|
|
@ -39,9 +39,9 @@ import com.raytheon.uf.viz.collaboration.comm.identity.CollaborationException;
|
|||
import com.raytheon.uf.viz.collaboration.comm.identity.IPeerToPeer;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.listener.IMessageListener;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID;
|
||||
import com.raytheon.uf.viz.collaboration.comm.provider.session.CollaborationConnection;
|
||||
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.ui.data.CollaborationDataManager;
|
||||
|
||||
/**
|
||||
* TODO Add Description
|
||||
|
@ -84,8 +84,8 @@ public class PeerToPeerView extends AbstractSessionView {
|
|||
userColor = Display.getCurrent().getSystemColor(SWT.COLOR_DARK_BLUE);
|
||||
chatterColor = Display.getCurrent().getSystemColor(SWT.COLOR_RED);
|
||||
black = Display.getCurrent().getSystemColor(SWT.COLOR_BLACK);
|
||||
CollaborationDataManager.getInstance().getCollaborationConnection(true)
|
||||
.getEventPublisher().register(this);
|
||||
CollaborationConnection.getConnection().getEventPublisher()
|
||||
.register(this);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -97,8 +97,10 @@ public class PeerToPeerView extends AbstractSessionView {
|
|||
*/
|
||||
@Override
|
||||
public void dispose() {
|
||||
CollaborationDataManager.getInstance().getCollaborationConnection(true)
|
||||
.getEventPublisher().unregister(this);
|
||||
CollaborationConnection conn = CollaborationConnection.getConnection();
|
||||
if (conn != null) {
|
||||
conn.getEventPublisher().unregister(this);
|
||||
}
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
|
@ -135,18 +137,17 @@ public class PeerToPeerView extends AbstractSessionView {
|
|||
String message = getComposedMessage();
|
||||
if (message.length() > 0) {
|
||||
try {
|
||||
CollaborationDataManager manager = CollaborationDataManager
|
||||
.getInstance();
|
||||
CollaborationConnection connection = CollaborationConnection
|
||||
.getConnection();
|
||||
if (online) {
|
||||
appendMessage(manager.getCollaborationConnection(true)
|
||||
.getUser(), System.currentTimeMillis(), message);
|
||||
IPeerToPeer p2p = (IPeerToPeer) manager
|
||||
.getCollaborationConnection(true)
|
||||
appendMessage(connection.getUser(),
|
||||
System.currentTimeMillis(), message);
|
||||
IPeerToPeer p2p = (IPeerToPeer) connection
|
||||
.getPeerToPeerSession();
|
||||
p2p.sendPeerToPeer(peer, message);
|
||||
} else {
|
||||
appendMessage(manager.getCollaborationConnection(true)
|
||||
.getUser(), System.currentTimeMillis(), message);
|
||||
appendMessage(connection.getUser(),
|
||||
System.currentTimeMillis(), message);
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("Unable to send message. User is not online.");
|
||||
sendErrorMessage(builder);
|
||||
|
@ -163,8 +164,8 @@ public class PeerToPeerView extends AbstractSessionView {
|
|||
Color color = null;
|
||||
if (userId == null) {
|
||||
color = black;
|
||||
} else if (!userId.equals(CollaborationDataManager.getInstance()
|
||||
.getCollaborationConnection(true).getUser())) {
|
||||
} else if (!userId.equals(CollaborationConnection.getConnection()
|
||||
.getUser())) {
|
||||
color = chatterColor;
|
||||
} else {
|
||||
color = userColor;
|
||||
|
@ -220,8 +221,7 @@ public class PeerToPeerView extends AbstractSessionView {
|
|||
*/
|
||||
@Override
|
||||
protected SessionMsgArchive getMessageArchive() {
|
||||
UserId me = CollaborationDataManager.getInstance()
|
||||
.getCollaborationConnection(true).getUser();
|
||||
UserId me = CollaborationConnection.getConnection().getUser();
|
||||
return new SessionMsgArchive(me.getHost(), me.getName(), peer.getName());
|
||||
}
|
||||
|
||||
|
|
|
@ -54,8 +54,8 @@ import com.raytheon.uf.common.localization.PathManagerFactory;
|
|||
import com.raytheon.uf.common.localization.exception.LocalizationException;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.viz.collaboration.comm.provider.session.CollaborationConnection;
|
||||
import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId;
|
||||
import com.raytheon.uf.viz.collaboration.ui.data.CollaborationDataManager;
|
||||
import com.raytheon.uf.viz.collaboration.ui.session.SearchComposite.SearchText;
|
||||
|
||||
/**
|
||||
|
@ -134,8 +134,7 @@ public class SessionMsgArchiveBrowser extends Composite implements SearchText {
|
|||
|
||||
try {
|
||||
if (logDir == null) {
|
||||
UserId user = CollaborationDataManager.getInstance()
|
||||
.getCollaborationConnection(true).getUser();
|
||||
UserId user = CollaborationConnection.getConnection().getUser();
|
||||
logDir = SessionMsgArchive.getArchiveDir(user.getHost(),
|
||||
user.getName(), null);
|
||||
}
|
||||
|
|
|
@ -143,8 +143,8 @@ public class SessionView extends AbstractSessionView {
|
|||
@Override
|
||||
protected void initComponents(Composite parent) {
|
||||
initColorManager();
|
||||
CollaborationDataManager.getInstance().getCollaborationConnection(true)
|
||||
.getEventPublisher().register(this);
|
||||
CollaborationConnection.getConnection().getEventPublisher()
|
||||
.register(this);
|
||||
super.initComponents(parent);
|
||||
}
|
||||
|
||||
|
@ -161,9 +161,8 @@ public class SessionView extends AbstractSessionView {
|
|||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
CollaborationConnection sessionManager = CollaborationDataManager
|
||||
.getInstance().getCollaborationConnection(true);
|
||||
ISession session = sessionManager.getPeerToPeerSession();
|
||||
ISession session = CollaborationConnection.getConnection()
|
||||
.getPeerToPeerSession();
|
||||
PlatformUI
|
||||
.getWorkbench()
|
||||
.getActiveWorkbenchWindow()
|
||||
|
@ -222,8 +221,7 @@ public class SessionView extends AbstractSessionView {
|
|||
// so not to have delay, going to handle messages from yourself
|
||||
// separately
|
||||
if (message.getFrom().equals(
|
||||
CollaborationDataManager.getInstance()
|
||||
.getCollaborationConnection(true).getUser())) {
|
||||
CollaborationConnection.getConnection().getUser())) {
|
||||
return;
|
||||
}
|
||||
VizApp.runAsync(new Runnable() {
|
||||
|
@ -371,9 +369,8 @@ public class SessionView extends AbstractSessionView {
|
|||
if (participant.equals(session.getUserID())) {
|
||||
RosterEntry rEntry = new RosterEntry(session
|
||||
.getConnection().getRosterManager().getRoster(),
|
||||
participant, CollaborationDataManager.getInstance()
|
||||
.getCollaborationConnection(true)
|
||||
.getPresence());
|
||||
participant, CollaborationConnection
|
||||
.getConnection().getPresence());
|
||||
users.add(rEntry);
|
||||
} else if (entry != null) {
|
||||
users.add(usersMap.get(participant));
|
||||
|
@ -416,8 +413,10 @@ public class SessionView extends AbstractSessionView {
|
|||
session.unRegisterEventHandler(this);
|
||||
CollaborationDataManager mgr = CollaborationDataManager.getInstance();
|
||||
mgr.closeSession(sessionId);
|
||||
mgr.getCollaborationConnection(true).getEventPublisher()
|
||||
.unregister(this);
|
||||
CollaborationConnection conn = CollaborationConnection.getConnection();
|
||||
if (conn != null) {
|
||||
conn.getEventPublisher().unregister(this);
|
||||
}
|
||||
|
||||
super.dispose();
|
||||
}
|
||||
|
@ -439,8 +438,7 @@ public class SessionView extends AbstractSessionView {
|
|||
String message = getComposedMessage();
|
||||
if (message.length() > 0) {
|
||||
try {
|
||||
UserId id = CollaborationDataManager.getInstance()
|
||||
.getCollaborationConnection(true).getUser();
|
||||
UserId id = CollaborationConnection.getConnection().getUser();
|
||||
appendMessage(id, System.currentTimeMillis(), message);
|
||||
session.sendChatMessage(message);
|
||||
} catch (CollaborationException e) {
|
||||
|
|
Loading…
Add table
Reference in a new issue