Skip to content

Commit 2cd41d8

Browse files
Fix #14556 Removed the extra space occupied by the table. (#15360)
* Fix #14556 Removed the extra space occupied by the table, The table in WebSearchTab was leaving unwanted space. This commit adjusts the layout to match the design specification. * Fix #14556 Removed the extra space occupied by the Table * Update CHANGELOG.md for #14556 * Improve table layout and address review feedback * Use constants for row height and header estimate to remove magic numbers * Fix Checkstyle: move constants above FXML fields * Remove extra blank line to satisfy Checkstyle * Remove redundant comment in WebSearchTab (line 115) --------- Co-authored-by: Subhramit Basu <subhramit.bb@live.in>
1 parent 50b38dc commit 2cd41d8

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv
4141

4242
### Fixed
4343

44+
- We fixed an issue where the Web search table had extra space, to improve the layout. [#14556](https://github.com/JabRef/jabref/issues/14556)
4445
- We fixed an issue where the side pane (Groups/Web search) width was not remembered after restarting JabRef. [#8907](https://github.com/JabRef/jabref/issues/8907)
4546
- We fixed the ScienceDirect fulltext fetcher not returning a PDF when the Elsevier API response includes a direct PDF link. [#12161](https://github.com/JabRef/jabref/issues/12161)
4647
- We fixed vertical cursor movement shortcuts (Command+Up/Down for document start/end, Option+Up/Down for paragraph start/end) not working correctly in the BibTeX source editor on macOS. [#5937](https://github.com/JabRef/jabref/issues/5937)

jabgui/src/main/java/org/jabref/gui/preferences/websearch/WebSearchTab.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import java.util.Optional;
55

66
import javafx.beans.InvalidationListener;
7+
import javafx.beans.binding.Bindings;
8+
import javafx.beans.binding.DoubleBinding;
79
import javafx.beans.property.ReadOnlyBooleanProperty;
810
import javafx.fxml.FXML;
911
import javafx.geometry.Pos;
@@ -33,6 +35,15 @@
3335
import com.airhacks.afterburner.views.ViewLoader;
3436

3537
public class WebSearchTab extends AbstractPreferenceTabView<WebSearchTabViewModel> implements PreferencesTab {
38+
// Multiplier for row height based on font size
39+
private static final double FONT_HEIGHT_MULTIPLIER = 2.5;
40+
41+
// Default row height if font is not available
42+
private static final double DEFAULT_ROW_HEIGHT = 30.0;
43+
44+
// Estimate for header height (used in table prefHeight calculation)
45+
private static final double HEADER_HEIGHT_ESTIMATE = 1.1;
46+
3647
@FXML private CheckBox enableWebSearch;
3748
@FXML private CheckBox warnAboutDuplicatesOnImport;
3849
@FXML private CheckBox downloadLinkedOnlineFiles;
@@ -94,6 +105,16 @@ public void initialize() {
94105

95106
searchEngineTable.setItems(viewModel.getSearchEngines());
96107

108+
// Dynamic height based on font size and number of items
109+
DoubleBinding rowHeight = Bindings.createDoubleBinding(
110+
() -> enableWebSearch.getFont() != null ? enableWebSearch.getFont().getSize() * FONT_HEIGHT_MULTIPLIER : DEFAULT_ROW_HEIGHT,
111+
enableWebSearch.fontProperty());
112+
searchEngineTable.fixedCellSizeProperty().bind(rowHeight);
113+
searchEngineTable.prefHeightProperty().bind(
114+
Bindings.size(searchEngineTable.getItems())
115+
.add(HEADER_HEIGHT_ESTIMATE)
116+
.multiply(rowHeight));
117+
97118
enableWebSearch.selectedProperty().bindBidirectional(viewModel.enableWebSearchProperty());
98119
warnAboutDuplicatesOnImport.selectedProperty().bindBidirectional(viewModel.warnAboutDuplicatesOnImportProperty());
99120
downloadLinkedOnlineFiles.selectedProperty().bindBidirectional(viewModel.shouldDownloadLinkedOnlineFiles());

jabgui/src/main/resources/org/jabref/gui/preferences/websearch/WebSearchTab.fxml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@
5353
<Label text="%( Note: Press return to commit changes in the table! )"/>
5454
<TableView
5555
fx:id="searchEngineTable"
56-
VBox.vgrow="ALWAYS"
5756
editable="true">
5857
<columns>
5958
<TableColumn minWidth="120"

0 commit comments

Comments
 (0)