Issue #244 Close Session connction when view closed. Tighen up dialogs.

Change-Id: I874058fde36f521cfd4bbbf602798896b6887be5

Former-commit-id: 486b2186014a14a845e48dac222c293a7891e39e
This commit is contained in:
Roger Ferrel 2012-03-14 09:26:23 -05:00
parent 39bce3d793
commit c321d2aacf
5 changed files with 143 additions and 77 deletions

View file

@ -23,7 +23,9 @@ import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Shell;
import com.raytheon.uf.common.status.IUFStatusHandler;
@ -54,7 +56,8 @@ import com.raytheon.uf.viz.core.VizApp;
*/
/**
* TODO Add Description
* This class contains information on user and session connections that can then
* be used by more then one veiw.
*
* <pre>
*
@ -99,6 +102,13 @@ public class CollaborationDataManager {
return instance;
}
/**
* Converts the venu's Id into a string that usable for a view's secondary
* ID. This is the used as the key in the session Map.
*
* @param venuId
* @return sessionId
*/
public String venuIdToSessionId(String venuId) {
return venuId.replace(':', ';');
}
@ -130,6 +140,7 @@ public class CollaborationDataManager {
* @return manager or null if unable to get connection.
*/
synchronized public SessionManager getSessionManager() {
// Get log on to server information and make connection.
if (manager == null) {
VizApp.runSync(new Runnable() {
@ -154,6 +165,7 @@ public class CollaborationDataManager {
loginId = loginData.getAccount();
DataUser user = CollaborationDataManager
.getInstance().getUser(loginId);
// TODO set status and message here.
user.status = loginData.getStatus();
user.statusMessage = loginData.getMessage();
} catch (Exception e) {
@ -161,6 +173,10 @@ public class CollaborationDataManager {
// revise as appropriate.
statusHandler.handle(Priority.PROBLEM,
e.getLocalizedMessage(), e);
MessageBox box = new MessageBox(shell, SWT.ERROR);
box.setText("Log On Failed");
box.setMessage(e.toString());
box.open();
e.printStackTrace();
}
}
@ -192,7 +208,26 @@ public class CollaborationDataManager {
}
/**
* @return sessionId
* Closes connection to the session.
*
* @param sessionId
*/
public void closeSession(String sessionId) {
IVenueSession session = sessionsMap.get(sessionId);
if (session != null) {
sessionsMap.remove(sessionId);
session.close();
}
}
/**
* Generate a new session with
*
* @param venue
* - Session name
* @param subject
* - Sessin topic
* @return sessionId or null if unable to create session
*/
public String createCollaborationSession(String venue, String subject) {
SessionManager manager = getSessionManager();

View file

@ -34,6 +34,7 @@ import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.viewers.DoubleClickEvent;
import org.eclipse.jface.viewers.IDoubleClickListener;
import org.eclipse.jface.viewers.IStructuredSelection;
@ -122,6 +123,8 @@ public class CollaborationGroupView extends ViewPart {
private Action addUserAction;
private Action selectGroups;
private Action removeGroupAction;
private Action removeUserAction;
@ -238,14 +241,20 @@ public class CollaborationGroupView extends ViewPart {
addUserAction.setImageDescriptor(CollaborationUtils
.getImageDescriptor("add_contact.gif"));
addGroupAction = new Action("Add Group") {
addGroupAction = new Action("Create Group") {
public void run() {
System.out.println("Add group");
System.out.println("Create Group here");
};
};
addGroupAction.setImageDescriptor(CollaborationUtils
.getImageDescriptor("add_group.gif"));
selectGroups = new Action("Select System Groups...") {
public void run() {
System.out.println("Select System Groups to Display...");
}
};
changeMessageAction = new Action("Change Message...") {
public void run() {
System.out.println("Change message");
@ -378,9 +387,14 @@ public class CollaborationGroupView extends ViewPart {
}
private void createMenu(IMenuManager mgr) {
mgr.add(addGroupAction);
mgr.add(addUserAction);
mgr.add(selectGroups);
mgr.add(new Separator());
mgr.add(changeStatusAction);
mgr.add(changeMessageAction);
mgr.add(changePasswordAction);
mgr.add(new Separator());
mgr.add(logoutAction);
}

View file

@ -44,7 +44,7 @@ import org.eclipse.swt.widgets.Text;
import com.raytheon.uf.viz.collaboration.comm.identity.info.IVenueInfo;
import com.raytheon.uf.viz.collaboration.data.CollaborationDataManager;
import com.raytheon.uf.viz.collaboration.data.DataUser;
import com.raytheon.viz.ui.dialogs.CaveSWTDialogBase;
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
/**
* TODO Add Description
@ -62,7 +62,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialogBase;
* @author rferrel
* @version 1.0
*/
public class CreateSessionDialog extends CaveSWTDialogBase {
public class CreateSessionDialog extends CaveSWTDialog {
private static DataUser.StatusType[] status = null;
private Text nameTF;
@ -97,29 +97,29 @@ public class CreateSessionDialog extends CaveSWTDialogBase {
}
Composite body = new Composite(parent, SWT.NONE);
body.setLayout(new GridLayout(2, false));
body.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL
| GridData.HORIZONTAL_ALIGN_FILL));
// body.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL
// | GridData.HORIZONTAL_ALIGN_FILL));
Label label = null;
label = new Label(body, SWT.NONE);
label.setText("Name: ");
nameTF = new Text(body, SWT.BORDER);
nameTF.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL
| GridData.HORIZONTAL_ALIGN_FILL));
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
gd.minimumWidth = 200;
nameTF.setLayoutData(gd);
label = new Label(body, SWT.NONE);
label.setText("Subject: ");
subjectTF = new Text(body, SWT.BORDER);
subjectTF.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL
| GridData.HORIZONTAL_ALIGN_FILL));
subjectTF.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
if (showInvite) {
inviteUsers = new Button(body, SWT.CHECK);
inviteUsers.setText("Invite Selected Users");
inviteUsers.setSelection(showInvite);
inviteUsers.setVisible(showInvite);
inviteUsers.setSelection(true);
inviteUsers.setVisible(true);
label = new Label(body, SWT.NONE);
label.setText("");
label.setVisible(showInvite);
if (showInvite) {
inviteLabel = new Label(body, SWT.NONE);
inviteLabel.setText("Invite Message: ");
inviteMessageTF = new StyledText(body, SWT.BORDER | SWT.MULTI
@ -127,7 +127,7 @@ public class CreateSessionDialog extends CaveSWTDialogBase {
inviteMessageTF.setLayoutData(new GridData(GridData.FILL_BOTH));
inviteMessageTF.pack();
Point p = inviteMessageTF.getSize();
GridData gd = (GridData) inviteMessageTF.getLayoutData();
gd = (GridData) inviteMessageTF.getLayoutData();
gd.heightHint = p.y * 3;
inviteUsers.addSelectionListener(new SelectionListener() {
@ -158,14 +158,13 @@ public class CreateSessionDialog extends CaveSWTDialogBase {
}
private void createButtonBar(Composite parent) {
Composite b = new Composite(parent, SWT.NONE);
GridData gd = null;
Composite bar = new Composite(parent, SWT.NONE);
// set up to center buttons.
b.setLayout(new GridLayout(3, true));
new Composite(b, SWT.NONE);
Composite bar = new Composite(b, SWT.NONE);
new Composite(b, SWT.NONE);
bar.setLayout(new GridLayout(0, true));
gd = new GridData(SWT.CENTER, SWT.DEFAULT, true, false);
bar.setLayoutData(gd);
createButton(bar, IDialogConstants.OK_ID, "Create", true);
createButton(bar, IDialogConstants.CANCEL_ID,
@ -214,7 +213,9 @@ public class CreateSessionDialog extends CaveSWTDialogBase {
((GridLayout) parent.getLayout()).numColumns++;
Button button = new Button(parent, SWT.PUSH);
button.setText(label);
// button.setFont(JFaceResources.getDialogFont());
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
gd.minimumWidth = 70;
button.setLayoutData(gd);
button.setData(new Integer(id));
button.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
@ -237,7 +238,11 @@ public class CreateSessionDialog extends CaveSWTDialogBase {
CreateSessionData result = new CreateSessionData();
result.setName(name);
result.setSubject(subject);
if (inviteUsers == null) {
result.setInviteUsers(false);
} else {
result.setInviteUsers(inviteUsers.getSelection());
}
setReturnValue(result);
CreateSessionDialog.this.getShell().dispose();
} else {

View file

@ -27,6 +27,7 @@ import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
@ -39,10 +40,10 @@ import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import com.raytheon.uf.viz.collaboration.data.DataUser;
import com.raytheon.viz.ui.dialogs.CaveSWTDialogBase;
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
/**
* TODO Add Description
* Dialog for getting user information to establish a connection to the server.
*
* <pre>
*
@ -57,12 +58,12 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialogBase;
* @author rferrel
* @version 1.0
*/
public class LoginDialog extends CaveSWTDialogBase {
public class LoginDialog extends CaveSWTDialog {
private static DataUser.StatusType[] status = null;
private Text userTF;
private Text serverTF;
private Label serverTF;
private Text passwordTF;
@ -70,11 +71,6 @@ public class LoginDialog extends CaveSWTDialogBase {
private Text messageTF;
// /**
// * Collection of buttons created by the <code>createButton</code> method.
// */
// private Map<Integer, Button> buttons = new HashMap<Integer, Button>();
public LoginDialog(Shell parentShell) {
super(parentShell);
setText("Collaboration Server Log On");
@ -92,35 +88,47 @@ public class LoginDialog extends CaveSWTDialogBase {
}
}
}
GridData gd = null;
Composite body = new Composite(parent, SWT.NONE);
body.setLayout(new GridLayout(2, false));
body.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL
| GridData.HORIZONTAL_ALIGN_FILL));
body.setLayout(new GridLayout(3, false));
Label label = null;
label = new Label(body, SWT.NONE);
label.setText("User: ");
userTF = new Text(body, SWT.BORDER);
userTF.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL
| GridData.HORIZONTAL_ALIGN_FILL));
// TODO Get user name based on linux log in name and the virtual sever
// from configuration then combine to make this label
// userTF.setText("rferrel");
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;
userTF.setLayoutData(gd);
label = new Label(body, SWT.NONE);
label = new Label(body, SWT.NONE);
label.setText("Server");
serverTF = new Text(body, SWT.BORDER);
serverTF.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL
| GridData.HORIZONTAL_ALIGN_FILL));
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");
serverTF.setEnabled(false);
Button serverButton = new Button(body, SWT.PUSH);
serverButton.setText("Server ...");
serverButton.setToolTipText("Change Server");
serverButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
System.out.println("Change server here.");
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
}
});
label = new Label(body, SWT.NONE);
label.setText("Password: ");
passwordTF = new Text(body, SWT.PASSWORD | SWT.BORDER);
passwordTF.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL
| GridData.HORIZONTAL_ALIGN_FILL));
passwordTF.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
passwordTF.setTextLimit(32);
label = new Label(body, SWT.NONE);
label = new Label(body, SWT.NONE);
label.setText("Status: ");
statusC = new Combo(body, SWT.DEFAULT);
@ -130,33 +138,35 @@ public class LoginDialog extends CaveSWTDialogBase {
}
statusC.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));
// body.pack();
// messageTF
// .setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
messageTF.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
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);
}
private void createButtonBar(Composite parent) {
Composite b = new Composite(parent, SWT.NONE);
// set up to center buttons.
b.setLayout(new GridLayout(3, true));
new Composite(b, SWT.NONE);
Composite bar = new Composite(b, SWT.NONE);
new Composite(b, SWT.NONE);
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);
createButton(bar, IDialogConstants.CANCEL_ID,
@ -165,9 +175,8 @@ public class LoginDialog extends CaveSWTDialogBase {
@Override
protected void preOpened() {
// TODO Auto-generated method stub
super.preOpened();
passwordTF.setFocus();
userTF.setFocus();
}
/**
@ -207,7 +216,9 @@ public class LoginDialog extends CaveSWTDialogBase {
((GridLayout) parent.getLayout()).numColumns++;
Button button = new Button(parent, SWT.PUSH);
button.setText(label);
// button.setFont(JFaceResources.getDialogFont());
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
gd.minimumWidth = 70;
button.setLayoutData(gd);
button.setData(new Integer(id));
button.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
@ -226,22 +237,22 @@ public class LoginDialog extends CaveSWTDialogBase {
if (focusField == null) {
focusField = userTF;
}
errorMessages.add("Must have a user.");
errorMessages.add("Must enter a user.");
userTF.setText("");
}
if (server.length() <= 0) {
if (focusField == null) {
focusField = serverTF;
}
errorMessages.add("Must have a server.");
serverTF.setText("");
}
// if (server.length() <= 0) {
// if (focusField == null) {
// focusField = serverTF;
// }
// errorMessages.add("Must have a server.");
// serverTF.setText("");
// }
if (password.length() <= 0) {
if (focusField == null) {
focusField = passwordTF;
}
errorMessages.add("Must have a password.");
errorMessages.add("Must enter a password.");
passwordTF.setText("");
}
if (focusField == null) {
@ -274,8 +285,6 @@ public class LoginDialog extends CaveSWTDialogBase {
shell.setDefaultButton(button);
}
}
// buttons.put(new Integer(id), button);
// setButtonLayoutData(button);
return button;
}
}

View file

@ -441,7 +441,10 @@ public class SessionView extends ViewPart implements IPartListener {
usersTable.setLabelProvider(labelProvider);
usersTable.setSorter(new ViewerSorter() {
public int compare(Viewer viewer, Object e1, Object e2) {
return super.compare(viewer, e1, e2);
CollaborationUser c1 = (CollaborationUser) e1;
CollaborationUser c2 = (CollaborationUser) e1;
// return super.compare(viewer, e1, e2);
return c1.compareTo(c2);
}
});
@ -590,7 +593,7 @@ public class SessionView extends ViewPart implements IPartListener {
disposeArrow(highlightedRightArrow);
disposeArrow(downArrow);
disposeArrow(rightArrow);
CollaborationDataManager.getInstance().closeSession(sessionId);
super.dispose();
}