Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
62ed1b5
Add Pagination for fetchers
paudelritij Jul 7, 2025
cfb4848
An Attempt to define pagination for arXiv
paudelritij Jul 18, 2025
ae34392
Merge branch 'main' into fix-for-issue-5507
paudelritij Jul 18, 2025
a10adf4
Fix page number display state for pagination
paudelritij Jul 18, 2025
ee4cabb
Minor fixes
paudelritij Jul 19, 2025
7511a6c
Refactor fetchMoreEntries method
paudelritij Jul 20, 2025
8b454fc
Merge branch 'main' into fix-for-issue-5507
paudelritij Jul 24, 2025
2030c8d
Add CHANGELOG.md entry
paudelritij Jul 24, 2025
3e8f567
Remove WebImportEntriesDialog, its ViewModel, and associated FXML in …
paudelritij Aug 2, 2025
1a9d5a4
Merge branch 'main' into fix-for-issue-5507
paudelritij Aug 2, 2025
539d54d
Refactor ImportEntriesDialog instantiation to remove unnecessary para…
paudelritij Aug 3, 2025
e8a14d8
Merge branch 'main' into fix-for-issue-5507
paudelritij Aug 16, 2025
f41f640
Minor fixes
paudelritij Aug 16, 2025
2506c6e
Minor fix
paudelritij Aug 16, 2025
f401572
Merge branch 'main' into fix-for-issue-5507
paudelritij Aug 22, 2025
5c2506c
Minor fix
paudelritij Aug 24, 2025
b23328f
Enhance UI
paudelritij Aug 25, 2025
51b5f6d
Update JabRef_en.properties
paudelritij Aug 25, 2025
d7fe212
Apply boy scout principle
paudelritij Aug 30, 2025
ae6975c
Merge branch 'main' into fix-for-issue-5507
paudelritij Aug 30, 2025
4a6eff6
Merge branch 'main' into fix-for-issue-5507
paudelritij Aug 30, 2025
562c7b0
Merge branch 'main' into fix-for-issue-5507
paudelritij Aug 31, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import javafx.beans.binding.Bindings;
import javafx.beans.binding.BooleanBinding;
import javafx.collections.ListChangeListener;
import javafx.css.PseudoClass;
import javafx.fxml.FXML;
import javafx.geometry.Insets;
Expand Down Expand Up @@ -35,6 +36,7 @@
import org.jabref.gui.util.BaseDialog;
import org.jabref.gui.util.NoSelectionModel;
import org.jabref.gui.util.ViewModelListCellFactory;
import org.jabref.logic.importer.PagedSearchBasedFetcher;
import org.jabref.logic.importer.ParserResult;
import org.jabref.logic.l10n.Localization;
import org.jabref.logic.shared.DatabaseLocation;
Expand Down Expand Up @@ -114,6 +116,20 @@ private void initialize() {
placeholder.textProperty().bind(viewModel.messageProperty());
entriesListView.setPlaceholder(placeholder);
entriesListView.setItems(viewModel.getEntries());
entriesListView.getCheckModel().getCheckedItems().addListener((ListChangeListener<BibEntry>) change -> {
while (change.next()) {
if (change.wasAdded()) {
for (BibEntry entry : change.getAddedSubList()) {
viewModel.getCheckedEntries().add(entry);
}
}
if (change.wasRemoved()) {
for (BibEntry entry : change.getRemoved()) {
viewModel.getCheckedEntries().remove(entry);
}
}
}
});

libraryListView.setEditable(false);
libraryListView.getItems().addAll(stateManager.getOpenDatabases());
Expand Down Expand Up @@ -225,4 +241,24 @@ public void selectAllEntries() {
unselectAll();
entriesListView.getCheckModel().checkAll();
}

@FXML
private void onPrevPage() {
viewModel.prevPage();
restoreCheckedEntries();
}

@FXML
private void onNextPage() {
viewModel.nextPage();
restoreCheckedEntries();
}

private void restoreCheckedEntries() {
for (BibEntry entry : viewModel.getEntries()) {
if (viewModel.getCheckedEntries().contains(entry)) {
entriesListView.getCheckModel().check(entry);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import java.io.IOException;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.Set;

import javax.swing.undo.UndoManager;

Expand All @@ -13,6 +15,7 @@
import javafx.beans.property.StringProperty;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.collections.ObservableSet;

import org.jabref.gui.AbstractViewModel;
import org.jabref.gui.DialogService;
Expand Down Expand Up @@ -40,6 +43,7 @@
public class ImportEntriesViewModel extends AbstractViewModel {

private static final Logger LOGGER = LoggerFactory.getLogger(ImportEntriesViewModel.class);
private static final int PAGE_SIZE = 20;

private final StringProperty message;
private final TaskExecutor taskExecutor;
Expand All @@ -53,6 +57,11 @@ public class ImportEntriesViewModel extends AbstractViewModel {
private final GuiPreferences preferences;
private final BibEntryTypesManager entryTypesManager;
private final ObjectProperty<BibDatabaseContext> selectedDb;
private final ObservableList<BibEntry> pagedEntries = FXCollections.observableArrayList();
private final ObservableSet<BibEntry> checkedEntries = FXCollections.observableSet();
private List<BibEntry> allEntries = new ArrayList<>();

private int currentPage = 0;

/**
* @param databaseContext the database to import into
Expand Down Expand Up @@ -85,6 +94,7 @@ public ImportEntriesViewModel(BackgroundTask<ParserResult> task,
this.parserResult = parserResult;
// fill in the list for the user, where one can select the entries to import
entries.addAll(parserResult.getDatabase().getEntries());
loadAllEntries(entries);
if (entries.isEmpty()) {
task.updateMessage(Localization.lang("No entries corresponding to given query"));
}
Expand All @@ -111,7 +121,7 @@ public BibDatabaseContext getSelectedDb() {
}

public ObservableList<BibEntry> getEntries() {
return entries;
return pagedEntries;
}

public boolean hasDuplicate(BibEntry entry) {
Expand Down Expand Up @@ -177,4 +187,42 @@ private Optional<BibEntry> findInternalDuplicate(BibEntry entry) {
}
return Optional.empty();
}

public Set<BibEntry> getCheckedEntries() {
return checkedEntries;
}

public void loadAllEntries(List<BibEntry> entries) {
this.allEntries = new ArrayList<>(entries);
this.currentPage = 0;
updatePagedEntries();
}

public void nextPage() {
if (hasNextPage()) {
currentPage++;
updatePagedEntries();
}
}

public void prevPage() {
if (hasPrevPage()) {
currentPage--;
updatePagedEntries();
}
}

public boolean hasNextPage() {
return (currentPage + 1) * PAGE_SIZE < allEntries.size();
}

public boolean hasPrevPage() {
return currentPage > 0;
}

private void updatePagedEntries() {
int fromIdx = currentPage * PAGE_SIZE;
int toIdx = Math.min(fromIdx + PAGE_SIZE, allEntries.size());
pagedEntries.setAll(allEntries.subList(fromIdx, toIdx));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
<VBox spacing="10.0">
<Label text="%Select the entries to be imported:"/>
<CheckListView fx:id="entriesListView" VBox.vgrow="ALWAYS"/>
<HBox spacing="10" alignment="CENTER">
<Button onAction="#onPrevPage" text="%Previous"/>
<Button onAction="#onNextPage" text="%Next"/>
</HBox>
<HBox spacing="4">
<VBox spacing="10">
<HBox spacing="4">
Expand Down
2 changes: 2 additions & 0 deletions jablib/src/main/resources/l10n/JabRef_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2040,6 +2040,8 @@ Total\ items\ found\:=Total items found:
Selected\ items\:=Selected items:
Download\ referenced\ files\ (PDFs,\ ...)=Download referenced files (PDFs, ...)
Select\ the\ entries\ to\ be\ imported\:=Select the entries to be imported\:
Previous=Previous
Next=Next
Open\ Help\ page=Open Help page
Add\ new\ keyword=Add new keyword
Keyword\:=Keyword:
Expand Down