Issue #244 update
Change-Id: I6f92dbd64d95cc853f6dcf43d39c209607a70105 Former-commit-id: 28969960d80066def0ef02930875e40d7693c234
This commit is contained in:
parent
c26e98376e
commit
c9459e2e8c
8 changed files with 595 additions and 148 deletions
|
@ -29,7 +29,7 @@
|
|||
class="com.raytheon.uf.viz.collaboration.ui.CollaborationGroupView"
|
||||
id="com.raytheon.uf.viz.collaboration.ui.CollaborationGroupView"
|
||||
icon="icons/browser.gif"
|
||||
name="Collaboration Groups"
|
||||
name="Collaboration Information"
|
||||
restorable="true"/>
|
||||
</extension>
|
||||
<extension
|
||||
|
|
|
@ -24,12 +24,13 @@ import java.util.HashMap;
|
|||
import java.util.Map;
|
||||
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
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.SessionManager;
|
||||
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.ui.login.LoginData;
|
||||
import com.raytheon.uf.viz.collaboration.ui.login.LoginDialog;
|
||||
|
@ -77,7 +78,7 @@ public class CollaborationDataManager {
|
|||
/**
|
||||
* The connection to the server.
|
||||
*/
|
||||
SessionManager manager;
|
||||
private SessionManager manager;
|
||||
|
||||
String loginId;
|
||||
|
||||
|
@ -89,7 +90,7 @@ public class CollaborationDataManager {
|
|||
/**
|
||||
* Mapping for all active chat sessions.
|
||||
*/
|
||||
Map<String, ISession> sessionsMap;
|
||||
Map<String, IVenueSession> sessionsMap;
|
||||
|
||||
public static CollaborationDataManager getInstance() {
|
||||
if (instance == null) {
|
||||
|
@ -98,12 +99,16 @@ public class CollaborationDataManager {
|
|||
return instance;
|
||||
}
|
||||
|
||||
public String venuIdToSessionId(String venuId) {
|
||||
return venuId.replace(':', ';');
|
||||
}
|
||||
|
||||
/**
|
||||
* Private constructor to for singleton class.
|
||||
*/
|
||||
private CollaborationDataManager() {
|
||||
usersMap = new HashMap<String, DataUser>();
|
||||
sessionsMap = new HashMap<String, ISession>();
|
||||
sessionsMap = new HashMap<String, IVenueSession>();
|
||||
}
|
||||
|
||||
public String getLoginId() {
|
||||
|
@ -124,14 +129,17 @@ public class CollaborationDataManager {
|
|||
*
|
||||
* @return manager or null if unable to get connection.
|
||||
*/
|
||||
public SessionManager getSessionManager() {
|
||||
synchronized public SessionManager getSessionManager() {
|
||||
if (manager == null) {
|
||||
VizApp.runSync(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
LoginDialog dlg = new LoginDialog(Display.getDefault()
|
||||
.getActiveShell());
|
||||
Shell shell = Display.getDefault().getActiveShell();
|
||||
if (shell == null) {
|
||||
return;
|
||||
}
|
||||
LoginDialog dlg = new LoginDialog(shell);
|
||||
LoginData loginData = null;
|
||||
while (manager == null) {
|
||||
loginData = (LoginData) dlg.open();
|
||||
|
@ -143,20 +151,19 @@ public class CollaborationDataManager {
|
|||
manager = new SessionManager(
|
||||
loginData.getAccount(), loginData
|
||||
.getPassword());
|
||||
loginId = loginData.getAccount();
|
||||
DataUser user = CollaborationDataManager
|
||||
.getInstance().getUser(loginId);
|
||||
user.status = loginData.getStatus();
|
||||
user.statusMessage = loginData.getMessage();
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block. Please
|
||||
// revise as appropriate.
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
e.getLocalizedMessage(), e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (manager != null) {
|
||||
loginId = loginData.getAccount();
|
||||
DataUser user = CollaborationDataManager.getInstance()
|
||||
.getUser(loginId);
|
||||
user.status = loginData.getStatus();
|
||||
user.statusMessage = loginData.getMessage();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -168,33 +175,38 @@ public class CollaborationDataManager {
|
|||
return manager;
|
||||
}
|
||||
|
||||
synchronized public void closeManager() {
|
||||
if (manager != null) {
|
||||
manager.closeManager();
|
||||
manager = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param sessionId
|
||||
* - key to fetch session
|
||||
* @return session
|
||||
*/
|
||||
public ISession getSession(String sessionId) {
|
||||
public IVenueSession getSession(String sessionId) {
|
||||
return sessionsMap.get(sessionId);
|
||||
}
|
||||
|
||||
private int colRm = 0;
|
||||
|
||||
/**
|
||||
* @return sessionId
|
||||
*/
|
||||
public String createCollaborationSession() {
|
||||
public String createCollaborationSession(String venue, String subject) {
|
||||
SessionManager manager = getSessionManager();
|
||||
ISession session = manager
|
||||
.createCollaborationSession(SessionManager.SESSION_COLLABORATION);
|
||||
// TODO get unique venue name from server
|
||||
session.createVenue("collaboration-" + ++colRm);
|
||||
String sessionId = session.getVenue().getInfo().getVenueID()
|
||||
.replace(':', ';');
|
||||
IVenueSession session = manager.createCollaborationSession();
|
||||
int status = session.createVenue(venue, subject);
|
||||
String sessionId = null;
|
||||
if (status == 0) {
|
||||
sessionId = venuIdToSessionId(session.getVenue().getInfo()
|
||||
.getVenueID());
|
||||
// TODO throw an exception if unable to make connection?
|
||||
if (session == null || session.isConnected() == false) {
|
||||
return null;
|
||||
}
|
||||
if (session.isConnected()) {
|
||||
sessionsMap.put(sessionId, session);
|
||||
}
|
||||
}
|
||||
return sessionId;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,9 +62,6 @@ public class CollaborationGroup extends CollaborationNode {
|
|||
}
|
||||
|
||||
public void addChild(CollaborationNode child) {
|
||||
// if (children == null) {
|
||||
// children = new ArrayList<CollaborationNode>();
|
||||
// }
|
||||
children.add(child);
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,18 @@ package com.raytheon.uf.viz.collaboration.data;
|
|||
*/
|
||||
|
||||
public class SessionGroup extends CollaborationGroup {
|
||||
boolean sessionRoot;
|
||||
|
||||
public SessionGroup(String id) {
|
||||
super(id);
|
||||
this.sessionRoot = false;
|
||||
}
|
||||
|
||||
public boolean isSessionRoot() {
|
||||
return sessionRoot;
|
||||
}
|
||||
|
||||
public void setSessionRoot(boolean sessionRoot) {
|
||||
this.sessionRoot = sessionRoot;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,8 +22,10 @@ package com.raytheon.uf.viz.collaboration.ui;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.jface.action.Action;
|
||||
import org.eclipse.jface.action.ActionContributionItem;
|
||||
|
@ -39,7 +41,9 @@ import org.eclipse.swt.layout.GridData;
|
|||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.swt.widgets.Menu;
|
||||
import org.eclipse.swt.widgets.MessageBox;
|
||||
import org.eclipse.ui.IViewPart;
|
||||
import org.eclipse.ui.IWorkbenchPage;
|
||||
import org.eclipse.ui.PartInitException;
|
||||
|
@ -115,6 +119,8 @@ public class CollaborationGroupView extends ViewPart {
|
|||
|
||||
private Action changeStatusAction;
|
||||
|
||||
private Action refreshSessonAction;
|
||||
|
||||
/**
|
||||
* @param parent
|
||||
*/
|
||||
|
@ -142,13 +148,13 @@ public class CollaborationGroupView extends ViewPart {
|
|||
joinCollaborationAction = new Action("Join...") {
|
||||
@Override
|
||||
public void run() {
|
||||
createJoinCollaboration();
|
||||
System.out.println("this join with menu goes away.");
|
||||
}
|
||||
};
|
||||
joinCollaborationAction
|
||||
.setToolTipText("Select a Collaboration\nroom to join.");
|
||||
|
||||
collaborateAction = new Action("Collaborate") {
|
||||
collaborateAction = new Action("Create Session...") {
|
||||
@Override
|
||||
public void run() {
|
||||
createCollaborationSession();
|
||||
|
@ -162,24 +168,35 @@ public class CollaborationGroupView extends ViewPart {
|
|||
}
|
||||
};
|
||||
|
||||
inviteAction = new Action("Invite") {
|
||||
inviteAction = new Action("Invite...") {
|
||||
@Override
|
||||
public void run() {
|
||||
System.out.println("Invite");
|
||||
System.out.println("Invite...");
|
||||
};
|
||||
};
|
||||
|
||||
joinAction = new Action("Join", Action.AS_DROP_DOWN_MENU) {
|
||||
joinAction = new Action("Join") {
|
||||
@Override
|
||||
public void run() {
|
||||
System.out.println("Join");
|
||||
createJoinCollaboration();
|
||||
};
|
||||
};
|
||||
|
||||
logoutAction = new Action("Logout") {
|
||||
@Override
|
||||
public void run() {
|
||||
System.out.println("Logout");
|
||||
MessageBox messageBox = new MessageBox(Display.getCurrent()
|
||||
.getActiveShell(), SWT.ICON_WARNING | SWT.OK
|
||||
| SWT.CANCEL);
|
||||
messageBox.setText("Log off Collaboration");
|
||||
messageBox.setMessage("Logging off will sever your\n"
|
||||
+ "connection to the server and\n"
|
||||
+ "remove and close all joined\n" + "sessions.");
|
||||
int result = messageBox.open();
|
||||
if (result == SWT.OK) {
|
||||
CollaborationDataManager.getInstance().closeManager();
|
||||
// TODO clean up ui here.
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -211,53 +228,40 @@ public class CollaborationGroupView extends ViewPart {
|
|||
|
||||
changePasswordAction = new Action("Change password...") {
|
||||
public void run() {
|
||||
System.out.println("Change password here");
|
||||
};
|
||||
};
|
||||
|
||||
changeStatusAction = new Action("Change Status",
|
||||
Action.AS_DROP_DOWN_MENU) {
|
||||
public void run() {
|
||||
System.out.println("Change Status here to: " + getId());
|
||||
};
|
||||
};
|
||||
|
||||
refreshSessonAction = new Action("Refresh") {
|
||||
public void run() {
|
||||
System.out.println("Refresh Active Sessions");
|
||||
}
|
||||
};
|
||||
refreshSessonAction
|
||||
.setToolTipText("Refresh the Active Sessions Entries.");
|
||||
|
||||
IMenuCreator creator = new IMenuCreator() {
|
||||
|
||||
Menu menu;
|
||||
|
||||
@Override
|
||||
public Menu getMenu(Menu parent) {
|
||||
for (final DataUser.StatusType type : DataUser.StatusType
|
||||
.values()) {
|
||||
System.out.println(type);
|
||||
Action action = new Action(type.name()) {
|
||||
public void run() {
|
||||
changeStatusAction.setId(type.name());
|
||||
changeStatusAction.run();
|
||||
};
|
||||
};
|
||||
action.setId(type.name());
|
||||
ActionContributionItem item = new ActionContributionItem(
|
||||
action);
|
||||
item.fill(menu, -1);
|
||||
}
|
||||
menu = new Menu(parent);
|
||||
fillStatusMeu(menu);
|
||||
return menu;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Menu getMenu(Control parent) {
|
||||
for (final DataUser.StatusType type : DataUser.StatusType
|
||||
.values()) {
|
||||
System.out.println(type);
|
||||
Action action = new Action(type.name()) {
|
||||
public void run() {
|
||||
changeStatusAction.setId(type.name());
|
||||
changeStatusAction.run();
|
||||
};
|
||||
};
|
||||
action.setId(type.name());
|
||||
ActionContributionItem item = new ActionContributionItem(
|
||||
action);
|
||||
item.fill(menu, -1);
|
||||
}
|
||||
menu = new Menu(parent);
|
||||
fillStatusMeu(menu);
|
||||
return menu;
|
||||
}
|
||||
|
||||
|
@ -278,6 +282,23 @@ public class CollaborationGroupView extends ViewPart {
|
|||
};
|
||||
}
|
||||
|
||||
private void fillStatusMeu(Menu menu) {
|
||||
for (DataUser.StatusType type : DataUser.StatusType.values()) {
|
||||
if (type != DataUser.StatusType.NOT_ON_LINE) {
|
||||
System.out.println(type + " " + type.value());
|
||||
Action action = new Action(type.value()) {
|
||||
public void run() {
|
||||
changeStatusAction.setId(getId());
|
||||
changeStatusAction.run();
|
||||
};
|
||||
};
|
||||
action.setId(type.name());
|
||||
ActionContributionItem item = new ActionContributionItem(action);
|
||||
item.fill(menu, -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void createToolbar() {
|
||||
IToolBarManager mgr = getViewSite().getActionBars().getToolBarManager();
|
||||
mgr.add(joinCollaborationAction);
|
||||
|
@ -297,82 +318,34 @@ public class CollaborationGroupView extends ViewPart {
|
|||
private void createCollaborationSession() {
|
||||
CollaborationDataManager dataManager = CollaborationDataManager
|
||||
.getInstance();
|
||||
SessionManager manager = CollaborationDataManager.getInstance()
|
||||
.getSessionManager();
|
||||
SessionManager manager = dataManager.getSessionManager();
|
||||
if (manager == null) {
|
||||
System.err.println("Unable to get session manager");
|
||||
return;
|
||||
}
|
||||
Collection<IVenueInfo> info = manager.getVenueInfo();
|
||||
for (IVenueInfo i : info) {
|
||||
System.out.println(i);
|
||||
|
||||
// TODO determine invite based on if any users/groups selected.
|
||||
|
||||
CreateSessionDialog dialog = new CreateSessionDialog(Display
|
||||
.getCurrent().getActiveShell(), usersSelected());
|
||||
dialog.open();
|
||||
|
||||
CreateSessionData result = (CreateSessionData) dialog.getReturnValue();
|
||||
|
||||
if (result == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
String sessionId = null;
|
||||
try {
|
||||
|
||||
sessionId = dataManager.createCollaborationSession();
|
||||
// dataManager.getSession(sessionId).addMessageListener(
|
||||
// new IMessageListener() {
|
||||
// @Override
|
||||
// public void processMessage(IMessage message) {
|
||||
// String s = message.getBody();
|
||||
// if ("INFO.ROOMS".equals(s)) {
|
||||
// Collection<IVenueInfo> info = CollaborationDataManager
|
||||
// .getInstance().getSessionManager()
|
||||
// .getVenueInfo();
|
||||
// for (IVenueInfo i : info) {
|
||||
// System.out.println(i);
|
||||
// }
|
||||
// } else {
|
||||
// System.out.println(message.getTimeStamp()
|
||||
// + " From: "
|
||||
// + message.getFrom().getFQName());
|
||||
// System.out.println("CollaborationSession:Message "
|
||||
// + message.getBody());
|
||||
// }
|
||||
// }
|
||||
// }, new IMessageFilter() {
|
||||
// @Override
|
||||
// public boolean filter(IMessage message) {
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// });
|
||||
//
|
||||
// dataManager.getSession(sessionId).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;
|
||||
// }
|
||||
//
|
||||
// });
|
||||
//
|
||||
sessionId = dataManager.createCollaborationSession(
|
||||
result.getName(), result.getSubject());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
IStructuredSelection selection = (IStructuredSelection) usersTreeViewer
|
||||
.getSelection();
|
||||
Object[] nodes = selection.toArray();
|
||||
List<String> users = new ArrayList<String>();
|
||||
for (Object node : nodes) {
|
||||
if (node instanceof CollaborationUser) {
|
||||
users.add(((CollaborationNode) node).getId());
|
||||
} else if (node instanceof CollaborationGroup) {
|
||||
CollaborationGroup group = (CollaborationGroup) node;
|
||||
for (CollaborationNode n : group.getChildren()) {
|
||||
users.add(n.getId());
|
||||
}
|
||||
} finally {
|
||||
if (sessionId == null) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -381,13 +354,16 @@ public class CollaborationGroupView extends ViewPart {
|
|||
.getWorkbench()
|
||||
.getActiveWorkbenchWindow()
|
||||
.getActivePage()
|
||||
.showView(
|
||||
CollaborationSessionView.ID,
|
||||
sessionId,
|
||||
IWorkbenchPage.VIEW_CREATE
|
||||
| IWorkbenchPage.VIEW_ACTIVATE);
|
||||
.showView(CollaborationSessionView.ID, sessionId,
|
||||
IWorkbenchPage.VIEW_ACTIVATE);
|
||||
|
||||
if (result.isInviteUsers()) {
|
||||
// TODO send invites to the users
|
||||
Set<CollaborationUser> selectedUsers = getSelectedUsers();
|
||||
for (CollaborationUser user : selectedUsers) {
|
||||
System.out.println("sessionId - Invite: " + user.getId());
|
||||
}
|
||||
}
|
||||
|
||||
} catch (PartInitException e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
|
@ -398,7 +374,15 @@ public class CollaborationGroupView extends ViewPart {
|
|||
}
|
||||
|
||||
private void createJoinCollaboration() {
|
||||
System.out.println("Send joinCollaboration request.");
|
||||
IStructuredSelection selection = (IStructuredSelection) usersTreeViewer
|
||||
.getSelection();
|
||||
Object[] nodes = selection.toArray();
|
||||
for (Object node : nodes) {
|
||||
if (node instanceof SessionGroup) {
|
||||
SessionGroup sg = (SessionGroup) node;
|
||||
System.out.println("Join: " + sg.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void createPrivateChat() {
|
||||
|
@ -467,7 +451,22 @@ public class CollaborationGroupView extends ViewPart {
|
|||
.getSelection();
|
||||
Object o = selection.getFirstElement();
|
||||
if (o instanceof LoginUser) {
|
||||
System.err.println("Setup login user here...");
|
||||
manager.add(changeStatusAction);
|
||||
manager.add(changeMessageAction);
|
||||
manager.add(changePasswordAction);
|
||||
manager.add(logoutAction);
|
||||
return;
|
||||
}
|
||||
|
||||
if (o instanceof SessionGroup) {
|
||||
SessionGroup sessionGroup = (SessionGroup) o;
|
||||
if (sessionGroup.isSessionRoot()) {
|
||||
manager.add(collaborateAction);
|
||||
manager.add(refreshSessonAction);
|
||||
} else {
|
||||
manager.add(joinAction);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (o instanceof CollaborationUser) {
|
||||
|
@ -508,20 +507,24 @@ public class CollaborationGroupView extends ViewPart {
|
|||
protected void populateTree() {
|
||||
final CollaborationGroup topLevel = new CollaborationGroup("kickstart");
|
||||
usersTreeViewer.setInput(topLevel);
|
||||
SessionManager manager = CollaborationDataManager.getInstance()
|
||||
.getSessionManager();
|
||||
CollaborationDataManager manager = CollaborationDataManager
|
||||
.getInstance();
|
||||
SessionManager sessionManager = manager.getSessionManager();
|
||||
LoginUser user = new LoginUser(CollaborationDataManager.getInstance()
|
||||
.getLoginId());
|
||||
topLevel.addChild(user);
|
||||
SessionGroup sessionGroup = new SessionGroup("Active Collaborations");
|
||||
SessionGroup sessionGroup = new SessionGroup("Active Sessions");
|
||||
sessionGroup.setSessionRoot(true);
|
||||
topLevel.addChild(sessionGroup);
|
||||
|
||||
Collection<IVenueInfo> venuList = manager.getVenueInfo();
|
||||
Collection<IVenueInfo> venuList = sessionManager.getVenueInfo();
|
||||
for (IVenueInfo venu : venuList) {
|
||||
SessionGroup gp = new SessionGroup(venu.getVenueID());
|
||||
SessionGroup gp = new SessionGroup(manager.venuIdToSessionId(venu
|
||||
.getVenueID()));
|
||||
gp.setText(venu.getVenueName());
|
||||
if (venu.getParticipantCount() > 0) {
|
||||
|
||||
if (venu.getParticipantCount() > 0) {
|
||||
// TODO add current participants of the venu here.
|
||||
}
|
||||
sessionGroup.addChild(gp);
|
||||
}
|
||||
|
@ -564,6 +567,58 @@ public class CollaborationGroupView extends ViewPart {
|
|||
usersTreeViewer.refresh(topLevel, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
private boolean usersSelected() {
|
||||
IStructuredSelection selection = (IStructuredSelection) usersTreeViewer
|
||||
.getSelection();
|
||||
Object[] nodes = selection.toArray();
|
||||
boolean result = false;
|
||||
|
||||
for (Object node : nodes) {
|
||||
if ((node instanceof LoginUser) == false
|
||||
&& (node instanceof SessionGroup) == false) {
|
||||
result = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private Set<CollaborationUser> getSelectedUsers() {
|
||||
Set<CollaborationUser> selectedUsers = new HashSet<CollaborationUser>();
|
||||
IStructuredSelection selection = (IStructuredSelection) usersTreeViewer
|
||||
.getSelection();
|
||||
Object[] nodes = selection.toArray();
|
||||
for (Object node : nodes) {
|
||||
if (node instanceof CollaborationUser) {
|
||||
if ((node instanceof LoginUser) == false) {
|
||||
selectedUsers.add((CollaborationUser) node);
|
||||
}
|
||||
} else if ((node instanceof SessionGroup) == false) {
|
||||
selectedUsers
|
||||
.addAll(getSelectedUsers((CollaborationGroup) node));
|
||||
}
|
||||
}
|
||||
|
||||
return selectedUsers;
|
||||
}
|
||||
|
||||
private Collection<CollaborationUser> getSelectedUsers(
|
||||
CollaborationGroup groupNode) {
|
||||
Set<CollaborationUser> selectedUsers = new HashSet<CollaborationUser>();
|
||||
for (CollaborationNode node : groupNode.getChildren()) {
|
||||
if (node instanceof CollaborationUser) {
|
||||
selectedUsers.add((CollaborationUser) node);
|
||||
} else if (node instanceof CollaborationGroup) {
|
||||
selectedUsers
|
||||
.addAll(getSelectedUsers((CollaborationGroup) node));
|
||||
}
|
||||
}
|
||||
return selectedUsers;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
|
|
|
@ -0,0 +1,79 @@
|
|||
/**
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* TODO Add Description
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Mar 7, 2012 rferrel Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author rferrel
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class CreateSessionData {
|
||||
private String name;
|
||||
|
||||
private String subject;
|
||||
|
||||
private boolean inviteUsers;
|
||||
|
||||
private String inviteMessage;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getSubject() {
|
||||
return subject;
|
||||
}
|
||||
|
||||
public void setSubject(String subject) {
|
||||
this.subject = subject;
|
||||
}
|
||||
|
||||
public boolean isInviteUsers() {
|
||||
return inviteUsers;
|
||||
}
|
||||
|
||||
public void setInviteUsers(boolean inviteUsers) {
|
||||
this.inviteUsers = inviteUsers;
|
||||
}
|
||||
|
||||
public String getInviteMessage() {
|
||||
return inviteMessage;
|
||||
}
|
||||
|
||||
public void setInviteMessage(String inviteMessage) {
|
||||
this.inviteMessage = inviteMessage;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,293 @@
|
|||
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.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.jface.dialogs.IDialogConstants;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.custom.StyledText;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.events.SelectionListener;
|
||||
import org.eclipse.swt.graphics.Point;
|
||||
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.Control;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.MessageBox;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
|
||||
import com.raytheon.uf.viz.collaboration.comm.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;
|
||||
|
||||
/**
|
||||
* TODO Add Description
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Feb 15, 2012 rferrel Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author rferrel
|
||||
* @version 1.0
|
||||
*/
|
||||
public class CreateSessionDialog extends CaveSWTDialogBase {
|
||||
private static DataUser.StatusType[] status = null;
|
||||
|
||||
private Text nameTF;
|
||||
|
||||
private Text subjectTF;
|
||||
|
||||
private Button inviteUsers;
|
||||
|
||||
private boolean showInvite;
|
||||
|
||||
private StyledText inviteMessageTF;
|
||||
|
||||
private Label inviteLabel;
|
||||
|
||||
public CreateSessionDialog(Shell parentShell, boolean showInvite) {
|
||||
super(parentShell);
|
||||
this.showInvite = showInvite;
|
||||
setText("Create Collaboration Session");
|
||||
}
|
||||
|
||||
private Control createDialogArea(Composite parent) {
|
||||
if (status == null) {
|
||||
DataUser.StatusType[] types = DataUser.StatusType.values();
|
||||
status = new DataUser.StatusType[types.length - 1];
|
||||
int index = 0;
|
||||
for (DataUser.StatusType type : types) {
|
||||
if (type != DataUser.StatusType.NOT_ON_LINE) {
|
||||
status[index] = type;
|
||||
++index;
|
||||
}
|
||||
}
|
||||
}
|
||||
Composite body = new Composite(parent, SWT.NONE);
|
||||
body.setLayout(new GridLayout(2, false));
|
||||
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));
|
||||
|
||||
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));
|
||||
|
||||
inviteUsers = new Button(body, SWT.CHECK);
|
||||
inviteUsers.setText("Invite Selected Users");
|
||||
inviteUsers.setSelection(showInvite);
|
||||
inviteUsers.setVisible(showInvite);
|
||||
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
|
||||
| SWT.WRAP | SWT.H_SCROLL | SWT.V_SCROLL);
|
||||
inviteMessageTF.setLayoutData(new GridData(GridData.FILL_BOTH));
|
||||
inviteMessageTF.pack();
|
||||
Point p = inviteMessageTF.getSize();
|
||||
GridData gd = (GridData) inviteMessageTF.getLayoutData();
|
||||
gd.heightHint = p.y * 3;
|
||||
inviteUsers.addSelectionListener(new SelectionListener() {
|
||||
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
boolean selected = ((Button) e.widget).getSelection();
|
||||
inviteLabel.setVisible(selected);
|
||||
inviteMessageTF.setVisible(selected);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void widgetDefaultSelected(SelectionEvent e) {
|
||||
boolean selected = ((Button) e.widget).getSelection();
|
||||
inviteLabel.setVisible(selected);
|
||||
inviteMessageTF.setVisible(selected);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
return body;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initializeComponents(Shell shell) {
|
||||
shell.setLayout(new GridLayout(1, false));
|
||||
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);
|
||||
bar.setLayout(new GridLayout(0, true));
|
||||
createButton(bar, IDialogConstants.OK_ID, "Create", true);
|
||||
|
||||
createButton(bar, IDialogConstants.CANCEL_ID,
|
||||
IDialogConstants.CANCEL_LABEL, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void preOpened() {
|
||||
super.preOpened();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new button with the given id.
|
||||
* <p>
|
||||
* The <code>Dialog</code> implementation of this framework method creates a
|
||||
* standard push button, registers it for selection events including button
|
||||
* presses, and registers default buttons with its shell. The button id is
|
||||
* stored as the button's client data. If the button id is
|
||||
* <code>IDialogConstants.CANCEL_ID</code>, the new button will be
|
||||
* accessible from <code>getCancelButton()</code>. If the button id is
|
||||
* <code>IDialogConstants.OK_ID</code>, the new button will be accesible
|
||||
* from <code>getOKButton()</code>. Note that the parent's layout is assumed
|
||||
* to be a <code>GridLayout</code> and the number of columns in this layout
|
||||
* is incremented. Subclasses may override.
|
||||
* </p>
|
||||
*
|
||||
* @param parent
|
||||
* the parent composite
|
||||
* @param id
|
||||
* the id of the button (see <code>IDialogConstants.*_ID</code>
|
||||
* constants for standard dialog button ids)
|
||||
* @param label
|
||||
* the label from the button
|
||||
* @param defaultButton
|
||||
* <code>true</code> if the button is to be the default button,
|
||||
* and <code>false</code> otherwise
|
||||
*
|
||||
* @return the new button
|
||||
*
|
||||
* @see #getCancelButton
|
||||
* @see #getOKButton()
|
||||
*/
|
||||
protected Button createButton(Composite parent, int id, String label,
|
||||
boolean defaultButton) {
|
||||
// increment the number of columns in the button bar
|
||||
((GridLayout) parent.getLayout()).numColumns++;
|
||||
Button button = new Button(parent, SWT.PUSH);
|
||||
button.setText(label);
|
||||
// button.setFont(JFaceResources.getDialogFont());
|
||||
button.setData(new Integer(id));
|
||||
button.addSelectionListener(new SelectionAdapter() {
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
Integer val = (Integer) event.widget.getData();
|
||||
if (val != IDialogConstants.OK_ID) {
|
||||
setReturnValue(null);
|
||||
CreateSessionDialog.this.getShell().dispose();
|
||||
} else {
|
||||
Text focusField = null;
|
||||
List<String> errorMessages = new ArrayList<String>();
|
||||
String subject = subjectTF.getText().trim();
|
||||
String err = validateVenuName();
|
||||
String name = nameTF.getText();
|
||||
if (err != null) {
|
||||
focusField = nameTF;
|
||||
errorMessages.add(err);
|
||||
}
|
||||
|
||||
if (focusField == null) {
|
||||
CreateSessionData result = new CreateSessionData();
|
||||
result.setName(name);
|
||||
result.setSubject(subject);
|
||||
result.setInviteUsers(inviteUsers.getSelection());
|
||||
setReturnValue(result);
|
||||
CreateSessionDialog.this.getShell().dispose();
|
||||
} else {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
String prefix = "";
|
||||
for (String msg : errorMessages) {
|
||||
sb.append(prefix).append(msg);
|
||||
prefix = "\n";
|
||||
}
|
||||
MessageBox messageBox = new MessageBox(event.widget
|
||||
.getDisplay().getActiveShell(), SWT.ERROR);
|
||||
messageBox.setText("Session Creation Error");
|
||||
messageBox.setMessage(sb.toString());
|
||||
messageBox.open();
|
||||
event.doit = false;
|
||||
setReturnValue(null);
|
||||
focusField.setFocus();
|
||||
focusField.selectAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
if (defaultButton) {
|
||||
Shell shell = parent.getShell();
|
||||
if (shell != null) {
|
||||
shell.setDefaultButton(button);
|
||||
}
|
||||
}
|
||||
return button;
|
||||
}
|
||||
|
||||
private String validateVenuName() {
|
||||
String name = nameTF.getText().trim();
|
||||
nameTF.setText(name);
|
||||
String err = null;
|
||||
if (name.length() <= 0) {
|
||||
err = "Must have session name.";
|
||||
} else if (false) {
|
||||
// TODO Above else make it a test for invalid characters.
|
||||
err = "Name contains invalid characters.";
|
||||
} else {
|
||||
Collection<IVenueInfo> info = CollaborationDataManager
|
||||
.getInstance().getSessionManager().getVenueInfo();
|
||||
for (IVenueInfo i : info) {
|
||||
if (name.equals(i.getVenueName())) {
|
||||
err = "Session already exists. Pick a different name.";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return err;
|
||||
}
|
||||
}
|
|
@ -72,7 +72,7 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
|
|||
* @author mnash
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
@Deprecated
|
||||
public class CollaborationData {
|
||||
private static final transient IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(CollaborationData.class);
|
||||
|
|
Loading…
Add table
Reference in a new issue