@Override
  protected void setInitialSelection(
      List<? extends ChangeList> changeLists,
      List<Change> changes,
      ChangeList initialListSelection) {
    myAllChanges = new ArrayList<Change>();
    mySelectedChangeList = initialListSelection;

    for (ChangeList list : changeLists) {
      if (list instanceof LocalChangeList) {
        myAllChanges.addAll(list.getChanges());
        if (initialListSelection == null) {
          for (Change c : list.getChanges()) {
            if (changes.contains(c)) {
              mySelectedChangeList = list;
              break;
            }
          }
        }
      }
    }

    if (mySelectedChangeList == null) {
      for (ChangeList list : changeLists) {
        if (list instanceof LocalChangeList && ((LocalChangeList) list).isDefault()) {
          mySelectedChangeList = list;
          break;
        }
      }
      if (mySelectedChangeList == null && !changeLists.isEmpty()) {
        mySelectedChangeList = changeLists.get(0);
      }
    }
  }
 private boolean hasChanges(JsArray<ChangeList> result) {
   for (ChangeList list : Natives.asList(result)) {
     if (list.length() != 0) {
       return true;
     }
   }
   return false;
 }
  @NotNull
  public Collection<Change> getChangesIn(final FilePath dirPath) {
    List<Change> changes = new ArrayList<Change>();
    for (ChangeList list : myMap.values()) {
      for (Change change : list.getChanges()) {
        final ContentRevision afterRevision = change.getAfterRevision();
        if (afterRevision != null && afterRevision.getFile().isUnder(dirPath, false)) {
          changes.add(change);
          continue;
        }

        final ContentRevision beforeRevision = change.getBeforeRevision();
        if (beforeRevision != null && beforeRevision.getFile().isUnder(dirPath, false)) {
          changes.add(change);
        }
      }
    }
    return changes;
  }
  @Override
  protected void onLoad() {
    super.onLoad();

    String who = mine ? "self" : ownerId.toString();
    ChangeList.query(
        new ScreenLoadCallback<JsArray<ChangeList>>(this) {
          @Override
          protected void preDisplay(JsArray<ChangeList> result) {
            display(result);
          }
        },
        mine ? EnumSet.of(ListChangesOption.REVIEWED) : EnumSet.noneOf(ListChangesOption.class),
        "is:open owner:" + who,
        "is:open reviewer:" + who + " -owner:" + who,
        "is:closed (owner:" + who + " OR reviewer:" + who + ") -age:4w limit:10");
  }
 @NotNull
 public List<Change> getCurrentDisplayedChanges() {
   return mySelectedChangeList != null
       ? ContainerUtil.newArrayList(mySelectedChangeList.getChanges())
       : Collections.emptyList();
 }