Esempio n. 1
0
  /**
   * Adds values to list of {@link UserItem}s which are above the first shown {@link UserItem}.
   *
   * @param values list of {@link UserItem}s
   */
  public void prependValues(List<UserItem> values) {
    if (values.size() > 0) {
      List<UserItem> newItems = new ArrayList<UserItem>();
      Set<Key> newKeys = new HashSet<Key>();
      for (UserItem ui : values) {
        RowWidget rowWidget = rows.get(ui.getKey());
        boolean add = true;
        if (rowWidget != null) {
          setValue(ui);
          add = false;
        }
        if (add) {
          if (headKeys.contains(ui.getKey())) {
            add = false;
            int index = head.indexOf(ui);
            head.set(index, ui);
          }
        }
        if (add) {
          newItems.add(ui);
          newKeys.add(ui.getKey());
        }
      }

      if (!newItems.isEmpty()) {
        head.addAll(0, newItems);
        headKeys.addAll(newKeys);
        NewDataEvent.fire(this, NewDataType.NEW_DATA_AVAILABLE);
      }
    }
  }
Esempio n. 2
0
  /** Does the actual addition of {@link UserItem}s to the top of the list. */
  public void addTail() {
    List<UserItem> l = tail;
    if (l.size() > 0) {
      tail = new ArrayList<UserItem>();
      tailKeys = new HashSet<Key>();

      for (UserItem e : l) {
        RowWidget row = createRow(e);
        flowPanel.add(row);
        rows.put(row.getKey(), row);
      }

      rowsAdded();
      NewDataEvent.fire(this, NewDataType.NEW_DATA_SHOWN);
    }
  }
Esempio n. 3
0
  /** Does the actual addition of {@link UserItem}s to the top of the list. */
  private void addHead() {
    List<UserItem> l = head;
    if (l.size() > 0) {
      head = new ArrayList<UserItem>();
      headKeys = new HashSet<Key>();

      int offsetHeight = flowPanel.getOffsetHeight();
      for (int i = l.size() - 1; i >= 0; i--) {
        UserItem e = l.get(i);
        RowWidget row = createRow(e);
        flowPanel.insert(row, 0);
        rows.put(row.getKey(), row);
      }

      int deltaHeight = flowPanel.getOffsetHeight() - offsetHeight;
      scrollPanel.setVerticalScrollPosition(scrollPanel.getVerticalScrollPosition() + deltaHeight);

      rowsAdded();
      NewDataEvent.fire(this, NewDataType.NEW_DATA_SHOWN);
    }
  }