コード例 #1
0
  /** {@inheritDoc} */
  public void render(
      final Panel renderContainer,
      final ItemRenderer itemRenderer,
      final PagedSet<? extends Serializable> items,
      final String noItemsMessage) {
    Panel left = new FlowPanel();
    left.addStyleName(StaticResourceBundle.INSTANCE.coreCss().connectionColLeft());
    left.addStyleName(StaticResourceBundle.INSTANCE.coreCss().connectionCol());
    Panel right = new FlowPanel();
    right.addStyleName(StaticResourceBundle.INSTANCE.coreCss().connectionColRight());
    right.addStyleName(StaticResourceBundle.INSTANCE.coreCss().connectionCol());

    int count = 0;

    if (items.getTotal() == 0) {
      Label noItemsMessageLabel = new Label(noItemsMessage);
      noItemsMessageLabel.addStyleName(
          StaticResourceBundle.INSTANCE.coreCss().connectionItemEmpty());
      renderContainer.add(noItemsMessageLabel);
    } else {
      renderContainer.add(left);
      renderContainer.add(right);
    }
    double halfwayPoint = items.getPagedSet().size() / 2.0;

    for (Serializable item : items.getPagedSet()) {
      if (count >= halfwayPoint) {
        right.add(itemRenderer.render(item));
      } else {
        left.add(itemRenderer.render(item));
      }

      count++;
    }
  }
コード例 #2
0
  /** Test getFollowing(). */
  @Test
  public void testGetFollowing() {
    final long followedGroupId = 1L;
    PagedSet<Followable> followedGroups = jpaGroupMapper.getFollowing("mrburns", 0, 9);
    assertEquals(1, followedGroups.getTotal());
    assertEquals(0, followedGroups.getFromIndex());
    assertEquals(0, followedGroups.getToIndex());

    List<Followable> groups = followedGroups.getPagedSet();
    assertEquals(1, groups.size());
    assertEquals(followedGroupId, groups.get(0).getId());
  }