private static void rebuildTable(@NotNull Project project,
                                   @NotNull Predicate<? super Usage> originUsageCheck,
                                   @NotNull List<UsageNode> data,
                                   @NotNull ShowUsagesTable table,
                                   @Nullable AbstractPopup popup,
                                   @NotNull RelativePoint popupPosition,
                                   @NotNull IntRef minWidth,
                                   @NotNull AtomicBoolean manuallyResized) {
    ThreadingAssertions.assertEventDispatchThread();

    ShowUsagesTable.MyModel tableModel = table.setTableModel(data);
    List<UsageNode> existingData = tableModel.getItems();

    int row = table.getSelectedRow();

    int newSelection = updateModel(tableModel, existingData, data, row == -1 ? 0 : row);
    if (newSelection < 0 || newSelection >= tableModel.getRowCount()) {
      ScrollingUtil.ensureSelectionExists(table);
      newSelection = table.getSelectedRow();
    }
    else {
      // do not pre-select the usage under caret by default
      if (newSelection == 0 && table.getModel().getRowCount() > 1) {
        Object valueInTopRow = table.getModel().getValueAt(0, 0);
        if (valueInTopRow instanceof UsageNode && originUsageCheck.test(((UsageNode)valueInTopRow).getUsage())) {
          newSelection++;
        }
      }
      table.getSelectionModel().setSelectionInterval(newSelection, newSelection);
    }
    ScrollingUtil.ensureIndexIsVisible(table, newSelection, 0);

    if (popup != null) {
      if (manuallyResized.get()) {
        calcMaxWidth(table); // compute column widths
      }
      else {
        PropertiesComponent properties = PropertiesComponent.getInstance(project);
        setPopupSize(table, popup, popupPosition, minWidth, properties.isValueSet(PREVIEW_PROPERTY_KEY), data.size());
      }
    }
  }
private static void rebuildTable(@NotNull Project project,
                                   @NotNull Predicate<? super Usage> originUsageCheck,
                                   @NotNull List<UsageNode> data,
                                   @NotNull ShowUsagesTable table,
                                   @Nullable AbstractPopup popup,
                                   @NotNull RelativePoint popupPosition,
                                   @NotNull IntRef minWidth,
                                   @NotNull AtomicBoolean manuallyResized)