class UserGroupsExplorer implements IsWidget {

    public void show(final Set<Group> groups,
                     final boolean canRemove) {
        // Clear current view.
        clear();

        // Remove assigned group feature.
        this.canRemove = canRemove;

        groupList.show(groups,
                       new EntitiesList.Callback<Group>() {

                           @Override
                           public String getEntityType() {
                               return UsersManagementWidgetsConstants.INSTANCE.groupsAssigned();
                           }

                           @Override
                           public boolean canRead() {
                               return false;
                           }

                           @Override
                           public boolean canRemove() {
                               return UserGroupsExplorer.this.canRemove;
                           }

                           @Override
                           public boolean canSelect() {
                               return false;
                           }

                           @Override
                           public boolean isSelected(final String id) {
                               return groups != null && groups.contains(id);
                           }

                           @Override
                           public String getIdentifier(final Group entity) {
                               return entity.getName();
                           }

                           @Override
                           public String getTitle(final Group entity) {
                               return entity.getName();
                           }

                           @Override
                           public void onReadEntity(final String identifier) {
                               // Not allowed.
                           }

                           @Override
                           public void onRemoveEntity(final String identifier) {
                               if (identifier != null) {
                                   confirmBox.show(UsersManagementWidgetsConstants.INSTANCE.confirmAction(),
                                                   UsersManagementWidgetsConstants.INSTANCE.ensureRemoveGroupFromUser(),
                                                   () -> {
                                                       // Delegate the recently created attribute addition to the entity.
                                                       removeUserGroupEventEvent.fire(new RemoveUserGroupEvent(UserGroupsExplorer.this,
                                                                                                               identifier));
                                                   },
                                                   () -> {
                                                   });
                               }
                           }

                           @Override
                           public void onSelectEntity(String identifier,
                                                      boolean isSelected) {
                               // Entity selection not available for the explorer widget.
                           }

                           @Override
                           public void onChangePage(int currentPage,
                                                    int goToPage) {
                               // Do nothing by default, let the groupList paginate.
                           }
                       });
    }

    @Inject public  UserGroupsExplorer(GroupsList groupList,
                              View view,
                              ConfirmBox confirmBox,
                              Event<RemoveUserGroupEvent> removeUserGroupEventEvent);

}