Skip to content

Commit

Permalink
Some suggestion and example to fix this bug by dramatically update th…
Browse files Browse the repository at this point in the history
…e Height of list JabRef#8823
  • Loading branch information
MVP-D77 committed May 27, 2022
1 parent 117bb1c commit ef042e0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<?import org.jabref.gui.icon.JabRefIconView?>
<fx:root xmlns:fx="http://javafx.com/fxml/1" type="HBox" xmlns="http://javafx.com/javafx/8.0.112"
fx:controller="org.jabref.gui.fieldeditors.LinkedFilesEditor">
<ListView fx:id="listView" prefHeight="0" HBox.hgrow="ALWAYS" maxHeight="100" />
<ListView fx:id="listView" HBox.hgrow="ALWAYS"/>
<Button onAction="#addNewFile"
styleClass="icon-button">
<graphic>
Expand Down
11 changes: 10 additions & 1 deletion src/main/java/org/jabref/gui/fieldeditors/LinkedFilesEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,16 @@ public Parent getNode() {

@FXML
private void addNewFile() {
viewModel.addNewFile();
// System.out.println(listView.getPrefHeight());
int number = viewModel.addNewFile();
if(number < 3)
return;
else{
listView.setMinHeight(number*20);
// listView.setPrefHeight(number*5);
System.out.println(listView.getPrefHeight());
}
//
}

@FXML
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public ListProperty<LinkedFileViewModel> filesProperty() {
return files;
}

public void addNewFile() {
public int addNewFile() {
Path workingDirectory = databaseContext.getFirstExistingFileDir(preferences.getFilePreferences())
.orElse(preferences.getFilePreferences().getWorkingDirectory());

Expand All @@ -155,6 +155,7 @@ public void addNewFile() {
preferences,
externalFileTypes));
});
return files.size();
}

@Override
Expand Down

0 comments on commit ef042e0

Please sign in to comment.