/**
   * 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;
  }
  @Override
  public void initTableColumns(DataGrid<T> dataGrid, ListHandler<T> sortHandler) {

    // ------------------------- Last Name ----------------------------------
    final Column<T, String> lastNameColumn =
        new Column<T, String>(new TextCell()) {

          @Override
          public String getValue(T object) {
            return ((UserInfoGwt) object).getLastName();
          }
        };
    lastNameColumn.setSortable(true);
    sortHandler.setComparator(
        lastNameColumn,
        new Comparator<T>() {

          @Override
          public int compare(T o1, T o2) {
            return ((UserInfoGwt) o1).getLastName().compareTo(((UserInfoGwt) o2).getLastName());
          }
        });
    dataGrid.addColumn(lastNameColumn, "Last Name");
    dataGrid.setColumnWidth(lastNameColumn, "50px");

    // ------------------------- First Name ---------------------------------
    final Column<T, String> firstNameColumn =
        new Column<T, String>(new TextCell()) {

          @Override
          public String getValue(T object) {
            return ((UserInfoGwt) object).getFirstName();
          }
        };
    firstNameColumn.setSortable(true);
    sortHandler.setComparator(
        firstNameColumn,
        new Comparator<T>() {

          @Override
          public int compare(T o1, T o2) {
            return ((UserInfoGwt) o1).getFirstName().compareTo(((UserInfoGwt) o2).getFirstName());
          }
        });
    dataGrid.addColumn(firstNameColumn, "First Name");
    dataGrid.setColumnWidth(firstNameColumn, "50px");

    // --------------------------- User ID ----------------------------------
    final Column<T, String> userIdColumn =
        new Column<T, String>(new TextCell()) {

          @Override
          public String getValue(T object) {
            return ((UserInfoGwt) object).getUserName();
          }
        };
    userIdColumn.setSortable(true);
    sortHandler.setComparator(
        userIdColumn,
        new Comparator<T>() {

          @Override
          public int compare(T o1, T o2) {
            return ((UserInfoGwt) o1).getUserName().compareTo(((UserInfoGwt) o2).getUserName());
          }
        });
    dataGrid.addColumn(userIdColumn, "User ID");
    dataGrid.setColumnWidth(userIdColumn, "50px");
  }
Esempio n. 3
0
  /**
   * The table that holds the basic friends list.
   *
   * @param result
   */
  private void setTable(GetLogResult result) {
    if (cellTable.getColumnCount() == 4) {
      dataList.clear();
      dataList = dataProvider.getList();
      for (GetLogType friend : result.getResults()) dataList.add(friend);
    } else {
      TextColumn<GetLogType> victimColumn =
          new TextColumn<GetLogType>() {
            @Override
            public String getValue(GetLogType log) {
              if (log.getFbVictimName() != null) return log.getFbVictimName();
              else return "";
            }
          };
      victimColumn.setSortable(true);

      TextColumn<GetLogType> commentPermalink =
          new TextColumn<GetLogType>() {
            @Override
            public String getValue(GetLogType log) {
              if (log.getFbCommentPermalink() != null) return log.getFbCommentPermalink();
              else return "";
            }
          };
      commentPermalink.setSortable(true);

      TextColumn<GetLogType> comment =
          new TextColumn<GetLogType>() {
            @Override
            public String getValue(GetLogType log) {
              if (log.getFbComment() != null) return log.getFbComment();
              else return "";
            }
          };
      comment.setSortable(true);

      TextColumn<GetLogType> date =
          new TextColumn<GetLogType>() {
            @Override
            public String getValue(GetLogType log) {
              if (log.getDate() != null) return log.getDate().toString();
              else return "";
            }
          };
      date.setSortable(true);

      cellTable.addColumn(victimColumn, "Name");
      cellTable.addColumn(commentPermalink, "Comment Link");
      cellTable.addColumn(comment, "Comment Text");
      cellTable.addColumn(date, "Time");

      // Fix column sizes for stupid facebook
      cellTable.setWidth("675px", true);
      cellTable.setColumnWidth(victimColumn, 10.0, Unit.PCT);
      cellTable.setColumnWidth(commentPermalink, 40.0, Unit.PCT);
      cellTable.setColumnWidth(comment, 40.0, Unit.PCT);
      cellTable.setColumnWidth(date, 10.0, Unit.PCT);

      // Attach provider
      dataProvider.addDataDisplay(cellTable);
      dataList = dataProvider.getList();
      for (GetLogType friend : result.getResults()) dataList.add(friend);

      // Set row count
      cellTable.setRowCount(dataList.size());
      cellTable.setPageSize(20);

      ListHandler<GetLogType> columnSortHandler = new ListHandler<GetLogType>(dataList);
      columnSortHandler.setComparator(
          victimColumn,
          new Comparator<GetLogType>() {

            @Override
            public int compare(GetLogType o1, GetLogType o2) {
              if (o1 == o2) {
                return 0;
              }

              // Compare the name columns.
              if (o1 != null) {
                return (o2 != null) ? o1.getFbVictimName().compareTo(o2.getFbVictimName()) : 1;
              }
              return -1;
            }
          });

      columnSortHandler.setComparator(
          commentPermalink,
          new Comparator<GetLogType>() {

            @Override
            public int compare(GetLogType o1, GetLogType o2) {
              if (o1 == o2) {
                return 0;
              }

              // Compare the role columns.
              if (o1 != null) {
                return (o2 != null)
                    ? o1.getFbCommentPermalink().compareTo(o2.getFbCommentPermalink())
                    : 1;
              }
              return -1;
            }
          });

      columnSortHandler.setComparator(
          comment,
          new Comparator<GetLogType>() {
            @Override
            public int compare(GetLogType o1, GetLogType o2) {
              if (o1 == o2) {
                return 0;
              }

              // Compare the role columns.
              if (o1 != null) {
                return (o2 != null) ? o1.getFbComment().compareTo(o2.getFbComment()) : 1;
              }
              return -1;
            }
          });

      columnSortHandler.setComparator(
          date,
          new Comparator<GetLogType>() {

            @Override
            public int compare(GetLogType o1, GetLogType o2) {
              if (o1 == o2) {
                return 0;
              }

              // Compare the role columns.
              if (o1 != null) {
                return (o2 != null) ? o1.getDate().compareTo(o2.getDate()) : 1;
              }
              return -1;
            }
          });

      cellTable.addColumnSortHandler(columnSortHandler);
      cellTable.getColumnSortList().push(date);
      cellTable.setPageSize(5000);
    }
  }
