From 3f03e0dca4791df3e749796c21a53509d7313627 Mon Sep 17 00:00:00 2001 From: yinpe <11810305@mail.sustech.edu.cn> Date: Tue, 9 Mar 2021 15:33:36 +0800 Subject: [PATCH 1/2] fix: fix for issue 6818 --- CHANGELOG.md | 1 + .../gui/maintable/SmartConstrainedResizePolicy.java | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index acdfd94176e..bae11a7651f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -57,6 +57,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve - We fixed an issue where a non valid value as font size results in an uncaught exception. [#7415](https://github.com/JabRef/jabref/issues/7415) - We fixed an issue where "Merge citations" in the Openoffice/Libreoffice integration panel did not have a corresponding opposite. [#7454](https://github.com/JabRef/jabref/issues/7454) - We fixed an issue where drag and drop of bib files for opening resulted in uncaught exceptions [#7464](https://github.com/JabRef/jabref/issues/7464) +- We fixed an issue where columns shrink in width when we try to enlarge JabRef window. [#6818](https://github.com/JabRef/jabref/issues/6818) ### Removed diff --git a/src/main/java/org/jabref/gui/maintable/SmartConstrainedResizePolicy.java b/src/main/java/org/jabref/gui/maintable/SmartConstrainedResizePolicy.java index e6c543fb02f..c725b4781f3 100644 --- a/src/main/java/org/jabref/gui/maintable/SmartConstrainedResizePolicy.java +++ b/src/main/java/org/jabref/gui/maintable/SmartConstrainedResizePolicy.java @@ -38,13 +38,19 @@ private Boolean initColumnSize(TableView table) { if (Math.abs(totalWidth - tableWidth) > 1) { double totalPrefWidth = visibleLeafColumns.stream().mapToDouble(TableColumnBase::getPrefWidth).sum(); + double currPrefWidth = 0; if (totalPrefWidth > 0) { for (TableColumnBase col : visibleLeafColumns) { double share = col.getPrefWidth() / totalPrefWidth; double newSize = tableWidth * share; // Just to make sure that we are staying under the total table width (due to rounding errors) - newSize -= 2; + currPrefWidth += newSize; + if (currPrefWidth > tableWidth) { + double surplus = currPrefWidth - tableWidth; + newSize -= surplus; + currPrefWidth -= surplus; + } resize(col, newSize - col.getWidth()); } From c90467d06eef213d7940e8d273863c78dc95799a Mon Sep 17 00:00:00 2001 From: yinpe <11810305@mail.sustech.edu.cn> Date: Tue, 9 Mar 2021 16:24:07 +0800 Subject: [PATCH 2/2] fix: fix for issue 6818 --- .../jabref/gui/maintable/SmartConstrainedResizePolicy.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/jabref/gui/maintable/SmartConstrainedResizePolicy.java b/src/main/java/org/jabref/gui/maintable/SmartConstrainedResizePolicy.java index c725b4781f3..4096455c765 100644 --- a/src/main/java/org/jabref/gui/maintable/SmartConstrainedResizePolicy.java +++ b/src/main/java/org/jabref/gui/maintable/SmartConstrainedResizePolicy.java @@ -47,9 +47,8 @@ private Boolean initColumnSize(TableView table) { // Just to make sure that we are staying under the total table width (due to rounding errors) currPrefWidth += newSize; if (currPrefWidth > tableWidth) { - double surplus = currPrefWidth - tableWidth; - newSize -= surplus; - currPrefWidth -= surplus; + newSize -= currPrefWidth - tableWidth; + currPrefWidth -= tableWidth; } resize(col, newSize - col.getWidth());