-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Copy linked files on entry transfer #13535
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
Open
UmutAkbayin
wants to merge
76
commits into
JabRef:main
Choose a base branch
from
UmutAkbayin:fix/copy-linked-files-on-entry-transfer
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
76 commits
Select commit
Hold shift + click to select a range
7b35786
refactor(RightClickMenu): pass libraryTab to createCopySubMenu
507c203
feat(ClipBoardManager): add static BibDatabaseContext field with gett…
327e8b3
refactor(ClipBoardManager): change sourceDatabaseContext to instance …
80a5dd8
feat(RightClickMenu): set sourceBibDatabaseContext from libraryTab
4a94235
feat: add LinkedFileTransferHelper#adjustLinkedFilesForTarget call to…
39e0484
feat(CopyTo): support file preferences in copy operations
2a58afb
feat(LinkedFileTransferHelper): add new helper class to support Entry…
4024b48
feat(LinkedFileTransferHelper): add helper to check reachability from…
87a064f
test(LinkedFileTransferHelperTest): add test cases for LinkedFileTran…
f864dc3
feat: adjust relative file paths after entry transfer between libraries
638bc91
feat(ImportHandler): clone entry in importEntryWithDuplicateCheck
593d36f
chore: update LinkedFileTransferHelper#adjustLinkedFilesForTarget cal…
f6cf22f
refactor: update LibraryTab#pasteEntry to copy with feedback
f53d4cc
feat(LinkedFileTransferHelper): enhance linked file adjustment and co…
d4871af
test(LinkedFileTransferHelperTest): add tests for all three scenarios
7385bd0
docs(requirements): add file transfer requirements specification
52fd290
chore: remove unnecessary comments and adjust filed.ms to increment t…
4b3011f
chore: replace Collection constructors with factories
2a9d039
chore: remove DisplayNames for test classes
646da11
chore: replace assertTrue with assertEquals
b06fbbc
refactor: change method signature to have boolean parameter last and …
3f03974
refactor: replace IOException with Exception in the throws clause and…
a85b157
refactor: remove unused import
a0dcacd
refactor: remove static modifier
0de8f52
fix: add messages for pasting entries in the properties file
9cc27f7
chore: use BibEntry copy constructor in LinkedFileTransferHelper for …
16bfa81
chore: align with style rules
a734930
fix: improve error logging and update assertions in LinkedFileTransfe…
2766ba9
fix: reorganize imports and improve code formatting in LinkedFileTran…
98b0a24
fix: rename filed.md to files.md for clarity
0309d35
docs: add requirement traceability comments to LinkedFileTransferHelper
ee18968
fix: replace file existence check with atomic copy and exception hand…
582c392
chore(LinkesFileTransferHelperTest): replace setters with withers
031f835
chore(LinkesFileTransferHelperTest): change back to setters
17d97b3
fix: reject null in setSourceBibDatabaseContext to enforce fail-fast
397efaf
test: update LinkedFileTransferHelperTest to use Set for returned ent…
f0e59a0
docs: clarify definition of "reachable" for linked files in file tran…
540fb72
chore: add line for separation
1e4e08c
refactor: remove requireNonNull
3863c2c
docs: update file transfer documentation for clarity and consistency
30c6ef5
refactor: streamline linked file adjustment by using ifPresent for so…
ac3cdd3
chore: move getSourceBibDatabaseContext method to improve code organi…
11d7dbe
chore: fix indentation in module-info.java after rebase
ae369d5
refactor: move clipboard context setting from RightClickMenu to EditA…
dd02975
test: refactor test to align with project standards
cd2cbf5
chore: change indents to 4 spaces to align with project standards
6e24f48
chore: change indents to 4 spaces to align with project standards in …
d862e20
Merge branch 'main' into fix/copy-linked-files-on-entry-transfer
koppor 0e22f72
chore: use Optional without fully qualified class name
526a86e
Merge remote-tracking branch 'origin/fix/copy-linked-files-on-entry-t…
bc21d34
Merge main into fix/copy-linked-files-on-entry-transfer
857380d
chore: fix import order
9fd3881
refactor: improve exception handling in file path adjustment
140dc2d
refactor: add nonnull annotation to parameters
ab218d8
refactor: remove null check
b171636
fix: use shared ClipBoardManager in EditAction
08847d2
fix: remove unnecessry injector and adjust dropEntry to handle drag a…
76a7e16
chore: remove unused import
fe33a01
refactor: update dropEntry methods to include source BibDatabaseConte…
041c2df
refactor: remove databasecontext from FrameDndHandler again
d2de51d
refactor: remove unused imports
765b7f8
refactor: set databasecontext in FramDndHandler
9a11db1
refactor: streamline clipboard management and linked file adjustments
91e67fb
chore: remove unused import
ad9d623
chore: remove block in switch expression
2fa7951
Merge remote-tracking branch 'upstream/main' into fix/copy-linked-fil…
7330a9e
Feature: Add option to deactivate the new feature by adjusting the fi…
61dfd6c
chore: adjust test cases to enable file copy feature
f6544ea
chore: replace Collections#emptySet with Set#of to align with best pr…
49ae45c
Merge branch 'main' into fix/copy-linked-files-on-entry-transfer
UmutAkbayin 6a99ffd
chore: remove unused import
59d8bc7
refactor: extract copyEntiresWithFeedback method to own utility class
49d9127
Merge remote-tracking branch 'upstream/main' into fix/copy-linked-fil…
3bdd340
chore: fix import order issues
e6e8454
chore: fix import order issues in LinkedFileTransferHelper
88e8506
chore: fix localization issues
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# File Transfer Between Bib Entries | ||
|
||
*Note:* | ||
"Reachable" here denotes that the linked file can be accessed via a relative path that does **not** climb up the directory structure (i.e., no "`..`" segments beyond the root directory). | ||
Additionally, this check respects all configured **directories for files** as defined in JabRef's file linking settings (see [directories for files](https://docs.jabref.org/finding-sorting-and-cleaning-entries/filelinks#directories-for-files)). | ||
|
||
## File is reachable and should not be copied | ||
`req~logic.externalfiles.file-transfer.reachable-no-copy~1` | ||
When a linked file is reachable from the target context, the system must adjust the relative path in the target entry but must not copy the file again. | ||
|
||
Needs: impl | ||
|
||
## File is not reachable, but the path is the same | ||
`req~logic.externalfiles.file-transfer.not-reachable-same-path~1` | ||
When a linked file is not reachable from the target context, and the relative path in both source and target entry is the same, the file must be copied to the target context. | ||
|
||
Needs: impl | ||
|
||
## File is not reachable, and a different path is used | ||
`req~logic.externalfiles.file-transfer.not-reachable-different-path~1` | ||
When a linked file is not reachable from the target context, and the relative path differs between source and target entries, the file must be copied and the directory structure must be created to preserve the relative link. | ||
|
||
Needs: impl | ||
|
||
<!-- markdownlint-disable-file MD022 --> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -104,6 +104,8 @@ | |
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import static org.jabref.gui.util.CopyUtil.copyEntriesWithFeedback; | ||
|
||
/** | ||
* Represents the ui area where the notifier pane, the library table and the entry editor are shown. | ||
*/ | ||
|
@@ -810,6 +812,7 @@ public void insertEntries(final List<BibEntry> entries) { | |
} | ||
|
||
public void copyEntry() { | ||
clipBoardManager.setSourceBibDatabaseContext(this.getBibDatabaseContext()); | ||
int entriesCopied = doCopyEntry(getSelectedEntries()); | ||
if (entriesCopied >= 0) { | ||
dialogService.notify(Localization.lang("Copied %0 entry(s)", entriesCopied)); | ||
|
@@ -838,17 +841,27 @@ private int doCopyEntry(List<BibEntry> selectedEntries) { | |
} | ||
|
||
public void pasteEntry() { | ||
List<BibEntry> entriesToAdd; | ||
String content = ClipBoardManager.getContents(); | ||
entriesToAdd = importHandler.handleBibTeXData(content); | ||
List<BibEntry> entriesToAdd = importHandler.handleBibTeXData(content); | ||
if (entriesToAdd.isEmpty()) { | ||
entriesToAdd = handleNonBibTeXStringData(content); | ||
} | ||
if (entriesToAdd.isEmpty()) { | ||
return; | ||
} | ||
|
||
importHandler.importEntriesWithDuplicateCheck(bibDatabaseContext, entriesToAdd); | ||
// Now, the BibEntries to add are known | ||
// The definitive insertion needs to happen now. | ||
BibDatabaseContext sourceBibDatabaseContext = clipBoardManager.getSourceBibDatabaseContext().orElse(null); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Comment before needs to be added
|
||
copyEntriesWithFeedback( | ||
sourceBibDatabaseContext, | ||
entriesToAdd, | ||
bibDatabaseContext, | ||
Localization.lang("Pasted %0 entry(s) to %1"), | ||
Localization.lang("Pasted %0 entry(s) to %1. %2 were skipped"), | ||
dialogService, | ||
preferences.getFilePreferences(), | ||
importHandler | ||
); | ||
} | ||
|
||
private List<BibEntry> handleNonBibTeXStringData(String data) { | ||
|
@@ -866,11 +879,21 @@ private List<BibEntry> handleNonBibTeXStringData(String data) { | |
} | ||
} | ||
|
||
public void dropEntry(List<BibEntry> entriesToAdd) { | ||
importHandler.importEntriesWithDuplicateCheck(bibDatabaseContext, entriesToAdd); | ||
public void dropEntry(BibDatabaseContext sourceBibDatabaseContext, List<BibEntry> entriesToAdd) { | ||
copyEntriesWithFeedback( | ||
sourceBibDatabaseContext, | ||
entriesToAdd, | ||
bibDatabaseContext, | ||
Localization.lang("Moved %0 entry(s) to %1"), | ||
Localization.lang("Moved %0 entry(s) to %1. %2 were skipped"), | ||
dialogService, | ||
preferences.getFilePreferences(), | ||
importHandler | ||
); | ||
} | ||
|
||
public void cutEntry() { | ||
clipBoardManager.setSourceBibDatabaseContext(this.getBibDatabaseContext()); | ||
int entriesCopied = doCopyEntry(getSelectedEntries()); | ||
int entriesDeleted = doDeleteEntry(StandardActions.CUT, mainTable.getSelectedEntries()); | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Maybe, add that in the following "reachable" denotes: reachable using a relative path not climbing up the directory structure?
Also that it respects all configured directories for files
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.
Here’s my update to the description regarding file reachability:
“Reachable” means the linked file can be accessed via a relative path that does not climb up the directory structure (no .. segments beyond the root).
Also, this respects all configured directories for files as per JabRef’s settings (link).
According to this understanding, the implementation is aligned with these cases.
Does this match your understanding?
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 should move the "reachable" paragraph before the list of requirements. Reason: One often jumps directly to a requirement - and does NOT read the other requirements --> but the definition is put in another requiement.
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.
Done.