Esempio n. 4
0
  // ------------------------------------------------------------------------
  //  CREATION OF ANNOTATIONS OF VARIOUS KIND
  // ------------------------------------------------------------------------
  public ComponentsPanel(IDomeo domeo, PluginsViewerPanel parent) {
    _domeo = domeo;
    _parent = parent;
    // _resources = resources;
    // _listPanel = new LogListPanel(_application);

    // Create layout
    initWidget(binder.createAndBindUi(this));
    this.setWidth((Window.getClientWidth() - 140) + "px");

    // Create a CellTable.
    final CellTable<PluginCard> table = new CellTable<PluginCard>();

    // Create name column.
    TextColumn<PluginCard> nameColumn =
        new TextColumn<PluginCard>() {
          @Override
          public String getValue(PluginCard pluginCard) {
            return pluginCard.name;
          }
        };

    // Make the name column sortable.
    nameColumn.setSortable(true);

    // Create type column.
    TextColumn<PluginCard> typeColumn =
        new TextColumn<PluginCard>() {
          @Override
          public String getValue(PluginCard pluginCard) {
            return pluginCard.type;
          }
        };
    typeColumn.setSortable(true);

    // Create sub type column.
    TextColumn<PluginCard> subTypeColumn =
        new TextColumn<PluginCard>() {
          @Override
          public String getValue(PluginCard pluginCard) {
            return pluginCard.subType;
          }
        };

    // Create sub type column.
    TextColumn<PluginCard> versionColumn =
        new TextColumn<PluginCard>() {
          @Override
          public String getValue(PluginCard pluginCard) {
            return pluginCard.version;
          }
        };

    // Add the columns.
    table.addColumn(typeColumn, "Type");
    table.addColumn(subTypeColumn, "Sub Type");
    table.addColumn(nameColumn, "Name");
    table.addColumn(versionColumn, "Version");

    // Create a data provider.
    ListDataProvider<PluginCard> dataProvider = new ListDataProvider<PluginCard>();

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

    // Add the data to the data provider, which automatically pushes it to the
    // widget.
    List<PluginCard> list = dataProvider.getList();
    for (APlugin plugin : _domeo.getPluginsManager().getPluginsList()) {
      if (plugin.getMandatory()) {
        PluginCard pluginCard =
            new PluginCard(
                plugin.getPluginName(),
                plugin.getType(),
                plugin.getSubType(),
                plugin.getVersion(),
                true,
                true);
        list.add(pluginCard);
      }
    }

    ListHandler<PluginCard> nameColumnSortHandler = new ListHandler<PluginCard>(list);
    nameColumnSortHandler.setComparator(
        nameColumn,
        new Comparator<PluginCard>() {
          public int compare(PluginCard o1, PluginCard o2) {
            if (o1 == o2) {
              return 0;
            }

            // Compare the name columns.
            if (o1 != null) {
              return (o2 != null) ? o1.name.compareTo(o2.name) : 1;
            }
            return -1;
          }
        });
    table.addColumnSortHandler(nameColumnSortHandler);

    ListHandler<PluginCard> typeColumnSortHandler = new ListHandler<PluginCard>(list);
    typeColumnSortHandler.setComparator(
        typeColumn,
        new Comparator<PluginCard>() {
          public int compare(PluginCard o1, PluginCard o2) {
            if (o1 == o2) {
              return 0;
            }

            // Compare the name columns.
            if (o1 != null) {
              return (o2 != null) ? o1.type.compareTo(o2.type) : 1;
            }
            return -1;
          }
        });
    table.addColumnSortHandler(typeColumnSortHandler);

    componentsPanel.add(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;
  }
  private void initTableColumns(final SelectionModel<ProcessSummary> selectionModel) {
    // Checkbox column. This table will uses a checkbox column for selection.
    // Alternatively, you can call dataGrid.setSelectionEnabled(true) to enable
    // mouse selection.

    Column<ProcessSummary, Boolean> checkColumn =
        new Column<ProcessSummary, Boolean>(new CheckboxCell(true, false)) {
          @Override
          public Boolean getValue(ProcessSummary object) {
            // Get the value from the selection model.
            return selectionModel.isSelected(object);
          }
        };

    processdefListGrid.addColumn(checkColumn, SafeHtmlUtils.fromSafeConstant("<br/>"));
    processdefListGrid.setColumnWidth(checkColumn, "40px");

    // Id.
    Column<ProcessSummary, String> processIdColumn =
        new Column<ProcessSummary, String>(new EditTextCell()) {
          @Override
          public String getValue(ProcessSummary object) {
            return object.getId();
          }
        };
    processIdColumn.setSortable(true);
    sortHandler.setComparator(
        processIdColumn,
        new Comparator<ProcessSummary>() {
          public int compare(ProcessSummary o1, ProcessSummary o2) {
            return Long.valueOf(o1.getId()).compareTo(Long.valueOf(o2.getId()));
          }
        });
    processdefListGrid.addColumn(
        processIdColumn, new ResizableHeader(constants.Id(), processdefListGrid, processIdColumn));

    // Process Id String.
    Column<ProcessSummary, String> processNameColumn =
        new Column<ProcessSummary, String>(new EditTextCell()) {
          @Override
          public String getValue(ProcessSummary object) {
            return object.getName();
          }
        };
    processNameColumn.setSortable(true);
    sortHandler.setComparator(
        processNameColumn,
        new Comparator<ProcessSummary>() {
          public int compare(ProcessSummary o1, ProcessSummary o2) {
            return o1.getName().compareTo(o2.getName());
          }
        });
    processdefListGrid.addColumn(
        processNameColumn,
        new ResizableHeader(constants.Name(), processdefListGrid, processNameColumn));

    // Process PKG.
    Column<ProcessSummary, String> processPkgColumn =
        new Column<ProcessSummary, String>(new EditTextCell()) {
          @Override
          public String getValue(ProcessSummary object) {
            return object.getPackageName();
          }
        };
    processPkgColumn.setSortable(true);
    sortHandler.setComparator(
        processPkgColumn,
        new Comparator<ProcessSummary>() {
          public int compare(ProcessSummary o1, ProcessSummary o2) {
            return o1.getPackageName().compareTo(o2.getPackageName());
          }
        });
    processdefListGrid.addColumn(
        processPkgColumn,
        new ResizableHeader(constants.Package(), processdefListGrid, processPkgColumn));

    // Process Session Id.
    Column<ProcessSummary, Number> processSessionIdColumn =
        new Column<ProcessSummary, Number>(new NumberCell()) {
          @Override
          public Number getValue(ProcessSummary object) {
            return object.getSessionId();
          }
        };
    processSessionIdColumn.setSortable(true);
    sortHandler.setComparator(
        processSessionIdColumn,
        new Comparator<ProcessSummary>() {
          public int compare(ProcessSummary o1, ProcessSummary o2) {
            return (o1.getSessionId() == o2.getSessionId()) ? 0 : 1;
          }
        });
    processdefListGrid.addColumn(
        processSessionIdColumn,
        new ResizableHeader("Session Id", processdefListGrid, processSessionIdColumn));
    processdefListGrid.setColumnWidth(processSessionIdColumn, "90px");

    // Version Type
    Column<ProcessSummary, String> versionColumn =
        new Column<ProcessSummary, String>(new EditTextCell()) {
          @Override
          public String getValue(ProcessSummary object) {
            return object.getVersion();
          }
        };
    versionColumn.setSortable(true);
    sortHandler.setComparator(
        versionColumn,
        new Comparator<ProcessSummary>() {
          public int compare(ProcessSummary o1, ProcessSummary o2) {
            return o1.getVersion().compareTo(o2.getVersion());
          }
        });
    processdefListGrid.addColumn(
        versionColumn, new ResizableHeader(constants.Version(), processdefListGrid, versionColumn));
    processdefListGrid.setColumnWidth(versionColumn, "90px");

    // actions (icons)
    List<HasCell<ProcessSummary, ?>> cells = new LinkedList<HasCell<ProcessSummary, ?>>();

    cells.add(
        new StartActionHasCell(
            "Start process",
            new Delegate<ProcessSummary>() {
              @Override
              public void execute(ProcessSummary process) {
                PlaceRequest placeRequestImpl = new DefaultPlaceRequest("Form Display");
                System.out.println("Opening form for process id = " + process.getId());
                placeRequestImpl.addParameter("processId", process.getId());
                placeRequestImpl.addParameter("sessionId", String.valueOf(process.getSessionId()));
                placeManager.goTo(placeRequestImpl);
              }
            }));

    cells.add(
        new DetailsActionHasCell(
            "Details",
            new Delegate<ProcessSummary>() {
              @Override
              public void execute(ProcessSummary process) {

                PlaceRequest placeRequestImpl =
                    new DefaultPlaceRequest(constants.Process_Definition_Details());
                placeRequestImpl.addParameter("processId", process.getId());
                placeRequestImpl.addParameter(
                    "sessionId", Integer.toString(process.getSessionId()));
                placeManager.goTo(placeRequestImpl);
              }
            }));

    CompositeCell<ProcessSummary> cell = new CompositeCell<ProcessSummary>(cells);
    Column<ProcessSummary, ProcessSummary> actionsColumn =
        new Column<ProcessSummary, ProcessSummary>(cell) {
          @Override
          public ProcessSummary getValue(ProcessSummary object) {
            return object;
          }
        };
    processdefListGrid.addColumn(actionsColumn, "Actions");
    processdefListGrid.setColumnWidth(actionsColumn, "70px");
  }
  /**
   * 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;
  }
Esempio n. 8
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;
  }
Esempio n. 9
0
  /**
   * 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;
  }
  private void initTableColumns() {
    // addedBy
    Column<CommentSummary, String> addedByColumn =
        new Column<CommentSummary, String>(new TextCell()) {
          @Override
          public String getValue(CommentSummary c) {
            // for some reason the username comes in format [User:'******'], so parse just the
            // <name>
            int first = c.getAddedBy().indexOf('\'');
            int last = c.getAddedBy().lastIndexOf('\'');
            return c.getAddedBy().substring(first + 1, last);
          }
        };
    addedByColumn.setSortable(false);
    commentsListGrid.addColumn(addedByColumn, constants.Added_By());
    commentsListGrid.setColumnWidth(addedByColumn, "100px");

    // date
    Column<CommentSummary, String> addedAtColumn =
        new Column<CommentSummary, String>(new TextCell()) {
          @Override
          public String getValue(CommentSummary c) {
            DateTimeFormat format = DateTimeFormat.getFormat("dd/MM/yyyy HH:mm");
            return format.format(c.getAddedAt());
          }
        };
    addedAtColumn.setSortable(true);
    addedAtColumn.setDefaultSortAscending(true);
    commentsListGrid.addColumn(addedAtColumn, constants.At());
    sortHandler.setComparator(
        addedAtColumn,
        new Comparator<CommentSummary>() {
          @Override
          public int compare(CommentSummary o1, CommentSummary o2) {
            return o1.getAddedAt().compareTo(o2.getAddedAt());
          }
        });

    // comment text
    Column<CommentSummary, String> commentTextColumn =
        new Column<CommentSummary, String>(new TextCell()) {
          @Override
          public String getValue(CommentSummary object) {
            return object.getText();
          }
        };
    addedByColumn.setSortable(false);
    commentsListGrid.addColumn(commentTextColumn, constants.Comment());

    List<HasCell<CommentSummary, ?>> cells = new LinkedList<HasCell<CommentSummary, ?>>();

    cells.add(
        new DeleteCommentActionHasCell(
            constants.Delete(),
            new Delegate<CommentSummary>() {
              @Override
              public void execute(CommentSummary comment) {
                presenter.removeTaskComment(comment.getId());
              }
            }));

    CompositeCell<CommentSummary> cell = new CompositeCell<CommentSummary>(cells);
    Column<CommentSummary, CommentSummary> actionsColumn =
        new Column<CommentSummary, CommentSummary>(cell) {
          @Override
          public CommentSummary getValue(CommentSummary object) {
            return object;
          }
        };
    commentsListGrid.addColumn(actionsColumn, "");
  }
Esempio n. 11
0
  private void initTableColumns(
      SelectionModel<Supply> selectionModel, ListHandler<Supply> sortHandler) {

    // НОМЕР
    Column<Supply, String> supplyIdColumn =
        new Column<Supply, String>(new TextCell()) {
          @Override
          public String getValue(Supply object) {
            return Integer.toString(object.getSupplyId());
          }
        };
    supplyIdColumn.setSortable(true);
    sortHandler.setComparator(
        supplyIdColumn,
        new Comparator<Supply>() {
          @Override
          public int compare(Supply o1, Supply o2) {
            if (o1.getSupplyId() == o2.getSupplyId()) return 0;
            else if (o1.getSupplyId() > o2.getSupplyId()) return 1;
            else return -1;
          }
        });
    dataGrid.addColumn(supplyIdColumn, "Номер");
    dataGrid.setColumnWidth(supplyIdColumn, 30, Unit.PX);

    // ТИП
    Column<Supply, String> typeColumn =
        new Column<Supply, String>(new TextCell()) {
          @Override
          public String getValue(Supply object) {
            if ("1".equals(object.getDeliveryDirection())) return "В филиал";
            else if ("0".equals(object.getDeliveryDirection())) return "На склад";
            else return "Ошибка!";
          }
        };
    typeColumn.setSortable(true);
    sortHandler.setComparator(
        typeColumn,
        new Comparator<Supply>() {
          @Override
          public int compare(Supply o1, Supply o2) {
            return o1.getDeliveryDirection().compareTo(o2.getDeliveryDirection());
          }
        });
    dataGrid.addColumn(typeColumn, "Направление");
    dataGrid.setColumnWidth(typeColumn, 50, Unit.PX);

    // ДАТА ПОСТАВКИ
    // если сроки нарушены, то показывается актуальная дата!
    Column<Supply, String> dateColumn =
        new Column<Supply, String>(new TextCell()) {
          @Override
          public String getValue(Supply object) {
            DateTimeFormat dateFormat = DateTimeFormat.getFormat("yyyy-MM-dd");
            if (object.getDateFact() != null) return dateFormat.format(object.getDateFact());
            else return dateFormat.format(object.getDateOk());
          }
        };
    dateColumn.setSortable(true);
    sortHandler.setComparator(
        dateColumn,
        new Comparator<Supply>() {
          @Override
          public int compare(Supply o1, Supply o2) {
            return o1.getDateOk().compareTo(o2.getDateOk());
          }
        });
    dataGrid.addColumn(dateColumn, "Дата доставки");
    dataGrid.setColumnWidth(dateColumn, 70, Unit.PX);

    // СТАТУС
    Column<Supply, String> statusColumn =
        new Column<Supply, String>(new TextCell()) {
          @Override
          public String getValue(Supply object) {
            return StatusDict.getType(object.getStatus().getStatusCode());
          }
        };
    statusColumn.setSortable(true);
    sortHandler.setComparator(
        statusColumn,
        new Comparator<Supply>() {
          @Override
          public int compare(Supply o1, Supply o2) {
            if (o1.getStatus().getStatusCode() == o2.getStatus().getStatusCode()) return 0;
            else if (o1.getStatus().getStatusCode() == o2.getStatus().getStatusCode()) return -1;
            return 1;
          }
        });
    dataGrid.addColumn(statusColumn, "Статус доставки");
    dataGrid.setColumnWidth(statusColumn, 70, Unit.PX);

    // НОМЕР НАКЛАДНОЙ
    Column<Supply, String> nakladNumColumn =
        new Column<Supply, String>(new TextCell()) {
          @Override
          public String getValue(Supply object) {
            return object.getNakladNum();
          }
        };
    nakladNumColumn.setSortable(true);
    sortHandler.setComparator(
        nakladNumColumn,
        new Comparator<Supply>() {
          @Override
          public int compare(Supply o1, Supply o2) {
            return o1.getNakladNum().compareTo(o2.getNakladNum());
          }
        });
    dataGrid.addColumn(nakladNumColumn, "Накладная");
    dataGrid.setColumnWidth(nakladNumColumn, 50, Unit.PX);

    // АДРЕС
    Column<Supply, String> addressColumn =
        new Column<Supply, String>(new TextCell()) {
          @Override
          public String getValue(Supply object) {
            return object.getAddress();
          }
        };
    addressColumn.setSortable(true);
    sortHandler.setComparator(
        addressColumn,
        new Comparator<Supply>() {
          @Override
          public int compare(Supply o1, Supply o2) {
            return o1.getAddress().compareTo(o2.getAddress());
          }
        });
    dataGrid.addColumn(addressColumn, "Адрес");
    // если направление - со склада к филиалу, то Адрес кликабелен
    dataGrid.setColumnWidth(addressColumn, 70, Unit.PX);

    // КОНТРАГЕНТЫ
    Column<Supply, String> kontrName =
        new Column<Supply, String>(new TextCell()) {
          @Override
          public String getValue(Supply object) {
            return object.getKont().getName();
          }
        };
    kontrName.setSortable(true);
    sortHandler.setComparator(
        kontrName,
        new Comparator<Supply>() {
          @Override
          public int compare(Supply o1, Supply o2) {
            return o1.getKont().getName().compareTo(o2.getKont().getName());
          }
        });
    dataGrid.addColumn(kontrName, "Контрагент");
    // TODO: при нажании на название компании-контрагента - окошко с
    // информацией о т.к.
    dataGrid.setColumnWidth(kontrName, 50, Unit.PX);

    // ТРАНСПОРТНЫЕ КОМПАНИИ
    Column<Supply, String> transCompName =
        new Column<Supply, String>(new ClickableTextCell()) {
          @Override
          public String getValue(Supply object) {
            return object.getTk().getName();
          }
        };
    transCompName.setSortable(true);
    sortHandler.setComparator(
        transCompName,
        new Comparator<Supply>() {
          @Override
          public int compare(Supply o1, Supply o2) {
            return o1.getTk().getName().compareTo(o2.getTk().getName());
          }
        });
    transCompName.setFieldUpdater(
        new FieldUpdater<Supply, String>() {

          @Override
          public void update(int index, Supply object, String value) {
            final DialogBox dialogBox = new DialogBox();
            TKDetailed tkDetailed = new TKDetailed(object.getTk());

            tkDetailed
                .getCancel()
                .addClickHandler(
                    new ClickHandler() {
                      public void onClick(ClickEvent event) {
                        dialogBox.hide();
                      }
                    });

            dialogBox.setAnimationEnabled(true);
            dialogBox.setWidget(tkDetailed);

            dialogBox.center();
          }
        });
    dataGrid.addColumn(transCompName, "Транспортная компания");
    // TODO: при нажании на название ТК - окошко с информацией о ТК
    dataGrid.setColumnWidth(transCompName, 70, Unit.PX);

    // Кнопка редактиварония
    Column<Supply, String> buttonColumn =
        new Column<Supply, String>(new ButtonCell()) {
          @Override
          public String getValue(Supply object) {
            return " ... ";
          }
        };
    buttonColumn.setFieldUpdater(
        new FieldUpdater<Supply, String>() {

          @Override
          public void update(int index, Supply object, String value) {
            final DialogBox dialogBox = new DialogBox();
            FlowPanel flowPanel = new FlowPanel();
            flowPanel.setHeight("100px");
            flowPanel.setWidth("100px");
            flowPanel.add(new HTML("Id = " + object.getSupplyId()));
            final Button closeButton = new Button("Закрыть");
            flowPanel.add(closeButton);
            dialogBox.setAnimationEnabled(true);
            dialogBox.setWidget(flowPanel);

            // Add a handler to close the DialogBox
            closeButton.addClickHandler(
                new ClickHandler() {
                  public void onClick(ClickEvent event) {
                    dialogBox.hide();
                  }
                });
            dialogBox.center();
          }
        });
    dataGrid.addColumn(buttonColumn, "");
    dataGrid.setColumnWidth(buttonColumn, 50, Unit.PX);
  }
Esempio n. 12
0
  /**
   * 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;
  }