Skip to content

Enhance "file" field in General Tab of Entry-Editor#8855

Closed
MVP-D77 wants to merge 1 commit into
JabRef:mainfrom
MVP-D77:main
Closed

Enhance "file" field in General Tab of Entry-Editor#8855
MVP-D77 wants to merge 1 commit into
JabRef:mainfrom
MVP-D77:main

Conversation

@MVP-D77

@MVP-D77 MVP-D77 commented May 27, 2022

Copy link
Copy Markdown

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.md described 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.

@ThiloteE ThiloteE changed the title Hello, our group is student 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! Enhance "file" field in General Tab of Entry-Editor May 27, 2022
@ThiloteE

ThiloteE commented May 27, 2022

Copy link
Copy Markdown
Member

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.

@Siedlerchr

Copy link
Copy Markdown
Member

Please fix the failing tests and the checkstyle issues and remove unused code comment.s

@Siedlerchr Siedlerchr added the status: changes-required Pull requests that are not yet complete label May 30, 2022
@calixtus

calixtus commented Jun 4, 2022

Copy link
Copy Markdown
Member

Any update here?

@koppor

koppor commented Jun 6, 2022

Copy link
Copy Markdown
Member

This PR misses a screenshot

@koppor

koppor commented Jun 6, 2022

Copy link
Copy Markdown
Member

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.

@ThiloteE

ThiloteE commented Jul 9, 2022

Copy link
Copy Markdown
Member

Screenshots are based on this pr.

Without files:
grafik

With many files:
grafik

To do:

  • only the file field should increase in size. Other fields should retain their height, even when many files are attached.

@ThiloteE

Copy link
Copy Markdown
Member

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);
        }
    }

@Siedlerchr

Copy link
Copy Markdown
Member

The height of the LinkedFilesEditor is controlled here as well, it returns the weight parameter used for the calculation

@Override
public double getWeight() {
return 2;
}

@ThiloteE

ThiloteE commented Dec 19, 2022

Copy link
Copy Markdown
Member

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();
     }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Increase size of "file" field in General Tab of Entry-Editor

5 participants