@Override
  @Nullable
  protected ClasspathTableItem<?> createTableItem(final Library item) {
    // clear invalid order entry corresponding to added library if any
    final ModifiableRootModel rootModel = myClasspathPanel.getRootModel();
    final OrderEntry[] orderEntries = rootModel.getOrderEntries();
    for (OrderEntry orderEntry : orderEntries) {
      if (orderEntry instanceof LibraryOrderEntry libraryOrderEntry) {
        if (item.equals(libraryOrderEntry.getLibrary())) {
          return ClasspathTableItem.createLibItem(libraryOrderEntry, myContext);
        }
        String name = item.getName();
        if (name != null && name.equals(libraryOrderEntry.getLibraryName())) {
          if (orderEntry.isValid()) {
            Messages.showErrorDialog(JavaUiBundle.message("classpath.message.library.already.added", item.getName()),
                                     JavaUiBundle.message("classpath.title.adding.dependency"));
            return null;
          }
          else {
            rootModel.removeOrderEntry(orderEntry);
          }
        }
      }
    }
    final LibraryOrderEntry orderEntry = rootModel.addLibraryEntry(item);
    orderEntry.setScope(LibraryDependencyScopeSuggester.getDefaultScope(item));
    return ClasspathTableItem.createLibItem(orderEntry, myContext);
  }
@Override
  @Nullable
  protected ClasspathTableItem<?> createTableItem(final Library item)