@Override
protected void handleEvent(AppEvent<?> event) {
switch (event.type) {
case WPaloEvent.INIT:
if(event.data instanceof XUser) {
XUser user = (XUser)event.data;
//check if we are admin:
if(user.isAdmin()) {
//create ui:
initUI(user);
}
} else if (event.data instanceof DisplayFlags) {
DisplayFlags df = (DisplayFlags) event.data;
if (!DisplayFlags.isHideNavigator()) {
XUser user = df.getUser();
//check if we are admin:
if(user.isAdmin()) {
//create ui:
if(!df.isHideUsersRights()){
initUI(user);
}
}
}
}
break;
case WPaloEvent.EXPANDED_ADMIN_SECTION: //load tree data
TreeNode node = (TreeNode) event.data;
if (node != null) {
treeLoader.load(node);
}
break;
case WPaloEvent.SAVED_USER_ITEM:
case WPaloEvent.SAVED_GROUP_ITEM:
case WPaloEvent.SAVED_ROLE_ITEM:
if (treeStore == null) {
return;
}
TreeNode nd = (TreeNode) event.data;
if (nd != null) {
if(nd.getParent() != null)
treeStore.update(nd);
else {
int index = getParentIndex(event.type);
treeStore.add(root.getChild(index), nd, false);
root.getChild(index).add(nd);
//shouldn't the store take care of this???
if(nd.getParent() == null)
nd.setParent(root.getChild(index));
}
}
if (event.type == WPaloEvent.SAVED_USER_ITEM) {
lastCreatedUser = (XUser) nd.getXObject();
final XUser user = ((Workbench)Registry.get(Workbench.ID)).getUser();
String sessionId = user.getSessionId();
final String userId = user.getId();
WPaloAdminServiceProvider.getInstance().hasRoles(sessionId, lastCreatedUser, new String [] {"VIEWER", "EDITOR"},
new AsyncCallback<Boolean[]>() {
public void onSuccess(Boolean[] result) {
String message = "";
if (lastCreatedUser.getAccountIDs() == null ||