Skip to content

Commit a2f295b

Browse files
Improve table layout and address review feedback
1 parent 1c3b60b commit a2f295b

File tree

3 files changed

+13
-16
lines changed

3 files changed

+13
-16
lines changed

CHANGELOG.md

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

3939
### Fixed
4040

41-
- We fixed an issue where the Websearch table had extra space, to improve the layout. [#14556](https://github.com/JabRef/jabref/issues/14556)
41+
- We fixed an issue where the Web search table had extra space, to improve the layout. [#14556](https://github.com/JabRef/jabref/issues/14556)
4242
- We fixed PDF import to prefer the content extracted title over filename like XMP metadata titles. [#11999](https://github.com/JabRef/jabref/issues/11999)
4343
- We fixed RIS export writing the full page range into both start page and end page fields instead of splitting them correctly. [#15106](https://github.com/JabRef/jabref/issues/15106)
4444
- We fixed an issue where shortcut keys did not work for linked files in the entry editor. [#12564](https://github.com/JabRef/jabref/issues/12564)

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

Lines changed: 12 additions & 14 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;
@@ -81,14 +83,9 @@ public String getTabName() {
8183
return Localization.lang("Web search");
8284
}
8385

84-
private static final double TABLE_ROW_HEIGHT = 30.0;
85-
private static final double TABLE_HEADER_HEIGHT = 32.0;
86-
8786
public void initialize() {
8887
this.viewModel = new WebSearchTabViewModel(preferences, refAiEnabled, taskExecutor);
8988

90-
searchEngineTable.setFixedCellSize(TABLE_ROW_HEIGHT);
91-
9289
searchEngineName.setCellValueFactory(param -> param.getValue().nameProperty());
9390
searchEngineName.setCellFactory(TextFieldTableCell.forTableColumn());
9491
searchEngineName.setEditable(false);
@@ -98,8 +95,16 @@ public void initialize() {
9895
searchEngineUrlTemplate.setEditable(true);
9996

10097
searchEngineTable.setItems(viewModel.getSearchEngines());
101-
adjustTableHeight();
102-
searchEngineTable.getItems().addListener((InvalidationListener) _ -> adjustTableHeight());
98+
99+
// Dynamic height based on font size and number of items
100+
DoubleBinding rowHeight = Bindings.createDoubleBinding(
101+
() -> enableWebSearch.getFont() != null ? enableWebSearch.getFont().getSize() * 2.5 : 30.0,
102+
enableWebSearch.fontProperty());
103+
searchEngineTable.fixedCellSizeProperty().bind(rowHeight);
104+
searchEngineTable.prefHeightProperty().bind(
105+
Bindings.size(searchEngineTable.getItems())
106+
.add(1.1) // Estimate for header height
107+
.multiply(rowHeight));
103108

104109
enableWebSearch.selectedProperty().bindBidirectional(viewModel.enableWebSearchProperty());
105110
warnAboutDuplicatesOnImport.selectedProperty().bindBidirectional(viewModel.warnAboutDuplicatesOnImportProperty());
@@ -183,13 +188,6 @@ private Node createFetcherNode(WebSearchTabViewModel.FetcherViewModel item) {
183188
return container;
184189
}
185190

186-
private void adjustTableHeight() {
187-
double height = TABLE_HEADER_HEIGHT + (searchEngineTable.getItems().size() * TABLE_ROW_HEIGHT) + 2.0;
188-
searchEngineTable.setPrefHeight(height);
189-
searchEngineTable.setMinHeight(height);
190-
searchEngineTable.setMaxHeight(height);
191-
}
192-
193191
private void showApiKeyDialog(WebSearchTabViewModel.FetcherViewModel fetcherViewModel) {
194192
dialogService.showCustomDialogAndWait(new ApiKeyDialog(viewModel, fetcherViewModel));
195193
}

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)