Package org.damour.base.client.objects

Examples of org.damour.base.client.objects.UserGroup


  }

  private void addGroupMembership() {
    final int index = allGroupsListBox.getSelectedIndex();
    final String groupName = allGroupsListBox.getItemText(index);
    final UserGroup group = groupMap.get(groupName);
    final AsyncCallback<GroupMembership> addUserCallback = new AsyncCallback<GroupMembership>() {
      public void onFailure(Throwable caught) {
        MessageDialogBox dialog = new MessageDialogBox("Error", caught.getMessage(), true, true, true);
        dialog.center();
      }
View Full Code Here


    final int index = groupsForUserListBox.getSelectedIndex();
    if (index == -1) {
      return;
    }
    final String groupName = groupsForUserListBox.getItemText(index);
    final UserGroup group = groupMap.get(groupName);
    final AsyncCallback<Void> deleteUserCallback = new AsyncCallback<Void>() {
      public void onFailure(Throwable caught) {
        MessageDialogBox dialog = new MessageDialogBox("Error", caught.getMessage(), true, true, true);
        dialog.center();
      }
View Full Code Here

            if (principalName.equalsIgnoreCase(user.getUsername())) {
              permission = mypermission;
              break;
            }
          } else if (showGroupPerms && mypermission.getSecurityPrincipal() instanceof UserGroup) {
            UserGroup group = (UserGroup) mypermission.getSecurityPrincipal();
            if (principalName.equalsIgnoreCase(group.getName())) {
              permission = mypermission;
              break;
            }
          }
        }
        permissions.remove(permission);
        dirty = true;
        populateUI();
        if (principalListBox.getItemCount() > 0) {
          principalListBox.setSelectedIndex(principalListBox.getItemCount() - 1);
        }
        populatePermissionPanel();
      }
    });

    Button newButton = new Button("New...");
    newButton.setCommand(new CreateGroupCommand(AuthenticationHandler.getInstance().getUser(), new IGenericCallback<UserGroup>() {
      public void invoke(UserGroup group) {
        dirty = true;
        Permission newPerm = new Permission();
        newPerm.setPermissibleObject(permissibleObject);
        newPerm.setSecurityPrincipal(group);
        permissions.add(newPerm);
        fetchedGroups.put(group.getName(), group);
        populateUI();
        if (principalListBox.getItemCount() > 0) {
          principalListBox.setSelectedIndex(principalListBox.getItemCount() - 1);
        }
        populatePermissionPanel();
View Full Code Here

        if (principalName.equalsIgnoreCase(user.getUsername())) {
          tmppermission = mypermission;
          break;
        }
      } else if (showGroupPerms && mypermission.getSecurityPrincipal() instanceof UserGroup) {
        UserGroup group = (UserGroup) mypermission.getSecurityPrincipal();
        if (principalName.equalsIgnoreCase(group.getName())) {
          tmppermission = mypermission;
          break;
        }
      }
    }
View Full Code Here

    for (Permission permission : permissions) {
      if (showUserPerms && permission.getSecurityPrincipal() instanceof User) {
        User user = (User) permission.getSecurityPrincipal();
        principalListBox.addItem(user.getUsername());
      } else if (showGroupPerms && permission.getSecurityPrincipal() instanceof UserGroup) {
        UserGroup group = (UserGroup) permission.getSecurityPrincipal();
        principalListBox.addItem(group.getName());
      }
    }
    populatePermissionPanel();
  }
View Full Code Here

    this.callback = callback;
  }

  public void execute() {
    popup.hide();
    final UserGroup group = new UserGroup();
    group.setOwner(user);

    final EditGroupPanel editGroupPanel = new EditGroupPanel(null, callback, null, group, false, false);
    final PromptDialogBox editGroupDialogBox = new PromptDialogBox("Create New Group", "OK", null, "Cancel", false, true);
    editGroupDialogBox.setContent(editGroupPanel);
    editGroupDialogBox.setFocusWidget(editGroupPanel.getNameTextBox());
View Full Code Here

    Button newGroupButton = new Button("New...");
    newGroupButton.setTitle("Create a New Group");
    newGroupButton.addClickHandler(new ClickHandler() {
      public void onClick(ClickEvent event) {
        final UserGroup group = new UserGroup();
        group.setOwner(user);
        editGroupPanel = new EditGroupPanel(callback, EditGroupsPanel.this, users, group, false, true);
        final PromptDialogBox editGroupDialogBox = new PromptDialogBox("Create New Group", "OK", null, "Cancel", false, true);
        editGroupDialogBox.setContent(editGroupPanel);
        editGroupDialogBox.setCallback(new IDialogCallback() {
          public void okPressed() {
            if (!editGroupPanel.apply()) {
              editGroupDialogBox.center();
            } else {
              populateUI();
              if (callback != null) {
                callback.userGroupsFetched(groups);
              }
            }
          }

          public void cancelPressed() {
          }
        });
        editGroupDialogBox.center();
      }
    });

    deleteGroupButton.setTitle("Delete Group");
    deleteGroupButton.setEnabled(false);
    deleteGroupButton.addClickHandler(new ClickHandler() {
      public void onClick(ClickEvent event) {

        if (groupsList.getSelectedIndex() < 0) {
          return;
        }

        final UserGroup group = groupMap.get(groupsList.getItemText(groupsList.getSelectedIndex()));

        final PromptDialogBox deleteGroupDialogBox = new PromptDialogBox("Confirm", "Yes", null, "No", false, true);
        deleteGroupDialogBox.setContent(new Label("Delete Group: " + group.getName() + "?"));
        deleteGroupDialogBox.setCallback(new IDialogCallback() {
          public void okPressed() {
            final AsyncCallback<Void> deleteGroupCallback = new AsyncCallback<Void>() {
              public void onFailure(Throwable caught) {
                MessageDialogBox dialog = new MessageDialogBox("Error", caught.getMessage(), true, true, true);
                dialog.center();
              }

              public void onSuccess(Void nothing) {
                groups.remove(group);
                lastListSelection = null;
                populateUI();
                if (callback != null) {
                  callback.userGroupsFetched(groups);
                }
              };
            };
            BaseServiceCache.getService().deleteGroup(group, deleteGroupCallback);

          }

          public void cancelPressed() {
          }
        });
        deleteGroupDialogBox.center();
      }
    });
    editGroupButton.setTitle("Edit Group Settings");
    editGroupButton.setEnabled(false);
    editGroupButton.addClickHandler(new ClickHandler() {
      public void onClick(ClickEvent event) {
        if (groupsList.getSelectedIndex() < 0) {
          return;
        }
        final UserGroup group = groupMap.get(groupsList.getItemText(groupsList.getSelectedIndex()));
        editGroupPanel = new EditGroupPanel(callback, EditGroupsPanel.this, users, group, false, true);
        final PromptDialogBox editGroupDialogBox = new PromptDialogBox("Edit Group", "OK", null, "Cancel", false, true);
        editGroupDialogBox.setContent(editGroupPanel);
        editGroupDialogBox.setCallback(new IDialogCallback() {
          public void okPressed() {
View Full Code Here

  private void populateUI() {
    setWidget(0, 1, new Label());
    groupsList.clear();
    groupMap.clear();
    for (int i = 0; i < groups.size(); i++) {
      UserGroup group = groups.get(i);
      groupsList.addItem(group.getName());
      if (lastListSelection != null && lastListSelection.equals(group.getName())) {
        groupsList.setSelectedIndex(i);
      }
      groupMap.put(group.getName(), group);
    }
    onChange(new com.google.gwt.event.dom.client.ChangeEvent() {
      public Object getSource() {
        return groupsList;
      }
View Full Code Here

  public void onChange(ChangeEvent event) {
    if (groupsList.getSelectedIndex() >= 0) {
      deleteGroupButton.setEnabled(true);
      editGroupButton.setEnabled(true);
      setWidget(0, 1, new Label("Loading..."));
      UserGroup group = groupMap.get(groupsList.getItemText(groupsList.getSelectedIndex()));
      lastListSelection = group.getName();

      if (editMembers) {
        CaptionPanel groupMembersCaptionPanel = new CaptionPanel("Edit Group Members");
        editGroupMembersPanel = new EditGroupMembersPanel(callback, this, users, group);
        groupMembersCaptionPanel.setContentWidget(editGroupMembersPanel);
View Full Code Here

  public void invoke(UserGroup group) {
    groupMap.put(group.getName(), group);
    lastListSelection = group.getName();

    if (groupsList.getSelectedIndex() != -1) {
      UserGroup tmpGroup = groupMap.get(groupsList.getItemText(groupsList.getSelectedIndex()));
      if (tmpGroup.getId().equals(group.getId())) {
        groupsList.setItemText(groupsList.getSelectedIndex(), group.getName());
      } else {
        groups.add(group);
        groupsList.addItem(group.getName());
        groupsList.setSelectedIndex(groupsList.getItemCount() - 1);
        onChange(new com.google.gwt.event.dom.client.ChangeEvent() {
          public Object getSource() {
            return groupsList;
          }
        });
      }
    } else {
      groups.add(group);
      groupsList.addItem(group.getName());
      groupsList.setSelectedIndex(groupsList.getItemCount() - 1);
      onChange(new com.google.gwt.event.dom.client.ChangeEvent() {
        public Object getSource() {
          return groupsList;
        }
      });
    }

    // replace
    for (int i = 0; i < groups.size(); i++) {
      UserGroup tmpGroup = groups.get(i);
      if (tmpGroup.getId().equals(group.getId())) {
        groups.set(i, group);
      }
    }

    if (callback != null) {
View Full Code Here

TOP

Related Classes of org.damour.base.client.objects.UserGroup

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.