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 value setting.
  *
  * @param value new value to show
  */
 private void doSetValue(UserItem value) {
   RowWidget row = rows.get(value.getKey());
   if (row != null) {
     Item itemObject = row.getValue().getItemObject();
     value.setItemObject(itemObject);
     row.setValue(value);
   }
 }
Esempio n. 3
0
  /** Makes all pending {@link UserItem}s below the last one show. */
  public void showTail() {
    Set<Key> labels = new HashSet<Key>();
    for (UserItem ui : tail) {
      labels.addAll(ui.getLabels());
    }
    if (!hasAllLabels(labels)) {
      Managers.LABELS_MANAGER.refresh(
          new AsyncCallback<Void>() {
            public void onSuccess(Void result) {
              addTail();
            }

            public void onFailure(Throwable caught) {}
          });
    } else {
      addTail();
    }
  }
Esempio n. 4
0
  /**
   * Sets new value of row if the {@link UserItem} is already shown.
   *
   * @param value new value to show
   */
  public void setValue(final UserItem value) {
    if (!hasAllLabels(value.getLabels())) {
      Managers.LABELS_MANAGER.refresh(
          new AsyncCallback<Void>() {
            public void onSuccess(Void result) {
              doSetValue(value);
            }

            public void onFailure(Throwable caught) {}
          });
    } else {
      doSetValue(value);
    }
  }