Пример #1
0
  @Override
  public void setTarget(Notifier newTarget) {
    // Don't need to track resources as targets (there are multiple)
    if (newTarget instanceof ResourceSet) {
      super.setTarget(newTarget);

      // Discover existing resources. Iterate the current set; any new additions
      // will be discovered automatically
      for (Resource next : ImmutableList.copyOf(((ResourceSet) newTarget).getResources())) {
        handleResourceAdded(next);
        if (next.isLoaded()) {
          handleResourceLoaded(next);
        }
      }
    }
  }
Пример #2
0
    @Override
    public void setTarget(Notifier newTarget) {
      if ((newTarget == null) || (newTarget instanceof ResourceSet)) {
        super.setTarget(newTarget);
      }

      if (newTarget instanceof ResourceSet) {
        // Iterate a defensive copy because other adapters cause concurrent additions by loading
        // additional resources
        for (Resource next : ImmutableList.copyOf(((ResourceSet) newTarget).getResources())) {
          adapt(next);
        }
      } else if (newTarget instanceof Resource) {
        Resource resource = (Resource) newTarget;
        if (resource.isLoaded()) {
          // already loaded? Handled it
          handleResourceLoaded(resource);
        }
      }
    }