Пример #1
0
  @Override
  public void doShowPage() {
    // table.setStyleName("permission-grant-table");
    mainPanel.clear();
    mainPanel.add(new Label(administrationConstants.loading()));

    AbstractCallback callback =
        new AbstractCallback(errorPanel) {
          public void onCallSuccess(Object permissions) {
            receivePermissions((Collection) permissions);
          }
        };
    getPermissions(callback);
  }
Пример #2
0
  protected void receiveGroups(Map groups2Permissions) {
    this.groups2Permissions = groups2Permissions;
    mainPanel.clear();

    ContentPanel cp = new FullContentPanel();
    cp.setHeading(administrationConstants.usersGroup());

    // add inline help string and widget
    //        cp.setTopComponent(new
    // InlineHelpPanel(galaxy.getRepositoryConstants().repo_Security_Tip(), 15));
    mainPanel.add(cp);

    table = createRowTable();
    cp.add(table);

    int col = 1;
    table.setWidget(0, 0, new Image("images/clearpixel.gif"));
    for (Iterator itr = permissions.iterator(); itr.hasNext(); ) {
      WPermission p = (WPermission) itr.next();
      table.setWidget(0, col, createTitleText(p.getDescription()));

      col++;
    }

    rows = new ArrayList<String>();
    for (Iterator itr = groups2Permissions.keySet().iterator(); itr.hasNext(); ) {
      rows.add(((WGroup) itr.next()).getName());
    }
    Collections.sort(rows);

    for (Iterator itr = groups2Permissions.entrySet().iterator(); itr.hasNext(); ) {
      Map.Entry e = (Map.Entry) itr.next();

      final WGroup role = (WGroup) e.getKey();
      final String groupName = role.getName();
      final Hyperlink hl = new Hyperlink(groupName, "groups/" + role.getId());

      int row = rows.indexOf(groupName) + 1;

      // certain groups should not be removed or edited via the GUI
      boolean isUberGroup = groupName.equals("Administrators") || groupName.equals("Anonymous");
      if (isUberGroup) {
        table.setWidget(row, 0, new Label(groupName));
      } else {
        table.setWidget(row, 0, hl);
      }

      Collection grants = (Collection) e.getValue();
      for (Iterator gItr = grants.iterator(); gItr.hasNext(); ) {
        WPermissionGrant pg = (WPermissionGrant) gItr.next();
        int permCol = getPermissionColumn(pg.getPermission().getName());
        if (permCol != -1) {
          Widget w = createGrantWidget(pg, isUberGroup);
          table.setWidget(row, permCol, w);
        }
      }
      row++;
    }

    // table.getFlexCellFormatter().setColSpan(rows.size() + 1, 0, col);

    SelectionListener listener =
        new SelectionListener<ComponentEvent>() {
          public void componentSelected(ComponentEvent ce) {
            Button btn = (Button) ce.getComponent();

            if (btn == applyButton) {
              beginApply();
            }
            if (btn == resetButton) {
              // Go back to the previously saved state.
              errorPanel.clearErrorMessage();
              doShowPage();
            }
          }
        };

    applyButton = new Button(administrationConstants.save(), listener);
    resetButton = new Button(administrationConstants.cancel(), listener);

    ButtonBar bb = new ButtonBar();
    bb.add(applyButton);
    bb.add(resetButton);
    bb.add(createHistoryButton(administrationConstants.newAdmin(), "groups/new"));

    // table.setWidget(rows.size() + 1, 0, bb);
    cp.add(bb);

    cp.layout(true);
  }