();
}
public String getUser() {
@@ -78,6 +75,10 @@ public class LoginData {
return status;
}
+ public String getServer() {
+ return server;
+ }
+
public String getMessage() {
return statusMessage;
}
diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/login/LoginDialog.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/login/LoginDialog.java
index c2d5a9f8c5..2810f933bc 100644
--- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/login/LoginDialog.java
+++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/login/LoginDialog.java
@@ -59,23 +59,40 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
* @version 1.0
*/
public class LoginDialog extends CaveSWTDialog {
+ // TODO get default user, server, status and message from localized file.
private static DataUser.StatusType[] status = null;
private Text userTF;
- private Label serverTF;
+ private Text serverTF;
+
+ private Button serverButton;
private Text passwordTF;
- private Combo statusC;
+ private Combo statusCombo;
private Text messageTF;
+ private Button logOnButton;
+
+ private String DEFAULT_SERVER = "awipscm.omaha.us.ray.com";
+
+ private Control[] noServerList;
+
+ private Control[] withServerList;
+
+ private LoginData loginData;
+
public LoginDialog(Shell parentShell) {
super(parentShell);
setText("Collaboration Server Log On");
}
+ public void setLoginData(LoginData loginData) {
+ this.loginData = loginData;
+ }
+
private Control createDialogArea(Composite parent) {
if (status == null) {
DataUser.StatusType[] types = DataUser.StatusType.values();
@@ -97,24 +114,55 @@ public class LoginDialog extends CaveSWTDialog {
userTF = new Text(body, SWT.BORDER);
gd = new GridData(SWT.FILL, SWT.FILL, true, true);
// Set minimum width one time and the fill will handle the other fields.
- gd.minimumWidth = 200;
+ gd.horizontalSpan = 2;
userTF.setLayoutData(gd);
- label = new Label(body, SWT.NONE);
label = new Label(body, SWT.NONE);
label.setText("Server: ");
- serverTF = new Label(body, SWT.NONE);
- serverTF.setLayoutData(new GridData(SWT.DEFAULT, SWT.CENTER, true,
- false));
- serverTF.setText("awipscm.omaha.us.ray.com");
- Button serverButton = new Button(body, SWT.PUSH);
- serverButton.setText("Server ...");
+ serverTF = new Text(body, SWT.BORDER);
+ gd = new GridData(SWT.FILL, SWT.FILL, true, true);
+ // Set minimum width one time and the fill will handle the other fields.
+ gd.minimumWidth = 200;
+ serverTF.setLayoutData(gd);
+ serverTF.setText(DEFAULT_SERVER);
+ serverTF.setEditable(false);
+ serverTF.setBackground(parent.getBackground());
+ serverButton = new Button(body, SWT.PUSH);
+ serverButton.setText("Edit");
+ gd = new GridData(SWT.FILL, SWT.FILL, true, true);
+ gd.minimumWidth = 45;
+ serverButton.setLayoutData(gd);
serverButton.setToolTipText("Change Server");
serverButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
- System.out.println("Change server here.");
+ if ("OK".equals(serverButton.getText())) {
+ serverButton.setText("Edit");
+ serverButton.setToolTipText("Change Server");
+ serverTF.setEditable(false);
+ serverTF.setBackground(serverTF.getParent().getBackground());
+ String server = serverTF.getText().trim();
+ if (server.length() == 0) {
+ serverTF.setText(DEFAULT_SERVER);
+ } else {
+ serverTF.setText(server);
+ DEFAULT_SERVER = server;
+ }
+ serverTF.clearSelection();
+ serverTF.getParent().setTabList(noServerList);
+ logOnButton.setEnabled(true);
+ } else {
+ serverButton.setText("OK");
+ serverButton
+ .setToolTipText("Implement Change.\nEmpty field restores previous server.");
+ serverTF.setEditable(true);
+ serverTF.setBackground(null);
+ serverTF.selectAll();
+ serverTF.setFocus();
+ serverTF.getParent().setTabList(withServerList);
+ logOnButton.setEnabled(false);
+ }
}
@Override
@@ -125,37 +173,41 @@ public class LoginDialog extends CaveSWTDialog {
label = new Label(body, SWT.NONE);
label.setText("Password: ");
passwordTF = new Text(body, SWT.PASSWORD | SWT.BORDER);
- passwordTF.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ gd = new GridData(SWT.FILL, SWT.FILL, true, true);
+ gd.horizontalSpan = 2;
+ passwordTF.setLayoutData(gd);
passwordTF.setTextLimit(32);
- label = new Label(body, SWT.NONE);
+
label = new Label(body, SWT.NONE);
label.setText("Status: ");
- statusC = new Combo(body, SWT.DEFAULT);
+ statusCombo = new Combo(body, SWT.DEFAULT);
- // TODO get status messages form config file?
+ // TODO get status messages from config file?
for (DataUser.StatusType type : status) {
- statusC.add(type.value());
+ statusCombo.add(type.value());
}
-
- statusC.select(0);
+ statusCombo.select(0);
label = new Label(body, SWT.NONE);
label = new Label(body, SWT.NONE);
label.setText("Message: ");
messageTF = new Text(body, SWT.BORDER);
- // messageTF
- // .setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
- messageTF.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ gd = new GridData(SWT.FILL, SWT.FILL, true, true);
+ gd.horizontalSpan = 2;
+ messageTF.setLayoutData(gd);
+
+ noServerList = new Control[] { userTF, passwordTF, statusCombo,
+ messageTF, serverButton };
+ withServerList = new Control[] { userTF, serverTF, serverButton,
+ passwordTF, statusCombo, messageTF };
+ body.setTabList(noServerList);
return body;
}
@Override
protected void initializeComponents(Shell shell) {
shell.setLayout(new GridLayout(1, false));
- // GridData gd = new GridData();
- // gd.
- // shell.setLayoutData(gd);
createDialogArea(shell);
createButtonBar(shell);
}
@@ -163,11 +215,10 @@ public class LoginDialog extends CaveSWTDialog {
private void createButtonBar(Composite parent) {
GridData gd = null;
Composite bar = new Composite(parent, SWT.NONE);
- // bar.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_RED));
gd = new GridData(SWT.CENTER, SWT.DEFAULT, true, false);
bar.setLayout(new GridLayout(0, true));
bar.setLayoutData(gd);
- createButton(bar, IDialogConstants.OK_ID, "Log On", true);
+ logOnButton = createButton(bar, IDialogConstants.OK_ID, "Log On", true);
createButton(bar, IDialogConstants.CANCEL_ID,
IDialogConstants.CANCEL_LABEL, false);
@@ -176,6 +227,13 @@ public class LoginDialog extends CaveSWTDialog {
@Override
protected void preOpened() {
super.preOpened();
+ if (loginData != null) {
+ userTF.setText(loginData.getUser());
+ serverTF.setText(loginData.getServer());
+ statusCombo.select(statusCombo.indexOf(loginData.getStatus()
+ .value()));
+ messageTF.setText(loginData.getMessage());
+ }
userTF.setFocus();
}
@@ -256,9 +314,10 @@ public class LoginDialog extends CaveSWTDialog {
passwordTF.setText("");
}
if (focusField == null) {
- setReturnValue(new LoginData(user, server, password,
- status[statusC.getSelectionIndex()], messageTF
- .getText().trim()));
+ loginData = new LoginData(user, server, password,
+ status[statusCombo.getSelectionIndex()],
+ messageTF.getText().trim());
+ setReturnValue(loginData);
LoginDialog.this.getShell().dispose();
} else {
StringBuilder sb = new StringBuilder();
diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/AbstractSessionView.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/AbstractSessionView.java
new file mode 100644
index 0000000000..b6d8bae1ae
--- /dev/null
+++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/AbstractSessionView.java
@@ -0,0 +1,317 @@
+/**
+ * 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.Map;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.SashForm;
+import org.eclipse.swt.custom.StyledText;
+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.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.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.ui.IPartListener;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.part.ViewPart;
+
+import com.raytheon.uf.viz.collaboration.ui.CollaborationUtils;
+import com.raytheon.viz.ui.perspectives.VizPerspectiveListener;
+
+/**
+ * This performs most of the work for creating a View for a peer-to-peer or
+ * multi-user session.
+ *
+ *
+ *
+ * SOFTWARE HISTORY
+ *
+ * Date Ticket# Engineer Description
+ * ------------ ---------- ----------- --------------------------
+ * Mar 16, 2012 244 rferrel Initial creation
+ *
+ *
+ *
+ * @author rferrel
+ * @version 1.0
+ */
+
+public abstract class AbstractSessionView extends ViewPart implements
+ IPartListener {
+ private static final String SESSION_IMAGE_KEY = "sessionId.key";
+
+ /**
+ * Mapping of images used in the view so they are not constantly created and
+ * allowing them to be disposed.
+ */
+ protected Map imageMap;
+
+ private static int SASH_WIDTH = 5;
+
+ private static int SASH_COLOR = SWT.COLOR_DARK_GRAY;
+
+ protected StyledText messagesText;
+
+ private StyledText composeText;
+
+ // protected Action chatAction;
+
+ protected abstract String getSessionImageName();
+
+ protected abstract String getSessionName();
+
+ // protected abstract void populateSashForm(SashForm sashForm);
+
+ public abstract void sendMessage();
+
+ protected abstract void setMessageLabel(Label label);
+
+ public AbstractSessionView() {
+ imageMap = new HashMap();
+ }
+
+ private void initComponents(Composite parent) {
+ Composite sashComp = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout(1, false);
+ GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
+ sashComp.setLayout(layout);
+ sashComp.setLayoutData(data);
+
+ Color sashColor = Display.getCurrent().getSystemColor(SASH_COLOR);
+
+ SashForm sashForm = new SashForm(sashComp, SWT.VERTICAL);
+ layout = new GridLayout(1, false);
+ data = new GridData(SWT.FILL, SWT.FILL, true, true);
+ sashForm.setLayout(layout);
+ sashForm.setLayoutData(data);
+ sashForm.setBackground(sashColor);
+ sashForm.setSashWidth(SASH_WIDTH);
+
+ createListeners();
+ populateSashForm(sashForm);
+ }
+
+ /**
+ * A Subclass must override this method to set sashForm's weight and to add
+ * other components.
+ *
+ * @param sashForm
+ */
+ protected void populateSashForm(SashForm sashForm) {
+ createMessagesComp(sashForm);
+ createComposeComp(sashForm);
+ }
+
+ protected void createListeners() {
+ }
+
+ private void createMessagesComp(Composite parent) {
+ Composite messagesComp = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout(1, false);
+ messagesComp.setLayout(layout);
+ // TODO, wrap label in view
+ Label label = new Label(messagesComp, SWT.WRAP);
+ setMessageLabel(label);
+ 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));
+ }
+
+ protected 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
+ | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
+ composeText.setLayoutData(new GridData(GridData.FILL_BOTH));
+ composeText.setToolTipText("Enter message here");
+ composeText.addKeyListener(new KeyListener() {
+ private boolean keyPressed;
+
+ @Override
+ public void keyReleased(KeyEvent e) {
+ if (e.keyCode == SWT.SHIFT) {
+ keyPressed = false;
+ }
+ // do nothing, all done on key pressed
+ }
+
+ @Override
+ public void keyPressed(KeyEvent e) {
+ if (!keyPressed
+ && (e.keyCode == SWT.CR || e.keyCode == SWT.KEYPAD_CR)) {
+ sendMessage();
+ }
+ if (e.keyCode == SWT.SHIFT) {
+ keyPressed = true;
+ }
+ }
+ });
+
+ composeText.addFocusListener(new FocusListener() {
+
+ @Override
+ public void focusLost(FocusEvent e) {
+ // Restore other perspective's key bindings.
+ VizPerspectiveListener.getCurrentPerspectiveManager()
+ .activateContexts();
+ }
+
+ @Override
+ public void focusGained(FocusEvent e) {
+ // Remove other perspective's key bindings.
+ VizPerspectiveListener.getCurrentPerspectiveManager()
+ .deactivateContexts();
+ }
+ });
+ }
+
+ private Image getImage() {
+ Image image = imageMap.get(SESSION_IMAGE_KEY);
+ if (image == null) {
+ image = CollaborationUtils
+ .getImageDescriptor(getSessionImageName()).createImage();
+ if (image != null) {
+ imageMap.put(SESSION_IMAGE_KEY, image);
+ }
+ }
+ return image;
+ }
+
+ /**
+ * Get the composed message and clear the text.
+ *
+ * @return message
+ */
+ protected String getComposedMessage() {
+ String message = composeText.getText().trim();
+ composeText.setText("");
+ composeText.setCaretOffset(0);
+ return message;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ui.IPartListener#partActivated(org.eclipse.ui.IWorkbenchPart)
+ */
+ @Override
+ public void partActivated(IWorkbenchPart part) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ui.IPartListener#partBroughtToTop(org.eclipse.ui.IWorkbenchPart
+ * )
+ */
+ @Override
+ public void partBroughtToTop(IWorkbenchPart part) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ui.IPartListener#partClosed(org.eclipse.ui.IWorkbenchPart)
+ */
+ @Override
+ public void partClosed(IWorkbenchPart part) {
+ getViewSite().getWorkbenchWindow().getPartService()
+ .removePartListener(this);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ui.IPartListener#partDeactivated(org.eclipse.ui.IWorkbenchPart
+ * )
+ */
+ @Override
+ public void partDeactivated(IWorkbenchPart part) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ui.IPartListener#partOpened(org.eclipse.ui.IWorkbenchPart)
+ */
+ @Override
+ public void partOpened(IWorkbenchPart part) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets
+ * .Composite)
+ */
+ @Override
+ public void createPartControl(Composite parent) {
+ setTitleImage(getImage());
+ setPartName(getSessionName());
+ initComponents(parent);
+ }
+
+ @Override
+ public void dispose() {
+ for (Image im : imageMap.values()) {
+ im.dispose();
+ }
+ imageMap.clear();
+ imageMap = null;
+ super.dispose();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.part.WorkbenchPart#setFocus()
+ */
+ @Override
+ public void setFocus() {
+ composeText.setFocus();
+ }
+
+}
diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/CollaborationSessionView.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/CollaborationSessionView.java
index db8e8e82bc..8e427722e5 100644
--- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/CollaborationSessionView.java
+++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/CollaborationSessionView.java
@@ -25,8 +25,11 @@ import org.eclipse.jface.action.ActionContributionItem;
import org.eclipse.jface.action.IMenuCreator;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Menu;
+import com.raytheon.uf.viz.collaboration.comm.identity.IVenueSession;
+import com.raytheon.uf.viz.collaboration.comm.identity.info.IVenueInfo;
import com.raytheon.uf.viz.collaboration.data.CollaborationDataManager;
/**
@@ -54,7 +57,8 @@ public class CollaborationSessionView extends SessionView {
protected void createActions() {
super.createActions();
- switchToAction = new Action("Switch to...", Action.AS_DROP_DOWN_MENU) {
+ switchToAction = new Action("Transfer Role...",
+ Action.AS_DROP_DOWN_MENU) {
public void run() {
if ("DataProvider".equals(switchToAction.getId())) {
switchDataProvider();
@@ -128,16 +132,11 @@ public class CollaborationSessionView extends SessionView {
*/
@Override
public void sendMessage() {
- String message = null;
- message = composeText.getText().trim();
- composeText.setText("");
- composeText.setCaretOffset(0);
- if (message.length() == 0) {
- // Do not send empty messages.
- return;
+ String message = getComposedMessage();
+ if (message.length() > 0) {
+ CollaborationDataManager.getInstance().getSession(sessionId)
+ .sendMessageToVenue(message);
}
- CollaborationDataManager.getInstance().getSession(sessionId)
- .sendMessageToVenue(message);
}
/*
@@ -154,4 +153,23 @@ public class CollaborationSessionView extends SessionView {
// check if session leader
manager.add(switchToAction);
}
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.raytheon.uf.viz.collaboration.ui.session.AbstractSessionView#
+ * setMessageLabel(org.eclipse.swt.widgets.Label)
+ */
+ @Override
+ protected void setMessageLabel(Label label) {
+ StringBuilder labelInfo = new StringBuilder();
+ 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());
+ }
}
diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/PeerToPeerView.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/PeerToPeerView.java
new file mode 100644
index 0000000000..8cb586b503
--- /dev/null
+++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/PeerToPeerView.java
@@ -0,0 +1,190 @@
+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.action.IMenuManager;
+import org.eclipse.swt.custom.SashForm;
+import org.eclipse.swt.widgets.Label;
+
+import com.raytheon.uf.common.status.IUFStatusHandler;
+import com.raytheon.uf.common.status.UFStatus;
+import com.raytheon.uf.viz.collaboration.comm.identity.ISession;
+import com.raytheon.uf.viz.collaboration.comm.identity.listener.IMessageListener;
+import com.raytheon.uf.viz.collaboration.data.CollaborationDataManager;
+
+/**
+ * TODO Add Description
+ *
+ *
+ *
+ * SOFTWARE HISTORY
+ *
+ * Date Ticket# Engineer Description
+ * ------------ ---------- ----------- --------------------------
+ * Mar 1, 2012 rferrel Initial creation
+ *
+ *
+ *
+ * @author rferrel
+ * @version 1.0
+ */
+public class PeerToPeerView extends AbstractSessionView {
+ private static final transient IUFStatusHandler statusHandler = UFStatus
+ .getHandler(PeerToPeerView.class);
+
+ private static final String PEER_TO_PEER_IMAGE_NAME = "chats.gif";
+
+ public static final String ID = "com.raytheon.uf.viz.collaboration.PeerToPeerView";
+
+ protected IMessageListener messageListener;
+
+ public PeerToPeerView() {
+ super();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.raytheon.uf.viz.collaboration.ui.session.AbstractSessionView#
+ * populateSashForm(org.eclipse.swt.custom.SashForm)
+ */
+ protected void populateSashForm(SashForm sashForm) {
+ super.populateSashForm(sashForm);
+ sashForm.setWeights(new int[] { 20, 5 });
+ }
+
+ protected void createActions() {
+ // TODO create peer-to-peer chat action here
+ // chatAction = new Action("Chat") {
+ // @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, session,
+ // 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();
+ // System.out.println(ob.toString());
+ // manager.add(chatAction);
+ // manager.add(new Separator());
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.raytheon.uf.viz.collaboration.ui.session.AbstractSessionView#
+ * setMessageLabel(org.eclipse.swt.widgets.Label)
+ */
+ protected void setMessageLabel(Label label) {
+ StringBuilder labelInfo = new StringBuilder();
+ labelInfo.append("Private Chat");
+ label.setText(labelInfo.toString());
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * com.raytheon.uf.viz.collaboration.ui.session.AbstractSessionView#sendMessage
+ * ()
+ */
+ public void sendMessage() {
+ String toUser = getViewSite().getSecondaryId();
+ String message = getComposedMessage();
+ if (message.length() > 0) {
+ // Get any open session to send peer-to-peer message
+ ISession session = CollaborationDataManager.getInstance()
+ .getSession(null);
+ if (session != null) {
+ session.sendTextMessage(toUser, message);
+ } else {
+ session = CollaborationDataManager.getInstance()
+ .getSessionManager().createPeerToPeerSession();
+ // session.sendTextMessage(toUser, message);
+ // session.close();
+ }
+ }
+ }
+
+ protected String getSessionImageName() {
+ return PEER_TO_PEER_IMAGE_NAME;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.raytheon.uf.viz.collaboration.ui.session.AbstractSessionView#
+ * getSessionName()
+ */
+ @Override
+ protected String getSessionName() {
+ return getViewSite().getSecondaryId();
+ }
+}
diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/SessionView.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/SessionView.java
index 3fc16ba921..d9bbea94f7 100644
--- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/SessionView.java
+++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/SessionView.java
@@ -23,15 +23,12 @@ package com.raytheon.uf.viz.collaboration.ui.session;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collection;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
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.Viewer;
@@ -40,11 +37,6 @@ 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.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;
@@ -59,14 +51,10 @@ import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.TableItem;
-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;
import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.part.ViewPart;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
@@ -83,9 +71,7 @@ import com.raytheon.uf.viz.collaboration.data.CollaborationDataManager;
import com.raytheon.uf.viz.collaboration.data.CollaborationKeywords;
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;
import com.raytheon.uf.viz.core.VizApp;
-import com.raytheon.viz.ui.perspectives.VizPerspectiveListener;
/**
* TODO Add Description
@@ -103,28 +89,16 @@ import com.raytheon.viz.ui.perspectives.VizPerspectiveListener;
* @author rferrel
* @version 1.0
*/
-public class SessionView extends ViewPart implements IPartListener {
+public class SessionView extends AbstractSessionView {
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(SessionView.class);
- protected static final String SESSION_IMAGE_KEY = "sessionId.key";
-
private static final String SESSION_IMAGE_NAME = "chats.gif";
- protected Map imageMap;
-
public static final String ID = "com.raytheon.uf.viz.collaboration.SessionView";
- private static int SASH_WIDTH = 5;
-
- private static int SASH_COLOR = SWT.COLOR_DARK_GRAY;
-
private TableViewer usersTable;
- private StyledText messagesText;
-
- protected StyledText composeText;
-
protected String sessionId;
private Image downArrow;
@@ -135,53 +109,29 @@ public class SessionView extends ViewPart implements IPartListener {
private Image highlightedDownArrow;
- private Action chatAction;
+ protected Action chatAction;
protected IVenueParticipantListener participantListener;
protected IMessageListener messageListener;
public SessionView() {
- imageMap = new HashMap();
+ super();
}
@Override
public void createPartControl(Composite parent) {
- setTitleImage(getImage());
- initComponents(parent);
+ super.createPartControl(parent);
createActions();
createContextMenu();
}
@Override
- public void setFocus() {
- composeText.setFocus();
- }
-
- private void initComponents(Composite parent) {
- Composite sashComp = new Composite(parent, SWT.NONE);
- GridLayout layout = new GridLayout(1, false);
- GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
- sashComp.setLayout(layout);
- sashComp.setLayoutData(data);
-
- Color sashColor = Display.getCurrent().getSystemColor(SASH_COLOR);
-
- SashForm sashForm = new SashForm(sashComp, SWT.VERTICAL);
- layout = new GridLayout(1, false);
- data = new GridData(SWT.FILL, SWT.FILL, true, true);
- sashForm.setLayout(layout);
- sashForm.setLayoutData(data);
- sashForm.setBackground(sashColor);
- sashForm.setSashWidth(SASH_WIDTH);
-
- createListeners();
+ protected void populateSashForm(SashForm sashForm) {
createArrows();
createUsersComp(sashForm);
- createMessagesComp(sashForm);
- createComposeComp(sashForm);
+ super.populateSashForm(sashForm);
sashForm.setWeights(new int[] { 1, 20, 5 });
-
}
protected void createActions() {
@@ -243,8 +193,9 @@ public class SessionView extends ViewPart implements IPartListener {
// do something here!
Object ob = selection.getFirstElement();
System.out.println(ob.toString());
- manager.add(chatAction);
- manager.add(new Separator());
+ // super.fillContextMenu(manager);
+ // manager.add(chatAction);
+ // manager.add(new Separator());
}
/**
@@ -252,15 +203,16 @@ public class SessionView extends ViewPart implements IPartListener {
*
* @param sessionId
*/
- private void createListeners() {
- this.getViewSite().getWorkbenchWindow().getPartService()
- .addPartListener(this);
-
- sessionId = getViewSite().getSecondaryId();
+ @Override
+ protected void createListeners() {
+ // this.getViewSite().getWorkbenchWindow().getPartService()
+ // .addPartListener(this);
+ super.createListeners();
+ // sessionId = getViewSite().getSecondaryId();
IVenueSession session = CollaborationDataManager.getInstance()
.getSession(sessionId);
if (session != null) {
- setPartName(session.getVenue().getInfo().getVenueDescription());
+ // setPartName(session.getVenue().getInfo().getVenueDescription());
messageListener = new IMessageListener() {
@Override
@@ -327,25 +279,10 @@ public class SessionView extends ViewPart implements IPartListener {
}
};
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(final Composite parent) {
+ protected 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);
@@ -496,122 +433,123 @@ public class SessionView extends ViewPart implements IPartListener {
((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);
- // TODO, wrap label in view
- Label label = new Label(messagesComp, SWT.WRAP);
+ // protected void createMessagesComp(Composite parent) {
+ // Composite messagesComp = new Composite(parent, SWT.NONE);
+ // GridLayout layout = new GridLayout(1, false);
+ // messagesComp.setLayout(layout);
+ // // TODO, wrap label in view
+ // Label label = new Label(messagesComp, SWT.WRAP);
+ //
+ // StringBuilder labelInfo = new StringBuilder();
+ // IVenueSession session = CollaborationDataManager.getInstance()
+ // .getSession(sessionId);
+ // if (session != null) {
+ // IVenueInfo info = session.getVenue().getInfo();
+ // labelInfo.append(info.getVenueSubject());
+ // label.setToolTipText(info.getVenueSubject());
+ // }
+ // 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());
+ // }
- StringBuilder labelInfo = new StringBuilder();
- IVenueSession session = CollaborationDataManager.getInstance()
- .getSession(sessionId);
- if (session != null) {
- IVenueInfo info = session.getVenue().getInfo();
- labelInfo.append(info.getVenueSubject());
- label.setToolTipText(info.getVenueSubject());
- }
- 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));
+ // protected 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
+ // | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
+ // composeText.setLayoutData(new GridData(GridData.FILL_BOTH));
+ // composeText.setToolTipText("Enter message here");
+ // composeText.addKeyListener(new KeyListener() {
+ // private boolean keyPressed;
+ //
+ // @Override
+ // public void keyReleased(KeyEvent e) {
+ // if (e.keyCode == SWT.SHIFT) {
+ // keyPressed = false;
+ // }
+ // // do nothing, all done on key pressed
+ // }
+ //
+ // @Override
+ // public void keyPressed(KeyEvent e) {
+ // if (!keyPressed
+ // && (e.keyCode == SWT.CR || e.keyCode == SWT.KEYPAD_CR)) {
+ // sendMessage();
+ // }
+ // if (e.keyCode == SWT.SHIFT) {
+ // keyPressed = true;
+ // }
+ // }
+ // });
+ //
+ // composeText.addFocusListener(new FocusListener() {
+ //
+ // @Override
+ // public void focusLost(FocusEvent e) {
+ // // Restore other perspective's key bindings.
+ // VizPerspectiveListener.getCurrentPerspectiveManager()
+ // .activateContexts();
+ // }
+ //
+ // @Override
+ // public void focusGained(FocusEvent e) {
+ // // Remove other perspective's key bindings.
+ // VizPerspectiveListener.getCurrentPerspectiveManager()
+ // .deactivateContexts();
+ // }
+ // });
+ //
+ // IVenueSession session = CollaborationDataManager.getInstance()
+ // .getSession(sessionId);
+ // if (session == null) {
+ // composeComp.setEnabled(false);
+ // composeText.setEnabled(false);
+ // label.setEnabled(false);
+ // }
+ // }
- 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
- | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
- composeText.setLayoutData(new GridData(GridData.FILL_BOTH));
- composeText.setToolTipText("Enter message here");
- composeText.addKeyListener(new KeyListener() {
- private boolean keyPressed;
-
- @Override
- public void keyReleased(KeyEvent e) {
- if (e.keyCode == SWT.SHIFT) {
- keyPressed = false;
- }
- // do nothing, all done on key pressed
- }
-
- @Override
- public void keyPressed(KeyEvent e) {
- if (!keyPressed
- && (e.keyCode == SWT.CR || e.keyCode == SWT.KEYPAD_CR)) {
- sendMessage();
- }
- if (e.keyCode == SWT.SHIFT) {
- keyPressed = true;
- }
- }
- });
-
- composeText.addFocusListener(new FocusListener() {
-
- @Override
- public void focusLost(FocusEvent e) {
- // Restore other perspective's key bindings.
- VizPerspectiveListener.getCurrentPerspectiveManager()
- .activateContexts();
- }
-
- @Override
- public void focusGained(FocusEvent e) {
- // Remove other perspective's key bindings.
- VizPerspectiveListener.getCurrentPerspectiveManager()
- .deactivateContexts();
- }
- });
-
- IVenueSession session = CollaborationDataManager.getInstance()
- .getSession(sessionId);
- if (session == null) {
- composeComp.setEnabled(false);
- composeText.setEnabled(false);
- label.setEnabled(false);
- }
- }
-
- private Image getImage() {
- Image image = imageMap.get(SESSION_IMAGE_KEY);
- if (image == null) {
- image = CollaborationUtils
- .getImageDescriptor(getSessionImageName()).createImage();
- if (image != null) {
- imageMap.put(SESSION_IMAGE_KEY, image);
- }
- }
- return image;
- }
+ // private Image getImage() {
+ // Image image = imageMap.get(SESSION_IMAGE_KEY);
+ // if (image == null) {
+ // image = CollaborationUtils
+ // .getImageDescriptor(getSessionImageName()).createImage();
+ // if (image != null) {
+ // imageMap.put(SESSION_IMAGE_KEY, image);
+ // }
+ // }
+ // return image;
+ // }
@Override
public void dispose() {
- if (messageListener != null) {
- CollaborationDataManager.getInstance().getSession(sessionId)
- .removeMessageListener(messageListener);
- }
+ // if (messageListener != null) {
+ // CollaborationDataManager.getInstance().getSession(sessionId)
+ // .removeMessageListener(messageListener);
+ // }
+ // for (Image im : imageMap.values()) {
+ // im.dispose();
+ // }
+ //
+ // imageMap.clear();
+ // imageMap = null;
+
if (participantListener != null) {
CollaborationDataManager.getInstance().getSession(sessionId)
.removeVenueParticipantListener(participantListener);
}
- for (Image im : imageMap.values()) {
- im.dispose();
- }
-
- imageMap.clear();
- imageMap = null;
// dispose of the images first
disposeArrow(highlightedDownArrow);
@@ -661,8 +599,8 @@ public class SessionView extends ViewPart implements IPartListener {
sb.append(user).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?
+ // read in localization file once and then don't read in again, per
+ // chat room?
List keywords = CollaborationKeywords.parseKeywords();
List ranges = new ArrayList();
if (keywords != null) {
@@ -704,18 +642,21 @@ public class SessionView extends ViewPart implements IPartListener {
// placeholder for future things
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * com.raytheon.uf.viz.collaboration.ui.session.AbstractSessionView#sendMessage
+ * ()
+ */
public void sendMessage() {
- String message = null;
- message = composeText.getText().trim();
- composeText.setText("");
- composeText.setCaretOffset(0);
- if (message.length() == 0) {
- // Do not send empty messages.
- return;
+ String message = getComposedMessage();
+ if (message.length() > 0) {
+ // CollaborationDataManager.getInstance().getSession(sessionId)
+ // .sendTextMessage(message);
+ CollaborationDataManager.getInstance().getSession(sessionId)
+ .sendMessageToVenue(message);
}
- CollaborationDataManager.getInstance().getSession(sessionId)
- .sendTextMessage(message);
-
}
public String getRoom() {
@@ -737,32 +678,33 @@ public class SessionView extends ViewPart implements IPartListener {
// if link with editor is on, need to activate the editor
}
- @Override
+ // @Override
public void partClosed(IWorkbenchPart part) {
+ super.partClosed(part);
// TODO
// here you need to end a session that is a temporary session
IVenueSession session = CollaborationDataManager.getInstance()
.getSession(sessionId);
if (session != null) {
- session.removeMessageListener(messageListener);
- for (IMessageListener list : session.getMessageListeners()) {
- session.removeMessageListener(list);
- }
+ // session.removeMessageListener(messageListener);
+ // for (IMessageListener list : session.getMessageListeners()) {
+ // session.removeMessageListener(list);
+ // }
session.removeVenueParticipantListener(participantListener);
}
- this.getViewSite().getWorkbenchWindow().getPartService()
- .removePartListener(this);
+ // this.getViewSite().getWorkbenchWindow().getPartService()
+ // .removePartListener(this);
}
- @Override
- public void partDeactivated(IWorkbenchPart part) {
- // nothing to do
- }
-
- @Override
- public void partOpened(IWorkbenchPart part) {
- // nothing to do
- }
+ // @Override
+ // public void partDeactivated(IWorkbenchPart part) {
+ // // nothing to do
+ // }
+ //
+ // @Override
+ // public void partOpened(IWorkbenchPart part) {
+ // // nothing to do
+ // }
private void createArrows() {
int imgWidth = 11;
@@ -814,4 +756,41 @@ public class SessionView extends ViewPart implements IPartListener {
gc.drawPolygon(polyArray);
}
}
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.raytheon.uf.viz.collaboration.ui.session.AbstractSessionView#
+ * setMessageLabel(org.eclipse.swt.widgets.Label)
+ */
+ @Override
+ protected void setMessageLabel(Label label) {
+ StringBuilder labelInfo = new StringBuilder();
+ labelInfo.append("Private Chat: ");
+ 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());
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.raytheon.uf.viz.collaboration.ui.session.AbstractSessionView#
+ * getSessionName()
+ */
+ @Override
+ protected String getSessionName() {
+ sessionId = getViewSite().getSecondaryId();
+ IVenueSession session = CollaborationDataManager.getInstance()
+ .getSession(sessionId);
+ if (session == null) {
+ return sessionId;
+ }
+ return session.getVenue().getInfo().getVenueDescription();
+ }
}