private void addPreviewDataListener(@NotNull AbstractListModel<Object> model) {
    model.addListDataListener(new ListDataListener() {
      @Override
      public void intervalAdded(ListDataEvent e) {
        updatePreviewVisibility();
      }

      @Override
      public void intervalRemoved(ListDataEvent e) {
        updatePreviewVisibility();
      }

      @Override
      public void contentsChanged(ListDataEvent e) {
        updatePreviewVisibility();
      }
    });
  }
private void addPreviewDataListener(@NotNull AbstractListModel<Object> model)