Enhance "file" field in General Tab of Entry-Editor
Fixes #8823
Hello, we are a group of students and interested in ui design, and we also think user experience is the most important, in the origin version, user can not quickly find which file he/she select. I want to use setPrefHeight to dynamically update the height of list. But also, there are some issues with other fields` height, maybe we should still make sure every box consist. Also, we hope continue to try to improve this problem!
- [ ] Change in
CHANGELOG.mddescribed in a way that is understandable for the average user (if applicable) - [ ] Tests created for changes (if applicable)
- [ ] Manually tested changed features in running JabRef (always required)
- [ ] Screenshots added in PR description (for UI changes)
- [ ] Checked developer's documentation: Is the information available and up to date? If not, I outlined it in this pull request.
- [ ] Checked documentation: Is the information available and up to date? If not, I created an issue at https://github.com/JabRef/user-documentation/issues or, even better, I submitted a pull request to the documentation repository.
Hey, the heading of this pull-request was way too long xD The header will show up in the list of commits to JabRef, so it is better, if it is short. I also added the fixes #8823, which makes it so that when this pull-request is merged, it automatically closes the issue :-)
Sorry for the edit.
See https://www.freecodecamp.org/news/how-to-write-better-git-commit-messages/ for typical intro to commit messages.
Please fix the failing tests and the checkstyle issues and remove unused code comment.s
Any update here?
This PR misses a screenshot
Single-line fields should have the same heights. Please also include text wrapping for these fields (to avoid hiding text). See https://stackoverflow.com/a/40652937/873282 for hints.
Screenshots are based on this pr.
Without files:

With many files:

To do:
- [ ] only the file field should increase in size. Other fields should retain their height, even when many files are attached.
I think https://github.com/JabRef/jabref/blob/main/src/main/java/org/jabref/gui/entryeditor/FieldsEditorTab.java might be the place regulating field width within the entry editor tabs?
e.g.
private void setRegularRowLayout(GridPane gridPane) {
double totalWeight = fields.stream()
.mapToDouble(field -> editors.get(field).getWeight())
.sum();
List<RowConstraints> constraints = new ArrayList<>();
for (Field field : fields) {
RowConstraints rowExpand = new RowConstraints();
rowExpand.setVgrow(Priority.ALWAYS);
rowExpand.setValignment(VPos.TOP);
rowExpand.setPercentHeight(100 * editors.get(field).getWeight() / totalWeight);
constraints.add(rowExpand);
}
gridPane.getRowConstraints().addAll(constraints);
}
private void setCompressedRowLayout(GridPane gridPane, int rows) {
RowConstraints rowExpand = new RowConstraints();
rowExpand.setVgrow(Priority.ALWAYS);
rowExpand.setValignment(VPos.TOP);
if (rows == 0) {
rowExpand.setPercentHeight(100);
} else {
rowExpand.setPercentHeight(100 / (double) rows);
}
for (int i = 0; i < rows; i++) {
gridPane.getRowConstraints().add(rowExpand);
}
}
The height of the LinkedFilesEditor is controlled here as well, it returns the weight parameter used for the calculation
https://github.com/JabRef/jabref/blob/110052655e8cdc38bc3d7ce4a29114baa729aa68/src/main/java/org/jabref/gui/fieldeditors/LinkedFilesEditor.java#L262-L265
In Oktober I experimented a little with this pr and found that listView.setMinHeight(number*33); works better than "20" in some situations.
Here the code I experimented with (but it did not work all too well either :/ It's quite the hack
src/main/java/org/jabref/gui/fieldeditors/LinkedFilesEditor.fxml
- <ListView fx:id="listView" prefHeight="0" HBox.hgrow="ALWAYS" maxHeight="100" />
+ <ListView fx:id="listView" HBox.hgrow="ALWAYS"/>
src/main/java/org/jabref/gui/fieldeditors/LinkedFilesEditor.java
@FXML
private void addNewFile() {
- viewModel.addNewFile();
+ int number = viewModel.addNewFile();
+ if (number < 4) {
+ return;
+ }
+ // else if (number > 7) {
+ // // listView.getMinHeight;
+ // return;
+ // }
+ //else {
+ // computeMinHeight(forWidth)
+ // listView.setMinHeight(number*33);
+ // listView.setPrefHeight(number*5);
+ // System.out.println(listView.getPrefHeight());
+ //}
}
src/main/java/org/jabref/gui/fieldeditors/LinkedFilesEditorViewModel.java
public ListProperty<LinkedFileViewModel> filesProperty() {
return files;
}
- public void addNewFile() {
+ //public void addNewFile() {
+ public int addNewFile() {
Path workingDirectory = databaseContext.getFirstExistingFileDir(preferences.getFilePreferences())
.orElse(preferences.getFilePreferences().getWorkingDirectory());
FileDialogConfiguration fileDialogConfiguration = new FileDialogConfiguration.Builder()
.withInitialDirectory(workingDirectory)
@@ -149,10 +150,11 @@ public class LinkedFilesEditorViewModel extends AbstractEditorViewModel {
databaseContext,
taskExecutor,
dialogService,
preferences));
});
+ return files.size();
}