Example #1
0
 /**
  * Sets the currently selected row by key of its {@link UserItem}.
  *
  * @param key key of {@link UserItem}
  * @param forceExpand whether the selected row shall be expanded
  */
 public void setSelectedKey(Key key, boolean forceExpand) {
   if (key == null) {
     RowWidget old = rows.get(selected);
     old.collapse();
     old.removeStyleDependentName("selected");
     selected = null;
     SelectionChangeEvent.fire(this);
   } else if (key.equals(selected)) {
     // was selected and is selected
   } else {
     boolean expand = true;
     // selected changed
     if (selected != null) {
       RowWidget old = rows.get(selected);
       old.removeStyleDependentName("selected");
       if (old.isExpanded()) {
         old.collapse();
       } else {
         expand = false;
       }
     }
     RowWidget newly = rows.get(key);
     if (expand || forceExpand) {
       newly.expand();
     }
     selected = key;
     newly.addStyleDependentName("selected");
     SelectionChangeEvent.fire(this);
   }
 }
Example #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);
   }
 }
Example #3
0
 /**
  * @param index index of row to be selected
  * @param forceExpand whether the selected row shall be expanded
  * @return whether the index exists
  */
 protected boolean setSelectedIndex(int index, boolean forceExpand) {
   try {
     RowWidget w = (RowWidget) flowPanel.getWidget(index);
     setSelectedKey(w.getKey(), forceExpand);
     return true;
   } catch (Exception e) {
     return false;
   }
 }
Example #4
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);
    }
  }
Example #5
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);
    }
  }
Example #6
0
 /**
  * Creates a new row for a {@link UserItem}.
  *
  * @param userItem {@link UserItem} which is the row created for
  * @return widget representing the {@link UserItem}
  */
 private RowWidget createRow(UserItem userItem) {
   RowWidget row = UserItemRow.FACTORY.createWidget(userItem);
   row.addOpenHandler(new OpenCloseHander());
   row.addCloseHandler(new OpenCloseHander());
   return row;
 }