Beispiel #1
0
  /**
   * Return table widget with external sources
   *
   * @return table widget containing ext sources
   */
  public CellTable<ExtSource> getTable() {

    // retrieve data
    retrieveData();

    // Table data provider.
    dataProvider = new ListDataProvider<ExtSource>(list);

    // Cell table
    table = new PerunTable<ExtSource>(list);

    // Connect the table to the data provider.
    dataProvider.addDataDisplay(table);

    // Sorting
    ListHandler<ExtSource> columnSortHandler = new ListHandler<ExtSource>(dataProvider.getList());
    table.addColumnSortHandler(columnSortHandler);

    // table selection
    table.setSelectionModel(
        selectionModel, DefaultSelectionEventManager.<ExtSource>createCheckboxManager());

    // set empty content & loader
    table.setEmptyTableWidget(loaderImage);
    loaderImage.setEmptyResultMessage("No external sources found in Perun.");

    // checkable
    if (this.checkable) {
      table.addCheckBoxColumn();
    }

    // ID column
    table.addIdColumn("Ext. source ID", null);

    // Name column
    table.addNameColumn(null);

    // Type column
    TextColumn<ExtSource> typeColumn =
        new TextColumn<ExtSource>() {
          @Override
          public String getValue(ExtSource extSource) {
            return String.valueOf(renameContent(extSource.getType()));
          }
        };
    table.addColumn(typeColumn, "Type");

    // return cellTable
    return table;
  }
  /**
   * Returns table with publications
   *
   * @return table
   */
  public CellTable<Publication> getEmptyTable() {

    // Table data provider.
    dataProvider = new ListDataProvider<Publication>(list);

    // Cell table
    table = new PerunTable<Publication>(list);
    table.removeRowCountChangeHandler();
    table.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED);

    // Connect the table to the data provider.
    dataProvider.addDataDisplay(table);

    // Sorting
    ListHandler<Publication> columnSortHandler =
        new ListHandler<Publication>(dataProvider.getList());
    table.addColumnSortHandler(columnSortHandler);

    // table selection
    table.setSelectionModel(
        selectionModel, DefaultSelectionEventManager.<Publication>createCheckboxManager());

    // set empty content & loader
    table.setEmptyTableWidget(
        loaderImage.prepareToSearch(
            "Please select external pub. system and year range to search for publications for import."));

    // show checkbox column
    if (this.checkable) {
      table.addCheckBoxColumn();
    }

    /*
    // CATEGORY COLUMN
    ArrayList<String> categories = new ArrayList<String>();
    categories.add("Bodované v RIVu");
    categories.add("Nebodované v RIVu");
    categories.add("Příspěvek do ročenky");
    categories.add("Výjimečné výsledky");
    categories.add("Jiné");

    Column<Publication, String> categoryColumn = new Column<Publication, String>(new SelectionCell(categories)){
    	@Override
    	public String getValue(Publication object) {
    		// category ID as string, 0 if not set
    		int id = object.getCategoryId();
    		if (id == 0) {
    			// set default == 21/Bodované v RIVu to object
    			object.setCategoryId(21);
    		}
    		if (id == 21) {
    			return "Bodované v RIVu";
    		} else if (id == 22) {
    			return "Nebodované v RIVu";
    		} else if (id == 23) {
    			return "Výjimečné výsledky";
    		} else if (id == 24) {
    			return "Příspěvek do ročenky";
    		} else if (id == 25) {
    			return "Jiné";
    		} else {
    			return String.valueOf(id); // return ID if no match
    		}
    	}
    };
    categoryColumn.setFieldUpdater(new FieldUpdater<Publication, String>() {
    	public void update(int index, Publication object, String value) {

    		int id = 0;
    		if (value.equalsIgnoreCase("Bodované v RIVu")) {
    			id = 21;
    		} else if (value.equalsIgnoreCase("Nebodované v RIVu")) {
    			id = 22;
    		} else if (value.equalsIgnoreCase("Příspěvek do ročenky")) {
    			id = 24;
    		} else if (value.equalsIgnoreCase("Výjimečné výsledky")) {
    			id = 23;
    		} else if (value.equalsIgnoreCase("Jiné")) {
    			id = 25;
    		}
    		object.setCategoryId(id);
    		selectionModel.setSelected(object, true);

    	}
    });
    table.addColumn(categoryColumn, "Category");

    // NOT USEFULL => DISABLED
    // EXTERNAL ID
    TextColumn<Publication> externalIdColumn = new TextColumn<Publication>() {
    	public String getValue(Publication object) {
    		return String.valueOf(object.getExternalId());
    	};
    };
    externalIdColumn.setSortable(true);
    columnSortHandler.setComparator(externalIdColumn, new PublicationComparator(PublicationComparator.Column.EXTERNAL_ID));
    table.addColumn(externalIdColumn, "External Id");
     */

    // TITLE COLUMN
    TextColumn<Publication> titleColumn =
        new TextColumn<Publication>() {
          public String getValue(Publication object) {
            return object.getTitle();
          };
        };
    titleColumn.setSortable(true);
    columnSortHandler.setComparator(
        titleColumn, new PublicationComparator(PublicationComparator.Column.TITLE));
    table.addColumn(titleColumn, "Title");

    // AUTHORS COLUMN
    TextColumn<Publication> authorColumn =
        new TextColumn<Publication>() {
          public String getValue(Publication object) {
            return object.getAuthorsFormatted();
          };
        };
    authorColumn.setSortable(true);
    columnSortHandler.setComparator(
        authorColumn, new PublicationComparator(PublicationComparator.Column.AUTHORS));
    table.addColumn(authorColumn, "Authors");

    // YEAR COLUMN
    TextColumn<Publication> yearColumn =
        new TextColumn<Publication>() {
          public String getValue(Publication object) {
            return String.valueOf(object.getYear());
          };
        };
    yearColumn.setSortable(true);
    columnSortHandler.setComparator(
        yearColumn, new PublicationComparator(PublicationComparator.Column.YEAR));
    table.addColumn(yearColumn, "Year");

    // ISBN COLUMN
    TextColumn<Publication> isbnColumn =
        new TextColumn<Publication>() {
          public String getValue(Publication object) {
            return object.getIsbn();
          };
        };
    isbnColumn.setSortable(true);
    columnSortHandler.setComparator(
        isbnColumn, new PublicationComparator(PublicationComparator.Column.ISBN));
    table.addColumn(isbnColumn, "ISBN");

    // CITE COLUMN
    Column<Publication, String> citaceColumn =
        JsonUtils.addColumn(
            new JsonUtils.GetValue<Publication, String>() {
              public String getValue(Publication object) {
                return "Cite";
              }
            },
            new FieldUpdater<Publication, String>() {
              public void update(int index, Publication object, String value) {
                SimplePanel sp = new SimplePanel();
                sp.add(new HTML(object.getMain()));
                Confirm cf = new Confirm("Cite publication", sp, true);
                cf.show();
              };
            });

    table.addColumn(citaceColumn, "Cite");

    return table;
  }
  /**
   * Returns empty table widget with attributes
   *
   * @return table widget
   */
  public CellTable<Attribute> getEmptyTable() {

    // Table data provider.
    dataProvider = new ListDataProvider<Attribute>(list);

    // Cell table
    table = new PerunTable<Attribute>(list);
    table.removeRowCountChangeHandler(); // remove row count change handler

    // Connect the table to the data provider.
    dataProvider.addDataDisplay(table);

    // Sorting
    ListHandler<Attribute> columnSortHandler = new ListHandler<Attribute>(dataProvider.getList());
    table.addColumnSortHandler(columnSortHandler);

    // table selection
    table.setSelectionModel(
        selectionModel, DefaultSelectionEventManager.<Attribute>createCheckboxManager());

    // set empty content & loader
    table.setEmptyTableWidget(loaderImage);

    // because of tab index
    table.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED);

    // checkbox column
    if (checkable) {

      // checkbox column column
      Column<Attribute, Attribute> checkBoxColumn =
          new Column<Attribute, Attribute>(new PerunCheckboxCell<Attribute>(true, false, false)) {
            @Override
            public Attribute getValue(Attribute object) {
              // Get the value from the selection model.
              GeneralObject go = object.cast();
              go.setChecked(selectionModel.isSelected(object));
              return go.cast();
            }
          };

      // updates the columns size
      table.setColumnWidth(checkBoxColumn, 40.0, Unit.PX);

      // Add the columns

      // Checkbox column header
      CheckboxCell cb = new CheckboxCell();
      Header<Boolean> checkBoxHeader =
          new Header<Boolean>(cb) {
            public Boolean getValue() {
              return false; // return true to see a checked checkbox.
            }
          };
      checkBoxHeader.setUpdater(
          new ValueUpdater<Boolean>() {
            public void update(Boolean value) {
              // sets selected to all, if value = true, unselect otherwise
              for (Attribute obj : list) {
                if (obj.isWritable()) {
                  selectionModel.setSelected(obj, value);
                }
              }
            }
          });

      table.addColumn(checkBoxColumn, checkBoxHeader);
    }

    // Create ID column.
    table.addIdColumn("Attr ID", null, 90);

    // Name column
    Column<Attribute, Attribute> nameColumn = JsonUtils.addColumn(new PerunAttributeNameCell());

    // Value column
    Column<Attribute, Attribute> valueColumn = JsonUtils.addColumn(new PerunAttributeValueCell());
    valueColumn.setFieldUpdater(
        new FieldUpdater<Attribute, Attribute>() {
          public void update(int index, Attribute object, Attribute value) {
            object = value;
            selectionModel.setSelected(object, object.isAttributeValid());
          }
        });

    // Description column
    Column<Attribute, Attribute> descriptionColumn =
        JsonUtils.addColumn(new PerunAttributeDescriptionCell());

    // Sorting name column
    nameColumn.setSortable(true);
    columnSortHandler.setComparator(
        nameColumn, new AttributeComparator<Attribute>(AttributeComparator.Column.TRANSLATED_NAME));

    // Sorting description column
    descriptionColumn.setSortable(true);
    columnSortHandler.setComparator(
        descriptionColumn,
        new AttributeComparator<Attribute>(AttributeComparator.Column.TRANSLATED_DESCRIPTION));

    // Add sorting
    this.table.addColumnSortHandler(columnSortHandler);

    // updates the columns size
    this.table.setColumnWidth(nameColumn, 200.0, Unit.PX);

    // Add the columns.
    this.table.addColumn(nameColumn, "Name");
    this.table.addColumn(valueColumn, "Value");
    this.table.addColumn(descriptionColumn, "Description");

    return this.table;
  }
  /**
   * Return table definition
   *
   * @return table widget
   */
  public CellTable<TaskResult> getEmptyTable() {

    // Table data provider.
    dataProvider = new ListDataProvider<TaskResult>(list);

    // Cell table
    table = new PerunTable<TaskResult>(list);
    table.removeRowCountChangeHandler();

    // Connect the table to the data provider.
    dataProvider.addDataDisplay(table);

    // Sorting
    ListHandler<TaskResult> columnSortHandler = new ListHandler<TaskResult>(dataProvider.getList());
    table.addColumnSortHandler(columnSortHandler);

    // table selection
    table.setSelectionModel(
        selectionModel, DefaultSelectionEventManager.<TaskResult>createCheckboxManager());

    // set empty content & loader
    table.setEmptyTableWidget(loaderImage);

    table.addIdColumn("Result Id", null, 85);

    // destination column
    TextColumn<TaskResult> destinationColumn =
        new TextColumn<TaskResult>() {
          @Override
          public String getValue(TaskResult object) {
            return String.valueOf(object.getDestination().getDestination());
          }
        };

    destinationColumn.setSortable(true);
    columnSortHandler.setComparator(
        destinationColumn,
        new Comparator<TaskResult>() {
          public int compare(TaskResult o1, TaskResult o2) {
            return o1.getDestination()
                .getDestination()
                .compareToIgnoreCase((o2.getDestination().getDestination()));
          }
        });

    // Type column
    TextColumn<TaskResult> typeColumn =
        new TextColumn<TaskResult>() {
          @Override
          public String getValue(TaskResult object) {
            return String.valueOf(object.getDestination().getType());
          }
        };

    typeColumn.setSortable(true);
    columnSortHandler.setComparator(
        typeColumn,
        new Comparator<TaskResult>() {
          public int compare(TaskResult o1, TaskResult o2) {
            return o1.getDestination().getType().compareToIgnoreCase(o2.getDestination().getType());
          }
        });

    TextColumn<TaskResult> servColumn =
        new TextColumn<TaskResult>() {
          @Override
          public String getValue(TaskResult taskResult) {
            return taskResult.getService().getName();
          }
        };
    servColumn.setSortable(true);
    columnSortHandler.setComparator(
        servColumn,
        new Comparator<TaskResult>() {
          public int compare(TaskResult o1, TaskResult o2) {
            return o1.getService().getName().compareToIgnoreCase(o2.getService().getName());
          }
        });

    // status column
    TextColumn<TaskResult> statusColumn =
        new TextColumn<TaskResult>() {
          @Override
          public String getValue(TaskResult object) {
            return String.valueOf(object.getStatus());
          }
        };

    statusColumn.setSortable(true);
    columnSortHandler.setComparator(
        statusColumn,
        new Comparator<TaskResult>() {
          public int compare(TaskResult o1, TaskResult o2) {
            return o1.getStatus().compareToIgnoreCase(o2.getStatus());
          }
        });

    // time column
    TextColumn<TaskResult> timeColumn =
        new TextColumn<TaskResult>() {
          @Override
          public String getValue(TaskResult object) {
            return object.getTimestamp();
          }
        };

    timeColumn.setSortable(true);
    columnSortHandler.setComparator(
        timeColumn,
        new Comparator<TaskResult>() {
          public int compare(TaskResult o1, TaskResult o2) {
            return o1.getTimestamp().compareToIgnoreCase(o2.getTimestamp());
          }
        });

    // returnCode column
    TextColumn<TaskResult> returnCodeColumn =
        new TextColumn<TaskResult>() {
          @Override
          public String getValue(TaskResult object) {
            return String.valueOf(object.getReturnCode());
          }
        };

    // standardMessageCode column
    TextColumn<TaskResult> standardMessageColumn =
        new TextColumn<TaskResult>() {
          @Override
          public void render(Context context, TaskResult object, SafeHtmlBuilder sb) {
            if (object != null) {
              sb.appendEscapedLines(object.getStandardMessage());
            }
          }

          @Override
          public String getValue(TaskResult object) {
            return String.valueOf(object.getStandardMessage());
          }
        };

    // errorMessageCode column
    TextColumn<TaskResult> errorMessageColumn =
        new TextColumn<TaskResult>() {
          @Override
          public void render(Context context, TaskResult object, SafeHtmlBuilder sb) {
            if (object != null) {
              sb.appendEscapedLines(object.getErrorMessage());
            }
          }

          @Override
          public String getValue(TaskResult object) {
            return String.valueOf(object.getErrorMessage());
          }
        };

    // Add the other columns.
    table.addColumn(destinationColumn, "Destination");
    table.addColumn(typeColumn, "Type");
    table.addColumn(servColumn, "Service");
    table.addColumn(statusColumn, "Status");
    table.addColumn(timeColumn, "Time");
    table.addColumn(returnCodeColumn, "Return code");
    table.addColumn(standardMessageColumn, "Standard Message");
    table.addColumn(errorMessageColumn, "Error Message");

    // set row styles based on task state
    table.setRowStyles(
        new RowStyles<TaskResult>() {
          public String getStyleNames(TaskResult row, int rowIndex) {

            if (row.getStatus().equalsIgnoreCase("DONE")) {
              return "rowgreen";
            } else if (row.getStatus().equalsIgnoreCase("DENIED")) {
              return "rowyellow";
            } else if (row.getStatus().equalsIgnoreCase("FATAL_ERROR")) {
              return "rowred";
            } else if (row.getStatus().equalsIgnoreCase("ERROR")) {
              return "roworange";
            }
            return "";
          }
        });

    return table;
  }
