Prevent Jabref from auto renaming and moving files

Note that we had a preference for it: Link file (without copying) doesn't work · Issue #5546 · JabRef/jabref · GitHub

A long discussion was made at Dropping a PDF on an entry should be consistent · Issue #121 · JabRef/jabref · GitHub

The dialog was as follows


We want to have “Remember decision”, thus we will re-add a preference.

Notes on the dialog:

  • Outputting the file directory is nice, because it makes explicit, where the file will be placed
  • “Copy to file directory” is a nice setting if one copies from a shared network folder. However, “move” should be default and “Copy” is only a secondary choice
  • “Leave file in its current directory” is incomplete. It should be “Link the file”
  • File renaming activation and showing the new file name is nice

New Proposal

How would you like to treat the file ‘{file name}’ residing in {directory}?

  • Link file
  • Move file
  • Copy file

(radio group)


Target directory is: {file directory}

  • Rename file to {new file name}

(This part is only enabled if move or copy is selected)


Notes

  • are the defaults to the radio group
  • If file already resides inside a file directory, then “Link file” is the only enabled option AND “Rename file to” can be selected (because as user, I want to keep the file in the folder hierarchy of files). “a file directory” means that one JabRef’s file directories (global file directory, main file directory, user-specific file directory). – Let’s call this “Mode inside-bib-directory”
  • org.jabref.model.database.BibDatabaseContext#getFirstExistingFileDir returns the target directory.
  • org.jabref.model.entry.LinkedFile#findIn(java.util.List<java.nio.file.Path>) can be used to check if the file resides inside a directory (to switch the mode to “inside-bib-directory”)