Issue #244 Creted AbstarctSessonView and PeerToPeerView. Code clean up so CAVE exits properly.
Change-Id: Ibd5feeb0412e4afbe8e1f0eac79944bb059b4687 Former-commit-id: e92969cb1440f3f6477a7003b031faab6ed484fc
This commit is contained in:
parent
8f8e690470
commit
1f4edd08e4
12 changed files with 1082 additions and 334 deletions
|
@ -60,7 +60,7 @@
|
|||
id="com.raytheon.uf.viz.collaboration.CollaborationSession"
|
||||
icon="icons/messages.gif"
|
||||
name="Collaboration Session"
|
||||
restorable="true"/>
|
||||
restorable="false"/>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.ui.views">
|
||||
|
@ -71,7 +71,18 @@
|
|||
id="com.raytheon.uf.viz.collaboration.SessionView"
|
||||
icon="icons/chats.gif"
|
||||
name="Private Session"
|
||||
restorable="true"/>
|
||||
restorable="false"/>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.ui.views">
|
||||
<view
|
||||
allowMultiple="true"
|
||||
category="com.raytheon.viz.ui"
|
||||
class="com.raytheon.uf.viz.collaboration.ui.session.PeerToPeerView"
|
||||
id="com.raytheon.uf.viz.collaboration.PeerToPeerView"
|
||||
icon="icons/chats.gif"
|
||||
name="Private Chat"
|
||||
restorable="false"/>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.ui.commands">
|
||||
|
|
|
@ -26,6 +26,9 @@ import org.eclipse.swt.SWT;
|
|||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.swt.widgets.MessageBox;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.ui.IWorkbench;
|
||||
import org.eclipse.ui.IWorkbenchListener;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
|
@ -52,24 +55,6 @@ import com.raytheon.uf.viz.core.VizApp;
|
|||
* @author rferrel
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class contains information on user and session connections that can then
|
||||
* be used by more then one veiw.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Mar 5, 2012 rferrel Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author rferrel
|
||||
* @version 1.0
|
||||
*/
|
||||
public class CollaborationDataManager {
|
||||
private static CollaborationDataManager instance;
|
||||
|
||||
|
@ -83,6 +68,12 @@ public class CollaborationDataManager {
|
|||
|
||||
String loginId;
|
||||
|
||||
/**
|
||||
* Created when connection made. Used to clean up connection when CAVE shuts
|
||||
* down.
|
||||
*/
|
||||
private IWorkbenchListener wbListener;
|
||||
|
||||
/**
|
||||
* User information such as sessions and groups user is in.
|
||||
*/
|
||||
|
@ -138,7 +129,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.
|
||||
// Get user's server account information and make connection.
|
||||
if (manager == null) {
|
||||
VizApp.runSync(new Runnable() {
|
||||
|
||||
|
@ -166,14 +157,39 @@ public class CollaborationDataManager {
|
|||
// TODO set status and message here.
|
||||
user.status = loginData.getStatus();
|
||||
user.statusMessage = loginData.getMessage();
|
||||
wbListener = new IWorkbenchListener() {
|
||||
|
||||
@Override
|
||||
public boolean preShutdown(
|
||||
IWorkbench workbench, boolean forced) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postShutdown(IWorkbench workbench) {
|
||||
if (manager != null) {
|
||||
manager.closeManager();
|
||||
manager = null;
|
||||
}
|
||||
}
|
||||
};
|
||||
PlatformUI.getWorkbench().addWorkbenchListener(
|
||||
wbListener);
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block. Please
|
||||
// revise as appropriate.
|
||||
if (manager != null) {
|
||||
manager.closeManager();
|
||||
manager = null;
|
||||
}
|
||||
if (wbListener != null) {
|
||||
PlatformUI.getWorkbench()
|
||||
.removeWorkbenchListener(wbListener);
|
||||
wbListener = null;
|
||||
}
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
e.getLocalizedMessage(), e);
|
||||
MessageBox box = new MessageBox(shell, SWT.ERROR);
|
||||
box.setText("Log On Failed");
|
||||
box.setMessage(e.toString());
|
||||
box.setMessage(e.getMessage());
|
||||
box.open();
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -189,15 +205,30 @@ public class CollaborationDataManager {
|
|||
manager.closeManager();
|
||||
manager = null;
|
||||
}
|
||||
if (wbListener != null) {
|
||||
PlatformUI.getWorkbench().removeWorkbenchListener(wbListener);
|
||||
wbListener = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Venue session associated with the key or any session when key is
|
||||
* null.
|
||||
*
|
||||
* @param sessionId
|
||||
* - key to fetch session
|
||||
* @return session
|
||||
* @return session - The venue session or null if none found
|
||||
*/
|
||||
public IVenueSession getSession(String sessionId) {
|
||||
return sessionsMap.get(sessionId);
|
||||
IVenueSession session = null;
|
||||
if (sessionId == null) {
|
||||
if (sessionsMap.size() > 0) {
|
||||
session = sessionsMap.get(sessionsMap.keySet().toArray()[0]);
|
||||
}
|
||||
} else {
|
||||
session = sessionsMap.get(sessionId);
|
||||
}
|
||||
return session;
|
||||
}
|
||||
|
||||
public Map<String, IVenueSession> getSessions() {
|
||||
|
@ -218,13 +249,14 @@ public class CollaborationDataManager {
|
|||
}
|
||||
|
||||
/**
|
||||
* Generate a new session with
|
||||
* Generate a new session.
|
||||
*
|
||||
* @param venue
|
||||
* - Session name
|
||||
* @param subject
|
||||
* - Sessin topic
|
||||
* @return sessionId or null if unable to create session
|
||||
* - Session topic
|
||||
* @return sessionId - the key to use to retrieve the sesson or null if
|
||||
* unable to create the session
|
||||
*/
|
||||
public String createCollaborationSession(String venue, String subject) {
|
||||
SessionManager manager = getSessionManager();
|
||||
|
@ -239,16 +271,17 @@ public class CollaborationDataManager {
|
|||
sessionsMap.put(sessionId, session);
|
||||
}
|
||||
}
|
||||
// TODO Start CAVE editor associated with this session and make sure the
|
||||
// user is data provider and session leader.
|
||||
return sessionId;
|
||||
}
|
||||
|
||||
public String joinCollaborationSession(String venuName, String sessionId) {
|
||||
// String sessionId = venuIdToSessionId(venuName);
|
||||
if (sessionsMap.get(sessionId) == null) {
|
||||
IVenueSession session = getSessionManager()
|
||||
.createCollaborationSession();
|
||||
session.joinVenue(venuName);
|
||||
sessionsMap.put(sessionId, session);
|
||||
session.joinVenue(venuName);
|
||||
}
|
||||
return sessionId;
|
||||
}
|
||||
|
|
|
@ -53,6 +53,7 @@ import org.eclipse.swt.widgets.Menu;
|
|||
import org.eclipse.swt.widgets.MessageBox;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
import org.eclipse.ui.IViewPart;
|
||||
import org.eclipse.ui.IViewReference;
|
||||
import org.eclipse.ui.IWorkbenchPage;
|
||||
import org.eclipse.ui.PartInitException;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
|
@ -72,7 +73,9 @@ import com.raytheon.uf.viz.collaboration.data.CollaborationUser;
|
|||
import com.raytheon.uf.viz.collaboration.data.DataUser;
|
||||
import com.raytheon.uf.viz.collaboration.data.LoginUser;
|
||||
import com.raytheon.uf.viz.collaboration.data.SessionGroup;
|
||||
import com.raytheon.uf.viz.collaboration.ui.session.AbstractSessionView;
|
||||
import com.raytheon.uf.viz.collaboration.ui.session.CollaborationSessionView;
|
||||
import com.raytheon.uf.viz.collaboration.ui.session.PeerToPeerView;
|
||||
import com.raytheon.uf.viz.collaboration.ui.session.SessionView;
|
||||
import com.raytheon.viz.ui.perspectives.VizPerspectiveListener;
|
||||
|
||||
|
@ -108,7 +111,7 @@ public class CollaborationGroupView extends ViewPart {
|
|||
|
||||
Map<String, String[]> groupMap;
|
||||
|
||||
private Action collaborateAction;
|
||||
private Action createSessionAction;
|
||||
|
||||
private Action linkToEditorAction;
|
||||
|
||||
|
@ -118,10 +121,14 @@ public class CollaborationGroupView extends ViewPart {
|
|||
|
||||
private Action joinCollaborationAction;
|
||||
|
||||
private Action peerToPeerChatAction;
|
||||
|
||||
private Action logoutAction;
|
||||
|
||||
private Action aliasAction;
|
||||
|
||||
private Action renameAction;
|
||||
|
||||
private Action addGroupAction;
|
||||
|
||||
private Action addUserAction;
|
||||
|
@ -173,14 +180,14 @@ public class CollaborationGroupView extends ViewPart {
|
|||
*/
|
||||
private void createActions() {
|
||||
|
||||
collaborateAction = new Action("Create Session...") {
|
||||
createSessionAction = new Action("Create Session...") {
|
||||
@Override
|
||||
public void run() {
|
||||
createCollaborationSession();
|
||||
createSession();
|
||||
}
|
||||
|
||||
};
|
||||
collaborateAction.setImageDescriptor(CollaborationUtils
|
||||
createSessionAction.setImageDescriptor(CollaborationUtils
|
||||
.getImageDescriptor("add_collaborate.gif"));
|
||||
|
||||
linkToEditorAction = new Action("Link Editor to Chat Session",
|
||||
|
@ -208,25 +215,21 @@ public class CollaborationGroupView extends ViewPart {
|
|||
@Override
|
||||
public void run() {
|
||||
createJoinCollaboration();
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
peerToPeerChatAction = new Action("Private Chat") {
|
||||
@Override
|
||||
public void run() {
|
||||
createPrivateChat(getId());
|
||||
}
|
||||
};
|
||||
|
||||
logoutAction = new Action("Logout") {
|
||||
@Override
|
||||
public void run() {
|
||||
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"
|
||||
+ "close all session views.");
|
||||
int result = messageBox.open();
|
||||
if (result == SWT.OK) {
|
||||
CollaborationDataManager.getInstance().closeManager();
|
||||
// TODO clean up ui here.
|
||||
}
|
||||
};
|
||||
performLogout();
|
||||
}
|
||||
};
|
||||
logoutAction.setImageDescriptor(CollaborationUtils
|
||||
.getImageDescriptor("logout.gif"));
|
||||
|
@ -239,6 +242,13 @@ public class CollaborationGroupView extends ViewPart {
|
|||
};
|
||||
};
|
||||
|
||||
renameAction = new Action("Rename") {
|
||||
@Override
|
||||
public void run() {
|
||||
System.out.println("Rename action");
|
||||
}
|
||||
};
|
||||
|
||||
addUserAction = new Action("Add User") {
|
||||
public void run() {
|
||||
System.out.println("Add User");
|
||||
|
@ -334,6 +344,44 @@ public class CollaborationGroupView extends ViewPart {
|
|||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* This displays a warning dialog then closes all collaboration views and
|
||||
* disconnects from the server.
|
||||
*/
|
||||
private void performLogout() {
|
||||
MessageBox messageBox = new MessageBox(Display.getCurrent()
|
||||
.getActiveShell(), SWT.ICON_WARNING | SWT.OK | SWT.CANCEL);
|
||||
messageBox.setText("Log Out of Collaboration");
|
||||
messageBox.setMessage("Logging out will sever your\n"
|
||||
+ "connection to the server and\n"
|
||||
+ "close all collaboration views\n" + "and editors.");
|
||||
int result = messageBox.open();
|
||||
if (result == SWT.OK) {
|
||||
PlatformUI.getWorkbench().getActiveWorkbenchWindow()
|
||||
.getActivePage().hideView(this);
|
||||
for (IViewReference ref : PlatformUI.getWorkbench()
|
||||
.getActiveWorkbenchWindow().getActivePage()
|
||||
.getViewReferences()) {
|
||||
IViewPart view = ref.getView(false);
|
||||
if (view instanceof AbstractSessionView) {
|
||||
PlatformUI.getWorkbench().getActiveWorkbenchWindow()
|
||||
.getActivePage().hideView(view);
|
||||
}
|
||||
}
|
||||
// TODO close collaboration CAVE editor(s).
|
||||
// for (IEditorReference ref :
|
||||
// PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences())
|
||||
// {
|
||||
// IEditorPart editor = ref.getEditor(false);
|
||||
// if (editor instanceof CollaborationEditor) {
|
||||
// PlatformUI.getWorkbench().getActiveWorkbenchWindow()
|
||||
// .getActivePage().hideEditor(ref);
|
||||
// }
|
||||
// }
|
||||
CollaborationDataManager.getInstance().closeManager();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@ -383,7 +431,7 @@ public class CollaborationGroupView extends ViewPart {
|
|||
private void createToolbar() {
|
||||
IToolBarManager mgr = getViewSite().getActionBars().getToolBarManager();
|
||||
// mgr.add(joinCollaborationAction);
|
||||
mgr.add(collaborateAction);
|
||||
mgr.add(createSessionAction);
|
||||
mgr.add(collapseAllAction);
|
||||
// mgr.add(privateChatAction);
|
||||
mgr.add(linkToEditorAction);
|
||||
|
@ -406,7 +454,7 @@ public class CollaborationGroupView extends ViewPart {
|
|||
mgr.add(logoutAction);
|
||||
}
|
||||
|
||||
private void createCollaborationSession() {
|
||||
private void createSession() {
|
||||
CollaborationDataManager manager = CollaborationDataManager
|
||||
.getInstance();
|
||||
SessionManager sessionManager = manager.getSessionManager();
|
||||
|
@ -423,15 +471,21 @@ public class CollaborationGroupView extends ViewPart {
|
|||
|
||||
CreateSessionData result = (CreateSessionData) dialog.getReturnValue();
|
||||
|
||||
if (result == null) {
|
||||
return;
|
||||
if (result != null) {
|
||||
if (result.isCollaborationSession()) {
|
||||
createCollaborationView(result);
|
||||
} else {
|
||||
createPrivateView(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void createCollaborationView(CreateSessionData result) {
|
||||
String sessionId = null;
|
||||
try {
|
||||
|
||||
sessionId = manager.createCollaborationSession(result.getName(),
|
||||
result.getSubject());
|
||||
sessionId = CollaborationDataManager.getInstance()
|
||||
.createCollaborationSession(result.getName(),
|
||||
result.getSubject());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
|
@ -464,6 +518,46 @@ public class CollaborationGroupView extends ViewPart {
|
|||
}
|
||||
}
|
||||
|
||||
private void createPrivateView(CreateSessionData result) {
|
||||
String sessionId = null;
|
||||
try {
|
||||
// TODO Do not use createCollaborationSession once private session
|
||||
// implemented.
|
||||
sessionId = CollaborationDataManager.getInstance()
|
||||
.createCollaborationSession(result.getName(),
|
||||
result.getSubject());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (sessionId == null) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
IViewPart part = PlatformUI
|
||||
.getWorkbench()
|
||||
.getActiveWorkbenchWindow()
|
||||
.getActivePage()
|
||||
.showView(SessionView.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());
|
||||
}
|
||||
}
|
||||
refreshActiveSessions();
|
||||
} catch (PartInitException e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Unable to open collaboation sesson", e);
|
||||
} catch (Exception e) {
|
||||
statusHandler.handle(Priority.ERROR, "Unexpected excepton", e);
|
||||
}
|
||||
}
|
||||
|
||||
private void createJoinCollaboration() {
|
||||
IStructuredSelection selection = (IStructuredSelection) usersTreeViewer
|
||||
.getSelection();
|
||||
|
@ -493,9 +587,10 @@ public class CollaborationGroupView extends ViewPart {
|
|||
}
|
||||
}
|
||||
|
||||
private void createPrivateChat() {
|
||||
IStructuredSelection selection = (IStructuredSelection) usersTreeViewer
|
||||
.getSelection();
|
||||
private void createPrivateChat(String user) {
|
||||
// IStructuredSelection selection = (IStructuredSelection)
|
||||
// usersTreeViewer
|
||||
// .getSelection();
|
||||
// TODO
|
||||
// List<ID> users = new ArrayList<ID>();
|
||||
// ID id = IDFactory.getDefault().createID(
|
||||
|
@ -510,11 +605,8 @@ public class CollaborationGroupView extends ViewPart {
|
|||
.getWorkbench()
|
||||
.getActiveWorkbenchWindow()
|
||||
.getActivePage()
|
||||
.showView(
|
||||
SessionView.ID,
|
||||
null,
|
||||
IWorkbenchPage.VIEW_CREATE
|
||||
| IWorkbenchPage.VIEW_VISIBLE);
|
||||
.showView(PeerToPeerView.ID, user,
|
||||
IWorkbenchPage.VIEW_ACTIVATE);
|
||||
// }
|
||||
} catch (PartInitException e) {
|
||||
statusHandler.handle(Priority.PROBLEM, "Unable to open chat", e);
|
||||
|
@ -581,7 +673,7 @@ public class CollaborationGroupView extends ViewPart {
|
|||
if (o instanceof SessionGroup) {
|
||||
SessionGroup sessionGroup = (SessionGroup) o;
|
||||
if (sessionGroup.isSessionRoot()) {
|
||||
manager.add(collaborateAction);
|
||||
manager.add(createSessionAction);
|
||||
manager.add(refreshActiveSessionsAction);
|
||||
} else {
|
||||
manager.add(joinAction);
|
||||
|
@ -601,7 +693,8 @@ public class CollaborationGroupView extends ViewPart {
|
|||
final IVenueInfo info = sessions.get(name).getVenue()
|
||||
.getInfo();
|
||||
if (info != null) {
|
||||
System.out.println(info.getVenueDescription());
|
||||
System.out.println("Add to Invite To menu: "
|
||||
+ info.getVenueDescription());
|
||||
Action action = new Action(info.getVenueDescription()) {
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
|
@ -620,6 +713,8 @@ public class CollaborationGroupView extends ViewPart {
|
|||
}
|
||||
}
|
||||
manager.add(inviteManager);
|
||||
manager.add(peerToPeerChatAction);
|
||||
peerToPeerChatAction.setId(user.getId());
|
||||
if (user.isLocal()) {
|
||||
manager.add(addUserAction);
|
||||
manager.add(addGroupAction);
|
||||
|
@ -628,14 +723,14 @@ public class CollaborationGroupView extends ViewPart {
|
|||
}
|
||||
} else if (o instanceof CollaborationGroup) {
|
||||
CollaborationGroup group = (CollaborationGroup) o;
|
||||
manager.add(collaborateAction);
|
||||
manager.add(createSessionAction);
|
||||
if (group.isLocal()) {
|
||||
manager.add(addUserAction);
|
||||
manager.add(addGroupAction);
|
||||
manager.add(removeGroupAction);
|
||||
manager.add(renameAction);
|
||||
}
|
||||
}
|
||||
manager.add(aliasAction);
|
||||
}
|
||||
|
||||
protected void populateTree() {
|
||||
|
@ -664,7 +759,7 @@ public class CollaborationGroupView extends ViewPart {
|
|||
group.setModifiable(true);
|
||||
topLevel.addChild(group);
|
||||
for (String u : new String[] { "OAX_user1", "DSM_user3",
|
||||
"LBF_user2" }) {
|
||||
"LBF_user2", "mnash@awipscm.omaha.us.ray.com" }) {
|
||||
CollaborationUser item = new CollaborationUser(u);
|
||||
group.addChild(item);
|
||||
item.setStatus(DataUser.StatusType.AVAILABLE);
|
||||
|
@ -783,14 +878,29 @@ public class CollaborationGroupView extends ViewPart {
|
|||
@Override
|
||||
public void doubleClick(DoubleClickEvent event) {
|
||||
TreeSelection selection = (TreeSelection) event.getSelection();
|
||||
if (selection.getFirstElement() instanceof SessionGroup) {
|
||||
CollaborationNode node = (CollaborationNode) selection
|
||||
.getFirstElement();
|
||||
if (node instanceof SessionGroup) {
|
||||
SessionGroup group = (SessionGroup) selection
|
||||
.getFirstElement();
|
||||
if (!group.isSessionRoot()) {
|
||||
createJoinCollaboration();
|
||||
}
|
||||
} else if (node instanceof CollaborationUser) {
|
||||
String loginUserId = CollaborationDataManager.getInstance()
|
||||
.getLoginId();
|
||||
if (loginUserId.equals(node.getId()) == false) {
|
||||
createPrivateChat(node.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
// TODO Auto-generated method stub
|
||||
System.out.println("Disposing: " + getClass().getName());
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,6 +43,8 @@ public class CreateSessionData {
|
|||
|
||||
private boolean inviteUsers;
|
||||
|
||||
private boolean collaborationSession;
|
||||
|
||||
private String inviteMessage;
|
||||
|
||||
public String getName() {
|
||||
|
@ -61,10 +63,18 @@ public class CreateSessionData {
|
|||
this.subject = subject;
|
||||
}
|
||||
|
||||
public boolean isCollaborationSession() {
|
||||
return collaborationSession;
|
||||
}
|
||||
|
||||
public boolean isInviteUsers() {
|
||||
return inviteUsers;
|
||||
}
|
||||
|
||||
public void setCollaborationSessioh(boolean collaborationSession) {
|
||||
this.collaborationSession = collaborationSession;
|
||||
}
|
||||
|
||||
public void setInviteUsers(boolean inviteUsers) {
|
||||
this.inviteUsers = inviteUsers;
|
||||
}
|
||||
|
|
|
@ -69,6 +69,8 @@ public class CreateSessionDialog extends CaveSWTDialog {
|
|||
|
||||
private Text subjectTF;
|
||||
|
||||
private Button publicCollaboration;
|
||||
|
||||
private Button inviteUsers;
|
||||
|
||||
private boolean showInvite;
|
||||
|
@ -80,7 +82,7 @@ public class CreateSessionDialog extends CaveSWTDialog {
|
|||
public CreateSessionDialog(Shell parentShell, boolean showInvite) {
|
||||
super(parentShell);
|
||||
this.showInvite = showInvite;
|
||||
setText("Create Collaboration Session");
|
||||
setText("Create Session");
|
||||
}
|
||||
|
||||
private Control createDialogArea(Composite parent) {
|
||||
|
@ -111,21 +113,31 @@ public class CreateSessionDialog extends CaveSWTDialog {
|
|||
label.setText("Subject: ");
|
||||
subjectTF = new Text(body, SWT.BORDER);
|
||||
subjectTF.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
|
||||
publicCollaboration = new Button(body, SWT.CHECK);
|
||||
gd = new GridData(SWT.DEFAULT, SWT.DEFAULT, false, false);
|
||||
gd.horizontalSpan = 2;
|
||||
publicCollaboration.setLayoutData(gd);
|
||||
publicCollaboration.setText("Create Public Collaboration");
|
||||
|
||||
if (showInvite) {
|
||||
inviteUsers = new Button(body, SWT.CHECK);
|
||||
gd = new GridData(SWT.DEFAULT, SWT.DEFAULT, false, false);
|
||||
gd.horizontalSpan = 2;
|
||||
inviteUsers.setLayoutData(gd);
|
||||
inviteUsers.setText("Invite Selected Users");
|
||||
inviteUsers.setSelection(true);
|
||||
// inviteUsers.setSelection(true);
|
||||
inviteUsers.setVisible(true);
|
||||
label = new Label(body, SWT.NONE);
|
||||
label.setText("");
|
||||
label.setVisible(showInvite);
|
||||
// label = new Label(body, SWT.NONE);
|
||||
// label.setText("");
|
||||
// label.setVisible(showInvite);
|
||||
inviteLabel = new Label(body, SWT.NONE);
|
||||
inviteLabel.setText("Invite Message: ");
|
||||
inviteLabel.setText("Message: ");
|
||||
inviteLabel.setToolTipText("Message to send to invited users");
|
||||
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();
|
||||
inviteMessageTF.setToolTipText("Message to send to invited users");
|
||||
Point p = inviteMessageTF.getSize();
|
||||
gd = (GridData) inviteMessageTF.getLayoutData();
|
||||
gd.heightHint = p.y * 3;
|
||||
|
@ -146,6 +158,8 @@ public class CreateSessionDialog extends CaveSWTDialog {
|
|||
|
||||
}
|
||||
});
|
||||
inviteLabel.setVisible(false);
|
||||
inviteMessageTF.setVisible(false);
|
||||
}
|
||||
return body;
|
||||
}
|
||||
|
@ -238,6 +252,8 @@ public class CreateSessionDialog extends CaveSWTDialog {
|
|||
CreateSessionData result = new CreateSessionData();
|
||||
result.setName(name);
|
||||
result.setSubject(subject);
|
||||
result.setCollaborationSessioh(publicCollaboration
|
||||
.getSelection());
|
||||
if (inviteUsers == null) {
|
||||
result.setInviteUsers(false);
|
||||
} else {
|
||||
|
|
|
@ -46,11 +46,15 @@ public class UsersTreeViewerSorter extends ViewerSorter {
|
|||
|
||||
@Override
|
||||
public int compare(Viewer viewer, Object e1, Object e2) {
|
||||
if (e1 == e2) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Make login user top node
|
||||
if (e1 instanceof LoginUser) {
|
||||
return -1;
|
||||
}
|
||||
if (e1 instanceof LoginUser) {
|
||||
if (e2 instanceof LoginUser) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -49,8 +49,6 @@ public class LoginData {
|
|||
|
||||
private String statusMessage;
|
||||
|
||||
// private List<String> errorMessages;
|
||||
|
||||
public LoginData(final String user, final String server,
|
||||
final String password, final DataUser.StatusType status,
|
||||
final String statusMessage) {
|
||||
|
@ -59,7 +57,6 @@ public class LoginData {
|
|||
this.password = password;
|
||||
this.status = status;
|
||||
this.statusMessage = statusMessage;
|
||||
// this.errorMessages = new ArrayList<String>();
|
||||
}
|
||||
|
||||
public String getUser() {
|
||||
|
@ -78,6 +75,10 @@ public class LoginData {
|
|||
return status;
|
||||
}
|
||||
|
||||
public String getServer() {
|
||||
return server;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return statusMessage;
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Mar 16, 2012 244 rferrel Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @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<String, Image> 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<String, Image>();
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Mar 1, 2012 rferrel Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @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();
|
||||
}
|
||||
}
|
|
@ -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<String, Image> 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<String, Image>();
|
||||
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<String> keywords = CollaborationKeywords.parseKeywords();
|
||||
List<StyleRange> ranges = new ArrayList<StyleRange>();
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue