private void listRoles() {
    // clear table.
    userRolesTable.removeAll();

    if (StringUtils.isNotBlank(serverUrlText.getText())
        && StringUtils.isNotBlank(userNameText.getText())
        && StringUtils.isNotBlank(passwordText.getText())) {
      UserManagerUtils.getInstance()
          .init(
              serverUrlText.getText().trim(),
              userNameText.getText().trim(),
              passwordText.getText().trim());
      String filter;
      if (StringUtils.isNotBlank(roleNamePatternText.getText())) {
        filter = roleNamePatternText.getText().trim();
      } else {
        filter = "*";
      }

      String[] roles = UserManagerUtils.getInstance().getRoles(filter, 1000);

      if (roles != null && roles.length > 0) {
        for (String role : roles) {
          if (!role.equals("false")) {
            TableItem item = new TableItem(userRolesTable, SWT.NONE);
            item.setText(new String[] {"", role});
          }
        }
      }
    }
  }
  private void listRoles() {
    // clear table.
    userRolesTable.removeAll();

    UserManagerUtils.getInstance()
        .init(
            serverUrlText.getText().trim(),
            userNameText.getText().trim(),
            passwordText.getText().trim());

    String filter;
    if (StringUtils.isNotBlank(roleNamePatternText.getText())) {
      filter = roleNamePatternText.getText().trim();
    } else {
      filter = "*";
    }

    List<String> roles;
    try {
      roles = UserManagerUtils.getInstance().getRoles(filter, 1000);
    } catch (Exception e) {
      // If the server connection fails due to connectivity issues or invalid credentials, showing
      // an error message
      MessageBox msg = new MessageBox(getShell(), SWT.ICON_ERROR);
      msg.setMessage(SecurityFormMessageConstants.SERVER_CONNECTION_FAILURE_MESSAGE);
      msg.open();
      return;
    }

    for (final String role : roles) {
      if (!role.equals("false")) {
        TableItem item = new TableItem(userRolesTable, SWT.RIGHT);
        item.setText(new String[] {role, role});
        if (selectedRoles.contains(role)) {
          item.setChecked(true);
        }
      }
    }

    userRolesTable.addListener(
        SWT.Selection,
        new Listener() {
          public void handleEvent(Event event) {
            updateSelectedRolesFromServer(event);
          }
        });
  }