-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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".
@Test | ||
public void testStartImportWithValidFiles() throws Exception { | ||
// Create temporary test files | ||
Path tempDir = Files.createTempDirectory("testDir"); |
There was a problem hiding this comment.
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
There was a problem hiding this 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 |
There was a problem hiding this comment.
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:
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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
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"); |
There was a problem hiding this comment.
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.
Files.deleteIfExists(tempFile1); | ||
Files.deleteIfExists(tempFile2); | ||
Files.deleteIfExists(subDir); | ||
Files.deleteIfExists(tempDir); |
There was a problem hiding this comment.
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
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.
Mandatory checks
CHANGELOG.md
described in a way that is understandable for the average user (if change is visible to the user)