From 7a47c6d7c784328fe9bd42390c674ff66b3b4c73 Mon Sep 17 00:00:00 2001 From: Siedlerchr Date: Fri, 27 Nov 2020 20:26:18 +0100 Subject: [PATCH 1/3] Fix document viewer starting with second page Fixes #7108 --- .../org/jabref/gui/documentviewer/PdfDocumentPageViewModel.java | 2 +- .../org/jabref/gui/documentviewer/PdfDocumentViewModel.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/jabref/gui/documentviewer/PdfDocumentPageViewModel.java b/src/main/java/org/jabref/gui/documentviewer/PdfDocumentPageViewModel.java index 5ad9a3b528c..ae665d01a12 100644 --- a/src/main/java/org/jabref/gui/documentviewer/PdfDocumentPageViewModel.java +++ b/src/main/java/org/jabref/gui/documentviewer/PdfDocumentPageViewModel.java @@ -60,7 +60,7 @@ public Image render(int width, int height) { @Override public int getPageNumber() { - return pageNumber; + return pageNumber +1; } @Override diff --git a/src/main/java/org/jabref/gui/documentviewer/PdfDocumentViewModel.java b/src/main/java/org/jabref/gui/documentviewer/PdfDocumentViewModel.java index 9b73c87102a..7e5ae9a5969 100644 --- a/src/main/java/org/jabref/gui/documentviewer/PdfDocumentViewModel.java +++ b/src/main/java/org/jabref/gui/documentviewer/PdfDocumentViewModel.java @@ -26,7 +26,7 @@ public ObservableList getPages() { List pdfPages = new ArrayList<>(); // There is apparently no neat way to get the page number from a PDPage...thus this old-style for loop for (int i = 0; i < pages.getCount(); i++) { - pdfPages.add(new PdfDocumentPageViewModel(pages.get(i), i + 1, document)); + pdfPages.add(new PdfDocumentPageViewModel(pages.get(i), i, document)); } return FXCollections.observableArrayList(pdfPages); } From 19125ad31f13ef42b4bcc19d47996a13e8e7eaf2 Mon Sep 17 00:00:00 2001 From: Siedlerchr Date: Fri, 27 Nov 2020 20:41:41 +0100 Subject: [PATCH 2/3] Fix update of total page number --- CHANGELOG.md | 1 + .../jabref/gui/documentviewer/DocumentViewerViewModel.java | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bfcd7cb3ce1..9f8342edb4c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -75,6 +75,7 @@ inserting new citations in a OpenOffic/LibreOffice document. [#6957](https://git - We fixed an issue where the EndNote XML Import would fail on empty keywords tags [forum#2387](https://discourse.jabref.org/t/importing-in-unknown-format-fails-to-import-xml-library-from-bookends-export/2387) - We fixed an issue where the color of groups of type "free search expression" not persisting after restarting the application [#6999](https://github.com/JabRef/jabref/issues/6999) - We fixed an issue where modifications in the source tab where not saved without switching to another field before saving the library [#6622](https://github.com/JabRef/jabref/issues/6622) +- We fixed an issue where the "Document Viewer" did not show the first page of the opened pdf document and did not show the correct total number of pages [#7108](https://github.com/JabRef/jabref/issues/7108) ### Removed diff --git a/src/main/java/org/jabref/gui/documentviewer/DocumentViewerViewModel.java b/src/main/java/org/jabref/gui/documentviewer/DocumentViewerViewModel.java index dc32be00a35..6cd41363a0a 100644 --- a/src/main/java/org/jabref/gui/documentviewer/DocumentViewerViewModel.java +++ b/src/main/java/org/jabref/gui/documentviewer/DocumentViewerViewModel.java @@ -5,6 +5,7 @@ import java.util.List; import java.util.Objects; +import javafx.application.Platform; import javafx.beans.property.BooleanProperty; import javafx.beans.property.IntegerProperty; import javafx.beans.property.ListProperty; @@ -55,8 +56,12 @@ public DocumentViewerViewModel(StateManager stateManager) { } }); - maxPages.bindBidirectional( + // we need to wrap this in run later so that the max pages number is correctly shown + Platform.runLater(() -> { + maxPages.bindBidirectional( EasyBind.wrapNullable(currentDocument).selectProperty(DocumentViewModel::maxPagesProperty)); + }); + setCurrentEntries(this.stateManager.getSelectedEntries()); } From f95f5c45dde223651a67a8a86548c486ef26e175 Mon Sep 17 00:00:00 2001 From: Siedlerchr Date: Fri, 27 Nov 2020 20:47:09 +0100 Subject: [PATCH 3/3] Fix checkstyle --- .../org/jabref/gui/documentviewer/DocumentViewerViewModel.java | 2 -- .../org/jabref/gui/documentviewer/PdfDocumentPageViewModel.java | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/org/jabref/gui/documentviewer/DocumentViewerViewModel.java b/src/main/java/org/jabref/gui/documentviewer/DocumentViewerViewModel.java index 6cd41363a0a..59eac25ae99 100644 --- a/src/main/java/org/jabref/gui/documentviewer/DocumentViewerViewModel.java +++ b/src/main/java/org/jabref/gui/documentviewer/DocumentViewerViewModel.java @@ -61,8 +61,6 @@ public DocumentViewerViewModel(StateManager stateManager) { maxPages.bindBidirectional( EasyBind.wrapNullable(currentDocument).selectProperty(DocumentViewModel::maxPagesProperty)); }); - - setCurrentEntries(this.stateManager.getSelectedEntries()); } diff --git a/src/main/java/org/jabref/gui/documentviewer/PdfDocumentPageViewModel.java b/src/main/java/org/jabref/gui/documentviewer/PdfDocumentPageViewModel.java index ae665d01a12..9010ec3379c 100644 --- a/src/main/java/org/jabref/gui/documentviewer/PdfDocumentPageViewModel.java +++ b/src/main/java/org/jabref/gui/documentviewer/PdfDocumentPageViewModel.java @@ -60,7 +60,7 @@ public Image render(int width, int height) { @Override public int getPageNumber() { - return pageNumber +1; + return pageNumber + 1; } @Override