Issue #244 added work on the chat for presence notifications
Former-commit-id:6f354374d6
[formerly ead836fb1bc7f5843a29dc26cf3d634c80e22a81] Former-commit-id:d264743199
This commit is contained in:
parent
1e4472cd78
commit
c96c33169b
9 changed files with 552 additions and 985 deletions
|
@ -1,5 +1,3 @@
|
||||||
package com.raytheon.uf.viz.collaboration.ui.session;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This software was developed and / or modified by Raytheon Company,
|
* This software was developed and / or modified by Raytheon Company,
|
||||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||||
|
@ -19,8 +17,11 @@ package com.raytheon.uf.viz.collaboration.ui.session;
|
||||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||||
* further licensing information.
|
* further licensing information.
|
||||||
**/
|
**/
|
||||||
|
package com.raytheon.uf.viz.collaboration.data;
|
||||||
|
|
||||||
import org.eclipse.swt.widgets.Composite;
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO Add Description
|
* TODO Add Description
|
||||||
|
@ -31,22 +32,34 @@ import org.eclipse.swt.widgets.Composite;
|
||||||
*
|
*
|
||||||
* Date Ticket# Engineer Description
|
* Date Ticket# Engineer Description
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------ ---------- ----------- --------------------------
|
||||||
* Mar 1, 2012 rferrel Initial creation
|
* Mar 7, 2012 mnash Initial creation
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @author rferrel
|
* @author mnash
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
public class CollaborationSessionComp extends SessionComp {
|
|
||||||
|
|
||||||
public CollaborationSessionComp(Composite parent) {
|
public class CollaborationKeywords {
|
||||||
super(parent);
|
@XmlElement(name = "keyword")
|
||||||
|
List<String> keywords;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param keywords
|
||||||
|
* the keywords to set
|
||||||
|
*/
|
||||||
|
public void setKeywords(List<String> keywords) {
|
||||||
|
this.keywords = keywords;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
/**
|
||||||
public String getRoomLabel() {
|
* @return the keywords
|
||||||
return "(C) - " + getRoom();
|
*/
|
||||||
|
public List<String> getKeywords() {
|
||||||
|
return keywords;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static List<String> parseKeywords() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,237 +0,0 @@
|
||||||
package com.raytheon.uf.viz.collaboration.ui;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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 java.util.Map;
|
|
||||||
|
|
||||||
import org.eclipse.jface.viewers.TreeViewer;
|
|
||||||
import org.eclipse.swt.SWT;
|
|
||||||
import org.eclipse.swt.custom.SashForm;
|
|
||||||
import org.eclipse.swt.events.SelectionEvent;
|
|
||||||
import org.eclipse.swt.events.SelectionListener;
|
|
||||||
import org.eclipse.swt.graphics.Color;
|
|
||||||
import org.eclipse.swt.layout.FillLayout;
|
|
||||||
import org.eclipse.swt.layout.GridData;
|
|
||||||
import org.eclipse.swt.layout.GridLayout;
|
|
||||||
import org.eclipse.swt.widgets.Button;
|
|
||||||
import org.eclipse.swt.widgets.Composite;
|
|
||||||
import org.eclipse.swt.widgets.Label;
|
|
||||||
import org.eclipse.swt.widgets.Menu;
|
|
||||||
import org.eclipse.swt.widgets.MenuItem;
|
|
||||||
import org.eclipse.swt.widgets.Shell;
|
|
||||||
import org.eclipse.swt.widgets.TabFolder;
|
|
||||||
import org.eclipse.swt.widgets.TabItem;
|
|
||||||
|
|
||||||
import com.raytheon.uf.viz.collaboration.data.CollaborationUser;
|
|
||||||
import com.raytheon.uf.viz.collaboration.ui.session.CollaborationSessionComp;
|
|
||||||
import com.raytheon.uf.viz.collaboration.ui.session.SessionComp;
|
|
||||||
import com.raytheon.viz.ui.dialogs.CaveSWTDialogBase;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* TODO Add Description
|
|
||||||
*
|
|
||||||
* <pre>
|
|
||||||
*
|
|
||||||
* SOFTWARE HISTORY
|
|
||||||
*
|
|
||||||
* Date Ticket# Engineer Description
|
|
||||||
* ------------ ---------- ----------- --------------------------
|
|
||||||
* Feb 16, 2012 rferrel Initial creation
|
|
||||||
*
|
|
||||||
* </pre>
|
|
||||||
*
|
|
||||||
* @author rferrel
|
|
||||||
* @version 1.0
|
|
||||||
*/
|
|
||||||
public class CollaborationUsersDlg extends CaveSWTDialogBase {
|
|
||||||
|
|
||||||
private TreeViewer usersTreeViewer;
|
|
||||||
|
|
||||||
private UsersTree usersTree;
|
|
||||||
|
|
||||||
private TabFolder chatTabComp;
|
|
||||||
|
|
||||||
Map<String, String[]> groupMap;
|
|
||||||
|
|
||||||
protected CollaborationUsersDlg(Shell parentShell) {
|
|
||||||
super(parentShell, SWT.DIALOG_TRIM | SWT.RESIZE,
|
|
||||||
CAVE.PERSPECTIVE_INDEPENDENT | CAVE.MODE_INDEPENDENT
|
|
||||||
| CAVE.INDEPENDENT_SHELL);
|
|
||||||
setText("Collaboration Contacts");
|
|
||||||
|
|
||||||
usersTree = new UsersTree("kickstart");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void initializeComponents(Shell shell) {
|
|
||||||
shell.setLayout(new GridLayout(1, false));
|
|
||||||
createMenus(shell);
|
|
||||||
createButtonBar(shell);
|
|
||||||
createMainArea(shell);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createMenus(Shell parent) {
|
|
||||||
Menu bar = new Menu(parent, SWT.BAR);
|
|
||||||
parent.setMenuBar(bar);
|
|
||||||
MenuItem item = new MenuItem(bar, SWT.CASCADE);
|
|
||||||
item.setText("&File");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createButtonBar(Shell parent) {
|
|
||||||
Composite bar = new Composite(parent, SWT.NONE);
|
|
||||||
bar.setLayout(new GridLayout(3, false));
|
|
||||||
Button button = new Button(bar, SWT.DEFAULT);
|
|
||||||
button.setText("Invite");
|
|
||||||
|
|
||||||
button = new Button(bar, SWT.DEFAULT);
|
|
||||||
button.setText("Collobration Chat");
|
|
||||||
button.addSelectionListener(new SelectionListener() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void widgetSelected(SelectionEvent e) {
|
|
||||||
createCollaborationChat();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void widgetDefaultSelected(SelectionEvent e) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
button = new Button(bar, SWT.DEFAULT);
|
|
||||||
button.setText("Private Chat");
|
|
||||||
button.addSelectionListener(new SelectionListener() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void widgetSelected(SelectionEvent e) {
|
|
||||||
createPrivateChat();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void widgetDefaultSelected(SelectionEvent e) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createCollaborationChat() {
|
|
||||||
TabItem item = new TabItem(chatTabComp, SWT.DEFAULT);
|
|
||||||
|
|
||||||
CollaborationSessionComp child = new CollaborationSessionComp(
|
|
||||||
chatTabComp);
|
|
||||||
item.setControl(child);
|
|
||||||
child.setRoom("Collaboration Room");
|
|
||||||
|
|
||||||
item.setText(child.getRoomLabel());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createPrivateChat() {
|
|
||||||
TabItem item = new TabItem(chatTabComp, SWT.DEFAULT);
|
|
||||||
SessionComp child = new SessionComp(chatTabComp);
|
|
||||||
item.setControl(child);
|
|
||||||
child.setRoom("Private room");
|
|
||||||
item.setText("Private Room");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createMainArea(Shell parent) {
|
|
||||||
Composite body = new Composite(parent, SWT.FILL);
|
|
||||||
Color red = getParent().getDisplay().getSystemColor(SWT.COLOR_RED);
|
|
||||||
body.setBackground(red);
|
|
||||||
body.setLayout(new GridLayout());
|
|
||||||
body.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
|
|
||||||
SashForm mainForm = new SashForm(body, SWT.HORIZONTAL);
|
|
||||||
mainForm.setLayout(new FillLayout());
|
|
||||||
mainForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
|
|
||||||
Color blue = getParent().getDisplay().getSystemColor(SWT.COLOR_BLUE);
|
|
||||||
mainForm.setBackground(blue);
|
|
||||||
mainForm.setSashWidth(10);
|
|
||||||
|
|
||||||
createUsersTree(mainForm);
|
|
||||||
createChatTabs(mainForm);
|
|
||||||
mainForm.setWeights(new int[] { 20, 80 });
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createUsersTree(SashForm form) {
|
|
||||||
Composite child = new Composite(form, SWT.NONE);
|
|
||||||
child.setLayout(new GridLayout(1, false));
|
|
||||||
Label label = new Label(child, SWT.NONE);
|
|
||||||
label.setText("Groups");
|
|
||||||
// usersTreeViewer = new TreeViewer(child, SWT.MULTI | SWT.BORDER
|
|
||||||
// | SWT.FILL);
|
|
||||||
usersTreeViewer = new TreeViewer(child);
|
|
||||||
usersTreeViewer.getTree().setToolTipText("User groups");
|
|
||||||
usersTreeViewer.getTree().setLayoutData(
|
|
||||||
new GridData(SWT.FILL, SWT.FILL, true, true));
|
|
||||||
usersTreeViewer.setContentProvider(new UsersTreeContentProvider(
|
|
||||||
/* usersTree */));
|
|
||||||
usersTreeViewer.setLabelProvider(new UsersTreeLabelProvider());
|
|
||||||
usersTreeViewer.setSorter(new UsersTreeViewerSorter());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createChatTabs(SashForm form) {
|
|
||||||
Composite tabComp = new Composite(form, SWT.NONE);
|
|
||||||
tabComp.setLayout(new GridLayout(1, false));
|
|
||||||
|
|
||||||
chatTabComp = new TabFolder(tabComp, SWT.NONE);
|
|
||||||
chatTabComp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void populateUsers() {
|
|
||||||
// TODO get from localization
|
|
||||||
for (String g : new String[] { "Mybuddy1", "buddy1" }) {
|
|
||||||
UsersTree root = usersTree.addChild(g);
|
|
||||||
root.setText(g);
|
|
||||||
for (String u : new String[] { "OAX_user1", "DSM_user3",
|
|
||||||
"LBF_user2" }) {
|
|
||||||
CollaborationUser item = new CollaborationUser(u);
|
|
||||||
root.addChild(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO get from server
|
|
||||||
for (String g : new String[] { "OAX", "DSM", "LBF", "FSD" }) {
|
|
||||||
UsersTree root = usersTree.addChild(g);
|
|
||||||
root.setText(g);
|
|
||||||
for (String u : new String[] { g + "_user2", g + "_user3",
|
|
||||||
g + "_user1" }) {
|
|
||||||
CollaborationUser item = new CollaborationUser(u);
|
|
||||||
root.addChild(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
usersTreeViewer.setInput(usersTree);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void preOpened() {
|
|
||||||
super.preOpened();
|
|
||||||
populateUsers();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void disposed() {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
super.disposed();
|
|
||||||
System.err.println("Contact being disposed.");
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,65 +0,0 @@
|
||||||
package com.raytheon.uf.viz.collaboration.ui;
|
|
||||||
|
|
||||||
import org.eclipse.swt.SWT;
|
|
||||||
import org.eclipse.swt.events.SelectionAdapter;
|
|
||||||
import org.eclipse.swt.events.SelectionEvent;
|
|
||||||
import org.eclipse.swt.layout.RowLayout;
|
|
||||||
import org.eclipse.swt.widgets.Button;
|
|
||||||
import org.eclipse.swt.widgets.Display;
|
|
||||||
import org.eclipse.swt.widgets.Shell;
|
|
||||||
|
|
||||||
import com.raytheon.uf.viz.collaboration.ui.login.LoginDialog;
|
|
||||||
|
|
||||||
public class TestMain {
|
|
||||||
private static CollaborationUsersDlg userDlg;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param args
|
|
||||||
*/
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
Display display = new Display();
|
|
||||||
final Shell shell = new Shell(display);
|
|
||||||
Button button = new Button(shell, SWT.PUSH);
|
|
||||||
button.setText("Log on dialog");
|
|
||||||
button.addSelectionListener(new SelectionAdapter() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void widgetSelected(SelectionEvent ev) {
|
|
||||||
super.widgetSelected(ev);
|
|
||||||
LoginDialog d = new LoginDialog(shell);
|
|
||||||
Object r = d.open();
|
|
||||||
System.err.println("Result: "
|
|
||||||
+ ((r == null) ? null : r.toString()));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
button = new Button(shell, SWT.PUSH);
|
|
||||||
button.setText("Contacts");
|
|
||||||
button.addSelectionListener(new SelectionAdapter() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void widgetSelected(SelectionEvent ev) {
|
|
||||||
super.widgetSelected(ev);
|
|
||||||
if (userDlg == null || userDlg.isDisposed()) {
|
|
||||||
userDlg = new CollaborationUsersDlg(shell);
|
|
||||||
userDlg.open();
|
|
||||||
} else {
|
|
||||||
userDlg.bringToTop();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
shell.setDefaultButton(button);
|
|
||||||
shell.setLayout(new RowLayout());
|
|
||||||
shell.pack();
|
|
||||||
shell.open();
|
|
||||||
|
|
||||||
while (!shell.isDisposed()) {
|
|
||||||
if (!display.readAndDispatch())
|
|
||||||
display.sleep();
|
|
||||||
}
|
|
||||||
display.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,106 +0,0 @@
|
||||||
package com.raytheon.uf.viz.collaboration.ui;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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 java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.raytheon.uf.viz.collaboration.data.CollaborationUser;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* TODO Add Description
|
|
||||||
*
|
|
||||||
* <pre>
|
|
||||||
*
|
|
||||||
* SOFTWARE HISTORY
|
|
||||||
*
|
|
||||||
* Date Ticket# Engineer Description
|
|
||||||
* ------------ ---------- ----------- --------------------------
|
|
||||||
* Mar 1, 2012 rferrel Initial creation
|
|
||||||
*
|
|
||||||
* </pre>
|
|
||||||
*
|
|
||||||
* @author rferrel
|
|
||||||
* @version 1.0
|
|
||||||
*/
|
|
||||||
public class UsersTree {
|
|
||||||
private List<UsersTree> children;
|
|
||||||
|
|
||||||
private String text;
|
|
||||||
|
|
||||||
private CollaborationUser node;
|
|
||||||
|
|
||||||
public UsersTree(String text) {
|
|
||||||
this.text = text;
|
|
||||||
this.children = new LinkedList<UsersTree>();
|
|
||||||
this.node = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public UsersTree(CollaborationUser user) {
|
|
||||||
this.text = user.getId();
|
|
||||||
this.children = null;
|
|
||||||
this.node = user;
|
|
||||||
}
|
|
||||||
|
|
||||||
public UsersTree addChild(String text) {
|
|
||||||
UsersTree child = new UsersTree(text);
|
|
||||||
children.add(child);
|
|
||||||
return child;
|
|
||||||
}
|
|
||||||
|
|
||||||
public UsersTree addChild(CollaborationUser user) {
|
|
||||||
UsersTree child = new UsersTree(user);
|
|
||||||
children.add(child);
|
|
||||||
return child;
|
|
||||||
}
|
|
||||||
|
|
||||||
public UsersTree findChildByText(String text) {
|
|
||||||
CollaborationUser user = new CollaborationUser(text);
|
|
||||||
if (hasChildren()) {
|
|
||||||
for (UsersTree child : children) {
|
|
||||||
if (user.compareTo(child.getUser()) == 0) {
|
|
||||||
return child;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<UsersTree> getChildren() {
|
|
||||||
return this.children;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasChildren() {
|
|
||||||
return children != null && children.size() > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setText(String text) {
|
|
||||||
this.text = text;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getText() {
|
|
||||||
return this.text;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CollaborationUser getUser() {
|
|
||||||
return this.node;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -22,7 +22,10 @@ package com.raytheon.uf.viz.collaboration.ui.session;
|
||||||
|
|
||||||
import org.eclipse.jface.action.Action;
|
import org.eclipse.jface.action.Action;
|
||||||
import org.eclipse.jface.action.ActionContributionItem;
|
import org.eclipse.jface.action.ActionContributionItem;
|
||||||
import org.eclipse.jface.action.IToolBarManager;
|
import org.eclipse.jface.action.IMenuCreator;
|
||||||
|
import org.eclipse.jface.action.IMenuManager;
|
||||||
|
import org.eclipse.swt.widgets.Control;
|
||||||
|
import org.eclipse.swt.widgets.Menu;
|
||||||
|
|
||||||
import com.raytheon.uf.viz.collaboration.data.CollaborationDataManager;
|
import com.raytheon.uf.viz.collaboration.data.CollaborationDataManager;
|
||||||
|
|
||||||
|
@ -47,50 +50,61 @@ public class CollaborationSessionView extends SessionView {
|
||||||
|
|
||||||
private static final String COLLABORATION_SESSION_IMAGE_NAME = "add_correction.gif";
|
private static final String COLLABORATION_SESSION_IMAGE_NAME = "add_correction.gif";
|
||||||
|
|
||||||
private Action switchDataProviderAction;
|
private Action switchToAction;
|
||||||
|
|
||||||
private Action switchLeaderAction;
|
protected void createActions() {
|
||||||
|
super.createActions();
|
||||||
public void createSwitchDataProviderAction() {
|
switchToAction = new Action("Switch to...", Action.AS_DROP_DOWN_MENU) {
|
||||||
switchDataProviderAction = new Action() {
|
|
||||||
public void run() {
|
public void run() {
|
||||||
switchDataProvider();
|
if ("DataProvider".equals(switchToAction.getId())) {
|
||||||
|
switchDataProvider();
|
||||||
|
} else if ("SessionLeader".equals(switchToAction.getId())) {
|
||||||
|
switchLeader();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
IMenuCreator creator = new IMenuCreator() {
|
||||||
|
Menu menu;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Menu getMenu(Menu parent) {
|
||||||
|
if (menu == null) {
|
||||||
|
menu = new Menu(parent);
|
||||||
|
}
|
||||||
|
Action dataProviderAction = new Action("Data Provider") {
|
||||||
|
public void run() {
|
||||||
|
switchToAction.setId("DataProvider");
|
||||||
|
switchToAction.run();
|
||||||
|
};
|
||||||
|
};
|
||||||
|
ActionContributionItem dataProviderItem = new ActionContributionItem(
|
||||||
|
dataProviderAction);
|
||||||
|
dataProviderItem.fill(menu, -1);
|
||||||
|
|
||||||
|
Action leaderAction = new Action("Session Leader") {
|
||||||
|
public void run() {
|
||||||
|
switchToAction.setId("SessionLeader");
|
||||||
|
switchToAction.run();
|
||||||
|
};
|
||||||
|
};
|
||||||
|
ActionContributionItem leaderItem = new ActionContributionItem(
|
||||||
|
leaderAction);
|
||||||
|
leaderItem.fill(menu, -1);
|
||||||
|
return menu;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dispose() {
|
||||||
|
menu.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Menu getMenu(Control parent) {
|
||||||
|
return getMenu(parent.getMenu());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
// TODO find image and use instead of text
|
switchToAction.setMenuCreator(creator);
|
||||||
// switchDataProviderAction.setImageDescriptor(CollaborationUtils
|
|
||||||
// .getImageDescriptor("browser.gif"));
|
|
||||||
switchDataProviderAction.setText("Data");
|
|
||||||
switchDataProviderAction.setToolTipText("Switch Data Provider Request");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void createSwitchLeaderAction() {
|
|
||||||
switchLeaderAction = new Action() {
|
|
||||||
public void run() {
|
|
||||||
switchLeader();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
// TODO find image and use instead of text
|
|
||||||
// switchLeaderAction.setImageDescriptor(CollaborationUtils
|
|
||||||
// .getImageDescriptor("browser.gif"));
|
|
||||||
switchLeaderAction.setText("Leader");
|
|
||||||
switchLeaderAction.setToolTipText("Switch Leader Request");
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void createToolBar() {
|
|
||||||
IToolBarManager mgr = getViewSite().getActionBars().getToolBarManager();
|
|
||||||
createSwitchDataProviderAction();
|
|
||||||
createSwitchLeaderAction();
|
|
||||||
ActionContributionItem item = null;
|
|
||||||
item = new ActionContributionItem(switchDataProviderAction);
|
|
||||||
item.setMode(ActionContributionItem.MODE_FORCE_TEXT);
|
|
||||||
mgr.add(item);
|
|
||||||
item = new ActionContributionItem(switchLeaderAction);
|
|
||||||
item.setMode(ActionContributionItem.MODE_FORCE_TEXT);
|
|
||||||
mgr.add(switchLeaderAction);
|
|
||||||
// item = new ActionContributionItem(sendMessageAction);
|
|
||||||
// item.setMode(ActionContributionItem.MODE_FORCE_TEXT);
|
|
||||||
super.createToolBar();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void switchDataProvider() {
|
public void switchDataProvider() {
|
||||||
|
@ -125,8 +139,19 @@ public class CollaborationSessionView extends SessionView {
|
||||||
CollaborationDataManager.getInstance().getSession(sessionId)
|
CollaborationDataManager.getInstance().getSession(sessionId)
|
||||||
.sendMessageToVenue(message);
|
.sendMessageToVenue(message);
|
||||||
}
|
}
|
||||||
// @Override
|
|
||||||
// public void dispose() {
|
/*
|
||||||
// super.dispose();
|
* (non-Javadoc)
|
||||||
// }
|
*
|
||||||
|
* @see
|
||||||
|
* com.raytheon.uf.viz.collaboration.ui.session.SessionView#fillContextMenu
|
||||||
|
* (org.eclipse.jface.action.IMenuManager)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void fillContextMenu(IMenuManager manager) {
|
||||||
|
super.fillContextMenu(manager);
|
||||||
|
// check if data provider
|
||||||
|
// check if session leader
|
||||||
|
manager.add(switchToAction);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,9 @@ import org.eclipse.swt.graphics.Color;
|
||||||
import org.eclipse.swt.graphics.Font;
|
import org.eclipse.swt.graphics.Font;
|
||||||
import org.eclipse.swt.graphics.Image;
|
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.CollaborationUser;
|
||||||
|
import com.raytheon.uf.viz.collaboration.data.DataUser.RoleType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO Add Description
|
* TODO Add Description
|
||||||
|
@ -49,6 +51,8 @@ import com.raytheon.uf.viz.collaboration.data.CollaborationUser;
|
||||||
public class ParticipantsLabelProvider implements ITableColorProvider,
|
public class ParticipantsLabelProvider implements ITableColorProvider,
|
||||||
ITableFontProvider, ITableLabelProvider {
|
ITableFontProvider, ITableLabelProvider {
|
||||||
|
|
||||||
|
private String sessionId = null;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addListener(ILabelProviderListener listener) {
|
public void addListener(ILabelProviderListener listener) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
@ -64,7 +68,7 @@ public class ParticipantsLabelProvider implements ITableColorProvider,
|
||||||
@Override
|
@Override
|
||||||
public boolean isLabelProperty(Object element, String property) {
|
public boolean isLabelProperty(Object element, String property) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
System.err.println("isLabelProperty");
|
System.out.println("isLabelProperty");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,7 +80,7 @@ public class ParticipantsLabelProvider implements ITableColorProvider,
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Image getColumnImage(Object element, int columnIndex) {
|
public Image getColumnImage(Object element, int columnIndex) {
|
||||||
System.err.println("getColumImage");
|
System.out.println("getColumnImage");
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -84,25 +88,86 @@ public class ParticipantsLabelProvider implements ITableColorProvider,
|
||||||
@Override
|
@Override
|
||||||
public String getColumnText(Object element, int columnIndex) {
|
public String getColumnText(Object element, int columnIndex) {
|
||||||
CollaborationUser user = (CollaborationUser) element;
|
CollaborationUser user = (CollaborationUser) element;
|
||||||
|
RoleType[] roles = user.getRoles(sessionId);
|
||||||
return user.getText();
|
return user.getText();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Font getFont(Object element, int columnIndex) {
|
public Font getFont(Object element, int columnIndex) {
|
||||||
// TODO Auto-generated method stub
|
System.out.println("getFont");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Color getForeground(Object element, int columnIndex) {
|
public Color getForeground(Object element, int columnIndex) {
|
||||||
// TODO Auto-generated method stub
|
CollaborationDataManager.getInstance().getUser(element.toString());
|
||||||
|
System.out.println("getForeground");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Color getBackground(Object element, int columnIndex) {
|
public Color getBackground(Object element, int columnIndex) {
|
||||||
|
System.out.println("getBackground");
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param sessionId
|
||||||
|
* the sessionId to set
|
||||||
|
*/
|
||||||
|
public void setSessionId(String sessionId) {
|
||||||
|
this.sessionId = sessionId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the sessionId
|
||||||
|
*/
|
||||||
|
public String getSessionId() {
|
||||||
|
return sessionId;
|
||||||
|
}
|
||||||
|
// usersList.setLabelProvider(new LabelProvider() {
|
||||||
|
// public String getText(Object element) {
|
||||||
|
// CollaborationUser user = (CollaborationUser) element;
|
||||||
|
// DataUser.RoleType[] roles = user.getRoles(sessionId);
|
||||||
|
// StringBuilder sb = new StringBuilder();
|
||||||
|
// if (roles.length > 0
|
||||||
|
// && roles[0] != DataUser.RoleType.PARTICIPANT) {
|
||||||
|
// sb.append("[");
|
||||||
|
// for (DataUser.RoleType r : roles) {
|
||||||
|
// switch (r) {
|
||||||
|
// case DATA_PROVIDER:
|
||||||
|
// sb.append("D");
|
||||||
|
// break;
|
||||||
|
// case LEADER:
|
||||||
|
// sb.append("L");
|
||||||
|
// break;
|
||||||
|
// default:
|
||||||
|
// sb.append("?");
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// sb.append("] - ");
|
||||||
|
// }
|
||||||
|
// sb.append(user.getId());
|
||||||
|
// return sb.toString();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public Image getImage(Object element) {
|
||||||
|
// Image image = null;
|
||||||
|
// if (element instanceof CollaborationNode) {
|
||||||
|
// CollaborationNode node = (CollaborationNode) element;
|
||||||
|
// String key = node.getImageKey();
|
||||||
|
// if (key != null) {
|
||||||
|
// image = imageMap.get(key);
|
||||||
|
// if (image == null) {
|
||||||
|
// image = CollaborationUtils.getNodeImage(node);
|
||||||
|
// imageMap.put(key, image);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return image;
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,77 @@
|
||||||
|
/**
|
||||||
|
* 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.session;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.eclipse.swt.SWT;
|
||||||
|
import org.eclipse.swt.graphics.Color;
|
||||||
|
import org.eclipse.swt.widgets.Display;
|
||||||
|
|
||||||
|
import com.raytheon.uf.viz.collaboration.data.DataUser.RoleType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO Add Description
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
*
|
||||||
|
* SOFTWARE HISTORY
|
||||||
|
*
|
||||||
|
* Date Ticket# Engineer Description
|
||||||
|
* ------------ ---------- ----------- --------------------------
|
||||||
|
* Mar 6, 2012 mnash Initial creation
|
||||||
|
*
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @author mnash
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class SessionColorAdvisor {
|
||||||
|
private static Map<RoleType, Color> colors = null;
|
||||||
|
|
||||||
|
public static Color getColor(List<RoleType> type, boolean isSelf) {
|
||||||
|
if (colors == null) {
|
||||||
|
colors = new HashMap<RoleType, Color>();
|
||||||
|
colors.put(RoleType.LEADER,
|
||||||
|
Display.getCurrent().getSystemColor(SWT.COLOR_BLUE));
|
||||||
|
colors.put(RoleType.DATA_PROVIDER, Display.getCurrent()
|
||||||
|
.getSystemColor(SWT.COLOR_RED));
|
||||||
|
colors.put(RoleType.PARTICIPANT, Display.getCurrent()
|
||||||
|
.getSystemColor(SWT.COLOR_DARK_GREEN));
|
||||||
|
}
|
||||||
|
if (isSelf) {
|
||||||
|
return Display.getCurrent().getSystemColor(SWT.COLOR_BLACK);
|
||||||
|
}
|
||||||
|
RoleType rType = null;
|
||||||
|
if (type == null || type.isEmpty()) {
|
||||||
|
rType = RoleType.PARTICIPANT;
|
||||||
|
} else if (type.contains(RoleType.LEADER)) {
|
||||||
|
rType = RoleType.LEADER;
|
||||||
|
} else if (type.contains(RoleType.DATA_PROVIDER)) {
|
||||||
|
rType = RoleType.DATA_PROVIDER;
|
||||||
|
} else {
|
||||||
|
rType = RoleType.PARTICIPANT;
|
||||||
|
}
|
||||||
|
return colors.get(rType);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,251 +0,0 @@
|
||||||
package com.raytheon.uf.viz.collaboration.ui.session;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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.jface.viewers.IStructuredContentProvider;
|
|
||||||
import org.eclipse.jface.viewers.LabelProvider;
|
|
||||||
import org.eclipse.jface.viewers.ListViewer;
|
|
||||||
import org.eclipse.jface.viewers.Viewer;
|
|
||||||
import org.eclipse.jface.viewers.ViewerSorter;
|
|
||||||
import org.eclipse.swt.SWT;
|
|
||||||
import org.eclipse.swt.custom.SashForm;
|
|
||||||
import org.eclipse.swt.graphics.Color;
|
|
||||||
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.Label;
|
|
||||||
import org.eclipse.swt.widgets.Text;
|
|
||||||
|
|
||||||
import com.raytheon.uf.viz.collaboration.data.CollaborationUser;
|
|
||||||
import com.raytheon.uf.viz.collaboration.data.DataUser;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* TODO Add Description
|
|
||||||
*
|
|
||||||
* <pre>
|
|
||||||
*
|
|
||||||
* SOFTWARE HISTORY
|
|
||||||
*
|
|
||||||
* Date Ticket# Engineer Description
|
|
||||||
* ------------ ---------- ----------- --------------------------
|
|
||||||
* Mar 1, 2012 rferrel Initial creation
|
|
||||||
*
|
|
||||||
* </pre>
|
|
||||||
*
|
|
||||||
* @author rferrel
|
|
||||||
* @version 1.0
|
|
||||||
*/
|
|
||||||
public class SessionComp extends Composite {
|
|
||||||
protected static Image image;
|
|
||||||
|
|
||||||
private static int SASH_WIDTH = 3;
|
|
||||||
|
|
||||||
private static int SASH_COLOR = SWT.COLOR_DARK_GRAY;
|
|
||||||
|
|
||||||
private ListViewer usersList;
|
|
||||||
|
|
||||||
private Text chatMessages;
|
|
||||||
|
|
||||||
private Text messageToSend;
|
|
||||||
|
|
||||||
private String session;
|
|
||||||
|
|
||||||
public SessionComp(Composite parent) {
|
|
||||||
this(parent, "UNKNOWN");
|
|
||||||
}
|
|
||||||
|
|
||||||
public SessionComp(Composite parent, String session) {
|
|
||||||
super(parent, SWT.NONE);
|
|
||||||
this.session = session;
|
|
||||||
initComponents();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initComponents() {
|
|
||||||
Color sashColor = getParent().getDisplay().getSystemColor(SASH_COLOR);
|
|
||||||
setLayout(new GridLayout(1, false));
|
|
||||||
setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
|
|
||||||
SashForm bar = new SashForm(this, SWT.HORIZONTAL);
|
|
||||||
bar.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
|
|
||||||
bar.setBackground(sashColor);
|
|
||||||
bar.setSashWidth(SASH_WIDTH);
|
|
||||||
|
|
||||||
Composite usersComp = new Composite(bar, SWT.NONE);
|
|
||||||
bar.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
|
|
||||||
Composite messagesComp = new Composite(bar, SWT.NONE);
|
|
||||||
bar.setWeights(new int[] { 20, 80 });
|
|
||||||
|
|
||||||
usersComp.setLayout(new GridLayout(1, false));
|
|
||||||
Label label = null;
|
|
||||||
label = new Label(usersComp, SWT.NONE);
|
|
||||||
label.setText("Participants");
|
|
||||||
|
|
||||||
usersList = new ListViewer(usersComp, SWT.MULTI | SWT.V_SCROLL
|
|
||||||
| SWT.H_SCROLL);
|
|
||||||
usersList.setContentProvider(new IStructuredContentProvider() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void inputChanged(Viewer viewer, Object oldInput,
|
|
||||||
Object newInput) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void dispose() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object[] getElements(Object inputElement) {
|
|
||||||
|
|
||||||
return (CollaborationUser[]) inputElement;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
usersList.setLabelProvider(new LabelProvider() {
|
|
||||||
public String getText(Object element) {
|
|
||||||
CollaborationUser user = (CollaborationUser) element;
|
|
||||||
DataUser.RoleType[] roles = user.getRoles(session);
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
if (roles.length > 0) {
|
|
||||||
sb.append("[");
|
|
||||||
for (DataUser.RoleType r : roles) {
|
|
||||||
switch (r) {
|
|
||||||
case DATA_PROVIDER:
|
|
||||||
sb.append("D");
|
|
||||||
break;
|
|
||||||
case LEADER:
|
|
||||||
sb.append("L");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
sb.append("P");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sb.append("] - ");
|
|
||||||
}
|
|
||||||
sb.append(user.getId());
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
usersList.setSorter(new ViewerSorter() {
|
|
||||||
public int compare(Viewer viewer, Object e1, Object e2) {
|
|
||||||
return super.compare(viewer, e1, e2);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
usersList.getList().setLayoutData(new GridData(GridData.FILL_BOTH));
|
|
||||||
|
|
||||||
CollaborationUser u = new CollaborationUser("OAX_user2");
|
|
||||||
u.addRole(DataUser.RoleType.DATA_PROVIDER);
|
|
||||||
u.addRole(DataUser.RoleType.LEADER);
|
|
||||||
u.setStatus(DataUser.StatusType.AVAILABLE);
|
|
||||||
usersList.add(u);
|
|
||||||
u = new CollaborationUser("OAX_user1");
|
|
||||||
u.addRole(DataUser.RoleType.PARTICIPANT);
|
|
||||||
u.setStatus(DataUser.StatusType.MEETING);
|
|
||||||
usersList.add(u);
|
|
||||||
|
|
||||||
messagesComp.setLayout(new GridLayout(1, false));
|
|
||||||
|
|
||||||
SashForm messagesSash = new SashForm(messagesComp, SWT.VERTICAL);
|
|
||||||
messagesSash
|
|
||||||
.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
|
|
||||||
messagesSash.setBackground(sashColor);
|
|
||||||
messagesSash.setSashWidth(SASH_WIDTH);
|
|
||||||
Composite chatComp = new Composite(messagesSash, SWT.BORDER
|
|
||||||
/* | SWT.H_SCROLL | SWT.V_SCROLL */);
|
|
||||||
Composite sendComp = new Composite(messagesSash, SWT.NONE);
|
|
||||||
messagesSash.setWeights(new int[] { 80, 20 });
|
|
||||||
|
|
||||||
chatComp.setLayout(new GridLayout(1, false));
|
|
||||||
label = new Label(chatComp, SWT.NONE);
|
|
||||||
label.setText("Messages");
|
|
||||||
chatMessages = new Text(chatComp, SWT.MULTI | SWT.READ_ONLY);
|
|
||||||
chatMessages
|
|
||||||
.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
|
|
||||||
chatMessages.setText("Chat messages\n go here.");
|
|
||||||
|
|
||||||
sendComp.setLayout(new GridLayout(1, false));
|
|
||||||
label = new Label(sendComp, SWT.NONE);
|
|
||||||
label.setText("Compose");
|
|
||||||
messageToSend = new Text(sendComp, SWT.MULTI);
|
|
||||||
messageToSend
|
|
||||||
.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
|
|
||||||
messageToSend.setText("send messages go here");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void dispose() {
|
|
||||||
if (image != null) {
|
|
||||||
image.dispose();
|
|
||||||
}
|
|
||||||
super.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addUsers(java.util.List<CollaborationUser> users) {
|
|
||||||
for (CollaborationUser user : users) {
|
|
||||||
addUser(user);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addUser(CollaborationUser user) {
|
|
||||||
usersList.add(user);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void clearUsers() {
|
|
||||||
usersList.getList().removeAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removeUser(CollaborationUser user) {
|
|
||||||
usersList.remove(user);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addMessage(CollaborationUser user, String timestamp,
|
|
||||||
String message) {
|
|
||||||
StringBuilder sb = new StringBuilder("\n");
|
|
||||||
sb.append(user.getId()).append(" (").append(timestamp).append(") ==> ")
|
|
||||||
.append(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sendMessage() {
|
|
||||||
System.out.println("Get and send message here");
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getRoom() {
|
|
||||||
return session;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRoom(String room) {
|
|
||||||
this.session = room;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getRoomLabel() {
|
|
||||||
return "(P) - " + getRoom();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Image getRoomImage() {
|
|
||||||
return image;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void grabFocus() {
|
|
||||||
messageToSend.setFocus();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -20,22 +20,26 @@ package com.raytheon.uf.viz.collaboration.ui.session;
|
||||||
* further licensing information.
|
* further licensing information.
|
||||||
**/
|
**/
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.eclipse.jface.action.Action;
|
import org.eclipse.jface.action.Action;
|
||||||
import org.eclipse.jface.action.IToolBarManager;
|
import org.eclipse.jface.action.IMenuListener;
|
||||||
import org.eclipse.jface.viewers.IStructuredContentProvider;
|
import org.eclipse.jface.action.IMenuManager;
|
||||||
import org.eclipse.jface.viewers.LabelProvider;
|
import org.eclipse.jface.action.MenuManager;
|
||||||
|
import org.eclipse.jface.action.Separator;
|
||||||
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||||
import org.eclipse.jface.viewers.TableViewer;
|
import org.eclipse.jface.viewers.TableViewer;
|
||||||
import org.eclipse.jface.viewers.Viewer;
|
import org.eclipse.jface.viewers.Viewer;
|
||||||
import org.eclipse.jface.viewers.ViewerSorter;
|
import org.eclipse.jface.viewers.ViewerSorter;
|
||||||
import org.eclipse.swt.SWT;
|
import org.eclipse.swt.SWT;
|
||||||
import org.eclipse.swt.custom.SashForm;
|
import org.eclipse.swt.custom.SashForm;
|
||||||
|
import org.eclipse.swt.custom.StyleRange;
|
||||||
import org.eclipse.swt.custom.StyledText;
|
import org.eclipse.swt.custom.StyledText;
|
||||||
import org.eclipse.swt.events.ControlEvent;
|
|
||||||
import org.eclipse.swt.events.ControlListener;
|
|
||||||
import org.eclipse.swt.events.ExpandEvent;
|
import org.eclipse.swt.events.ExpandEvent;
|
||||||
import org.eclipse.swt.events.ExpandListener;
|
import org.eclipse.swt.events.ExpandListener;
|
||||||
import org.eclipse.swt.events.FocusEvent;
|
import org.eclipse.swt.events.FocusEvent;
|
||||||
|
@ -47,21 +51,34 @@ import org.eclipse.swt.graphics.Image;
|
||||||
import org.eclipse.swt.layout.GridData;
|
import org.eclipse.swt.layout.GridData;
|
||||||
import org.eclipse.swt.layout.GridLayout;
|
import org.eclipse.swt.layout.GridLayout;
|
||||||
import org.eclipse.swt.widgets.Composite;
|
import org.eclipse.swt.widgets.Composite;
|
||||||
|
import org.eclipse.swt.widgets.Display;
|
||||||
import org.eclipse.swt.widgets.ExpandBar;
|
import org.eclipse.swt.widgets.ExpandBar;
|
||||||
import org.eclipse.swt.widgets.ExpandItem;
|
import org.eclipse.swt.widgets.ExpandItem;
|
||||||
import org.eclipse.swt.widgets.Label;
|
import org.eclipse.swt.widgets.Label;
|
||||||
|
import org.eclipse.swt.widgets.Menu;
|
||||||
|
import org.eclipse.ui.IPartListener;
|
||||||
|
import org.eclipse.ui.IWorkbenchPage;
|
||||||
|
import org.eclipse.ui.IWorkbenchPart;
|
||||||
|
import org.eclipse.ui.PartInitException;
|
||||||
|
import org.eclipse.ui.PlatformUI;
|
||||||
import org.eclipse.ui.part.ViewPart;
|
import org.eclipse.ui.part.ViewPart;
|
||||||
|
|
||||||
|
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.identity.IMessage;
|
||||||
import com.raytheon.uf.viz.collaboration.comm.identity.IPresence;
|
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.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.IMessageFilter;
|
||||||
import com.raytheon.uf.viz.collaboration.comm.identity.listener.IMessageListener;
|
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.IPresenceListener;
|
||||||
|
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.CollaborationDataManager;
|
||||||
import com.raytheon.uf.viz.collaboration.data.CollaborationNode;
|
import com.raytheon.uf.viz.collaboration.data.CollaborationKeywords;
|
||||||
import com.raytheon.uf.viz.collaboration.data.CollaborationUser;
|
import com.raytheon.uf.viz.collaboration.data.CollaborationUser;
|
||||||
import com.raytheon.uf.viz.collaboration.data.DataUser;
|
import com.raytheon.uf.viz.collaboration.data.DataUser.RoleType;
|
||||||
import com.raytheon.uf.viz.collaboration.ui.CollaborationUtils;
|
import com.raytheon.uf.viz.collaboration.ui.CollaborationUtils;
|
||||||
import com.raytheon.uf.viz.core.VizApp;
|
import com.raytheon.uf.viz.core.VizApp;
|
||||||
import com.raytheon.viz.ui.perspectives.VizPerspectiveListener;
|
import com.raytheon.viz.ui.perspectives.VizPerspectiveListener;
|
||||||
|
@ -82,7 +99,9 @@ import com.raytheon.viz.ui.perspectives.VizPerspectiveListener;
|
||||||
* @author rferrel
|
* @author rferrel
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
public class SessionView extends ViewPart {
|
public class SessionView extends ViewPart implements IPartListener {
|
||||||
|
private static final transient IUFStatusHandler statusHandler = UFStatus
|
||||||
|
.getHandler(SessionView.class);
|
||||||
|
|
||||||
protected static final String SESSION_IMAGE_KEY = "sessionId.key";
|
protected static final String SESSION_IMAGE_KEY = "sessionId.key";
|
||||||
|
|
||||||
|
@ -92,13 +111,11 @@ public class SessionView extends ViewPart {
|
||||||
|
|
||||||
public static final String ID = "com.raytheon.uf.viz.collaboration.SessionView";
|
public static final String ID = "com.raytheon.uf.viz.collaboration.SessionView";
|
||||||
|
|
||||||
protected Composite view;
|
private static int SASH_WIDTH = 5;
|
||||||
|
|
||||||
private static int SASH_WIDTH = 3;
|
|
||||||
|
|
||||||
private static int SASH_COLOR = SWT.COLOR_DARK_GRAY;
|
private static int SASH_COLOR = SWT.COLOR_DARK_GRAY;
|
||||||
|
|
||||||
private TableViewer usersList;
|
private TableViewer usersTable;
|
||||||
|
|
||||||
private StyledText messagesText;
|
private StyledText messagesText;
|
||||||
|
|
||||||
|
@ -106,16 +123,14 @@ public class SessionView extends ViewPart {
|
||||||
|
|
||||||
protected String sessionId;
|
protected String sessionId;
|
||||||
|
|
||||||
private int usersCollapsedHeight = -1;
|
|
||||||
|
|
||||||
private boolean usersExpanding = true;
|
|
||||||
|
|
||||||
private int usersBarExpandedHeight = -1;
|
|
||||||
|
|
||||||
private int[] usersExpandedWeights;
|
|
||||||
|
|
||||||
private Action sendMessageAction;
|
private Action sendMessageAction;
|
||||||
|
|
||||||
|
private Action chatAction;
|
||||||
|
|
||||||
|
protected IPresenceListener presListener;
|
||||||
|
|
||||||
|
protected IMessageListener messageListener;
|
||||||
|
|
||||||
public SessionView() {
|
public SessionView() {
|
||||||
imageMap = new HashMap<String, Image>();
|
imageMap = new HashMap<String, Image>();
|
||||||
}
|
}
|
||||||
|
@ -124,7 +139,8 @@ public class SessionView extends ViewPart {
|
||||||
public void createPartControl(Composite parent) {
|
public void createPartControl(Composite parent) {
|
||||||
setTitleImage(getImage());
|
setTitleImage(getImage());
|
||||||
initComponents(parent);
|
initComponents(parent);
|
||||||
createToolBar();
|
createActions();
|
||||||
|
createContextMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -133,22 +149,85 @@ public class SessionView extends ViewPart {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initComponents(Composite parent) {
|
private void initComponents(Composite parent) {
|
||||||
view = new Composite(parent, SWT.NONE);
|
Composite view = new Composite(parent, SWT.NONE);
|
||||||
Color sashColor = view.getParent().getDisplay()
|
GridLayout layout = new GridLayout(1, false);
|
||||||
.getSystemColor(SASH_COLOR);
|
layout.marginWidth = 0;
|
||||||
view.setLayout(new GridLayout(1, false));
|
GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
|
||||||
view.setLayoutData(new GridData(GridData.FILL_BOTH));
|
view.setLayout(layout);
|
||||||
SashForm bar = new SashForm(view, SWT.VERTICAL);
|
view.setData(data);
|
||||||
bar.setLayoutData(new GridData(GridData.FILL_BOTH));
|
|
||||||
bar.setBackground(sashColor);
|
Color sashColor = Display.getCurrent().getSystemColor(SASH_COLOR);
|
||||||
bar.setSashWidth(SASH_WIDTH);
|
|
||||||
bar.setLayoutData(new GridData(GridData.FILL_BOTH));
|
SashForm sashForm = new SashForm(view, SWT.VERTICAL);
|
||||||
|
layout = new GridLayout(1, false);
|
||||||
|
sashForm.setLayout(layout);
|
||||||
|
data = new GridData(SWT.FILL, SWT.FILL, true, true);
|
||||||
|
sashForm.setLayoutData(data);
|
||||||
|
sashForm.setBackground(sashColor);
|
||||||
|
sashForm.setSashWidth(SASH_WIDTH);
|
||||||
|
|
||||||
createUsersComp(bar);
|
|
||||||
createMessagesComp(bar);
|
|
||||||
createComposeComp(bar);
|
|
||||||
bar.setWeights(new int[] { 5, 85, 10 });
|
|
||||||
createListeners();
|
createListeners();
|
||||||
|
createUsersComp(sashForm);
|
||||||
|
createMessagesComp(sashForm);
|
||||||
|
createComposeComp(sashForm);
|
||||||
|
sashForm.setWeights(new int[] { 1, 20, 5 });
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void createActions() {
|
||||||
|
chatAction = new Action("Chat") {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
PlatformUI
|
||||||
|
.getWorkbench()
|
||||||
|
.getActiveWorkbenchWindow()
|
||||||
|
.getActivePage()
|
||||||
|
.showView(CollaborationSessionView.ID, null,
|
||||||
|
IWorkbenchPage.VIEW_ACTIVATE);
|
||||||
|
// }
|
||||||
|
} catch (PartInitException e) {
|
||||||
|
statusHandler.handle(Priority.PROBLEM,
|
||||||
|
"Unable to open chat", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private void createContextMenu() {
|
||||||
|
MenuManager menuManager = new MenuManager();
|
||||||
|
menuManager.setRemoveAllWhenShown(true);
|
||||||
|
menuManager.addMenuListener(new IMenuListener() {
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see
|
||||||
|
* org.eclipse.jface.action.IMenuListener#menuAboutToShow(org.eclipse
|
||||||
|
* .jface.action.IMenuManager)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void menuAboutToShow(IMenuManager manager) {
|
||||||
|
fillContextMenu(manager);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
Menu menu = menuManager.createContextMenu(usersTable.getControl());
|
||||||
|
usersTable.getControl().setMenu(menu);
|
||||||
|
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
|
||||||
|
.getActivePart().getSite()
|
||||||
|
.registerContextMenu(menuManager, usersTable);
|
||||||
|
usersTable.getTable().setMenu(menu);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void fillContextMenu(IMenuManager manager) {
|
||||||
|
IStructuredSelection selection = (IStructuredSelection) usersTable
|
||||||
|
.getSelection();
|
||||||
|
// do something here!
|
||||||
|
Object ob = selection.getFirstElement();
|
||||||
|
manager.add(chatAction);
|
||||||
|
manager.add(new Separator());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -158,248 +237,178 @@ public class SessionView extends ViewPart {
|
||||||
*/
|
*/
|
||||||
private void createListeners() {
|
private void createListeners() {
|
||||||
sessionId = getViewSite().getSecondaryId();
|
sessionId = getViewSite().getSecondaryId();
|
||||||
setPartName(CollaborationDataManager.getInstance()
|
if (CollaborationDataManager.getInstance().getSession(sessionId) != null) {
|
||||||
.getSession(sessionId).getVenue().getInfo().getVenueName());
|
setPartName(CollaborationDataManager.getInstance()
|
||||||
|
.getSession(sessionId).getVenue().getInfo().getVenueName());
|
||||||
|
// Attach desired listeners to the session
|
||||||
|
ISession session = CollaborationDataManager.getInstance()
|
||||||
|
.getSession(sessionId);
|
||||||
|
messageListener = new IMessageListener() {
|
||||||
|
|
||||||
// Attach desired listeners to the session
|
@Override
|
||||||
ISession session = CollaborationDataManager.getInstance().getSession(
|
public void processMessage(final IMessage message) {
|
||||||
sessionId);
|
VizApp.runAsync(new Runnable() {
|
||||||
session.addMessageListener(new IMessageListener() {
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void processMessage(final IMessage message) {
|
public void run() {
|
||||||
VizApp.runAsync(new Runnable() {
|
addMessage(message.getFrom().getName(),
|
||||||
|
message.getTimeStamp(), message.getBody());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
session.addMessageListener(messageListener, new IMessageFilter() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public boolean filter(IMessage message) {
|
||||||
addMessage(message.getFrom().getFQName(),
|
return true;
|
||||||
message.getTimeStamp(), message.getBody());
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
presListener = new IPresenceListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void notifyPresence(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()
|
||||||
|
.getParticipants();
|
||||||
|
final List<CollaborationUser> users = new ArrayList<CollaborationUser>();
|
||||||
|
for (IVenueParticipant part : participants) {
|
||||||
|
CollaborationUser user = new CollaborationUser(
|
||||||
|
part.getName());
|
||||||
|
user.setText(user.getId());
|
||||||
|
users.add(user);
|
||||||
}
|
}
|
||||||
});
|
VizApp.runAsync(new Runnable() {
|
||||||
}
|
@Override
|
||||||
}, new IMessageFilter() {
|
public void run() {
|
||||||
|
usersTable.setInput(users
|
||||||
|
.toArray(new CollaborationUser[users.size()]));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
};
|
||||||
|
session.addPresenceListener(presListener, new IMessageFilter() {
|
||||||
|
@Override
|
||||||
|
public boolean filter(IMessage message) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
});
|
||||||
public boolean filter(IMessage message) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// TODO populate participants table
|
|
||||||
session.addPresenceListener(new IPresenceListener() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void notifyPresence(IPresence presence) {
|
|
||||||
System.out.println(presence.getMode());
|
|
||||||
System.out.println(presence.getType());
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}, new IMessageFilter() {
|
|
||||||
@Override
|
|
||||||
public boolean filter(IMessage message) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
// for (String id : users) {
|
|
||||||
// CollaborationUser user = new CollaborationUser(id, sessionId);
|
|
||||||
// usersList.add(user);
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setUsersHeight(ExpandBar bar) {
|
|
||||||
ExpandItem item = bar.getItem(0);
|
|
||||||
|
|
||||||
// Composite comp = (Composite) item.getControl();
|
|
||||||
// GridLayout gl = (GridLayout) comp.getLayout();
|
|
||||||
int y = bar.getSize().y;
|
|
||||||
// y -= usersCollapsedHeight + 0 * gl.verticalSpacing + gl.marginBottom;
|
|
||||||
y -= usersCollapsedHeight;
|
|
||||||
if (y < usersCollapsedHeight) {
|
|
||||||
y = usersCollapsedHeight;
|
|
||||||
}
|
}
|
||||||
item.setHeight(y);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createUsersComp(Composite parent) {
|
private void createUsersComp(Composite parent) {
|
||||||
Composite comp = new Composite(parent, SWT.NONE);
|
Composite comp = new Composite(parent, SWT.NONE);
|
||||||
comp.setLayout(new GridLayout(1, false));
|
GridLayout layout = new GridLayout(1, false);
|
||||||
comp.setLayoutData(new GridData(GridData.FILL_BOTH));
|
GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
|
||||||
comp.addControlListener(new ControlListener() {
|
comp.setLayout(layout);
|
||||||
|
comp.setLayoutData(data);
|
||||||
|
|
||||||
@Override
|
ExpandBar usersBar = new ExpandBar(comp, SWT.NONE);
|
||||||
public void controlResized(ControlEvent e) {
|
layout = new GridLayout(1, false);
|
||||||
if (usersExpanding) {
|
data = new GridData(SWT.FILL, SWT.FILL, true, true);
|
||||||
// Expand control listener is adjusting the height.
|
usersBar.setLayout(layout);
|
||||||
usersExpanding = false;
|
usersBar.setLayoutData(data);
|
||||||
} else {
|
Image usersImage = Display.getCurrent().getSystemImage(SWT.ICON_SEARCH);
|
||||||
Composite comp = (Composite) e.getSource();
|
|
||||||
ExpandBar bar = (ExpandBar) comp.getChildren()[0];
|
|
||||||
usersBarExpandedHeight = comp.getSize().y;
|
|
||||||
bar.setSize(bar.getSize().x, usersBarExpandedHeight);
|
|
||||||
setUsersHeight(bar);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
final Composite usersComp = new Composite(usersBar, SWT.NONE);
|
||||||
public void controlMoved(ControlEvent e) {
|
layout = new GridLayout(1, false);
|
||||||
}
|
data = new GridData(SWT.FILL, SWT.FILL, true, true);
|
||||||
});
|
usersComp.setLayout(layout);
|
||||||
|
usersComp.setLayoutData(data);
|
||||||
|
|
||||||
ExpandBar usersBar = new ExpandBar(comp, SWT.BORDER | SWT.V_SCROLL);
|
ExpandItem usersItem = new ExpandItem(usersBar, SWT.NONE);
|
||||||
usersBar.setLayoutData(new GridData(GridData.FILL_BOTH));
|
|
||||||
Image usersImage = parent.getParent().getDisplay()
|
|
||||||
.getSystemImage(SWT.ICON_SEARCH);
|
|
||||||
|
|
||||||
Composite usersComp = new Composite(usersBar, SWT.NONE);
|
|
||||||
usersComp.setLayout(new GridLayout(1, false));
|
|
||||||
usersComp.addControlListener(new ControlListener() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void controlResized(ControlEvent e) {
|
|
||||||
System.err.println("controlResized: " + e.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void controlMoved(ControlEvent e) {
|
|
||||||
System.err.println("controlMoved: " + e.toString());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
ExpandItem usersItem = new ExpandItem(usersBar, SWT.DEFAULT);
|
|
||||||
usersItem.setText("Participants");
|
usersItem.setText("Participants");
|
||||||
usersItem.setControl(usersComp);
|
|
||||||
usersItem.setImage(usersImage);
|
usersItem.setImage(usersImage);
|
||||||
|
|
||||||
usersBar.addExpandListener(new ExpandListener() {
|
usersBar.addExpandListener(new ExpandListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void itemExpanded(ExpandEvent e) {
|
public void itemExpanded(ExpandEvent e) {
|
||||||
usersExpanding = true;
|
usersComp.setSize(usersTable.getTable().computeSize(
|
||||||
ExpandBar bar = (ExpandBar) e.getSource();
|
SWT.DEFAULT, 500));
|
||||||
SashForm form = (SashForm) bar.getParent().getParent();
|
((SashForm) usersComp.getParent().getParent().getParent())
|
||||||
form.setWeights(usersExpandedWeights);
|
.layout();
|
||||||
bar.setSize(bar.getSize().x, usersBarExpandedHeight);
|
|
||||||
setUsersHeight(bar);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void itemCollapsed(ExpandEvent e) {
|
public void itemCollapsed(ExpandEvent e) {
|
||||||
usersExpanding = true;
|
usersComp.setSize(usersTable.getTable().computeSize(
|
||||||
ExpandBar bar = (ExpandBar) e.getSource();
|
SWT.DEFAULT, 100));
|
||||||
SashForm form = (SashForm) bar.getParent().getParent();
|
|
||||||
ExpandItem item = bar.getItem(0);
|
|
||||||
usersExpandedWeights = form.getWeights();
|
|
||||||
Composite c = (Composite) item.getControl();
|
|
||||||
GridLayout gl = (GridLayout) c.getLayout();
|
|
||||||
int y = usersCollapsedHeight + 6 * gl.verticalSpacing
|
|
||||||
+ gl.marginBottom;
|
|
||||||
|
|
||||||
item.setHeight(y);
|
((SashForm) usersComp.getParent().getParent().getParent())
|
||||||
int[] wts = usersExpandedWeights.clone();
|
.layout();
|
||||||
wts[0] = y;
|
|
||||||
wts[1] += usersExpandedWeights[0] - y;
|
|
||||||
form.setWeights(wts);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
usersList = new TableViewer(usersComp, SWT.BORDER | SWT.SINGLE
|
usersTable = new TableViewer(usersComp, SWT.BORDER | SWT.SINGLE
|
||||||
| SWT.V_SCROLL | SWT.H_SCROLL);
|
| SWT.V_SCROLL | SWT.H_SCROLL);
|
||||||
usersList.setContentProvider(new IStructuredContentProvider() {
|
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);
|
||||||
|
|
||||||
@Override
|
usersItem.setHeight(usersComp.computeSize(SWT.DEFAULT, SWT.DEFAULT).y);
|
||||||
public void inputChanged(Viewer viewer, Object oldInput,
|
usersItem.setControl(usersComp);
|
||||||
Object newInput) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
ParticipantsContentProvider contentProvider = new ParticipantsContentProvider();
|
||||||
public void dispose() {
|
ParticipantsLabelProvider labelProvider = new ParticipantsLabelProvider();
|
||||||
}
|
labelProvider.setSessionId(sessionId);
|
||||||
|
usersTable.setContentProvider(contentProvider);
|
||||||
|
|
||||||
@Override
|
usersTable.setLabelProvider(labelProvider);
|
||||||
public Object[] getElements(Object inputElement) {
|
usersTable.setSorter(new ViewerSorter() {
|
||||||
|
|
||||||
return (CollaborationUser[]) inputElement;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
usersList.setLabelProvider(new LabelProvider() {
|
|
||||||
public String getText(Object element) {
|
|
||||||
CollaborationUser user = (CollaborationUser) element;
|
|
||||||
DataUser.RoleType[] roles = user.getRoles(sessionId);
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
if (roles.length > 0
|
|
||||||
&& roles[0] != DataUser.RoleType.PARTICIPANT) {
|
|
||||||
sb.append("[");
|
|
||||||
for (DataUser.RoleType r : roles) {
|
|
||||||
switch (r) {
|
|
||||||
case DATA_PROVIDER:
|
|
||||||
sb.append("D");
|
|
||||||
break;
|
|
||||||
case LEADER:
|
|
||||||
sb.append("L");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
sb.append("?");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sb.append("] - ");
|
|
||||||
}
|
|
||||||
sb.append(user.getId());
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Image getImage(Object element) {
|
|
||||||
Image image = null;
|
|
||||||
if (element instanceof CollaborationNode) {
|
|
||||||
CollaborationNode node = (CollaborationNode) element;
|
|
||||||
String key = node.getImageKey();
|
|
||||||
if (key != null) {
|
|
||||||
image = imageMap.get(key);
|
|
||||||
if (image == null) {
|
|
||||||
image = CollaborationUtils.getNodeImage(node);
|
|
||||||
imageMap.put(key, image);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return image;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
usersList.setSorter(new ViewerSorter() {
|
|
||||||
public int compare(Viewer viewer, Object e1, Object e2) {
|
public int compare(Viewer viewer, Object e1, Object e2) {
|
||||||
// return ((CollaborationUser) e1)
|
|
||||||
// .compareTo((CollaborationUser) e1);
|
|
||||||
return super.compare(viewer, e1, e2);
|
return super.compare(viewer, e1, e2);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
usersList.getTable().setLayoutData(new GridData(GridData.FILL_BOTH));
|
IVenueSession session = CollaborationDataManager.getInstance()
|
||||||
usersCollapsedHeight = usersComp.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
|
.getSession(sessionId);
|
||||||
usersItem.setHeight(usersCollapsedHeight);
|
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);
|
||||||
|
}
|
||||||
|
usersTable.setInput(users.toArray(new CollaborationUser[users.size()]));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createMessagesComp(Composite parent) {
|
private void createMessagesComp(Composite parent) {
|
||||||
Composite messagesComp = new Composite(parent, SWT.BORDER);
|
Composite messagesComp = new Composite(parent, SWT.NONE);
|
||||||
messagesComp.setLayout(new GridLayout(1, false));
|
GridLayout layout = new GridLayout(1, false);
|
||||||
|
messagesComp.setLayout(layout);
|
||||||
Label label = new Label(messagesComp, SWT.NONE);
|
Label label = new Label(messagesComp, SWT.NONE);
|
||||||
label.setText("Messages");
|
|
||||||
|
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(":");
|
||||||
|
labelInfo.append(info.getVenueSubject());
|
||||||
|
}
|
||||||
|
label.setText(labelInfo.toString());
|
||||||
messagesText = new StyledText(messagesComp, SWT.MULTI | SWT.WRAP
|
messagesText = new StyledText(messagesComp, SWT.MULTI | SWT.WRAP
|
||||||
| SWT.READ_ONLY | SWT.H_SCROLL | SWT.V_SCROLL);
|
| SWT.READ_ONLY | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
|
||||||
messagesText.setLayoutData(new GridData(GridData.FILL_BOTH));
|
messagesText.setLayoutData(new GridData(GridData.FILL_BOTH));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createComposeComp(Composite parent) {
|
private void createComposeComp(Composite parent) {
|
||||||
Composite composeComp = new Composite(parent, SWT.BORDER);
|
Composite composeComp = new Composite(parent, SWT.NONE);
|
||||||
composeComp.setLayout(new GridLayout(1, false));
|
GridLayout layout = new GridLayout(1, false);
|
||||||
|
composeComp.setLayout(layout);
|
||||||
Label label = new Label(composeComp, SWT.NONE);
|
Label label = new Label(composeComp, SWT.NONE);
|
||||||
label.setText("Compose");
|
label.setText("Compose:");
|
||||||
composeText = new StyledText(composeComp, SWT.MULTI | SWT.WRAP
|
composeText = new StyledText(composeComp, SWT.MULTI | SWT.WRAP
|
||||||
| SWT.H_SCROLL | SWT.V_SCROLL);
|
| SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
|
||||||
composeText.setLayoutData(new GridData(GridData.FILL_BOTH));
|
composeText.setLayoutData(new GridData(GridData.FILL_BOTH));
|
||||||
|
composeText.setToolTipText("Enter message here");
|
||||||
composeText.addKeyListener(new KeyListener() {
|
composeText.addKeyListener(new KeyListener() {
|
||||||
private boolean keyPressed;
|
private boolean keyPressed;
|
||||||
|
|
||||||
|
@ -413,7 +422,8 @@ public class SessionView extends ViewPart {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void keyPressed(KeyEvent e) {
|
public void keyPressed(KeyEvent e) {
|
||||||
if (!keyPressed && e.keyCode == SWT.CR) {
|
if (!keyPressed
|
||||||
|
&& (e.keyCode == SWT.CR || e.keyCode == SWT.KEYPAD_CR)) {
|
||||||
sendMessage();
|
sendMessage();
|
||||||
}
|
}
|
||||||
if (e.keyCode == SWT.SHIFT) {
|
if (e.keyCode == SWT.SHIFT) {
|
||||||
|
@ -454,6 +464,14 @@ public class SessionView extends ViewPart {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dispose() {
|
public void dispose() {
|
||||||
|
if (messageListener != null) {
|
||||||
|
CollaborationDataManager.getInstance().getSession(sessionId)
|
||||||
|
.removeMessageListener(messageListener);
|
||||||
|
}
|
||||||
|
if (presListener != null) {
|
||||||
|
CollaborationDataManager.getInstance().getSession(sessionId)
|
||||||
|
.removePresenceListener(presListener);
|
||||||
|
}
|
||||||
for (String key : imageMap.keySet()) {
|
for (String key : imageMap.keySet()) {
|
||||||
imageMap.get(key).dispose();
|
imageMap.get(key).dispose();
|
||||||
}
|
}
|
||||||
|
@ -469,26 +487,62 @@ public class SessionView extends ViewPart {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addUser(CollaborationUser user) {
|
public void addUser(CollaborationUser user) {
|
||||||
usersList.add(user);
|
usersTable.add(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearUsers() {
|
public void clearUsers() {
|
||||||
usersList.getTable().removeAll();
|
usersTable.getTable().removeAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeUser(CollaborationUser user) {
|
public void removeUser(CollaborationUser user) {
|
||||||
usersList.remove(user);
|
usersTable.remove(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addMessage(String user, long timestamp, String message) {
|
public void addMessage(String user, long timestamp, String message) {
|
||||||
Calendar cal = Calendar.getInstance();
|
Calendar cal = Calendar.getInstance();
|
||||||
cal.setTimeInMillis(timestamp);
|
cal.setTimeInMillis(timestamp);
|
||||||
String time = String.format("%1$tI:%1$tM:%1$tS %1$Tp", cal);
|
String time = String.format("%1$tI:%1$tM:%1$tS %1$Tp", cal);
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
if (messagesText.getCharCount() != 0) {
|
||||||
|
sb.append("\n");
|
||||||
|
}
|
||||||
|
int offset = 0;
|
||||||
|
sb.append("(").append(time).append(") ");
|
||||||
|
offset = sb.length();
|
||||||
|
|
||||||
StringBuilder sb = new StringBuilder("\n");
|
sb.append(user).append(": ").append(message);
|
||||||
sb.append(user).append(" (").append(time).append(") ==> ")
|
|
||||||
.append(message);
|
// here is the place to put the font and color changes for keywords
|
||||||
|
// read in localization file once and then don't read in again, per chat
|
||||||
|
// room?
|
||||||
|
List<String> keywords = CollaborationKeywords.parseKeywords();
|
||||||
|
List<StyleRange> ranges = new ArrayList<StyleRange>();
|
||||||
|
if (keywords != null) {
|
||||||
|
for (String keyword : keywords) {
|
||||||
|
if (sb.toString().toLowerCase().contains(keyword.toLowerCase())) {
|
||||||
|
StyleRange keywordRange = new StyleRange(
|
||||||
|
messagesText.getCharCount()
|
||||||
|
+ sb.toString().toLowerCase()
|
||||||
|
.indexOf(keyword.toLowerCase()),
|
||||||
|
keyword.length(), null, null, SWT.BOLD | SWT.ITALIC);
|
||||||
|
ranges.add(keywordRange);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// XXX determine from the user data
|
||||||
|
// get self
|
||||||
|
List<RoleType> type = new ArrayList<RoleType>();
|
||||||
|
type.add(RoleType.LEADER);
|
||||||
|
Color color = SessionColorAdvisor.getColor(type, false);
|
||||||
|
StyleRange range = new StyleRange(messagesText.getCharCount() + offset,
|
||||||
|
user.length() + 1, color, null, SWT.BOLD);
|
||||||
messagesText.append(sb.toString());
|
messagesText.append(sb.toString());
|
||||||
|
messagesText.setStyleRange(range);
|
||||||
|
for (StyleRange newRange : ranges) {
|
||||||
|
messagesText.setStyleRange(newRange);
|
||||||
|
}
|
||||||
|
messagesText.setTopIndex(messagesText.getLineCount() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendMessage() {
|
public void sendMessage() {
|
||||||
|
@ -509,42 +563,34 @@ public class SessionView extends ViewPart {
|
||||||
return sessionId;
|
return sessionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRoom(String room) {
|
|
||||||
this.sessionId = room;
|
|
||||||
setPartName(room);
|
|
||||||
// setTitleImage(getImage());
|
|
||||||
}
|
|
||||||
|
|
||||||
protected String getSessionImageName() {
|
protected String getSessionImageName() {
|
||||||
return SESSION_IMAGE_NAME;
|
return SESSION_IMAGE_NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendMessageAction() {
|
@Override
|
||||||
sendMessageAction = new Action() {
|
public void partActivated(IWorkbenchPart part) {
|
||||||
public void run() {
|
// nothing to do
|
||||||
sendMessage();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
// TODO this the image we want?
|
|
||||||
sendMessageAction.setImageDescriptor(CollaborationUtils
|
|
||||||
.getImageDescriptor("icon_show_advanced_prop.png"));
|
|
||||||
sendMessageAction.setToolTipText("Send Message");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void createToolBar() {
|
@Override
|
||||||
IToolBarManager mgr = getViewSite().getActionBars().getToolBarManager();
|
public void partBroughtToTop(IWorkbenchPart part) {
|
||||||
sendMessageAction();
|
// TODO
|
||||||
// switchDataProviderAction();
|
// if link with editor is on, need to activate the editor
|
||||||
// switchLeaderAction();
|
}
|
||||||
// ActionContributionItem item = null;
|
|
||||||
// item = new ActionContributionItem(switchDataProviderAction);
|
@Override
|
||||||
// item.setMode(ActionContributionItem.MODE_FORCE_TEXT);
|
public void partClosed(IWorkbenchPart part) {
|
||||||
// mgr.add(item);
|
// TODO
|
||||||
// item = new ActionContributionItem(switchLeaderAction);
|
// here you need to end a session that is a temporary session
|
||||||
// item.setMode(ActionContributionItem.MODE_FORCE_TEXT);
|
}
|
||||||
// mgr.add(switchLeaderAction);
|
|
||||||
// // item = new ActionContributionItem(sendMessageAction);
|
@Override
|
||||||
// // item.setMode(ActionContributionItem.MODE_FORCE_TEXT);
|
public void partDeactivated(IWorkbenchPart part) {
|
||||||
mgr.add(sendMessageAction);
|
// nothing to do
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void partOpened(IWorkbenchPart part) {
|
||||||
|
// nothing to do
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue