Issue #244 new icons for collaboration
Former-commit-id:6398c01aec
[formerly79f1cbec74
] [formerly39bce3d793
[formerly da2177babfe9fa8b7efbad9bf9d938e4ecb4313b]] Former-commit-id:39bce3d793
Former-commit-id:22eb44eb26
After Width: | Height: | Size: 348 B |
BIN
cave/com.raytheon.uf.viz.collaboration.ui/icons/add_contact.gif
Normal file
After Width: | Height: | Size: 330 B |
BIN
cave/com.raytheon.uf.viz.collaboration.ui/icons/add_group.gif
Normal file
After Width: | Height: | Size: 595 B |
BIN
cave/com.raytheon.uf.viz.collaboration.ui/icons/available.gif
Normal file
After Width: | Height: | Size: 308 B |
Before Width: | Height: | Size: 91 B After Width: | Height: | Size: 542 B |
Before Width: | Height: | Size: 144 B After Width: | Height: | Size: 947 B |
Before Width: | Height: | Size: 176 B After Width: | Height: | Size: 329 B |
BIN
cave/com.raytheon.uf.viz.collaboration.ui/icons/collapseall.gif
Normal file
After Width: | Height: | Size: 157 B |
After Width: | Height: | Size: 329 B |
Before Width: | Height: | Size: 183 B |
BIN
cave/com.raytheon.uf.viz.collaboration.ui/icons/group.gif
Normal file
After Width: | Height: | Size: 598 B |
BIN
cave/com.raytheon.uf.viz.collaboration.ui/icons/invite.gif
Normal file
After Width: | Height: | Size: 173 B |
After Width: | Height: | Size: 160 B |
BIN
cave/com.raytheon.uf.viz.collaboration.ui/icons/logout.gif
Normal file
After Width: | Height: | Size: 215 B |
BIN
cave/com.raytheon.uf.viz.collaboration.ui/icons/messages.gif
Normal file
After Width: | Height: | Size: 344 B |
Before Width: | Height: | Size: 193 B |
|
@ -1,5 +1,9 @@
|
|||
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.Mode;
|
||||
import com.raytheon.uf.viz.collaboration.data.DataUser.StatusType;
|
||||
|
||||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
|
@ -93,6 +97,16 @@ public class CollaborationUser extends CollaborationNode implements
|
|||
CollaborationDataManager.getInstance().getUser(id).status = status;
|
||||
}
|
||||
|
||||
public void setStatus(IPresence.Mode mode) {
|
||||
if (mode.getMode().equals(Mode.AWAY)) {
|
||||
CollaborationDataManager.getInstance().getUser(id).status = StatusType.AWAY;
|
||||
} else if (mode.getMode().equals(Mode.DND)) {
|
||||
CollaborationDataManager.getInstance().getUser(id).status = StatusType.DO_NOT_DISTURB;
|
||||
} else if (mode.getMode().equals(Mode.AVAILABLE)) {
|
||||
CollaborationDataManager.getInstance().getUser(id).status = StatusType.AVAILABLE;
|
||||
}
|
||||
}
|
||||
|
||||
public String getStatusMessage() {
|
||||
return CollaborationDataManager.getInstance().getUser(id).statusMessage;
|
||||
}
|
||||
|
|
|
@ -45,8 +45,8 @@ import java.util.Map;
|
|||
|
||||
public class DataUser {
|
||||
public static enum StatusType {
|
||||
AVAILABLE("Available"), AWAY("Away"), MEETING("In A Meeting"), DO_NOT_DISTURB(
|
||||
"Do Not Disturb"), NOT_ON_LINE("UnAvailable");
|
||||
AVAILABLE("Available"), AWAY("Away"), DO_NOT_DISTURB("Do Not Disturb"), NOT_ON_LINE(
|
||||
"UnAvailable");
|
||||
|
||||
private final String value;
|
||||
|
||||
|
@ -177,4 +177,19 @@ public class DataUser {
|
|||
public String getSessString(String key) {
|
||||
return sessionsMap.get(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param status
|
||||
* the status to set
|
||||
*/
|
||||
public void setStatus(StatusType status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the status
|
||||
*/
|
||||
public StatusType getStatus() {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,4 +51,15 @@ public class SessionGroup extends CollaborationGroup {
|
|||
public void setSessionRoot(boolean sessionRoot) {
|
||||
this.sessionRoot = sessionRoot;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.viz.collaboration.data.CollaborationNode#getImageKey()
|
||||
*/
|
||||
@Override
|
||||
public String getImageKey() {
|
||||
return "session";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ public class CollaborationGroupAction extends AbstractHandler {
|
|||
.getActivePage().showView(CollaborationGroupView.ID);
|
||||
} catch (PartInitException e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Unable to open collaboration", e);
|
||||
"Unable to open collaboration contact list", e);
|
||||
}
|
||||
return event;
|
||||
}
|
||||
|
|
|
@ -34,9 +34,15 @@ import org.eclipse.jface.action.IMenuListener;
|
|||
import org.eclipse.jface.action.IMenuManager;
|
||||
import org.eclipse.jface.action.IToolBarManager;
|
||||
import org.eclipse.jface.action.MenuManager;
|
||||
import org.eclipse.jface.viewers.DoubleClickEvent;
|
||||
import org.eclipse.jface.viewers.IDoubleClickListener;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.jface.viewers.TreeSelection;
|
||||
import org.eclipse.jface.viewers.TreeViewer;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.custom.TreeEditor;
|
||||
import org.eclipse.swt.events.ModifyEvent;
|
||||
import org.eclipse.swt.events.ModifyListener;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
|
@ -44,6 +50,7 @@ import org.eclipse.swt.widgets.Control;
|
|||
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.IViewPart;
|
||||
import org.eclipse.ui.IWorkbenchPage;
|
||||
import org.eclipse.ui.PartInitException;
|
||||
|
@ -99,7 +106,7 @@ public class CollaborationGroupView extends ViewPart {
|
|||
|
||||
private Action collaborateAction;
|
||||
|
||||
private Action privateChatAction;
|
||||
private Action linkToEditorAction;
|
||||
|
||||
private Action inviteAction;
|
||||
|
||||
|
@ -127,6 +134,10 @@ public class CollaborationGroupView extends ViewPart {
|
|||
|
||||
private Action refreshActiveSessionsAction;
|
||||
|
||||
private Action collapseAllAction;
|
||||
|
||||
private TreeEditor treeEditor;
|
||||
|
||||
/**
|
||||
* @param parent
|
||||
*/
|
||||
|
@ -136,6 +147,7 @@ public class CollaborationGroupView extends ViewPart {
|
|||
createToolbar();
|
||||
createMenubar();
|
||||
createUsersTree(parent);
|
||||
addDoubleClickListeners();
|
||||
createContextMenu();
|
||||
|
||||
SessionManager manger = CollaborationDataManager.getInstance()
|
||||
|
@ -151,28 +163,28 @@ public class CollaborationGroupView extends ViewPart {
|
|||
*
|
||||
*/
|
||||
private void createActions() {
|
||||
joinCollaborationAction = new Action("Join...") {
|
||||
@Override
|
||||
public void run() {
|
||||
System.out.println("this join with menu goes away.");
|
||||
}
|
||||
};
|
||||
joinCollaborationAction
|
||||
.setToolTipText("Select a Collaboration\nroom to join.");
|
||||
|
||||
collaborateAction = new Action("Create Session...") {
|
||||
@Override
|
||||
public void run() {
|
||||
createCollaborationSession();
|
||||
}
|
||||
};
|
||||
|
||||
privateChatAction = new Action("Chat") {
|
||||
};
|
||||
collaborateAction.setImageDescriptor(CollaborationUtils
|
||||
.getImageDescriptor("add_collaborate.gif"));
|
||||
|
||||
linkToEditorAction = new Action("Link Editor to Chat Session",
|
||||
Action.AS_CHECK_BOX) {
|
||||
@Override
|
||||
public void run() {
|
||||
createPrivateChat();
|
||||
// TODO
|
||||
System.out.println("Link to editor here");
|
||||
// createPrivateChat();
|
||||
}
|
||||
};
|
||||
linkToEditorAction.setImageDescriptor(CollaborationUtils
|
||||
.getImageDescriptor("link_to_editor.gif"));
|
||||
|
||||
inviteAction = new Action("Invite...") {
|
||||
@Override
|
||||
|
@ -180,8 +192,10 @@ public class CollaborationGroupView extends ViewPart {
|
|||
System.out.println("Invite...");
|
||||
};
|
||||
};
|
||||
inviteAction.setImageDescriptor(CollaborationUtils
|
||||
.getImageDescriptor("invite.gif"));
|
||||
|
||||
joinAction = new Action("Join") {
|
||||
joinAction = new Action("Join Session") {
|
||||
@Override
|
||||
public void run() {
|
||||
createJoinCollaboration();
|
||||
|
@ -205,10 +219,13 @@ public class CollaborationGroupView extends ViewPart {
|
|||
}
|
||||
};
|
||||
};
|
||||
logoutAction.setImageDescriptor(CollaborationUtils
|
||||
.getImageDescriptor("logout.gif"));
|
||||
|
||||
aliasAction = new Action("Alias") {
|
||||
@Override
|
||||
public void run() {
|
||||
aliasItem();
|
||||
System.out.println("Alias");
|
||||
};
|
||||
};
|
||||
|
@ -216,15 +233,18 @@ public class CollaborationGroupView extends ViewPart {
|
|||
addUserAction = new Action("Add User") {
|
||||
public void run() {
|
||||
System.out.println("Add User");
|
||||
|
||||
};
|
||||
};
|
||||
addUserAction.setImageDescriptor(CollaborationUtils
|
||||
.getImageDescriptor("add_contact.gif"));
|
||||
|
||||
addGroupAction = new Action("Add Group") {
|
||||
public void run() {
|
||||
System.out.println("Add group");
|
||||
};
|
||||
};
|
||||
addGroupAction.setImageDescriptor(CollaborationUtils
|
||||
.getImageDescriptor("add_group.gif"));
|
||||
|
||||
changeMessageAction = new Action("Change Message...") {
|
||||
public void run() {
|
||||
|
@ -254,6 +274,14 @@ public class CollaborationGroupView extends ViewPart {
|
|||
refreshActiveSessionsAction
|
||||
.setToolTipText("Refresh the Active Sessions Entries.");
|
||||
|
||||
collapseAllAction = new Action("Collapse All") {
|
||||
public void run() {
|
||||
usersTreeViewer.collapseAll();
|
||||
}
|
||||
};
|
||||
collapseAllAction.setImageDescriptor(CollaborationUtils
|
||||
.getImageDescriptor("collapseall.gif"));
|
||||
|
||||
IMenuCreator creator = new IMenuCreator() {
|
||||
|
||||
Menu menu;
|
||||
|
@ -261,14 +289,14 @@ public class CollaborationGroupView extends ViewPart {
|
|||
@Override
|
||||
public Menu getMenu(Menu parent) {
|
||||
menu = new Menu(parent);
|
||||
fillStatusMeu(menu);
|
||||
fillStatusMenu(menu);
|
||||
return menu;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Menu getMenu(Control parent) {
|
||||
menu = new Menu(parent);
|
||||
fillStatusMeu(menu);
|
||||
fillStatusMenu(menu);
|
||||
return menu;
|
||||
}
|
||||
|
||||
|
@ -289,10 +317,37 @@ public class CollaborationGroupView extends ViewPart {
|
|||
};
|
||||
}
|
||||
|
||||
private void fillStatusMeu(Menu menu) {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected void aliasItem() {
|
||||
Control oldEditor = treeEditor.getEditor();
|
||||
if (oldEditor != null) {
|
||||
oldEditor.dispose();
|
||||
}
|
||||
TreeSelection selection = (TreeSelection) usersTreeViewer
|
||||
.getSelection();
|
||||
selection.getFirstElement();
|
||||
|
||||
Text newEditor = new Text(usersTreeViewer.getTree(), SWT.NONE);
|
||||
newEditor.setText(((CollaborationNode) selection.getFirstElement())
|
||||
.getId());
|
||||
newEditor.addModifyListener(new ModifyListener() {
|
||||
public void modifyText(ModifyEvent e) {
|
||||
Text text = (Text) treeEditor.getEditor();
|
||||
treeEditor.getItem().setText(text.getText());
|
||||
}
|
||||
});
|
||||
newEditor.selectAll();
|
||||
newEditor.setFocus();
|
||||
treeEditor.setEditor(newEditor, usersTreeViewer.getTree()
|
||||
.getSelection()[0]);
|
||||
|
||||
}
|
||||
|
||||
private void fillStatusMenu(Menu menu) {
|
||||
for (DataUser.StatusType type : DataUser.StatusType.values()) {
|
||||
if (type != DataUser.StatusType.NOT_ON_LINE) {
|
||||
System.out.println(type + " " + type.value());
|
||||
Action action = new Action(type.value()) {
|
||||
public void run() {
|
||||
changeStatusAction.setId(getId());
|
||||
|
@ -301,6 +356,8 @@ public class CollaborationGroupView extends ViewPart {
|
|||
};
|
||||
action.setId(type.name());
|
||||
ActionContributionItem item = new ActionContributionItem(action);
|
||||
action.setImageDescriptor(CollaborationUtils
|
||||
.getImageDescriptor(type.name().toLowerCase() + ".gif"));
|
||||
item.fill(menu, -1);
|
||||
}
|
||||
}
|
||||
|
@ -310,12 +367,17 @@ public class CollaborationGroupView extends ViewPart {
|
|||
IToolBarManager mgr = getViewSite().getActionBars().getToolBarManager();
|
||||
// mgr.add(joinCollaborationAction);
|
||||
mgr.add(collaborateAction);
|
||||
mgr.add(collapseAllAction);
|
||||
// mgr.add(privateChatAction);
|
||||
mgr.add(inviteAction);
|
||||
mgr.add(linkToEditorAction);
|
||||
}
|
||||
|
||||
private void createMenubar() {
|
||||
IMenuManager mgr = getViewSite().getActionBars().getMenuManager();
|
||||
createMenu(mgr);
|
||||
}
|
||||
|
||||
private void createMenu(IMenuManager mgr) {
|
||||
mgr.add(changeStatusAction);
|
||||
mgr.add(changeMessageAction);
|
||||
mgr.add(changePasswordAction);
|
||||
|
@ -447,6 +509,8 @@ public class CollaborationGroupView extends ViewPart {
|
|||
usersTreeViewer.setContentProvider(new UsersTreeContentProvider());
|
||||
usersTreeViewer.setLabelProvider(new UsersTreeLabelProvider());
|
||||
usersTreeViewer.setSorter(new UsersTreeViewerSorter());
|
||||
|
||||
treeEditor = new TreeEditor(usersTreeViewer.getTree());
|
||||
}
|
||||
|
||||
private void createContextMenu() {
|
||||
|
@ -475,10 +539,7 @@ public class CollaborationGroupView extends ViewPart {
|
|||
.getSelection();
|
||||
Object o = selection.getFirstElement();
|
||||
if (o instanceof LoginUser) {
|
||||
manager.add(changeStatusAction);
|
||||
manager.add(changeMessageAction);
|
||||
manager.add(changePasswordAction);
|
||||
manager.add(logoutAction);
|
||||
createMenu(manager);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -578,6 +639,7 @@ public class CollaborationGroupView extends ViewPart {
|
|||
break;
|
||||
}
|
||||
}
|
||||
usersTreeViewer.setInput(topLevel);
|
||||
usersTreeViewer.refresh(topLevel, true);
|
||||
}
|
||||
|
||||
|
@ -664,4 +726,20 @@ public class CollaborationGroupView extends ViewPart {
|
|||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
private void addDoubleClickListeners() {
|
||||
usersTreeViewer.addDoubleClickListener(new IDoubleClickListener() {
|
||||
@Override
|
||||
public void doubleClick(DoubleClickEvent event) {
|
||||
TreeSelection selection = (TreeSelection) event.getSelection();
|
||||
if (selection.getFirstElement() instanceof SessionGroup) {
|
||||
SessionGroup group = (SessionGroup) selection
|
||||
.getFirstElement();
|
||||
if (!group.isSessionRoot()) {
|
||||
createJoinCollaboration();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ 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.DataUser;
|
||||
import com.raytheon.uf.viz.collaboration.data.DataUser.StatusType;
|
||||
import com.raytheon.uf.viz.collaboration.data.SessionGroup;
|
||||
|
||||
/**
|
||||
* Methods for sending, receiving messages
|
||||
|
@ -75,14 +75,24 @@ public class CollaborationUtils {
|
|||
if (node instanceof CollaborationUser) {
|
||||
CollaborationUser user = (CollaborationUser) node;
|
||||
if (user.getStatus() == DataUser.StatusType.AVAILABLE) {
|
||||
nodeImage = getImageDescriptor("online.gif").createImage();
|
||||
nodeImage = getImageDescriptor("available.gif").createImage();
|
||||
} else if (user.getStatus() == DataUser.StatusType.AWAY) {
|
||||
nodeImage = getImageDescriptor("away.gif").createImage();
|
||||
} else if (user.getStatus() == DataUser.StatusType.MEETING) {
|
||||
nodeImage = getImageDescriptor("busy.gif").createImage();
|
||||
} else if (user.getStatus() == DataUser.StatusType.DO_NOT_DISTURB) {
|
||||
nodeImage = getImageDescriptor("do_not_disturb.gif")
|
||||
.createImage();
|
||||
} else {
|
||||
nodeImage = getImageDescriptor("available.gif").createImage();
|
||||
}
|
||||
} else if (node instanceof SessionGroup) {
|
||||
if (!((SessionGroup) node).isSessionRoot()) {
|
||||
nodeImage = getImageDescriptor("group.gif").createImage();
|
||||
} else {
|
||||
// nodeImage = getImageDescriptor("").createImage();
|
||||
|
||||
}
|
||||
} else if (node instanceof CollaborationGroup) {
|
||||
nodeImage = null;
|
||||
nodeImage = getImageDescriptor("group.gif").createImage();
|
||||
}
|
||||
return nodeImage;
|
||||
}
|
||||
|
|
|
@ -1,67 +0,0 @@
|
|||
package com.raytheon.uf.viz.collaboration.ui.actions;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
**/
|
||||
|
||||
import org.eclipse.core.commands.AbstractHandler;
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
import org.eclipse.core.commands.ExecutionException;
|
||||
import org.eclipse.ui.PartInitException;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
|
||||
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.ui.CollaborationGroupView;
|
||||
|
||||
/**
|
||||
* TODO Add Description
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Mar 1, 2012 rferrel Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author rferrel
|
||||
* @version 1.0
|
||||
*/
|
||||
public class CollaborationBrowserAction extends AbstractHandler {
|
||||
private static final transient IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(CollaborationBrowserAction.class);
|
||||
|
||||
@Override
|
||||
public Object execute(ExecutionEvent event) throws ExecutionException {
|
||||
// this opens the collaboration view
|
||||
try {
|
||||
PlatformUI.getWorkbench().getActiveWorkbenchWindow()
|
||||
.getActivePage().showView(CollaborationGroupView.ID);
|
||||
} catch (PartInitException e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Unable to open collaboration contact list", e);
|
||||
}
|
||||
return event;
|
||||
}
|
||||
|
||||
}
|
|
@ -111,7 +111,8 @@ public class LoginDialog extends CaveSWTDialogBase {
|
|||
serverTF = new Text(body, SWT.BORDER);
|
||||
serverTF.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL
|
||||
| GridData.HORIZONTAL_ALIGN_FILL));
|
||||
// serverTF.setText("awipscm.omaha.us.ray.com");
|
||||
serverTF.setText("awipscm.omaha.us.ray.com");
|
||||
serverTF.setEnabled(false);
|
||||
|
||||
label = new Label(body, SWT.NONE);
|
||||
label.setText("Password: ");
|
||||
|
|
|
@ -30,6 +30,7 @@ import org.eclipse.swt.graphics.Image;
|
|||
import com.raytheon.uf.viz.collaboration.data.CollaborationDataManager;
|
||||
import com.raytheon.uf.viz.collaboration.data.CollaborationUser;
|
||||
import com.raytheon.uf.viz.collaboration.data.DataUser.RoleType;
|
||||
import com.raytheon.uf.viz.collaboration.ui.CollaborationUtils;
|
||||
|
||||
/**
|
||||
* TODO Add Description
|
||||
|
@ -81,8 +82,9 @@ public class ParticipantsLabelProvider implements ITableColorProvider,
|
|||
@Override
|
||||
public Image getColumnImage(Object element, int columnIndex) {
|
||||
System.out.println("getColumnImage");
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
CollaborationUser user = (CollaborationUser) element;
|
||||
CollaborationDataManager.getInstance().getUser(user.getId());
|
||||
return CollaborationUtils.getNodeImage(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -37,26 +37,29 @@ import org.eclipse.jface.viewers.TableViewer;
|
|||
import org.eclipse.jface.viewers.Viewer;
|
||||
import org.eclipse.jface.viewers.ViewerSorter;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.custom.CLabel;
|
||||
import org.eclipse.swt.custom.SashForm;
|
||||
import org.eclipse.swt.custom.StyleRange;
|
||||
import org.eclipse.swt.custom.StyledText;
|
||||
import org.eclipse.swt.events.ExpandEvent;
|
||||
import org.eclipse.swt.events.ExpandListener;
|
||||
import org.eclipse.swt.events.FocusEvent;
|
||||
import org.eclipse.swt.events.FocusListener;
|
||||
import org.eclipse.swt.events.KeyEvent;
|
||||
import org.eclipse.swt.events.KeyListener;
|
||||
import org.eclipse.swt.events.MouseAdapter;
|
||||
import org.eclipse.swt.events.MouseEvent;
|
||||
import org.eclipse.swt.events.MouseTrackAdapter;
|
||||
import org.eclipse.swt.graphics.Color;
|
||||
import org.eclipse.swt.graphics.GC;
|
||||
import org.eclipse.swt.graphics.Image;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.swt.widgets.ExpandBar;
|
||||
import org.eclipse.swt.widgets.ExpandItem;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.Menu;
|
||||
import org.eclipse.ui.IPartListener;
|
||||
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;
|
||||
|
@ -68,12 +71,11 @@ 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.identity.IPresence;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.ISession;
|
||||
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.listener.IMessageFilter;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.listener.IMessageListener;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.listener.IPresenceListener;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.listener.IVenueParticipantListener;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.user.IVenueParticipant;
|
||||
import com.raytheon.uf.viz.collaboration.data.CollaborationDataManager;
|
||||
import com.raytheon.uf.viz.collaboration.data.CollaborationKeywords;
|
||||
|
@ -123,11 +125,17 @@ public class SessionView extends ViewPart implements IPartListener {
|
|||
|
||||
protected String sessionId;
|
||||
|
||||
private Action sendMessageAction;
|
||||
private Image downArrow;
|
||||
|
||||
private Image rightArrow;
|
||||
|
||||
private Image highlightedRightArrow;
|
||||
|
||||
private Image highlightedDownArrow;
|
||||
|
||||
private Action chatAction;
|
||||
|
||||
protected IPresenceListener presListener;
|
||||
protected IVenueParticipantListener participantListener;
|
||||
|
||||
protected IMessageListener messageListener;
|
||||
|
||||
|
@ -149,24 +157,24 @@ public class SessionView extends ViewPart implements IPartListener {
|
|||
}
|
||||
|
||||
private void initComponents(Composite parent) {
|
||||
Composite view = new Composite(parent, SWT.NONE);
|
||||
Composite sashComp = new Composite(parent, SWT.NONE);
|
||||
GridLayout layout = new GridLayout(1, false);
|
||||
layout.marginWidth = 0;
|
||||
GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
|
||||
view.setLayout(layout);
|
||||
view.setData(data);
|
||||
sashComp.setLayout(layout);
|
||||
sashComp.setLayoutData(data);
|
||||
|
||||
Color sashColor = Display.getCurrent().getSystemColor(SASH_COLOR);
|
||||
|
||||
SashForm sashForm = new SashForm(view, SWT.VERTICAL);
|
||||
SashForm sashForm = new SashForm(sashComp, SWT.VERTICAL);
|
||||
layout = new GridLayout(1, false);
|
||||
sashForm.setLayout(layout);
|
||||
data = new GridData(SWT.FILL, SWT.FILL, true, true);
|
||||
sashForm.setLayout(layout);
|
||||
sashForm.setLayoutData(data);
|
||||
sashForm.setBackground(sashColor);
|
||||
sashForm.setSashWidth(SASH_WIDTH);
|
||||
|
||||
createListeners();
|
||||
createArrows();
|
||||
createUsersComp(sashForm);
|
||||
createMessagesComp(sashForm);
|
||||
createComposeComp(sashForm);
|
||||
|
@ -179,11 +187,17 @@ public class SessionView extends ViewPart implements IPartListener {
|
|||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
CollaborationDataManager dataManager = CollaborationDataManager
|
||||
.getInstance();
|
||||
CollaborationUser user = (CollaborationUser) ((IStructuredSelection) usersTable
|
||||
.getSelection()).getFirstElement();
|
||||
String session = dataManager.createCollaborationSession(
|
||||
user.getId(), "Chatting...");
|
||||
PlatformUI
|
||||
.getWorkbench()
|
||||
.getActiveWorkbenchWindow()
|
||||
.getActivePage()
|
||||
.showView(CollaborationSessionView.ID, null,
|
||||
.showView(CollaborationSessionView.ID, session,
|
||||
IWorkbenchPage.VIEW_ACTIVATE);
|
||||
// }
|
||||
} catch (PartInitException e) {
|
||||
|
@ -226,6 +240,7 @@ public class SessionView extends ViewPart implements IPartListener {
|
|||
.getSelection();
|
||||
// do something here!
|
||||
Object ob = selection.getFirstElement();
|
||||
System.out.println(ob.toString());
|
||||
manager.add(chatAction);
|
||||
manager.add(new Separator());
|
||||
}
|
||||
|
@ -236,13 +251,14 @@ public class SessionView extends ViewPart implements IPartListener {
|
|||
* @param sessionId
|
||||
*/
|
||||
private void createListeners() {
|
||||
this.getViewSite().getWorkbenchWindow().getPartService()
|
||||
.addPartListener(this);
|
||||
|
||||
sessionId = getViewSite().getSecondaryId();
|
||||
if (CollaborationDataManager.getInstance().getSession(sessionId) != null) {
|
||||
setPartName(CollaborationDataManager.getInstance()
|
||||
.getSession(sessionId).getVenue().getInfo().getVenueName());
|
||||
// Attach desired listeners to the session
|
||||
ISession session = CollaborationDataManager.getInstance()
|
||||
.getSession(sessionId);
|
||||
IVenueSession session = CollaborationDataManager.getInstance()
|
||||
.getSession(sessionId);
|
||||
if (session != null) {
|
||||
setPartName(session.getVenue().getInfo().getVenueDescription());
|
||||
messageListener = new IMessageListener() {
|
||||
|
||||
@Override
|
||||
|
@ -265,11 +281,17 @@ public class SessionView extends ViewPart implements IPartListener {
|
|||
}
|
||||
});
|
||||
|
||||
presListener = new IPresenceListener() {
|
||||
participantListener = new IVenueParticipantListener() {
|
||||
@Override
|
||||
public void handleUpdated(IVenueParticipant participant) {
|
||||
System.out.println("updated");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyPresence(IPresence presence) {
|
||||
// not the best way to do it, should just be adding the new
|
||||
public void handlePresenceUpdated(IVenueParticipant fromID,
|
||||
IPresence presence) {
|
||||
// not the best way to do it, should just be adding the
|
||||
// new
|
||||
// user instead of requerying for participants
|
||||
Collection<IVenueParticipant> participants = CollaborationDataManager
|
||||
.getInstance().getSession(sessionId).getVenue()
|
||||
|
@ -278,6 +300,7 @@ public class SessionView extends ViewPart implements IPartListener {
|
|||
for (IVenueParticipant part : participants) {
|
||||
CollaborationUser user = new CollaborationUser(
|
||||
part.getName());
|
||||
user.setStatus(presence.getMode());
|
||||
user.setText(user.getId());
|
||||
users.add(user);
|
||||
}
|
||||
|
@ -288,59 +311,118 @@ public class SessionView extends ViewPart implements IPartListener {
|
|||
.toArray(new CollaborationUser[users.size()]));
|
||||
}
|
||||
});
|
||||
};
|
||||
};
|
||||
session.addPresenceListener(presListener, new IMessageFilter() {
|
||||
@Override
|
||||
public boolean filter(IMessage message) {
|
||||
return true;
|
||||
}
|
||||
|
||||
});
|
||||
@Override
|
||||
public void handleDeparted(IVenueParticipant participant) {
|
||||
System.out.println("goodbye");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleArrived(IVenueParticipant participant) {
|
||||
System.out.println("you've got mail");
|
||||
}
|
||||
};
|
||||
session.addVenueParticipantListener(participantListener);
|
||||
|
||||
getViewSite().getWorkbenchWindow().getWorkbench()
|
||||
.addWorkbenchListener(new IWorkbenchListener() {
|
||||
|
||||
@Override
|
||||
public boolean preShutdown(IWorkbench workbench,
|
||||
boolean forced) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postShutdown(IWorkbench workbench) {
|
||||
System.out.println("Shutting down");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void createUsersComp(Composite parent) {
|
||||
private void createUsersComp(final Composite parent) {
|
||||
Composite comp = new Composite(parent, SWT.NONE);
|
||||
GridLayout layout = new GridLayout(1, false);
|
||||
GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
|
||||
comp.setLayout(layout);
|
||||
comp.setLayoutData(data);
|
||||
|
||||
ExpandBar usersBar = new ExpandBar(comp, SWT.NONE);
|
||||
final CLabel participantsLabel = new CLabel(comp, SWT.NONE);
|
||||
layout = new GridLayout(1, false);
|
||||
data = new GridData(SWT.FILL, SWT.FILL, true, true);
|
||||
usersBar.setLayout(layout);
|
||||
usersBar.setLayoutData(data);
|
||||
Image usersImage = Display.getCurrent().getSystemImage(SWT.ICON_SEARCH);
|
||||
data = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
|
||||
participantsLabel.setLayout(layout);
|
||||
participantsLabel.setLayoutData(data);
|
||||
participantsLabel.setText("Participants");
|
||||
participantsLabel.setImage(rightArrow);
|
||||
participantsLabel.setToolTipText("Select to show participants...");
|
||||
|
||||
final Composite usersComp = new Composite(usersBar, SWT.NONE);
|
||||
final Composite usersComp = new Composite(comp, SWT.NONE);
|
||||
layout = new GridLayout(1, false);
|
||||
data = new GridData(SWT.FILL, SWT.FILL, true, true);
|
||||
usersComp.setVisible(false);
|
||||
layout.marginWidth = 0;
|
||||
usersComp.setLayout(layout);
|
||||
usersComp.setLayoutData(data);
|
||||
|
||||
ExpandItem usersItem = new ExpandItem(usersBar, SWT.NONE);
|
||||
usersItem.setText("Participants");
|
||||
usersItem.setImage(usersImage);
|
||||
|
||||
usersBar.addExpandListener(new ExpandListener() {
|
||||
participantsLabel.addMouseTrackListener(new MouseTrackAdapter() {
|
||||
@Override
|
||||
public void itemExpanded(ExpandEvent e) {
|
||||
usersComp.setSize(usersTable.getTable().computeSize(
|
||||
SWT.DEFAULT, 500));
|
||||
((SashForm) usersComp.getParent().getParent().getParent())
|
||||
.layout();
|
||||
public void mouseEnter(MouseEvent e) {
|
||||
if (usersComp.getVisible()) {
|
||||
participantsLabel.setImage(highlightedDownArrow);
|
||||
} else {
|
||||
participantsLabel.setImage(highlightedRightArrow);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void itemCollapsed(ExpandEvent e) {
|
||||
usersComp.setSize(usersTable.getTable().computeSize(
|
||||
SWT.DEFAULT, 100));
|
||||
public void mouseExit(MouseEvent e) {
|
||||
if (usersComp.getVisible()) {
|
||||
participantsLabel.setImage(downArrow);
|
||||
} else {
|
||||
participantsLabel.setImage(rightArrow);
|
||||
}
|
||||
}
|
||||
});
|
||||
participantsLabel.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseDown(MouseEvent e) {
|
||||
GridData data = ((GridData) usersComp.getLayoutData());
|
||||
data.exclude = !data.exclude;
|
||||
usersComp.setVisible(!data.exclude);
|
||||
|
||||
((SashForm) usersComp.getParent().getParent().getParent())
|
||||
.layout();
|
||||
usersComp.layout();
|
||||
int[] weights = ((SashForm) parent).getWeights();
|
||||
if (!usersComp.getVisible()) {
|
||||
int val = weights[0] + weights[1] + weights[2];
|
||||
val = (int) Math.ceil(((double) val / 26.0));
|
||||
weights[1] = weights[0] + weights[1] - 1;
|
||||
weights[0] = val;
|
||||
participantsLabel.setImage(rightArrow);
|
||||
participantsLabel
|
||||
.setToolTipText("Select to show participants...");
|
||||
} else {
|
||||
// fix this to make up for possible negative values TODO XXX
|
||||
int val = usersComp.computeSize(SWT.DEFAULT, SWT.DEFAULT).y
|
||||
+ participantsLabel.getBounds().height;
|
||||
double percentage = ((double) val)
|
||||
/ (double) parent.getSize().y;
|
||||
// not greater than 50% of view when popping out
|
||||
if (percentage > 0.5) {
|
||||
percentage = 0.5;
|
||||
}
|
||||
int weight = weights[0] + weights[1] + weights[2];
|
||||
double tmp = weight * percentage;
|
||||
weights[1] = (int) (weights[1] - tmp);
|
||||
weights[0] = (int) (weights[0] + tmp);
|
||||
participantsLabel.setImage(downArrow);
|
||||
participantsLabel
|
||||
.setToolTipText("Select to hide participants...");
|
||||
}
|
||||
((SashForm) parent).setWeights(weights);
|
||||
parent.layout();
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -348,13 +430,9 @@ public class SessionView extends ViewPart implements IPartListener {
|
|||
| SWT.V_SCROLL | SWT.H_SCROLL);
|
||||
layout = new GridLayout(1, false);
|
||||
data = new GridData(SWT.FILL, SWT.FILL, true, true);
|
||||
data.heightHint = 100;
|
||||
usersTable.getTable().setLayout(layout);
|
||||
usersTable.getTable().setLayoutData(data);
|
||||
|
||||
usersItem.setHeight(usersComp.computeSize(SWT.DEFAULT, SWT.DEFAULT).y);
|
||||
usersItem.setControl(usersComp);
|
||||
|
||||
ParticipantsContentProvider contentProvider = new ParticipantsContentProvider();
|
||||
ParticipantsLabelProvider labelProvider = new ParticipantsLabelProvider();
|
||||
labelProvider.setSessionId(sessionId);
|
||||
|
@ -370,39 +448,59 @@ public class SessionView extends ViewPart implements IPartListener {
|
|||
IVenueSession session = CollaborationDataManager.getInstance()
|
||||
.getSession(sessionId);
|
||||
List<CollaborationUser> users = new ArrayList<CollaborationUser>();
|
||||
for (IVenueParticipant part : session.getVenue().getParticipants()) {
|
||||
CollaborationUser user = new CollaborationUser(part.getName());
|
||||
user.setText(part.getName());
|
||||
users.add(user);
|
||||
if (session != null) {
|
||||
for (IVenueParticipant part : session.getVenue().getParticipants()) {
|
||||
CollaborationUser user = new CollaborationUser(part.getName());
|
||||
RoleType[] roles = user.getRoles(sessionId);
|
||||
for (RoleType role : roles) {
|
||||
user.addRole(role);
|
||||
}
|
||||
user.setText(part.getName());
|
||||
users.add(user);
|
||||
}
|
||||
} else {
|
||||
participantsLabel.setEnabled(false);
|
||||
participantsLabel.setForeground(Display.getCurrent()
|
||||
.getSystemColor(SWT.COLOR_DARK_GRAY));
|
||||
comp.setEnabled(false);
|
||||
}
|
||||
usersTable.setInput(users.toArray(new CollaborationUser[users.size()]));
|
||||
((GridData) usersComp.getLayoutData()).exclude = true;
|
||||
}
|
||||
|
||||
private void createMessagesComp(Composite parent) {
|
||||
Composite messagesComp = new Composite(parent, SWT.NONE);
|
||||
GridLayout layout = new GridLayout(1, false);
|
||||
messagesComp.setLayout(layout);
|
||||
Label label = new Label(messagesComp, SWT.NONE);
|
||||
// TODO, wrap label in view
|
||||
Label label = new Label(messagesComp, SWT.WRAP);
|
||||
|
||||
StringBuilder labelInfo = new StringBuilder();
|
||||
IVenueInfo info = CollaborationDataManager.getInstance()
|
||||
.getSession(sessionId).getVenue().getInfo();
|
||||
labelInfo.append(info.getVenueDescription());
|
||||
label.setToolTipText(info.getVenueSubject());
|
||||
if (info.getVenueSubject() != null && !info.getVenueSubject().isEmpty()) {
|
||||
labelInfo.append(":");
|
||||
IVenueSession session = CollaborationDataManager.getInstance()
|
||||
.getSession(sessionId);
|
||||
if (session != null) {
|
||||
IVenueInfo info = session.getVenue().getInfo();
|
||||
labelInfo.append(info.getVenueSubject());
|
||||
label.setToolTipText(info.getVenueSubject());
|
||||
}
|
||||
label.setText(labelInfo.toString());
|
||||
messagesText = new StyledText(messagesComp, SWT.MULTI | SWT.WRAP
|
||||
| SWT.READ_ONLY | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
|
||||
messagesText.setLayoutData(new GridData(GridData.FILL_BOTH));
|
||||
|
||||
if (session == null) {
|
||||
labelInfo.append("There is no active session.");
|
||||
label.setEnabled(false);
|
||||
messagesText.setEnabled(false);
|
||||
}
|
||||
|
||||
label.setText(labelInfo.toString());
|
||||
}
|
||||
|
||||
private void createComposeComp(Composite parent) {
|
||||
Composite composeComp = new Composite(parent, SWT.NONE);
|
||||
GridLayout layout = new GridLayout(1, false);
|
||||
composeComp.setLayout(layout);
|
||||
|
||||
Label label = new Label(composeComp, SWT.NONE);
|
||||
label.setText("Compose:");
|
||||
composeText = new StyledText(composeComp, SWT.MULTI | SWT.WRAP
|
||||
|
@ -448,6 +546,14 @@ public class SessionView extends ViewPart implements IPartListener {
|
|||
.deactivateContexts();
|
||||
}
|
||||
});
|
||||
|
||||
IVenueSession session = CollaborationDataManager.getInstance()
|
||||
.getSession(sessionId);
|
||||
if (session == null) {
|
||||
composeComp.setEnabled(false);
|
||||
composeText.setEnabled(false);
|
||||
label.setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
private Image getImage() {
|
||||
|
@ -468,18 +574,32 @@ public class SessionView extends ViewPart implements IPartListener {
|
|||
CollaborationDataManager.getInstance().getSession(sessionId)
|
||||
.removeMessageListener(messageListener);
|
||||
}
|
||||
if (presListener != null) {
|
||||
if (participantListener != null) {
|
||||
CollaborationDataManager.getInstance().getSession(sessionId)
|
||||
.removePresenceListener(presListener);
|
||||
.removeVenueParticipantListener(participantListener);
|
||||
}
|
||||
for (String key : imageMap.keySet()) {
|
||||
imageMap.get(key).dispose();
|
||||
for (Image im : imageMap.values()) {
|
||||
im.dispose();
|
||||
}
|
||||
|
||||
imageMap.clear();
|
||||
imageMap = null;
|
||||
|
||||
// dispose of the images first
|
||||
disposeArrow(highlightedDownArrow);
|
||||
disposeArrow(highlightedRightArrow);
|
||||
disposeArrow(downArrow);
|
||||
disposeArrow(rightArrow);
|
||||
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
private void disposeArrow(Image image) {
|
||||
if (image != null && !image.isDisposed()) {
|
||||
image.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
public void addUsers(java.util.List<CollaborationUser> users) {
|
||||
for (CollaborationUser user : users) {
|
||||
addUser(user);
|
||||
|
@ -543,6 +663,17 @@ public class SessionView extends ViewPart implements IPartListener {
|
|||
messagesText.setStyleRange(newRange);
|
||||
}
|
||||
messagesText.setTopIndex(messagesText.getLineCount() - 1);
|
||||
|
||||
// room for other fun things here, such as sounds and such
|
||||
executeSightsSounds();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private void executeSightsSounds() {
|
||||
// TODO Auto-generated method stub
|
||||
// placeholder for future things
|
||||
}
|
||||
|
||||
public void sendMessage() {
|
||||
|
@ -582,6 +713,17 @@ public class SessionView extends ViewPart implements IPartListener {
|
|||
public void partClosed(IWorkbenchPart part) {
|
||||
// TODO
|
||||
// here you need to end a session that is a temporary session
|
||||
IVenueSession session = CollaborationDataManager.getInstance()
|
||||
.getSession(sessionId);
|
||||
if (session != null) {
|
||||
session.removeMessageListener(messageListener);
|
||||
for (IMessageListener list : session.getMessageListeners()) {
|
||||
session.removeMessageListener(list);
|
||||
}
|
||||
session.removeVenueParticipantListener(participantListener);
|
||||
}
|
||||
this.getViewSite().getWorkbenchWindow().getPartService()
|
||||
.removePartListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -593,4 +735,55 @@ public class SessionView extends ViewPart implements IPartListener {
|
|||
public void partOpened(IWorkbenchPart part) {
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
private void createArrows() {
|
||||
int imgWidth = 11;
|
||||
int imgHeight = 11;
|
||||
|
||||
rightArrow = new Image(Display.getCurrent(), imgWidth, imgHeight);
|
||||
downArrow = new Image(Display.getCurrent(), imgWidth, imgHeight);
|
||||
highlightedRightArrow = new Image(Display.getCurrent(), imgWidth,
|
||||
imgHeight);
|
||||
highlightedDownArrow = new Image(Display.getCurrent(), imgWidth,
|
||||
imgHeight);
|
||||
|
||||
// the right arrow
|
||||
GC gc = new GC(rightArrow);
|
||||
drawArrowImage(gc, imgWidth, imgHeight, false, false);
|
||||
|
||||
// the down arrow
|
||||
gc = new GC(downArrow);
|
||||
drawArrowImage(gc, imgWidth, imgHeight, true, false);
|
||||
|
||||
// the down arrow
|
||||
gc = new GC(highlightedRightArrow);
|
||||
drawArrowImage(gc, imgWidth, imgHeight, false, true);
|
||||
|
||||
// the down arrow
|
||||
gc = new GC(highlightedDownArrow);
|
||||
drawArrowImage(gc, imgWidth, imgHeight, true, true);
|
||||
|
||||
gc.dispose();
|
||||
}
|
||||
|
||||
private void drawArrowImage(GC gc, int imgWidth, int imgHeight,
|
||||
boolean down, boolean fill) {
|
||||
gc.setAntialias(SWT.ON);
|
||||
// "Erase" the canvas by filling it in with a rectangle.
|
||||
gc.setBackground(Display.getCurrent().getSystemColor(
|
||||
SWT.COLOR_WIDGET_BACKGROUND));
|
||||
gc.fillRectangle(0, 0, imgWidth, imgHeight);
|
||||
gc.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK));
|
||||
int[] polyArray = null;
|
||||
if (down) {
|
||||
polyArray = new int[] { 2, 3, 5, 6, 8, 3 };
|
||||
} else {
|
||||
polyArray = new int[] { 3, 2, 6, 5, 3, 8 };
|
||||
}
|
||||
if (fill) {
|
||||
gc.fillPolygon(polyArray);
|
||||
} else {
|
||||
gc.drawPolygon(polyArray);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -139,17 +139,17 @@ import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueUserId;
|
|||
* TODO Add Description
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Mar 7, 2012 jkorman Initial creation
|
||||
*
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
* @author jkorman
|
||||
* @version 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
public class CollaborationSession implements IVenueSession {
|
||||
|
||||
|
@ -158,26 +158,26 @@ public class CollaborationSession implements IVenueSession {
|
|||
* TODO Add Description
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Feb 27, 2012 jkorman Initial creation
|
||||
*
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
* @author jkorman
|
||||
* @version 1.0
|
||||
*/
|
||||
private static class InternalListener {
|
||||
|
||||
|
||||
private IMessageListener messageListener;
|
||||
|
||||
|
||||
private IPresenceListener presenceListener;
|
||||
|
||||
private IMessageFilter filter;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param listener
|
||||
|
@ -193,7 +193,8 @@ public class CollaborationSession implements IVenueSession {
|
|||
* @param listener
|
||||
* @param filter
|
||||
*/
|
||||
public InternalListener(IPresenceListener listener, IMessageFilter filter) {
|
||||
public InternalListener(IPresenceListener listener,
|
||||
IMessageFilter filter) {
|
||||
presenceListener = listener;
|
||||
this.filter = filter;
|
||||
}
|
||||
|
@ -222,35 +223,37 @@ public class CollaborationSession implements IVenueSession {
|
|||
public boolean filter(IMessage message) {
|
||||
return filter.filter(message);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private IContainer container = null;
|
||||
|
||||
private IPresenceContainerAdapter presence = null;
|
||||
|
||||
|
||||
private IChatMessageSender chatSender = null;
|
||||
|
||||
|
||||
private Namespace namespace = null;
|
||||
|
||||
private IChatRoomManager venueManager = null;
|
||||
|
||||
private IChatRoomContainer venueContainer = null;
|
||||
|
||||
private IChatRoomInfo venueInfo = null;
|
||||
|
||||
|
||||
private List<InternalListener> messageListeners = null;
|
||||
|
||||
|
||||
private List<IVenueParticipantListener> venueParticipantListeners = null;
|
||||
|
||||
|
||||
private List<InternalListener> collaborationListeners = null;
|
||||
|
||||
|
||||
private List<InternalListener> presenceListeners = null;
|
||||
|
||||
private IIMMessageListener intListener = null;
|
||||
|
||||
|
||||
private IQualifiedID receiver = null;
|
||||
|
||||
|
||||
private IQualifiedID userID = null;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@ -267,19 +270,22 @@ public class CollaborationSession implements IVenueSession {
|
|||
*
|
||||
* @param userName
|
||||
* @param password
|
||||
* @see com.raytheon.uf.viz.collaboration.comm.identity.ISession#connect(java.lang.String, java.lang.String)
|
||||
* @see com.raytheon.uf.viz.collaboration.comm.identity.ISession#connect(java.lang.String,
|
||||
* java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void connect(String userName, String password) {
|
||||
|
||||
if(!isConnected()) {
|
||||
if (!isConnected()) {
|
||||
ID targetID = IDFactory.getDefault().createID(namespace, userName);
|
||||
// Now connect
|
||||
try {
|
||||
container.connect(targetID, ConnectContextFactory.createPasswordConnectContext(password));
|
||||
|
||||
System.out.println("Container connected as " + container.getConnectedID());
|
||||
|
||||
container.connect(targetID, ConnectContextFactory
|
||||
.createPasswordConnectContext(password));
|
||||
|
||||
System.out.println("Container connected as "
|
||||
+ container.getConnectedID());
|
||||
|
||||
} catch (ContainerConnectException e) {
|
||||
System.out.println("Error attempting to connect");
|
||||
e.printStackTrace();
|
||||
|
@ -295,7 +301,7 @@ public class CollaborationSession implements IVenueSession {
|
|||
public IQualifiedID getUserID() {
|
||||
return userID;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @see com.raytheon.uf.viz.collaboration.comm.identity.ISession#isConnected()
|
||||
|
@ -303,22 +309,22 @@ public class CollaborationSession implements IVenueSession {
|
|||
@Override
|
||||
public boolean isConnected() {
|
||||
boolean connected = false;
|
||||
if(container != null) {
|
||||
if (container != null) {
|
||||
connected = (container.getConnectedID() != null);
|
||||
}
|
||||
return connected;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @see com.raytheon.uf.viz.collaboration.comm.identity.ISession#close()
|
||||
*/
|
||||
@Override
|
||||
public void close() {
|
||||
if(container != null) {
|
||||
if (container != null) {
|
||||
// Ensure the listeners are cleared first.
|
||||
// unhook the internal listener first.
|
||||
if(intListener != null) {
|
||||
if (intListener != null) {
|
||||
venueContainer.removeMessageListener(intListener);
|
||||
}
|
||||
|
||||
|
@ -330,7 +336,7 @@ public class CollaborationSession implements IVenueSession {
|
|||
|
||||
presenceListeners.clear();
|
||||
presenceListeners = null;
|
||||
|
||||
|
||||
// Now dispose of the comm container.
|
||||
container.dispose();
|
||||
container = null;
|
||||
|
@ -342,27 +348,29 @@ public class CollaborationSession implements IVenueSession {
|
|||
* @throws ECFException
|
||||
*/
|
||||
private void setup() throws ECFException {
|
||||
|
||||
|
||||
if (container == null) {
|
||||
container = ContainerFactory.getDefault().createContainer(SessionManager.PROVIDER);
|
||||
container = ContainerFactory.getDefault().createContainer(
|
||||
SessionManager.PROVIDER);
|
||||
}
|
||||
if(container != null) {
|
||||
if (container != null) {
|
||||
namespace = container.getConnectNamespace();
|
||||
|
||||
|
||||
presence = (IPresenceContainerAdapter) container
|
||||
.getAdapter(IPresenceContainerAdapter.class);
|
||||
.getAdapter(IPresenceContainerAdapter.class);
|
||||
|
||||
chatSender = presence.getChatManager().getChatMessageSender();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
private ID createID(String name) {
|
||||
return IDFactory.getDefault().createID(container.getConnectNamespace(), name);
|
||||
return IDFactory.getDefault().createID(container.getConnectNamespace(),
|
||||
name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -376,7 +384,7 @@ public class CollaborationSession implements IVenueSession {
|
|||
// Create chat room container from manager
|
||||
venueManager = presence.getChatRoomManager();
|
||||
venueInfo = venueManager.getChatRoomInfo(venueName);
|
||||
if(venueInfo != null) {
|
||||
if (venueInfo != null) {
|
||||
errorStatus = completeVenueConnection(venueInfo);
|
||||
} else {
|
||||
// Could not join venue.
|
||||
|
@ -392,7 +400,8 @@ public class CollaborationSession implements IVenueSession {
|
|||
*
|
||||
* @param venueName
|
||||
* @throws Exception
|
||||
* @see com.raytheon.uf.viz.collaboration.comm.identity.IVenueSession#createVenue(java.lang.String, java.lang.String)
|
||||
* @see com.raytheon.uf.viz.collaboration.comm.identity.IVenueSession#createVenue(java.lang.String,
|
||||
* java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public int createVenue(String venueName, String subject) {
|
||||
|
@ -401,10 +410,10 @@ public class CollaborationSession implements IVenueSession {
|
|||
// Create chat room container from manager
|
||||
venueManager = presence.getChatRoomManager();
|
||||
venueInfo = venueManager.getChatRoomInfo(venueName);
|
||||
if(venueInfo == null) {
|
||||
if (venueInfo == null) {
|
||||
Map<String, String> props = null;
|
||||
if(subject != null) {
|
||||
props = new HashMap<String,String>();
|
||||
if (subject != null) {
|
||||
props = new HashMap<String, String>();
|
||||
props.put(Tools.VENUE_SUBJECT_PROP, subject);
|
||||
}
|
||||
venueInfo = venueManager.createChatRoom(venueName, props);
|
||||
|
@ -449,39 +458,45 @@ public class CollaborationSession implements IVenueSession {
|
|||
IChatRoomParticipantListener pListener = new IChatRoomParticipantListener() {
|
||||
@Override
|
||||
public void handleArrived(IUser participant) {
|
||||
IVenueParticipant p = new VenueParticipant(participant.getName(), participant.getNickname());
|
||||
for(IVenueParticipantListener listener : venueParticipantListeners) {
|
||||
IVenueParticipant p = new VenueParticipant(
|
||||
participant.getName(),
|
||||
participant.getNickname());
|
||||
for (IVenueParticipantListener listener : venueParticipantListeners) {
|
||||
listener.handleArrived(p);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleUpdated(IUser participant) {
|
||||
IVenueParticipant p = new VenueParticipant(participant.getName(), participant.getNickname());
|
||||
for(IVenueParticipantListener listener : venueParticipantListeners) {
|
||||
IVenueParticipant p = new VenueParticipant(
|
||||
participant.getName(),
|
||||
participant.getNickname());
|
||||
for (IVenueParticipantListener listener : venueParticipantListeners) {
|
||||
listener.handleUpdated(p);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleDeparted(IUser participant) {
|
||||
IVenueParticipant p = new VenueParticipant(participant.getName(), participant.getNickname());
|
||||
for(IVenueParticipantListener listener : venueParticipantListeners) {
|
||||
IVenueParticipant p = new VenueParticipant(
|
||||
participant.getName(),
|
||||
participant.getNickname());
|
||||
for (IVenueParticipantListener listener : venueParticipantListeners) {
|
||||
listener.handleDeparted(p);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePresenceUpdated(
|
||||
ID fromID,
|
||||
public void handlePresenceUpdated(ID fromID,
|
||||
org.eclipse.ecf.presence.IPresence presence) {
|
||||
|
||||
fromID.getName();
|
||||
IVenueParticipant vp = new VenueParticipant();
|
||||
vp.setName(fromID.getName());
|
||||
|
||||
|
||||
IPresence p = Presence.convertPresence(presence);
|
||||
for(IVenueParticipantListener listener : venueParticipantListeners) {
|
||||
|
||||
for (IVenueParticipantListener listener : venueParticipantListeners) {
|
||||
listener.handlePresenceUpdated(vp, p);
|
||||
}
|
||||
}
|
||||
|
@ -494,29 +509,29 @@ public class CollaborationSession implements IVenueSession {
|
|||
}
|
||||
return errorStatus;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @return The information about this venue. May return a null reference
|
||||
* if the venue is not connected.
|
||||
* @return The information about this venue. May return a null reference if
|
||||
* the venue is not connected.
|
||||
*/
|
||||
public IVenue getVenue() {
|
||||
IVenue venue = null;
|
||||
if(isConnected()) {
|
||||
if (isConnected()) {
|
||||
venue = new Venue();
|
||||
ID [] ids = venueContainer.getChatRoomParticipants();
|
||||
for(ID id : ids) {
|
||||
ID[] ids = venueContainer.getChatRoomParticipants();
|
||||
for (ID id : ids) {
|
||||
IVenueParticipant participant = new VenueParticipant();
|
||||
participant.setName(id.getName());
|
||||
venue.addParticipant(participant);
|
||||
}
|
||||
venue.setInfo(InfoAdapter.createVenueInfo(venueInfo));
|
||||
} else {
|
||||
|
||||
|
||||
}
|
||||
return venue;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@ -524,10 +539,12 @@ public class CollaborationSession implements IVenueSession {
|
|||
public int sendPresence(IPresence userPresence) {
|
||||
// Assume success
|
||||
int status = 0;
|
||||
|
||||
IPresenceSender sender = presence.getRosterManager().getPresenceSender();
|
||||
|
||||
IPresenceSender sender = presence.getRosterManager()
|
||||
.getPresenceSender();
|
||||
try {
|
||||
sender.sendPresenceUpdate(null, Presence.convertPresence(userPresence));
|
||||
sender.sendPresenceUpdate(null,
|
||||
Presence.convertPresence(userPresence));
|
||||
} catch (ECFException e) {
|
||||
status = -1;
|
||||
}
|
||||
|
@ -549,20 +566,21 @@ public class CollaborationSession implements IVenueSession {
|
|||
public int sendTextMessage(IMessage message) {
|
||||
// Assume success
|
||||
int status = 0;
|
||||
if(chatSender != null) {
|
||||
if (chatSender != null) {
|
||||
ID toID = createID(message.getTo().getName());
|
||||
String subject = message.getSubject();
|
||||
String body = message.getBody();
|
||||
Collection<Property> properties = message.getProperties();
|
||||
Map<String, String> props = null;
|
||||
if((properties != null) && (properties.size() > 0)) {
|
||||
if ((properties != null) && (properties.size() > 0)) {
|
||||
props = new HashMap<String, String>();
|
||||
for(Property p : properties) {
|
||||
props.put(p.getKey(),p.getValue());
|
||||
for (Property p : properties) {
|
||||
props.put(p.getKey(), p.getValue());
|
||||
}
|
||||
}
|
||||
try {
|
||||
chatSender.sendChatMessage(toID, null, IChatMessage.Type.CHAT, subject, body, props);
|
||||
chatSender.sendChatMessage(toID, null, IChatMessage.Type.CHAT,
|
||||
subject, body, props);
|
||||
} catch (ECFException e) {
|
||||
System.out.println("Error sending message");
|
||||
e.printStackTrace();
|
||||
|
@ -573,7 +591,7 @@ public class CollaborationSession implements IVenueSession {
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param to
|
||||
* @param message
|
||||
*/
|
||||
|
@ -587,15 +605,15 @@ public class CollaborationSession implements IVenueSession {
|
|||
|
||||
IMessage msg = new TextMessage(receiver, message);
|
||||
status = sendTextMessage(msg);
|
||||
|
||||
|
||||
} catch (ECFException e) {
|
||||
System.out.println("Error sending message");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param message
|
||||
|
@ -605,15 +623,17 @@ public class CollaborationSession implements IVenueSession {
|
|||
IMessage msg = new TextMessage(receiver, message);
|
||||
return sendTextMessage(msg);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param message A message to send.
|
||||
* @param message
|
||||
* A message to send.
|
||||
*/
|
||||
public int sendMessageToVenue(String message) {
|
||||
// Assume success
|
||||
int status = 0;
|
||||
if(venueContainer != null) {
|
||||
IChatRoomMessageSender sender = venueContainer.getChatRoomMessageSender();
|
||||
if (venueContainer != null) {
|
||||
IChatRoomMessageSender sender = venueContainer
|
||||
.getChatRoomMessageSender();
|
||||
try {
|
||||
sender.sendMessage(message);
|
||||
} catch (ECFException e) {
|
||||
|
@ -622,7 +642,7 @@ public class CollaborationSession implements IVenueSession {
|
|||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param message
|
||||
|
@ -633,7 +653,7 @@ public class CollaborationSession implements IVenueSession {
|
|||
// Assume success
|
||||
int status = 0;
|
||||
// for now we're sending everything via regular messages.
|
||||
return sendMessageToVenue(message.getBody());
|
||||
return sendMessageToVenue(message.getBody());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -649,23 +669,33 @@ public class CollaborationSession implements IVenueSession {
|
|||
|
||||
/**
|
||||
* Send an invitation from this venue to another user.
|
||||
* @param room The target venue for this invitation.
|
||||
* @param id The target user for this invitation.
|
||||
* @param subject The intended subject of the venue conversation.
|
||||
* @param body Any text that the user may wish to include.
|
||||
*
|
||||
* @param room
|
||||
* The target venue for this invitation.
|
||||
* @param id
|
||||
* The target user for this invitation.
|
||||
* @param subject
|
||||
* The intended subject of the venue conversation.
|
||||
* @param body
|
||||
* Any text that the user may wish to include.
|
||||
* @return
|
||||
* @see com.raytheon.uf.viz.collaboration.comm.identity.IVenueSession#sendInvitation(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
|
||||
* @see com.raytheon.uf.viz.collaboration.comm.identity.IVenueSession#sendInvitation(java.lang.String,
|
||||
* java.lang.String, java.lang.String, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public int sendInvitation(String room, String id, String subject, String body) {
|
||||
public int sendInvitation(String room, String id, String subject,
|
||||
String body) {
|
||||
// Assume success
|
||||
int status = 0;
|
||||
IChatRoomInvitationSender sender = presence.getChatRoomManager().getInvitationSender();
|
||||
if(sender != null) {
|
||||
|
||||
ID roomId = presence.getChatRoomManager().getChatRoomInfo(room).getConnectedID();
|
||||
ID userId = IDFactory.getDefault().createID(namespace, id + "@awipscm.omaha.us.ray.com");
|
||||
|
||||
IChatRoomInvitationSender sender = presence.getChatRoomManager()
|
||||
.getInvitationSender();
|
||||
if (sender != null) {
|
||||
|
||||
ID roomId = presence.getChatRoomManager().getChatRoomInfo(room)
|
||||
.getConnectedID();
|
||||
ID userId = IDFactory.getDefault().createID(namespace,
|
||||
id + "@awipscm.omaha.us.ray.com");
|
||||
|
||||
try {
|
||||
sender.sendInvitation(roomId, userId, subject, body);
|
||||
} catch (ECFException e) {
|
||||
|
@ -674,22 +704,29 @@ public class CollaborationSession implements IVenueSession {
|
|||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Send an invitation from this venue to another user.
|
||||
* @param room The target venue for this invitation.
|
||||
* @param id The target user for this invitation.
|
||||
* @param subject The intended subject of the venue conversation.
|
||||
* @param body Any text that the user may wish to include.
|
||||
*
|
||||
* @param room
|
||||
* The target venue for this invitation.
|
||||
* @param id
|
||||
* The target user for this invitation.
|
||||
* @param subject
|
||||
* The intended subject of the venue conversation.
|
||||
* @param body
|
||||
* Any text that the user may wish to include.
|
||||
* @return
|
||||
* @see com.raytheon.uf.viz.collaboration.comm.identity.IVenueSession#sendInvitation(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
|
||||
* @see com.raytheon.uf.viz.collaboration.comm.identity.IVenueSession#sendInvitation(java.lang.String,
|
||||
* java.lang.String, java.lang.String, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public int sendInvitation(String room, List<String> ids, String subject, String body) {
|
||||
public int sendInvitation(String room, List<String> ids, String subject,
|
||||
String body) {
|
||||
// Assume success
|
||||
int status = 0;
|
||||
if(ids != null) {
|
||||
for(String id : ids) {
|
||||
if (ids != null) {
|
||||
for (String id : ids) {
|
||||
sendInvitation(room, id, subject, body);
|
||||
}
|
||||
} else {
|
||||
|
@ -697,12 +734,12 @@ public class CollaborationSession implements IVenueSession {
|
|||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public IMessageListener addMessageListener(IMessageListener listener, IMessageFilter filter) {
|
||||
InternalListener messageListener = new InternalListener(listener, filter);
|
||||
public IMessageListener addMessageListener(IMessageListener listener,
|
||||
IMessageFilter filter) {
|
||||
InternalListener messageListener = new InternalListener(listener,
|
||||
filter);
|
||||
messageListeners.add(messageListener);
|
||||
return listener;
|
||||
}
|
||||
|
@ -713,8 +750,8 @@ public class CollaborationSession implements IVenueSession {
|
|||
@Override
|
||||
public Collection<IMessageListener> getMessageListeners() {
|
||||
Collection<IMessageListener> listeners = new ArrayList<IMessageListener>();
|
||||
synchronized(messageListeners) {
|
||||
for(InternalListener intListener : messageListeners) {
|
||||
synchronized (messageListeners) {
|
||||
for (InternalListener intListener : messageListeners) {
|
||||
listeners.add(intListener.messageListener);
|
||||
}
|
||||
}
|
||||
|
@ -727,7 +764,7 @@ public class CollaborationSession implements IVenueSession {
|
|||
@Override
|
||||
public IMessageListener removeMessageListener(IMessageListener listener) {
|
||||
IMessageListener removed = null;
|
||||
if(messageListeners.remove(listener)) {
|
||||
if (messageListeners.remove(listener)) {
|
||||
removed = listener;
|
||||
}
|
||||
return removed;
|
||||
|
@ -737,8 +774,9 @@ public class CollaborationSession implements IVenueSession {
|
|||
*
|
||||
*/
|
||||
@Override
|
||||
public IVenueParticipantListener addVenueParticipantListener(IVenueParticipantListener listener) {
|
||||
if(listener != null) {
|
||||
public IVenueParticipantListener addVenueParticipantListener(
|
||||
IVenueParticipantListener listener) {
|
||||
if (listener != null) {
|
||||
venueParticipantListeners.add(listener);
|
||||
} else {
|
||||
// TODO : Need some error condition here?
|
||||
|
@ -752,8 +790,8 @@ public class CollaborationSession implements IVenueSession {
|
|||
@Override
|
||||
public Collection<IVenueParticipantListener> getVenueParticipantListeners() {
|
||||
Collection<IVenueParticipantListener> listeners = new ArrayList<IVenueParticipantListener>();
|
||||
synchronized(collaborationListeners) {
|
||||
for(IVenueParticipantListener listener : venueParticipantListeners) {
|
||||
synchronized (collaborationListeners) {
|
||||
for (IVenueParticipantListener listener : venueParticipantListeners) {
|
||||
listeners.add(listener);
|
||||
}
|
||||
}
|
||||
|
@ -764,9 +802,10 @@ public class CollaborationSession implements IVenueSession {
|
|||
*
|
||||
*/
|
||||
@Override
|
||||
public IVenueParticipantListener removeVenueParticipantListener(IVenueParticipantListener listener) {
|
||||
public IVenueParticipantListener removeVenueParticipantListener(
|
||||
IVenueParticipantListener listener) {
|
||||
IVenueParticipantListener removed = null;
|
||||
if(venueParticipantListeners.remove(listener)) {
|
||||
if (venueParticipantListeners.remove(listener)) {
|
||||
removed = listener;
|
||||
}
|
||||
return removed;
|
||||
|
@ -776,8 +815,10 @@ public class CollaborationSession implements IVenueSession {
|
|||
*
|
||||
*/
|
||||
@Override
|
||||
public IMessageListener addCollaborationListener(IMessageListener listener, IMessageFilter filter) {
|
||||
InternalListener messageListener = new InternalListener(listener, filter);
|
||||
public IMessageListener addCollaborationListener(IMessageListener listener,
|
||||
IMessageFilter filter) {
|
||||
InternalListener messageListener = new InternalListener(listener,
|
||||
filter);
|
||||
collaborationListeners.add(messageListener);
|
||||
return listener;
|
||||
}
|
||||
|
@ -788,8 +829,8 @@ public class CollaborationSession implements IVenueSession {
|
|||
@Override
|
||||
public Collection<IMessageListener> getCollaborationListeners() {
|
||||
Collection<IMessageListener> listeners = new ArrayList<IMessageListener>();
|
||||
synchronized(collaborationListeners) {
|
||||
for(InternalListener intListener : collaborationListeners) {
|
||||
synchronized (collaborationListeners) {
|
||||
for (InternalListener intListener : collaborationListeners) {
|
||||
listeners.add(intListener.messageListener);
|
||||
}
|
||||
}
|
||||
|
@ -800,9 +841,10 @@ public class CollaborationSession implements IVenueSession {
|
|||
*
|
||||
*/
|
||||
@Override
|
||||
public IMessageListener removeCollaborationListener(IMessageListener listener) {
|
||||
public IMessageListener removeCollaborationListener(
|
||||
IMessageListener listener) {
|
||||
IMessageListener removed = null;
|
||||
if(collaborationListeners.remove(listener)) {
|
||||
if (collaborationListeners.remove(listener)) {
|
||||
removed = listener;
|
||||
}
|
||||
return removed;
|
||||
|
@ -812,8 +854,10 @@ public class CollaborationSession implements IVenueSession {
|
|||
*
|
||||
*/
|
||||
@Override
|
||||
public IPresenceListener addPresenceListener(IPresenceListener listener, IMessageFilter filter) {
|
||||
InternalListener presenceListener = new InternalListener(listener, filter);
|
||||
public IPresenceListener addPresenceListener(IPresenceListener listener,
|
||||
IMessageFilter filter) {
|
||||
InternalListener presenceListener = new InternalListener(listener,
|
||||
filter);
|
||||
presenceListeners.add(presenceListener);
|
||||
return listener;
|
||||
}
|
||||
|
@ -824,8 +868,8 @@ public class CollaborationSession implements IVenueSession {
|
|||
@Override
|
||||
public Collection<IPresenceListener> getPresenceListeners() {
|
||||
Collection<IPresenceListener> listeners = new ArrayList<IPresenceListener>();
|
||||
synchronized(presenceListeners) {
|
||||
for(InternalListener intListener : presenceListeners) {
|
||||
synchronized (presenceListeners) {
|
||||
for (InternalListener intListener : presenceListeners) {
|
||||
listeners.add(intListener.presenceListener);
|
||||
}
|
||||
}
|
||||
|
@ -835,7 +879,7 @@ public class CollaborationSession implements IVenueSession {
|
|||
@Override
|
||||
public IPresenceListener removePresenceListener(IPresenceListener listener) {
|
||||
IPresenceListener removed = null;
|
||||
if(presenceListeners.remove(listener)) {
|
||||
if (presenceListeners.remove(listener)) {
|
||||
removed = listener;
|
||||
}
|
||||
return removed;
|
||||
|
@ -845,10 +889,14 @@ public class CollaborationSession implements IVenueSession {
|
|||
* Set up the various message listener lists.
|
||||
*/
|
||||
private void initListeners() {
|
||||
messageListeners = Collections.synchronizedList(new ArrayList<InternalListener>());
|
||||
venueParticipantListeners = Collections.synchronizedList(new ArrayList<IVenueParticipantListener>());
|
||||
presenceListeners = Collections.synchronizedList(new ArrayList<InternalListener>());
|
||||
collaborationListeners = Collections.synchronizedList(new ArrayList<InternalListener>());
|
||||
messageListeners = Collections
|
||||
.synchronizedList(new ArrayList<InternalListener>());
|
||||
venueParticipantListeners = Collections
|
||||
.synchronizedList(new ArrayList<IVenueParticipantListener>());
|
||||
presenceListeners = Collections
|
||||
.synchronizedList(new ArrayList<InternalListener>());
|
||||
collaborationListeners = Collections
|
||||
.synchronizedList(new ArrayList<InternalListener>());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -856,14 +904,16 @@ public class CollaborationSession implements IVenueSession {
|
|||
* @param message
|
||||
*/
|
||||
private void distributeMessage(IMessage message) {
|
||||
if(message != null) {
|
||||
if (message != null) {
|
||||
fireMessageListeners(message);
|
||||
|
||||
// if(IMessage.MessageType.CHAT.equals(message.getMessageType())) {
|
||||
// fireMessageListeners(message);
|
||||
// } else if (IMessage.MessageType.COLLABORATION.equals(message.getMessageType())) {
|
||||
// fireCollaborationListeners(message);
|
||||
// }
|
||||
// if(IMessage.MessageType.CHAT.equals(message.getMessageType())) {
|
||||
// fireMessageListeners(message);
|
||||
// } else if
|
||||
// (IMessage.MessageType.COLLABORATION.equals(message.getMessageType()))
|
||||
// {
|
||||
// fireCollaborationListeners(message);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -872,9 +922,9 @@ public class CollaborationSession implements IVenueSession {
|
|||
* @param message
|
||||
*/
|
||||
private void fireMessageListeners(IMessage message) {
|
||||
synchronized(messageListeners) {
|
||||
for(InternalListener listener : messageListeners) {
|
||||
if(listener.filter(message)) {
|
||||
synchronized (messageListeners) {
|
||||
for (InternalListener listener : messageListeners) {
|
||||
if (listener.filter(message)) {
|
||||
listener.processMessage(message);
|
||||
}
|
||||
}
|
||||
|
@ -886,25 +936,25 @@ public class CollaborationSession implements IVenueSession {
|
|||
* @param message
|
||||
*/
|
||||
private void fireCollaborationListeners(IMessage message) {
|
||||
synchronized(collaborationListeners) {
|
||||
for(InternalListener listener : collaborationListeners) {
|
||||
if(listener.filter(message)) {
|
||||
synchronized (collaborationListeners) {
|
||||
for (InternalListener listener : collaborationListeners) {
|
||||
if (listener.filter(message)) {
|
||||
listener.processMessage(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param message
|
||||
*/
|
||||
private void firePresenceListeners(IMessage message) {
|
||||
synchronized(presenceListeners) {
|
||||
if(message instanceof IPresence) {
|
||||
synchronized (presenceListeners) {
|
||||
if (message instanceof IPresence) {
|
||||
IPresence presence = (IPresence) message;
|
||||
for(InternalListener listener : presenceListeners) {
|
||||
if(listener.filter(message)) {
|
||||
for (InternalListener listener : presenceListeners) {
|
||||
if (listener.filter(message)) {
|
||||
listener.processPresence(presence);
|
||||
}
|
||||
}
|
||||
|
@ -920,28 +970,28 @@ public class CollaborationSession implements IVenueSession {
|
|||
private IMessage createMessage(IChatMessage msg) {
|
||||
IMessage message = null;
|
||||
Map props = msg.getProperties();
|
||||
if(props != null) {
|
||||
if (props != null) {
|
||||
Map<String, String> p = new HashMap<String, String>();
|
||||
for(Object k : props.keySet()) {
|
||||
for (Object k : props.keySet()) {
|
||||
Object v = props.get(k);
|
||||
if((k instanceof String) && (v instanceof String)) {
|
||||
p.put((String) k,(String) v);
|
||||
if ((k instanceof String) && (v instanceof String)) {
|
||||
p.put((String) k, (String) v);
|
||||
}
|
||||
}
|
||||
String s = (String) props.get(IMessage.MESSAGE_TYPE);
|
||||
if(IMessage.MessageType.CHAT.name().equals(s)) {
|
||||
if (IMessage.MessageType.CHAT.name().equals(s)) {
|
||||
IQualifiedID to = null;
|
||||
message = new TextMessage(to, msg.getBody());
|
||||
} else if(IMessage.MessageType.COLLABORATION.name().equals(s)) {
|
||||
} else if (IMessage.MessageType.COLLABORATION.name().equals(s)) {
|
||||
IQualifiedID to = null;
|
||||
message = new CollaborationMessage(to, msg.getBody());
|
||||
} else {
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param msg
|
||||
|
@ -949,16 +999,17 @@ public class CollaborationSession implements IVenueSession {
|
|||
*/
|
||||
private IMessage createMessage(IChatRoomMessage msg) {
|
||||
IMessage message = null;
|
||||
|
||||
|
||||
String body = msg.getMessage();
|
||||
if(body != null) {
|
||||
if (body != null) {
|
||||
message = new CollaborationMessage(null, msg.getMessage());
|
||||
|
||||
IChatID cID = (IChatID) msg.getFromID();
|
||||
XMPPRoomID rID = (XMPPRoomID) msg.getChatRoomID();
|
||||
|
||||
|
||||
System.out.println("nickname = " + rID.getNickname());
|
||||
IQualifiedID id = new VenueUserId(cID.getUsername(), rID.getHostname());
|
||||
IQualifiedID id = new VenueUserId(cID.getUsername(),
|
||||
rID.getHostname());
|
||||
message.setFrom(id);
|
||||
}
|
||||
return message;
|
||||
|
|