Library (final @NotNull NewLibraryEditor editor, final LibraryTable table) { LibraryTable.ModifiableModel modifiableModel = table.getModifiableModel(); final String name = StringUtil.isEmpty(editor.getName()) ? null : getUniqueLibraryName(editor.getName(), modifiableModel); final LibraryType<?> type = editor.getType(); Library library = modifiableModel.createLibrary(name, type == null ? null : type.getKind()); final LibraryEx.ModifiableModelEx model = (LibraryEx.ModifiableModelEx)library.getModifiableModel(); editor.applyTo(model); model.commit(); modifiableModel.commit(); return library; }