Refined the "Select files to import" page in "Search for unlinked local files" dialog#15110
Conversation
|
|
||
| relatedEntries.setAll(relatedEntriesList); | ||
| return relatedEntries; | ||
| } |
There was a problem hiding this comment.
This is the part I was asking about in this comment #13689 (comment).
This is the function that gets the related entries that the files can be linked with. I compare them with the citation key, with the different patterns of the file name, I can't find a specific way to parse the citation key from the file name.
I read the documentation you provided here #13689 (comment), but I still don't have a solution @koppor.
There was a problem hiding this comment.
I don't know what the existing code does. Need to read the existing code.
There was a problem hiding this comment.
I am continuing investigating the existing code also.
There was a problem hiding this comment.
The UnlinkedFilesCrawler and the UnlinkedPDFFileFilter are your friends
Roughly speaking, we create a list of all values of the file field in the library from all entries.
Then the crawlers use the Filter to check if the current found file a.pdf is already in the list of the entries, and so on
I think @koppor is confusing the logic here with "Automatically set File Links" which tries to automatically find matching files AutoLinkFilesAction.
There was a problem hiding this comment.
This is kind of inverse action - and should be properly designed.
There was a problem hiding this comment.
The UnlinkedFilesCrawler and the UnlinkedPDFFileFilter are your friends
Thanks a lot for the guidance.
I think @koppor is confusing the logic here with "Automatically set File Links" which tries to automatically find matching files
AutoLinkFilesAction.
Yeah I am really confused, is the refined dialog about only letting the user know that there are entries that are related to the file and the file will always be in new entry if it is imported or the user can link the files related to some entries without creating a new entry for them.
This comment has been minimized.
This comment has been minimized.
| List<BibEntry> relatedEntriesList = new ArrayList<>(); | ||
| List<BibEntry> allEntries = bibDatabase.getDatabase().getEntries(); | ||
|
|
||
| AutoSetFileLinksUtil util = new AutoSetFileLinksUtil( |
There was a problem hiding this comment.
I found this method here
But I had to change the CliPreferences to GuiPreferences to be able to call getExternalApplicationsPreferences(). Is this ok?
This method gets the files that are found but not linked to each entry, so I think it's the best method for searching the related entries for each file.
There was a problem hiding this comment.
this comment should have gone to line 79?
Since we are in the GUI, this change is OK.
|
Now, this PR, when the
2. Multiple related entries:
3. No related entries:
|
koppor
left a comment
There was a problem hiding this comment.
While reading #13689 (comment), I think, this PR goes in the right direction.
I wonder why so much is happing in the GUI. But this is PR #14710 - and neesd to be fixed seperately.
| preferences.getFilePreferences(), | ||
| preferences.getAutoLinkPreferences()); | ||
|
|
||
| for (BibEntry entry : allEntries) { |
There was a problem hiding this comment.
The algorithm should be explained.
| List<BibEntry> relatedEntriesList = new ArrayList<>(); | ||
| List<BibEntry> allEntries = bibDatabase.getDatabase().getEntries(); | ||
|
|
||
| AutoSetFileLinksUtil util = new AutoSetFileLinksUtil( |
There was a problem hiding this comment.
this comment should have gone to line 79?
Since we are in the GUI, this change is OK.
| if (empty || item == null) { | ||
| setText(null); | ||
| setGraphic(null); | ||
| } else { |
There was a problem hiding this comment.
When can entry or item be null? Is this a wrong call?
If you cannot avoid, please add a JavaDoc comment and also @Nulalble
Furthermore, return early. meaing: if, then return
and then no else branch.
| } else { | ||
| leftSide.getChildren().clear(); | ||
| CheckBox checkBox = (CheckBox) getGraphic(); | ||
| if (checkBox != null) { |
There was a problem hiding this comment.
I checked the normal scenarios where the checkbox can be null, and I think no one of them will happen in our case, so I think this check is dummy here.
| cellContent.getChildren().clear(); | ||
| cellContent.getChildren().add(leftSide); | ||
|
|
||
| if (item.getPath().toFile().isFile()) { |
There was a problem hiding this comment.
can it be no -file? when?
exit early again.
There was a problem hiding this comment.
can it be no -file? when?
exit early again.
We want to show blank space if it's a directory, not a file.
| } | ||
| } | ||
| setGraphic(cellContent); | ||
| setText(null); |
| jumpToEntryButton.getStyleClass().add("icon-button"); | ||
| jumpToEntryButton.setTooltip(new Tooltip(Localization.lang("Jump to entry"))); | ||
| jumpToEntryButton.setOnAction(_ -> { | ||
| BibEntry selectedEntry = relatedEntries.getValue(); |
There was a problem hiding this comment.
When can it happen that there is no value? --> add java ocmment
| new ViewModelTreeCellFactory<FileNodeViewModel>() | ||
| .withText(FileNodeViewModel::getDisplayTextWithEditDate) | ||
| .install(unlinkedFilesList); | ||
| unlinkedFilesList.setCellFactory(_ -> new CheckBoxTreeCell<>() { |
There was a problem hiding this comment.
Write a separate class - this is way too long for an anoymous class.
|
Your pull request conflicts with the target branch. Please merge with your code. For a step-by-step guide to resolve merge conflicts, see https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/addressing-merge-conflicts/resolving-a-merge-conflict-using-the-command-line. |
It's just because it's my first time working with GUI using JavaFX in this way. |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
pass StateManager via constructor parameter
|
|
||
| unlinkedFilesList = new CheckTreeView<>(); | ||
| new ViewModelTreeCellFactory<FileNodeViewModel>().withText(FileNodeViewModel::getDisplayTextWithEditDate).install(unlinkedFilesList); | ||
| unlinkedFilesList.setCellFactory(_ -> new UnlinkedFilesCellFactory(this.viewModel.getStateManager(), viewModel)); |
There was a problem hiding this comment.
Pas stateManager from constructor down
This comment has been minimized.
This comment has been minimized.
✅ All tests passed ✅🏷️ Commit: 76a24ba Learn more about TestLens at testlens.app. |
…al files" dialog (JabRef#15110) * Refined the Find unlinked files dialog * Added search for entries by pdf names * Added search icon for the selected entry * Fix submodules * Refactored the searching process * Fix submodules * Enhanced some code * Added manual test * Fix submodules * Added CHANGELOG entry * Fix submodules * Fix submodules * Fix submodules * Fix submodules * Changed "new" to localized one * Fixed some typos * Moved the CHANGELOG entry under Unreleased * Changed the tree cell of the FileSelectionPage * Passed StateManager via constructor parameter * Added the dropdown for one entry * Added do not link to deselect the entry in the dropdown * Added linking the file to the selected entry from the dropdown * Refined the Select files to import page in Search for unlinked local files dialog * Removed unused expressions
…rg.openrewrite.recipe-rewrite-recipe-bom-3.25.0 * upstream/main: (35 commits) Chore: add dependency-management.md (#15278) Chore(deps): Bump dev.langchain4j:langchain4j-bom in /versions (#15277) New Crowdin updates (#15274) Chore(deps): Bump actions/upload-artifact from 6 to 7 (#15271) Chore(deps): Bump actions/download-artifact from 7 to 8 (#15270) Chore(deps): Bump docker/login-action from 3 to 4 (#15268) Fix threading issues in citations relations tab (#15233) Fix: Citavi XML importer now preserves citation keys (#14658) (#15257) Preserve no break spaces in Latex to Unicode conversion (#15174) Fix: open javafx.scene.control.skin to controlsfx (#15260) Reduce complexity in dependencies setup (restore) (#15194) New translations jabref_en.properties (French) (#15256) Fix: exception dialog shows up when moving sidepanel down/up (#15248) Implement reset for Name Display Preferences (#15136) Chore(deps): Bump net.bytebuddy:byte-buddy in /versions (#15252) Chore(deps): Bump io.zonky.test.postgres:embedded-postgres-binaries-bom (#15253) Chore(deps): Bump io.zonky.test:embedded-postgres in /versions (#15254) Chore(deps): Bump net.ltgt.errorprone from 5.0.0 to 5.1.0 in /jablib (#15251) New Crowdin updates (#15247) Refined the "Select files to import" page in "Search for unlinked local files" dialog (#15110) ...






Related issues and pull requests
Closes #13689
PR Description
Refined the "Select files to import" page in "Search for unlinked local files" dialog to give the users the choice of linking the file to a related entry or import it to a new entry.
Steps to test
First open test-support/src/manual-tests/issue-13689/issue-13689.bib library



Select
Lookup - Search for unlinked local filesThis dialog will pop up
Click

NextNow the dialog provides jumping to related entries for each unlinked file. If the file can be linked to one entry or more, the entries will be in a dropdown, if the file isn't linked to any entry, it will have a blank beside it.


On clicking
Next, if there is a selected entry for a file, this file will be linked to the selected entry otherwise, it will be imported into a new entry.Checklist
CHANGELOG.mdin a way that can be understood by the average user (if change is visible to the user)