From 34f57345ac5cc0f7b10e757cbfa5931f97fdd17d Mon Sep 17 00:00:00 2001 From: Matt Nash Date: Wed, 13 Jun 2012 12:58:11 -0500 Subject: [PATCH] Issue #711 add roles and site capability Former-commit-id: a9d225066a536ac27e2c8fa4081e6c5382aea487 [formerly a9d225066a536ac27e2c8fa4081e6c5382aea487 [formerly a49eee36dac39f172d7c4fa723a297d7cf94d5db]] Former-commit-id: 032827aa1b8e079d75f73f3a035b6bb9333284a2 Former-commit-id: 13a1fa879e75b5f317fec2a308f496c0ed445b64 --- .../META-INF/MANIFEST.MF | 3 +- .../icons/add_contact.gif | Bin 330 -> 0 bytes .../collaboration/userInformation.xml | 15 ++ .../plugin.xml | 45 ++-- .../ui/CollaborationGroupView.java | 225 ++++++++---------- .../ui/UserInformationParser.java | 89 +++++++ .../viz/collaboration/ui/UsersTreeFilter.java | 98 ++++++++ .../ui/UsersTreeLabelProvider.java | 27 ++- .../collaboration/ui/login/LoginDialog.java | 78 +++++- ...CollaborationSubscribeListPreferences.java | 69 ------ .../ui/role/UserInformation.java | 125 ++++++++++ .../ui/session/SessionFeedView.java | 4 +- .../collaboration/ui/session/SessionView.java | 4 +- 13 files changed, 548 insertions(+), 234 deletions(-) delete mode 100644 cave/com.raytheon.uf.viz.collaboration.ui/icons/add_contact.gif create mode 100644 cave/com.raytheon.uf.viz.collaboration.ui/localization/collaboration/userInformation.xml create mode 100644 cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/UserInformationParser.java create mode 100644 cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/UsersTreeFilter.java delete mode 100644 cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/prefs/CollaborationSubscribeListPreferences.java create mode 100644 cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/role/UserInformation.java diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/META-INF/MANIFEST.MF b/cave/com.raytheon.uf.viz.collaboration.ui/META-INF/MANIFEST.MF index 5c3e795ab8..5b57730529 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/META-INF/MANIFEST.MF +++ b/cave/com.raytheon.uf.viz.collaboration.ui/META-INF/MANIFEST.MF @@ -25,7 +25,8 @@ Require-Bundle: com.raytheon.viz.ui, com.raytheon.uf.viz.collaboration.display;bundle-version="1.0.0", gov.noaa.nws.ncep.ui.pgen;bundle-version="1.0.0", gov.noaa.nws.ncep.staticdataprovider;bundle-version="1.0.0", - gov.noaa.nws.ncep.common.staticdata;bundle-version="1.0.0" + gov.noaa.nws.ncep.common.staticdata;bundle-version="1.0.0", + org.eclipse.ecf.presence Import-Package: com.raytheon.uf.common.status, com.raytheon.uf.viz.core.maps.display, com.raytheon.uf.viz.core.maps.rsc, diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/icons/add_contact.gif b/cave/com.raytheon.uf.viz.collaboration.ui/icons/add_contact.gif deleted file mode 100644 index d3323e64fcbe8478a2e75795b85b9a3158f34037..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 330 zcmZ?wbhEHb6krfwxN68CkYS-QA;4fp#DkZw4_rvteC!TGfI{W;BNfw*e*X5uH*eL~ zA3r%FG#)%i`2O?PjYn@3DjX)QIO~%+@7(RD#eD~6Y`omCA>huF4{ttxZd-iz;Kc_^ zcVEB$=*5GV?@!%$;+DQ-+3xFY^H1G){GxBgg@n3omQiz;?!J-MwEe(^hbON;zWU&~ zSJv_cJ0hOH``9$+#EgwsoRSy)|NozXXrTC$g^_{5kUA6CDqi;Y%Jh==y1cnh5Qy#!WyjF y&H^m$?E>7gQmkt7&J2@uCNXgGvr3B^xbleca8GAd&{tM + + + + OAX + DMX + + + None + Short Term Forecaster + Long Term Forecaster + + diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/plugin.xml b/cave/com.raytheon.uf.viz.collaboration.ui/plugin.xml index 4f540e9180..2fe2423bb2 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/plugin.xml +++ b/cave/com.raytheon.uf.viz.collaboration.ui/plugin.xml @@ -22,26 +22,6 @@ - - - - - - + - - - - + + + diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/CollaborationGroupView.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/CollaborationGroupView.java index a3fdd86fc5..c9ff191421 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/CollaborationGroupView.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/CollaborationGroupView.java @@ -55,7 +55,6 @@ import org.eclipse.jface.viewers.DoubleClickEvent; import org.eclipse.jface.viewers.IDoubleClickListener; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.TreeSelection; -import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.jface.window.ToolTip; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.TreeEditor; @@ -90,6 +89,8 @@ import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.PartInitException; import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.dialogs.FilteredTree; +import org.eclipse.ui.dialogs.PatternFilter; import org.osgi.framework.Bundle; import com.google.common.eventbus.Subscribe; @@ -119,6 +120,7 @@ import com.raytheon.uf.viz.collaboration.ui.prefs.CollabPrefConstants; 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.SessionFeedView; import com.raytheon.uf.viz.collaboration.ui.session.SessionMsgArchive; import com.raytheon.uf.viz.collaboration.ui.session.SessionView; import com.raytheon.uf.viz.core.VizApp; @@ -151,7 +153,7 @@ public class CollaborationGroupView extends CaveFloatingView implements private SessionGroupContainer activeSessionGroup; - private TreeViewer usersTreeViewer; + private FilteredTree usersTreeViewer; private CollaborationGroupContainer topLevel; @@ -175,10 +177,6 @@ public class CollaborationGroupView extends CaveFloatingView implements private Action addGroupAction; - private Action addUserAction; - - private Action selectGroups; - private Action changeStatusMessageAction; private Action changeStatusAction; @@ -187,6 +185,8 @@ public class CollaborationGroupView extends CaveFloatingView implements private Action changePasswordAction; + private Action displayFeedAction; + // Drawing *will* be activated in collaboration views // private Action drawToolbarAction; @@ -253,7 +253,7 @@ public class CollaborationGroupView extends CaveFloatingView implements connection.registerEventHandler(this); } populateTree(); - usersTreeViewer.refresh(); + usersTreeViewer.getViewer().refresh(); parent.layout(); } @@ -295,7 +295,7 @@ public class CollaborationGroupView extends CaveFloatingView implements createArchiveViewerAction = new Action("View Log...") { private String getSessionName() { IStructuredSelection selection = (IStructuredSelection) usersTreeViewer - .getSelection(); + .getViewer().getSelection(); Object o = selection.getFirstElement(); String sessionName = null; @@ -316,15 +316,6 @@ public class CollaborationGroupView extends CaveFloatingView implements return sessionName; } - // @Override - // public boolean isEnabled() { - // CollaborationConnection conn = CollaborationDataManager - // .getInstance().getCollaborationConnection(true); - // UserId user = conn.getUser(); - // return SessionMsgArchive.getArchiveDir(user.getHost(), - // user.getName(), getSessionName()).exists(); - // }; - @Override public void runWithEvent(Event event) { UserId user = CollaborationConnection.getConnection().getUser(); @@ -398,12 +389,11 @@ public class CollaborationGroupView extends CaveFloatingView implements @Override public void run() { TreeSelection selection = (TreeSelection) usersTreeViewer - .getSelection(); + .getViewer().getSelection(); Object node = selection.getFirstElement(); if (node instanceof IVenueSession) { // loop through all the views so that we can bring the one - // that - // was selected to the top... + // that was selected to the top... IVenueSession session = (IVenueSession) selection .getFirstElement(); for (IViewReference ref : getViewSite() @@ -423,7 +413,7 @@ public class CollaborationGroupView extends CaveFloatingView implements @Override public void run() { TreeSelection selection = (TreeSelection) usersTreeViewer - .getSelection(); + .getViewer().getSelection(); Object node = selection.getFirstElement(); if (node instanceof IRosterEntry) { IRosterEntry user = (IRosterEntry) node; @@ -469,16 +459,6 @@ public class CollaborationGroupView extends CaveFloatingView implements }; }; - addUserAction = new Action("Add User") { - public void run() { - // addUsersToGroup(); - nyiFeature("Add User to a Group"); - }; - }; - addUserAction.setImageDescriptor(IconUtil.getImageDescriptor(bundle, - "add_contact.gif")); - addUserAction.setEnabled(false); - addGroupAction = new Action("Create Group") { public void run() { System.out.println("Create Group here"); @@ -489,14 +469,6 @@ public class CollaborationGroupView extends CaveFloatingView implements "add_group.gif")); addGroupAction.setEnabled(false); - selectGroups = new Action("Select System Groups...") { - public void run() { - System.out.println("Select System Groups to Display..."); - nyiFeature("Select System Groups."); - } - }; - selectGroups.setEnabled(false); - changeStatusMessageAction = new Action("Change Status Message...") { public void run() { changeStatusMessage(); @@ -541,7 +513,7 @@ public class CollaborationGroupView extends CaveFloatingView implements collapseAllAction = new Action("Collapse All") { public void run() { if (usersTreeViewer != null) { - usersTreeViewer.collapseAll(); + usersTreeViewer.getViewer().collapseAll(); } } }; @@ -575,45 +547,30 @@ public class CollaborationGroupView extends CaveFloatingView implements }; changeStatusAction.setMenuCreator(creator); - // TODO: Delete once drawing is activated in collaboration shared - // dispaly views - // drawToolbarAction = new Action("Drawing Toolbar") { - // @Override - // public void run() { - // // TODO: What should this do now? - // System.err.println("What should this method do now!?"); - // } - // }; - // drawToolbarAction.setImageDescriptor(IconUtil.getImageDescriptor( - // com.raytheon.uf.viz.drawing.Activator.getDefault().getBundle(), - // "draw.gif")); - // - // pgenAction = new Action("PGEN") { - // @Override - // public void run() { - // StaticDataProvider.getInstance(); - // try { - // // cause the classloader to load StaticDataProvider and thus - // // to call the Activator for - // // gov.noaa.nws.ncep.staticdataprovider. - // // This is done because of an initialization order problem - // // in PgenStaticDataProvider - // StaticDataProvider.getInstance(); - // ServiceReference ref = Activator - // .getDefault() - // .getBundle() - // .getBundleContext() - // .getServiceReference( - // IStaticDataProvider.class.getName()); - // - // PlatformUI.getWorkbench().getActiveWorkbenchWindow() - // .getActivePage().showView(PgenUtil.VIEW_ID); - // } catch (PartInitException e) { - // statusHandler.handle(Priority.PROBLEM, - // "Unable to open PGEN palette", e); - // } - // } - // }; + displayFeedAction = new Action("Display Feed") { + public void run() { + CollaborationConnection connection = CollaborationConnection + .getConnection(); + try { + // TODO, make this configurable? + IVenueSession session = connection + .joinTextOnlyVenue("nws-collaboration"); + PlatformUI + .getWorkbench() + .getActiveWorkbenchWindow() + .getActivePage() + .showView(SessionFeedView.ID, + session.getSessionId(), + IWorkbenchPage.VIEW_ACTIVATE); + } catch (CollaborationException e) { + statusHandler.handle(Priority.PROBLEM, + "Unable to join the collaboration feed", e); + } catch (PartInitException e) { + statusHandler.handle(Priority.PROBLEM, + "Unable to join collaboration feed", e); + } + }; + }; } /** @@ -624,6 +581,7 @@ public class CollaborationGroupView extends CaveFloatingView implements mgr.add(createSessionAction); mgr.add(collapseAllAction); mgr.add(linkToEditorAction); + // mgr.add(displayFeedAction); } /** @@ -645,8 +603,6 @@ public class CollaborationGroupView extends CaveFloatingView implements private void createMenu(IMenuManager mgr) { mgr.add(addGroupAction); - mgr.add(addUserAction); - mgr.add(selectGroups); mgr.add(new Separator()); mgr.add(fontChangeAction); mgr.add(changeStatusAction); @@ -676,9 +632,10 @@ public class CollaborationGroupView extends CaveFloatingView implements fillContextMenu(manager); } }); - Menu menu = menuMgr.createContextMenu(usersTreeViewer.getControl()); - usersTreeViewer.getControl().setMenu(menu); - getSite().registerContextMenu(menuMgr, usersTreeViewer); + Menu menu = menuMgr.createContextMenu(usersTreeViewer.getViewer() + .getControl()); + usersTreeViewer.getViewer().getControl().setMenu(menu); + getSite().registerContextMenu(menuMgr, usersTreeViewer.getViewer()); } /** @@ -690,10 +647,8 @@ public class CollaborationGroupView extends CaveFloatingView implements topLevel.clear(); // set all the menu actions to false to start with if (connection == null) { - usersTreeViewer.getTree().setEnabled(false); + usersTreeViewer.getViewer().getTree().setEnabled(false); addGroupAction.setEnabled(false); - addUserAction.setEnabled(false); - selectGroups.setEnabled(false); changeStatusAction.setEnabled(false); fontChangeAction.setEnabled(false); changeStatusMessageAction.setEnabled(false); @@ -703,8 +658,6 @@ public class CollaborationGroupView extends CaveFloatingView implements // enable all the actions addGroupAction.setEnabled(true); - addUserAction.setEnabled(true); - selectGroups.setEnabled(true); changeStatusAction.setEnabled(true); fontChangeAction.setEnabled(true); changeStatusMessageAction.setEnabled(true); @@ -726,8 +679,8 @@ public class CollaborationGroupView extends CaveFloatingView implements populateGroups(); // enable the tree, and then refresh it just to be safe - usersTreeViewer.getTree().setEnabled(true); - usersTreeViewer.refresh(topLevel, true); + usersTreeViewer.getViewer().getTree().setEnabled(true); + usersTreeViewer.getViewer().refresh(topLevel, true); this.disableOrEnableToolbarActions(); createArchiveViewerAction.setEnabled(true); } @@ -787,7 +740,7 @@ public class CollaborationGroupView extends CaveFloatingView implements */ private void fillContextMenu(IMenuManager manager) { IStructuredSelection selection = (IStructuredSelection) usersTreeViewer - .getSelection(); + .getViewer().getSelection(); Object o = selection.getFirstElement(); // handle the session group portion of the group view @@ -847,18 +800,20 @@ public class CollaborationGroupView extends CaveFloatingView implements } private void addDoubleClickListeners() { - usersTreeViewer.addDoubleClickListener(new IDoubleClickListener() { - @Override - public void doubleClick(DoubleClickEvent event) { - peerToPeerChatAction.run(); - } - }); - usersTreeViewer.addDoubleClickListener(new IDoubleClickListener() { - @Override - public void doubleClick(DoubleClickEvent event) { - joinAction.run(); - } - }); + usersTreeViewer.getViewer().addDoubleClickListener( + new IDoubleClickListener() { + @Override + public void doubleClick(DoubleClickEvent event) { + peerToPeerChatAction.run(); + } + }); + usersTreeViewer.getViewer().addDoubleClickListener( + new IDoubleClickListener() { + @Override + public void doubleClick(DoubleClickEvent event) { + joinAction.run(); + } + }); } /** @@ -872,11 +827,11 @@ public class CollaborationGroupView extends CaveFloatingView implements if (oldEditor != null) { oldEditor.dispose(); } - TreeSelection selection = (TreeSelection) usersTreeViewer + TreeSelection selection = (TreeSelection) usersTreeViewer.getViewer() .getSelection(); final IRosterEntry entry = (IRosterEntry) selection.getFirstElement(); - final Composite comp = new Composite(usersTreeViewer.getTree(), - SWT.NONE); + final Composite comp = new Composite(usersTreeViewer.getViewer() + .getTree(), SWT.NONE); comp.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK)); final Text text = new Text(comp, SWT.NONE); @@ -909,10 +864,11 @@ public class CollaborationGroupView extends CaveFloatingView implements // public void handleEvent(Event event) { // final TreeItem item = (TreeItem) event.item; // if (item != null && item == lastItem[0]) { - final TreeItem item = usersTreeViewer.getTree().getSelection()[0]; + final TreeItem item = usersTreeViewer.getViewer().getTree() + .getSelection()[0]; boolean showBorder = true; - final Composite composite = new Composite(usersTreeViewer.getTree(), - SWT.NONE); + final Composite composite = new Composite(usersTreeViewer.getViewer() + .getTree(), SWT.NONE); if (showBorder) composite.setBackground(Display.getCurrent().getSystemColor( SWT.COLOR_BLACK)); @@ -959,7 +915,8 @@ public class CollaborationGroupView extends CaveFloatingView implements size = modText.computeSize(size.x, SWT.DEFAULT); treeEditor.horizontalAlignment = SWT.LEFT; Rectangle itemRect = item.getBounds(), - rect = usersTreeViewer.getTree().getClientArea(); + rect = usersTreeViewer.getViewer().getTree() + .getClientArea(); treeEditor.minimumWidth = Math.max(size.x, itemRect.width) + inset * 2; int left = itemRect.x, @@ -1035,7 +992,7 @@ public class CollaborationGroupView extends CaveFloatingView implements // need to refresh the local tree so that the top user shows up with the // current status UserId id = (UserId) topLevel.getObjects().get(0); - usersTreeViewer.refresh(id); + usersTreeViewer.getViewer().refresh(id); } private void createSession() { @@ -1161,7 +1118,7 @@ public class CollaborationGroupView extends CaveFloatingView implements UserId id = (UserId) peer; String name = peer.getFQName(); TreeSelection selection = (TreeSelection) usersTreeViewer - .getSelection(); + .getViewer().getSelection(); IRosterEntry entry = (IRosterEntry) selection.getFirstElement(); if (id.getAlias() != null && !id.getAlias().isEmpty()) { name = id.getAlias(); @@ -1192,21 +1149,27 @@ public class CollaborationGroupView extends CaveFloatingView implements Composite child = new Composite(parent, SWT.NONE); child.setLayout(new GridLayout(1, false)); child.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - usersTreeViewer = new TreeViewer(child); - usersTreeViewer.getTree().setLayoutData( - new GridData(SWT.FILL, SWT.FILL, true, true)); + PatternFilter pFilter = new UsersTreeFilter(); + usersTreeViewer = new FilteredTree(child, SWT.MULTI | SWT.V_SCROLL + | SWT.H_SCROLL | SWT.BORDER, pFilter, true); + usersTreeViewer.getViewer().getTree() + .setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - TreeColumn column = new TreeColumn(usersTreeViewer.getTree(), SWT.NONE); + TreeColumn column = new TreeColumn(usersTreeViewer.getViewer() + .getTree(), SWT.NONE); column.setWidth(200); // any width would work - usersTreeViewer.setContentProvider(new UsersTreeContentProvider()); - usersTreeViewer.setLabelProvider(new UsersTreeLabelProvider()); - usersTreeViewer.setSorter(new UsersTreeViewerSorter()); - ColumnViewerToolTipSupport.enableFor(usersTreeViewer, ToolTip.RECREATE); + usersTreeViewer.getViewer().setContentProvider( + new UsersTreeContentProvider()); + usersTreeViewer.getViewer().setLabelProvider( + new UsersTreeLabelProvider()); + usersTreeViewer.getViewer().setSorter(new UsersTreeViewerSorter()); + ColumnViewerToolTipSupport.enableFor(usersTreeViewer.getViewer(), + ToolTip.RECREATE); topLevel = new CollaborationGroupContainer(); - usersTreeViewer.setInput(topLevel); + usersTreeViewer.getViewer().setInput(topLevel); - treeEditor = new TreeEditor(usersTreeViewer.getTree()); + treeEditor = new TreeEditor(usersTreeViewer.getViewer().getTree()); } /** @@ -1280,7 +1243,7 @@ public class CollaborationGroupView extends CaveFloatingView implements private Set getSelectedUsers() { Set selectedUsers = new HashSet(); IStructuredSelection selection = (IStructuredSelection) usersTreeViewer - .getSelection(); + .getViewer().getSelection(); Object[] nodes = selection.toArray(); for (Object node : nodes) { @@ -1323,7 +1286,7 @@ public class CollaborationGroupView extends CaveFloatingView implements for (Object child : group.getEntries()) { if (child instanceof IRosterEntry) { if (userId.equals(((IRosterEntry) child).getUser())) { - usersTreeViewer.refresh(child, true); + usersTreeViewer.getViewer().refresh(child, true); } } else if (child instanceof IRosterGroup) { refreshUser(userId, (IRosterGroup) child); @@ -1380,7 +1343,7 @@ public class CollaborationGroupView extends CaveFloatingView implements VizApp.runAsync(new Runnable() { @Override public void run() { - usersTreeViewer.refresh(rosterItem); + usersTreeViewer.getViewer().refresh(rosterItem); } }); } else if (rosterItem instanceof IRosterGroup) { @@ -1399,7 +1362,7 @@ public class CollaborationGroupView extends CaveFloatingView implements VizApp.runAsync(new Runnable() { @Override public void run() { - usersTreeViewer.refresh(topLevel); + usersTreeViewer.getViewer().refresh(topLevel); } }); } @@ -1429,7 +1392,7 @@ public class CollaborationGroupView extends CaveFloatingView implements VizApp.runAsync(new Runnable() { @Override public void run() { - usersTreeViewer.refresh(ob); + usersTreeViewer.getViewer().refresh(ob); } }); } @@ -1444,7 +1407,7 @@ public class CollaborationGroupView extends CaveFloatingView implements VizApp.runAsync(new Runnable() { @Override public void run() { - usersTreeViewer.refresh(ob); + usersTreeViewer.getViewer().refresh(ob); } }); break; @@ -1542,7 +1505,7 @@ public class CollaborationGroupView extends CaveFloatingView implements activeSessionGroup.addObject(session); // register here because we unregister in part closed session.registerEventHandler(sessionView); - usersTreeViewer.refresh(activeSessionGroup); + usersTreeViewer.getViewer().refresh(activeSessionGroup); } } @@ -1571,7 +1534,7 @@ public class CollaborationGroupView extends CaveFloatingView implements // active sessions if (sessionId.equals(group.getSessionId())) { activeSessionGroup.removeObject(node); - usersTreeViewer.refresh(activeSessionGroup); + usersTreeViewer.getViewer().refresh(activeSessionGroup); break; } } diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/UserInformationParser.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/UserInformationParser.java new file mode 100644 index 0000000000..ac351300ba --- /dev/null +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/UserInformationParser.java @@ -0,0 +1,89 @@ +/** + * 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; + +import java.io.File; +import java.util.Map; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Unmarshaller; + +import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel; +import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType; +import com.raytheon.uf.common.localization.LocalizationFile; +import com.raytheon.uf.common.localization.PathManager; +import com.raytheon.uf.common.localization.PathManagerFactory; +import com.raytheon.uf.viz.collaboration.ui.role.UserInformation; + +/** + * Parse a file to grab attributes about a user + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Jun 12, 2012            mnash     Initial creation
+ * 
+ * 
+ * + * @author mnash + * @version 1.0 + */ +public class UserInformationParser { + + /** + * Go to the userinformation.xml file and grab the user information, for use + * in determining what kind of user you are in collaboration + * + * @return + */ + public static UserInformation parseUserInformation() { + PathManager pm = (PathManager) PathManagerFactory.getPathManager(); + Map files = pm + .getTieredLocalizationFile(LocalizationType.CAVE_STATIC, + "collaboration" + File.separator + + "userInformation.xml"); + + LocalizationFile lFile = null; + for (LocalizationFile file : files.values()) { + // this is not something that the user should define + if (file.getContext().getLocalizationLevel().isSystemLevel() + || file.getContext().getLocalizationLevel() == LocalizationLevel.SITE) { + lFile = file; + } + } + + File toFile = lFile.getFile(); + try { + JAXBContext context = JAXBContext + .newInstance(UserInformation.class); + Unmarshaller unmarshaller = context.createUnmarshaller(); + UserInformation info = (UserInformation) unmarshaller + .unmarshal(toFile); + return info; + } catch (JAXBException e) { + e.printStackTrace(); + } + return null; + } +} diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/UsersTreeFilter.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/UsersTreeFilter.java new file mode 100644 index 0000000000..e6d3c0f16e --- /dev/null +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/UsersTreeFilter.java @@ -0,0 +1,98 @@ +/** + * 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; + +import java.text.BreakIterator; +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.ui.dialogs.PatternFilter; + +/** + * TODO Add Description + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Jun 13, 2012            mnash     Initial creation
+ * 
+ * 
+ * + * @author mnash + * @version 1.0 + */ + +public class UsersTreeFilter extends PatternFilter { + /** + * + */ + public UsersTreeFilter() { + // TODO Auto-generated constructor stub + setIncludeLeadingWildcard(true); + } + + @Override + public void setPattern(String patternString) { + super.setPattern(patternString); + // String[] words = getWords(patternString); + // StringBuilder builder = new StringBuilder(); + // for (String word : words) { + // builder.append("(?=").append(word).append(")"); + // } + // super.setPattern(builder.toString()); + } + + /** + * Taken from PatternFilter + * + * @param text + * @return + */ + private String[] getWords(String text) { + List words = new ArrayList(); + // Break the text up into words, separating based on whitespace and + // common punctuation. + // Previously used String.split(..., "\\W"), where "\W" is a regular + // expression (see the Javadoc for class Pattern). + // Need to avoid both String.split and regular expressions, in order to + // compile against JCL Foundation (bug 80053). + // Also need to do this in an NL-sensitive way. The use of BreakIterator + // was suggested in bug 90579. + BreakIterator iter = BreakIterator.getWordInstance(); + iter.setText(text); + int i = iter.first(); + while (i != java.text.BreakIterator.DONE && i < text.length()) { + int j = iter.following(i); + if (j == java.text.BreakIterator.DONE) { + j = text.length(); + } + // match the word + if (Character.isLetterOrDigit(text.charAt(i))) { + String word = text.substring(i, j); + words.add(word); + } + i = j; + } + return (String[]) words.toArray(new String[words.size()]); + } +} \ No newline at end of file diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/UsersTreeLabelProvider.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/UsersTreeLabelProvider.java index 43b81a42fe..e92ad779cc 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/UsersTreeLabelProvider.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/UsersTreeLabelProvider.java @@ -119,7 +119,21 @@ public class UsersTreeLabelProvider extends ColumnLabelProvider { return id.getAlias(); } else if (entry.getUser().getName() != null && !entry.getUser().getName().isEmpty()) { - return entry.getUser().getName(); + IPresence presence = entry.getPresence(); + String returnVal = entry.getUser().getName(); + if (presence != null) { + if (presence.getProperties() != null) { + if (presence.getProperties().get("site") != null) { + returnVal += " - " + + presence.getProperties().get("site"); + } + if (presence.getProperties().get("role") != null) { + returnVal += " - " + + presence.getProperties().get("role"); + } + } + } + return returnVal; } else { return id.getName(); } @@ -128,7 +142,11 @@ public class UsersTreeLabelProvider extends ColumnLabelProvider { } else if (element instanceof SessionGroupContainer) { return "Active Sessions"; } else if (element instanceof UserId) { + IPresence presence = CollaborationConnection.getConnection() + .getPresence(); return ((UserId) element).getName() + " - " + + presence.getProperties().get("site") + " - " + + presence.getProperties().get("role") + " - " + ((UserId) element).getHost(); } else if (element instanceof IVenueSession) { if (((IVenueSession) element).getVenue() == null) { @@ -174,14 +192,17 @@ public class UsersTreeLabelProvider extends ColumnLabelProvider { builder.append(CollaborationUtils.formatMode(user.getPresence() .getMode())); - // builder.append("Type: ").append(user.getType()) - // .append("\n"); String message = user.getPresence().getStatus(); if (message != null && message.length() > 0) { builder.append("\n"); builder.append("Message: \"").append( user.getPresence().getStatus() + "\""); } + + for (Object ob : user.getPresence().getProperties().keySet()) { + builder.append("\n").append(ob.toString()).append(" : ") + .append(user.getPresence().getProperties().get(ob)); + } } return builder.toString(); } diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/login/LoginDialog.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/login/LoginDialog.java index 5e7c4d0c5f..3660385f25 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/login/LoginDialog.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/login/LoginDialog.java @@ -22,7 +22,9 @@ package com.raytheon.uf.viz.collaboration.ui.login; import java.io.IOException; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; @@ -55,7 +57,9 @@ import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId; import com.raytheon.uf.viz.collaboration.ui.Activator; import com.raytheon.uf.viz.collaboration.ui.CollaborationUtils; import com.raytheon.uf.viz.collaboration.ui.ConnectionSubscriber; +import com.raytheon.uf.viz.collaboration.ui.UserInformationParser; import com.raytheon.uf.viz.collaboration.ui.prefs.CollabPrefConstants; +import com.raytheon.uf.viz.collaboration.ui.role.UserInformation; import com.raytheon.uf.viz.core.VizApp; import com.raytheon.viz.ui.dialogs.CaveSWTDialog; @@ -90,6 +94,8 @@ public class LoginDialog extends CaveSWTDialog { private Combo statusCombo; + private List combos; + private Text messageTF; private Button logOnButton; @@ -233,6 +239,53 @@ public class LoginDialog extends CaveSWTDialog { gd.horizontalSpan = 2; messageTF.setLayoutData(gd); + Composite comp = new Composite(body, SWT.NONE); + gd = new GridData(SWT.FILL, SWT.FILL, true, true); + gd.horizontalSpan = 3; + GridLayout layout = new GridLayout(4, false); + layout.marginHeight = 0; + layout.marginWidth = 0; + comp.setLayout(layout); + comp.setLayoutData(gd); + + UserInformation information = UserInformationParser + .parseUserInformation(); + combos = new ArrayList(); + for (UserInformation.Info info : information.getInfo()) { + Label comboLabel = new Label(comp, SWT.NONE); + gd = new GridData(SWT.NONE, SWT.FILL, false, true); + comboLabel.setLayoutData(gd); + String name = info.getName(); + final StringBuilder result = new StringBuilder(name.length()); + String[] words = name.split("\\s"); + for (int i = 0, l = words.length; i < l; ++i) { + if (i > 0) + result.append(" "); + result.append(Character.toUpperCase(words[i].charAt(0))) + .append(words[i].substring(1)); + } + ; + comboLabel.setText(result.toString() + " :"); + if (info.isAllowMultiple()) { + org.eclipse.swt.widgets.List list = new org.eclipse.swt.widgets.List( + comp, SWT.MULTI); + list.setData(info.getName()); + list.setItems(info.getAttibuteOptions()); + gd = new GridData(SWT.FILL, SWT.FILL, true, true); + list.setLayoutData(gd); + list.select(0); + combos.add(list); + } else { + Combo combo = new Combo(comp, SWT.DROP_DOWN | SWT.READ_ONLY); + combo.setData(info.getName()); + combo.setItems(info.getAttibuteOptions()); + gd = new GridData(SWT.FILL, SWT.NONE, true, true); + combo.setLayoutData(gd); + combo.select(0); + combos.add(combo); + } + } + noServerList = new Control[] { userTF, passwordTF, statusCombo, messageTF, serverButton }; withServerList = new Control[] { userTF, serverTF, serverButton, @@ -358,11 +411,35 @@ public class LoginDialog extends CaveSWTDialog { final String usr = user; final String passwd = password; final IPresence pres = initialPres; + final Map nameToText = new HashMap(); + for (Control control : combos) { + if (control instanceof Combo) { + Combo combo = (Combo) control; + nameToText.put(combo.getData().toString(), + combo.getText()); + } else if (control instanceof org.eclipse.swt.widgets.List) { + org.eclipse.swt.widgets.List list = (org.eclipse.swt.widgets.List) control; + String result = ""; + for (String string : list.getSelection()) { + result += string + "/"; + } + result = result.substring(0, + result.length() - 1); + nameToText.put(list.getData().toString(), + result); + } + } Job job = new Job( "Creating the server connection...") { protected org.eclipse.core.runtime.IStatus run( org.eclipse.core.runtime.IProgressMonitor monitor) { try { + // add all the values from the combo + // boxes into the presence + for (String name : nameToText.keySet()) { + pres.getProperties().put(name, + nameToText.get(name)); + } CollaborationConnection connection = CollaborationConnection .connect(new UserId(usr, srvr), passwd, pres); @@ -434,5 +511,4 @@ public class LoginDialog extends CaveSWTDialog { } return button; } - } diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/prefs/CollaborationSubscribeListPreferences.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/prefs/CollaborationSubscribeListPreferences.java deleted file mode 100644 index 852b83c59a..0000000000 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/prefs/CollaborationSubscribeListPreferences.java +++ /dev/null @@ -1,69 +0,0 @@ -/** - * 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.prefs; - -import org.eclipse.jface.preference.FieldEditorPreferencePage; - -/** - * TODO Add Description - * - *
- * 
- * SOFTWARE HISTORY
- * 
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * Jun 7, 2012            mnash     Initial creation
- * 
- * 
- * - * @author mnash - * @version 1.0 - */ - -public class CollaborationSubscribeListPreferences extends - FieldEditorPreferencePage { - - /** - * - */ - public CollaborationSubscribeListPreferences() { - } - - /** - * @param style - */ - public CollaborationSubscribeListPreferences(int style) { - super(GRID); - } - - /* - * (non-Javadoc) - * - * @see - * org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors - * () - */ - @Override - protected void createFieldEditors() { - // // TODO Auto-generated method stub - // CollaborationConnection.getConnection().getRosterManager().get - } -} diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/role/UserInformation.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/role/UserInformation.java new file mode 100644 index 0000000000..ab8f89c791 --- /dev/null +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/role/UserInformation.java @@ -0,0 +1,125 @@ +/** + * 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.role; + +import java.util.List; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +/** + * TODO Add Description + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Jun 12, 2012            mnash     Initial creation
+ * 
+ * 
+ * + * @author mnash + * @version 1.0 + */ + +@XmlRootElement +@XmlAccessorType(XmlAccessType.NONE) +public class UserInformation { + @XmlElement + private List info; + + /** + * @return the infos + */ + public List getInfo() { + return info; + } + + /** + * @param infos + * the infos to set + */ + public void setInfo(List info) { + this.info = info; + } + + @XmlAccessorType(XmlAccessType.NONE) + public static class Info { + + @XmlAttribute + private String name; + + @XmlElement + private String[] attibuteOptions; + + @XmlAttribute + private boolean allowMultiple; + + /** + * @return the name + */ + public String getName() { + return name; + } + + /** + * @param name + * the name to set + */ + public void setName(String name) { + this.name = name; + } + + /** + * @return the attibuteOptions + */ + public String[] getAttibuteOptions() { + return attibuteOptions; + } + + /** + * @param attibuteOptions + * the attibuteOptions to set + */ + public void setAttibuteOptions(String[] attibuteOptions) { + this.attibuteOptions = attibuteOptions; + } + + /** + * @param allowMultiple + * the allowMultiple to set + */ + public void setAllowMultiple(boolean allowMultiple) { + this.allowMultiple = allowMultiple; + } + + /** + * @return the allowMultiple + */ + public boolean isAllowMultiple() { + return allowMultiple; + } + } +} \ No newline at end of file diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/SessionFeedView.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/SessionFeedView.java index 8d8ecd7339..2d90512fb5 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/SessionFeedView.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/SessionFeedView.java @@ -96,7 +96,8 @@ public class SessionFeedView extends SessionView { private List readEnabledUsers() { LocalizationFile file = getLocalizationFile(); if (file.exists()) { - SubscribeList list = JAXB.unmarshal(file.getFile(), SubscribeList.class); + SubscribeList list = JAXB.unmarshal(file.getFile(), + SubscribeList.class); return list.getEnabledUsers(); } return new ArrayList(); @@ -233,6 +234,7 @@ public class SessionFeedView extends SessionView { */ @Override protected void setParticipantValues(ParticipantsLabelProvider labelProvider) { + participantsLabel.setText("Subscribed"); super.setParticipantValues(labelProvider); labelProvider.setEnabledUsers(enabledUsers); } diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/SessionView.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/SessionView.java index 02f872c156..a51d617b13 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/SessionView.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/SessionView.java @@ -102,6 +102,8 @@ public class SessionView extends AbstractSessionView { protected TableViewer usersTable; + protected CLabel participantsLabel; + protected String sessionId; protected IVenueSession session; @@ -250,7 +252,7 @@ public class SessionView extends AbstractSessionView { comp.setLayout(layout); comp.setLayoutData(data); - final CLabel participantsLabel = new CLabel(comp, SWT.NONE); + participantsLabel = new CLabel(comp, SWT.NONE); layout = new GridLayout(1, false); data = new GridData(SWT.FILL, SWT.DEFAULT, true, false); participantsLabel.setLayout(layout);