Ejemplo n.º 1
0
    @Override
    @SuppressWarnings("unchecked")
    public void handleSuccess(ItemUpdates<I> aResult) {
      GWT.log("RPC-response: received new items");
      isLoading = false;
      if (myKnownItems == null) {
        myKnownItems = new HashMap<U, I>();
      }

      ArrayList<I> theOldValue = null;
      if (myVisibleItems != null) {
        theOldValue = new ArrayList<I>();
        theOldValue.addAll(myVisibleItems);
        myVisibleItems.clear();
      } else {
        myVisibleItems = new ArrayList<I>();
      }

      // update the local data.
      updateItems(aResult.getItems());
      if (aResult.getNewlyCreatedItem() != null) {
        updateItems(Arrays.asList(aResult.getNewlyCreatedItem()));
      }

      final ArrayList<BonitaUUID> theVisibleItemsUUIDs = new ArrayList<BonitaUUID>();
      for (I theItem : aResult.getItems()) {
        myVisibleItems.add(myKnownItems.get(theItem.getUUID()));
        theVisibleItemsUUIDs.add(theItem.getUUID());
      }

      // Keep the selection consistent
      final ArrayList<U> selectedItems = new ArrayList<U>(myItemSelection.getSelectedItems());
      for (U theItemUUID : selectedItems) {
        if (!theVisibleItemsUUIDs.contains(theItemUUID)) {
          GWT.log(
              "Removed item from selection as it do not belong to the visible items anymore: "
                  + theItemUUID.getValue());
          myItemSelection.removeItemFromSelection(theItemUUID);
        }
      }

      // Store the total size.
      mySize = aResult.getNbOfItems();
      if (myMessageDataSource != null) {
        myMessageDataSource.addInfoMessage(
            patterns.lastTimeRefreshed(
                DateTimeFormat.getFormat(constants.timeShortFormat()).format(new Date())));
      }
      myChanges.fireModelChange(ITEM_LIST_PROPERTY, theOldValue, myVisibleItems);
    }
Ejemplo n.º 2
0
 @SuppressWarnings("unchecked")
 protected void updateItems(List<I> anItemList) {
   I theExistingItem;
   for (I theNewItem : anItemList) {
     // Update the local cache.
     if (myKnownItems.containsKey(theNewItem.getUUID())) {
       theExistingItem = myKnownItems.get(theNewItem.getUUID());
       theExistingItem.updateItem(theNewItem);
     } else {
       // A new case is available. Add it into the local cache.
       myKnownItems.put((U) theNewItem.getUUID(), theNewItem);
     }
   }
 }
Ejemplo n.º 3
0
 /*
  * (non-Javadoc)
  * @see
  * org.bonitasoft.console.client.model.BonitaFilteredDataSource#getVisibleItems
  * ()
  */
 @Override
 @SuppressWarnings("unchecked")
 public List<U> getVisibleItems() {
   List<U> theResult = null;
   if (myVisibleItems != null) {
     theResult = new ArrayList<U>();
     for (I theCaseItem : myVisibleItems) {
       theResult.add((U) theCaseItem.getUUID());
     }
   } else {
     // DataSource not yet initialized.
     // Reload asynchronously
     if (!isLoading) {
       isLoading = true;
       reload();
     }
   }
   return theResult;
 }