Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
wants to merge 1 commit into from

Conversation

MVP-D77
Copy link

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

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
Copy link
Member

ThiloteE commented May 27, 2022

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
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
Copy link
Member

calixtus commented Jun 4, 2022

Any update here?

@koppor
Copy link
Member

koppor commented Jun 6, 2022

This PR misses a screenshot

@koppor
Copy link
Member

koppor commented Jun 6, 2022

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
Copy link
Member

ThiloteE commented Jul 9, 2022

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
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
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
Copy link
Member

ThiloteE commented Dec 19, 2022

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
Labels
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