Beispiel #5
0
  /**
   * Returns the table with member-Groups
   *
   * @return CellTable widget
   */
  public CellTable<Group> getTable() {

    // Retrieves data
    this.retrieveData();

    // Table data provider.
    dataProvider = new ListDataProvider<Group>(list);

    // Cell table
    table = new PerunTable<Group>(list);

    // Connect the table to the data provider.
    dataProvider.addDataDisplay(table);

    // Sorting
    ListHandler<Group> columnSortHandler = new ListHandler<Group>(dataProvider.getList());
    table.addColumnSortHandler(columnSortHandler);

    // Table selection
    table.setSelectionModel(
        selectionModel, DefaultSelectionEventManager.<Group>createCheckboxManager());

    // Set empty content & loader
    table.setEmptyTableWidget(loaderImage);

    if (entity.equals(PerunEntity.VIRTUAL_ORGANIZATION)) {
      loaderImage.setEmptyResultMessage(
          "VO has no groups of managers (try to switch to 'Users' view).");
    } else if (entity.equals(PerunEntity.GROUP)) {
      loaderImage.setEmptyResultMessage(
          "Group has no groups of managers (try to switch to 'Users' view).");
    } else if (entity.equals(PerunEntity.FACILITY)) {
      loaderImage.setEmptyResultMessage(
          "Facility has no groups of managers (try to switch to 'Users' view).");
    }

    // Checkbox column column
    table.addCheckBoxColumn();

    // Create Group ID column.
    Column<Group, String> groupIdColumn =
        JsonUtils.addColumn(
            new JsonUtils.GetValue<Group, String>() {
              public String getValue(Group object) {
                return String.valueOf(object.getId());
              }
            },
            this.tableFieldUpdater);

    groupIdColumn.setSortable(true);
    columnSortHandler.setComparator(
        groupIdColumn, new GeneralComparator<Group>(GeneralComparator.Column.ID));

    table.setColumnWidth(groupIdColumn, 110.0, Unit.PX);

    if (JsonUtils.isExtendedInfoVisible()) {
      table.addColumn(groupIdColumn, "Group ID");
    }

    table.addNameColumn(tableFieldUpdater);
    table.addDescriptionColumn(tableFieldUpdater);

    return table;
  }
  /**
   * Returns empty table
   *
   * @return table widget
   */
  public CellTable<Destination> getEmptyTable() {

    // Table data provider.
    dataProvider = new ListDataProvider<Destination>(list);

    // Cell table
    table = new PerunTable<Destination>(list);

    // Connect the table to the data provider.
    dataProvider.addDataDisplay(table);

    if (showFac) {
      loaderImage.setEmptyResultMessage("Service has no destination.");
    } else {
      loaderImage.setEmptyResultMessage(
          "Facility has no services destinations. Service configuration can't be propagated.");
    }

    // Sorting
    ListHandler<Destination> columnSortHandler =
        new ListHandler<Destination>(dataProvider.getList());
    table.addColumnSortHandler(columnSortHandler);

    // table selection
    table.setSelectionModel(
        selectionModel, DefaultSelectionEventManager.<Destination>createCheckboxManager());

    // set empty content & loader
    table.setEmptyTableWidget(loaderImage);

    if (this.checkable) {
      table.addCheckBoxColumn();
    }

    // add id column
    table.addIdColumn("Destination ID", null);

    // DESTINATION COLUMN
    TextColumn<Destination> destinationColumn =
        new TextColumn<Destination>() {
          public String getValue(Destination object) {
            return object.getDestination();
          }
        };

    // TYPE COLUMN
    TextColumn<Destination> typeColumn =
        new TextColumn<Destination>() {
          public String getValue(Destination object) {
            return object.getType().toUpperCase();
          }
        };

    // SERVICE COLUMN
    TextColumn<Destination> serviceColumn =
        new TextColumn<Destination>() {
          public String getValue(Destination object) {
            return object.getService().getName();
          }
        };

    // FACILITY COLUMN
    TextColumn<Destination> facilityColumn =
        new TextColumn<Destination>() {
          public String getValue(Destination object) {
            return object.getFacility().getName();
          }
        };

    destinationColumn.setSortable(true);
    columnSortHandler.setComparator(
        destinationColumn,
        new Comparator<Destination>() {
          public int compare(Destination o1, Destination o2) {
            return o1.getDestination().compareToIgnoreCase(o2.getDestination());
          }
        });

    typeColumn.setSortable(true);
    columnSortHandler.setComparator(
        typeColumn,
        new Comparator<Destination>() {
          public int compare(Destination o1, Destination o2) {
            return o1.getType().compareToIgnoreCase(o2.getType());
          }
        });

    serviceColumn.setSortable(true);
    columnSortHandler.setComparator(
        serviceColumn,
        new Comparator<Destination>() {
          public int compare(Destination o1, Destination o2) {
            return o1.getService().getName().compareToIgnoreCase(o2.getService().getName());
          }
        });

    facilityColumn.setSortable(true);
    columnSortHandler.setComparator(
        facilityColumn,
        new Comparator<Destination>() {
          public int compare(Destination o1, Destination o2) {
            return o1.getFacility().getName().compareToIgnoreCase(o2.getFacility().getName());
          }
        });

    // updates the columns size
    table.setColumnWidth(serviceColumn, 250.0, Unit.PX);
    table.setColumnWidth(facilityColumn, 250.0, Unit.PX);

    // Add the columns.

    if (showServ) {
      table.addColumn(serviceColumn, "Service");
    }
    if (showFac) {
      table.addColumn(facilityColumn, "Facility");
    }

    table.addColumn(destinationColumn, "Destination");
    table.addColumn(typeColumn, "Type");

    return table;
  }
  /**
   * Return table with tasks
   *
   * @return table widget
   */
  public CellTable<Task> getEmptyTable() {

    // Table data provider.
    dataProvider = new ListDataProvider<Task>(list);

    // Cell table
    table = new PerunTable<Task>(list);

    // Connect the table to the data provider.
    dataProvider.addDataDisplay(table);

    // Sorting
    ListHandler<Task> columnSortHandler = new ListHandler<Task>(dataProvider.getList());
    table.addColumnSortHandler(columnSortHandler);

    // table selection
    table.setSelectionModel(
        selectionModel, DefaultSelectionEventManager.<Task>createCheckboxManager());

    // set empty content & loader
    table.setEmptyTableWidget(loaderImage);

    // checkbox column column
    table.addCheckBoxColumn();

    table.addIdColumn("Task Id", tableFieldUpdater);

    // Service column
    Column<Task, String> serviceColumn =
        JsonUtils.addColumn(
            new JsonUtils.GetValue<Task, String>() {
              public String getValue(Task task) {
                return String.valueOf(task.getExecService().getService().getName());
              }
            },
            tableFieldUpdater);

    // Service Type column
    Column<Task, String> serviceTypeColumn =
        JsonUtils.addColumn(
            new JsonUtils.GetValue<Task, String>() {
              public String getValue(Task task) {
                return String.valueOf(task.getExecService().getType());
              }
            },
            tableFieldUpdater);

    // status column
    Column<Task, String> statusColumn =
        JsonUtils.addColumn(
            new JsonUtils.GetValue<Task, String>() {
              public String getValue(Task task) {
                return String.valueOf(task.getStatus());
              }
            },
            tableFieldUpdater);

    // start COLUMN
    TextColumn<Task> startTimeColumn =
        new TextColumn<Task>() {
          public String getValue(Task result) {
            return result.getStartTime();
          }
        };

    // end COLUMN
    TextColumn<Task> endTimeColumn =
        new TextColumn<Task>() {
          public String getValue(Task result) {
            return result.getEndTime();
          }
        };

    // schedule COLUMN
    TextColumn<Task> scheduleColumn =
        new TextColumn<Task>() {
          public String getValue(Task result) {
            return result.getSchedule();
          }
        };

    // Add the columns.
    table.addColumn(serviceColumn, "Service");
    table.addColumn(serviceTypeColumn, "Type");
    table.addColumn(statusColumn, "Status");
    table.addColumn(scheduleColumn, "Scheduled");
    table.addColumn(startTimeColumn, "Started");
    table.addColumn(endTimeColumn, "Ended");

    // set row styles based on task state
    table.setRowStyles(
        new RowStyles<Task>() {
          public String getStyleNames(Task row, int rowIndex) {

            if (row.getStatus().equalsIgnoreCase("NONE")) {
              return "rowdarkgreen";
            } else if (row.getStatus().equalsIgnoreCase("DONE")) {
              return "rowgreen";
            } else if (row.getStatus().equalsIgnoreCase("PROCESSING")) {
              return "rowyellow";
            } else if (row.getStatus().equalsIgnoreCase("ERROR")) {
              return "rowred";
            }
            return "";
          }
        });

    return table;
  }
  /**
   * Returns the table with member-users
   *
   * @return CellTable widget
   */
  public CellTable<User> getTable() {

    // Retrieves data
    this.retrieveData();

    // Table data provider.
    dataProvider = new ListDataProvider<User>(list);

    // Cell table
    table = new PerunTable<User>(list);

    // Connect the table to the data provider.
    dataProvider.addDataDisplay(table);

    if (entity.equals(PerunEntity.VIRTUAL_ORGANIZATION)) {
      loaderImage.setEmptyResultMessage("VO has no managers (try to switch to 'Groups' view).");
    } else if (entity.equals(PerunEntity.GROUP)) {
      loaderImage.setEmptyResultMessage("Group has no managers (try to switch to 'Groups' view).");
    } else if (entity.equals(PerunEntity.FACILITY)) {
      loaderImage.setEmptyResultMessage(
          "Facility has no managers (try to switch to 'Groups' view).");
    } else if (entity.equals(PerunEntity.SECURITY_TEAM)) {
      loaderImage.setEmptyResultMessage(
          "SecurityTeam has no members (try to switch to 'Groups' view).");
    }

    // Sorting
    ListHandler<User> columnSortHandler = new ListHandler<User>(dataProvider.getList());
    table.addColumnSortHandler(columnSortHandler);

    // Table selection
    table.setSelectionModel(
        selectionModel, DefaultSelectionEventManager.<User>createCheckboxManager());

    // Set empty content & loader
    table.setEmptyTableWidget(loaderImage);

    // Checkbox column column
    if (checkable) {
      table.addCheckBoxColumn();
    }

    // Create User ID column.
    Column<User, String> userIdColumn =
        JsonUtils.addColumn(
            new JsonUtils.GetValue<User, String>() {
              public String getValue(User object) {
                return String.valueOf(object.getId());
              }
            },
            this.tableFieldUpdater);

    userIdColumn.setSortable(true);
    columnSortHandler.setComparator(
        userIdColumn, new GeneralComparator<User>(GeneralComparator.Column.ID));

    table.setColumnWidth(userIdColumn, 110.0, Unit.PX);

    if (JsonUtils.isExtendedInfoVisible()) {
      table.addColumn(userIdColumn, "User ID");
    }

    table.setHyperlinksAllowed(false);
    table.addNameColumn(tableFieldUpdater);

    // Create organization column.
    Column<User, String> organizationColumn =
        JsonUtils.addColumn(
            new JsonUtils.GetValue<User, String>() {
              public String getValue(User object) {
                Attribute at = object.getAttribute("urn:perun:user:attribute-def:def:organization");
                if (at != null
                    && at.getValue() != null
                    && !"null".equalsIgnoreCase(at.getValue())) {
                  return at.getValue();
                }
                return "";
              }
            },
            this.tableFieldUpdater);

    // Create e-mail column.
    Column<User, String> emailColumn =
        JsonUtils.addColumn(
            new JsonUtils.GetValue<User, String>() {
              public String getValue(User object) {
                Attribute at =
                    object.getAttribute("urn:perun:user:attribute-def:def:preferredMail");
                if (at != null
                    && at.getValue() != null
                    && !"null".equalsIgnoreCase(at.getValue())) {
                  return at.getValue().replace(",", " ");
                }
                return "";
              }
            },
            this.tableFieldUpdater);

    // Create name column.
    Column<User, String> loginsColumn =
        JsonUtils.addColumn(
            new JsonUtils.GetValue<User, String>() {
              public String getValue(User object) {
                return object.getLogins();
              }
            },
            this.tableFieldUpdater);

    organizationColumn.setSortable(true);
    columnSortHandler.setComparator(
        organizationColumn, new RichUserComparator(RichUserComparator.Column.ORGANIZATION));

    emailColumn.setSortable(true);
    columnSortHandler.setComparator(
        emailColumn, new RichUserComparator(RichUserComparator.Column.EMAIL));

    // Add the other columns.
    table.addColumn(organizationColumn, "Organization");
    table.addColumn(emailColumn, "E-mail");
    table.addColumn(loginsColumn, "Logins");

    return table;
  }