private List<Menus> getRoles() {
   final List<Menus> result = new ArrayList<Menus>(identity.getRoles().size());
   result.add(
       MenuFactory.newSimpleItem(constants.LogOut())
           .respondsWith(new LogoutCommand())
           .endMenu()
           .build());
   for (final Role role : identity.getRoles()) {
     if (!role.getName().equals("IS_REMEMBER_ME")) {
       result.add(
           MenuFactory.newSimpleItem(constants.Role() + ": " + role.getName()).endMenu().build());
     }
   }
   return result;
 }
Exemplo n.º 2
0
 private List<AuditLogEntry> filterDeletedEntries(final List<AuditLogEntry> entries) {
   if (!identity.getRoles().contains(new RoleImpl(AppRoles.ADMIN.getName()))) {
     return entries;
   }
   final List<AuditLogEntry> filteredEntries = new ArrayList<AuditLogEntry>();
   final Iterator<AuditLogEntry> i = entries.iterator();
   while (i.hasNext()) {
     final AuditLogEntry entry = i.next();
     if (!entry.isDeleted()) {
       filteredEntries.add(entry);
     }
   }
   return filteredEntries;
 }
Exemplo n.º 3
0
  public void setup() {
    // BZ-996917: Use a the gwtboostrap style "row-fluid" to allow display some events in the same
    // row.
    eventTypes.setStyleName(Styles.ROW);

    // Fill panel with available events.
    for (Map.Entry<String, Boolean> e :
        auditLog.getAuditLogFilter().getAcceptedTypes().entrySet()) {
      eventTypes.add(makeEventTypeCheckBox(e.getKey(), e.getValue()));
    }

    // Create the GWT Cell Table as events container.
    // BZ-996942: Set custom width and table css style.
    events = new CellTable<AuditLogEntry>();
    events.setWidth("100%");
    events.addStyleName(Styles.TABLE);

    final ListDataProvider<AuditLogEntry> dlp =
        new ListDataProvider<AuditLogEntry>(filterDeletedEntries(auditLog));
    dlp.addDataDisplay(events);

    AuditLogEntrySummaryColumn summaryColumn =
        new AuditLogEntrySummaryColumn(style.auditLogDetailLabel(), style.auditLogDetailValue());
    AuditLogEntryCommentColumn commentColumn = new AuditLogEntryCommentColumn();

    events.addColumn(summaryColumn);
    events.addColumn(commentColumn);

    events.setColumnWidth(summaryColumn, 60.0, Unit.PCT);
    events.setColumnWidth(commentColumn, 40.0, Unit.PCT);

    // If the current user is not an Administrator include the delete comment column
    if (identity.getRoles().contains(new RoleImpl(AppRoles.ADMIN.getName()))) {

      AuditLogEntryDeleteCommentColumn deleteCommentColumn = new AuditLogEntryDeleteCommentColumn();
      deleteCommentColumn.setFieldUpdater(
          new FieldUpdater<AuditLogEntry, SafeHtml>() {

            public void update(int index, AuditLogEntry row, SafeHtml value) {
              row.setDeleted(true);
              dlp.setList(filterDeletedEntries(auditLog));
              dlp.refresh();
            }
          });
      events.addColumn(deleteCommentColumn);
      events.setColumnWidth(commentColumn, 35.0, Unit.PCT);
      events.setColumnWidth(deleteCommentColumn, 5.0, Unit.PCT);
    }

    events.setEmptyTableWidget(
        new Label(GuidedDecisionTableConstants.INSTANCE.DecisionTableAuditLogNoEntries()));
    events.setKeyboardPagingPolicy(KeyboardPagingPolicy.CHANGE_PAGE);
    events.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED);
    events.setPageSize(PAGE_SIZE);

    // Configure the simple pager.
    pager.setDisplay(events);
    pager.setPageSize(PAGE_SIZE);

    events.addRangeChangeHandler(
        new RangeChangeEvent.Handler() {
          @Override
          public void onRangeChange(final RangeChangeEvent event) {
            cellTablePagination.rebuild(pager);
          }
        });

    cellTablePagination.rebuild(pager);

    // Add the table to the container.
    eventsContainer.add(events);
  }
Exemplo n.º 4
0
 public void updateLabels(User user) {
   userLabel.setText(user.getIdentifier());
   rolesLabel.setText(user.getRoles().toString());
   groupsLabel.setText(user.getGroups().toString());
 }