Пример #1
0
 /** {@inheritDoc} */
 @Override
 public void resetSelectedItems() {
   markAllItemsDirty();
   Set<IModel<T>> oldSelected = new HashSet<IModel<T>>(selectedItems);
   selectedItems.clear();
   for (IModel<T> model : oldSelected) {
     onItemSelectionChanged(model, false);
   }
 }
Пример #2
0
  /** {@inheritDoc} */
  @Override
  public void selectItem(IModel<T> itemModel, boolean selected) {
    if (isAllowSelectMultiple() == false && selectedItems.size() > 0) {
      for (Iterator<IModel<T>> i = selectedItems.iterator(); i.hasNext(); ) {
        IModel<T> current = i.next();
        if (current.equals(itemModel) == false) {
          i.remove();
          onItemSelectionChanged(current, false);
        }
      }
    }

    if (selected == true && selectedItems.contains(itemModel) == false) {
      selectedItems.add(itemModel);
      onItemSelectionChanged(itemModel, selected);
    } else if (selected == false && selectedItems.contains(itemModel) == true) {
      selectedItems.remove(itemModel);
      onItemSelectionChanged(itemModel, selected);
    }
  }