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

improve unlinked files dialog #12195

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

agondekova
Copy link

Description of changes:

I modified the display of file paths in the "File" column so that relative paths, starting from the directory specified in the "Directory" field, are shown instead of full absolute paths. I also added the ability to resize the columns in the table, making them customizable for the user. Additionally, I changed the alignment of the text in the column, which was previously aligned to the right, to the left, as described in the issue, to ensure proper display when the text doesn’t fit within the available space.

This change improves the clarity and flexibility when working with the table.

Closes #11878.

relativePath columnResize

Mandatory checks

  • I own the copyright of the code submitted and I licence it under the MIT license
  • Change in CHANGELOG.md described in a way that is understandable for the average user (if change is visible to the user)
  • 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.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your code currently does not meet JabRef's code guidelines.
We use OpenRewrite to ensure "modern" Java coding practices.
The issues found can be automatically fixed.
Please execute the gradle task rewriteRun, check the results, commit, and push.

You can check the detailed error output by navigating to your pull request, selecting the tab "Checks", section "Tests" (on the left), subsection "OpenRewrite".

@Siedlerchr Siedlerchr changed the title Fix for issue 11878 improve unlinked files dialog Nov 16, 2024
@Test
public void testStartImportWithValidFiles() throws Exception {
// Create temporary test files
Path tempDir = Files.createTempDirectory("testDir");
Copy link
Member

@Siedlerchr Siedlerchr Nov 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use the @tempdir annotaiton from junit jupiter https://www.baeldung.com/junit-5-temporary-directory#1-tempdir-as-a-method-parameter
it has the advantage of auto cleanup of files, so no manual deleting necessary

Copy link
Member

@Siedlerchr Siedlerchr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

codewise looks good already, just some small improvements.
will do a proper test tomorrow

@@ -145,9 +146,11 @@ public void startSearch() {
}

public void startImport() {
Path directory = Paths.get(this.getSearchDirectory().toString()); // Get the base directory
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is more complicated than it needs to be:

Suggested change
Path directory = Paths.get(this.getSearchDirectory().toString()); // Get the base directory
Path directory = this.getSearchDirectory();

List<Path> fileList = checkedFileListProperty.stream()
.map(item -> item.getValue().getPath())
.filter(path -> path.toFile().isFile())
.map(path -> directory.toAbsolutePath().relativize(path.toAbsolutePath())) // Convert to relative path
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remoe the comment, it's clear from the code what is done.
Despite that I am not sure if you really need the second toAbsolutePath

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, the directory should already be an absolute path?

@Siedlerchr Siedlerchr added the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Nov 16, 2024
Comment on lines +116 to +120
assertEquals(2, fileList.size(), "fileList should contain 2 paths");
assertTrue(fileList.contains(directory.toAbsolutePath().relativize(tempFile1.toAbsolutePath())),
"fileList should contain the relative path of file1.pdf");
assertTrue(fileList.contains(directory.toAbsolutePath().relativize(tempFile2.toAbsolutePath())),
"fileList should contain the relative path of file2.txt");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do one assertEquals

assertEquals(List.of(directory.toAbsolutePath().relativize(tempFile1.toAbsolutePath()), fileList.contains(directory.toAbsolutePath().relativize(tempFile2.toAbsolutePath())), fileList)

Then, you checked both size and the containment.

Comment on lines +121 to +124
Files.deleteIfExists(tempFile1);
Files.deleteIfExists(tempFile2);
Files.deleteIfExists(subDir);
Files.deleteIfExists(tempDir);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need if youuse @TempDir

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Lookup -> Search Unlinked local files: Improve dialog
4 participants