Fix a trivial null pointer exception while working on user management for connect...
authorBruno Sinou <bsinou@argeo.org>
Mon, 20 Jan 2014 16:52:33 +0000 (16:52 +0000)
committerBruno Sinou <bsinou@argeo.org>
Mon, 20 Jan 2014 16:52:33 +0000 (16:52 +0000)
git-svn-id: https://svn.argeo.org/commons/trunk@6731 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

security/plugins/org.argeo.security.ui.admin/src/main/java/org/argeo/security/ui/admin/commands/RefreshUsersList.java

index 0904ed2fb0e36645f0c34d87035d2af5bf9945b4..e4c14ab21b6ad0b3c2fe9aa83e11a5b7cbb9cf63 100644 (file)
@@ -33,6 +33,7 @@ import org.argeo.security.ui.admin.views.UsersView;
 import org.eclipse.core.commands.AbstractHandler;
 import org.eclipse.core.commands.ExecutionEvent;
 import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.ui.IWorkbenchPart;
 import org.eclipse.ui.handlers.HandlerUtil;
 
 /**
@@ -69,12 +70,22 @@ public class RefreshUsersList extends AbstractHandler {
                } finally {
                        JcrUtils.logoutQuietly(session);
                }
-
                userAdminService.synchronize();
+
+               // FIXME try to refresh views that extend the UsersView and have another
+               // ID
+               IWorkbenchPart part = HandlerUtil.getActiveWorkbenchWindow(event)
+                               .getActivePage().getActivePart();
+               if (part instanceof UsersView)
+                       ((UsersView) part).refresh();
+
+               // Try to refresh UsersView if opened
                UsersView view = (UsersView) HandlerUtil
                                .getActiveWorkbenchWindow(event).getActivePage()
                                .findView(UsersView.ID);
-               view.refresh();
+               if (view != null)
+                       view.refresh();
+
                return null;
        }