-
-
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
Add a preference to add files in entry editor #4408
Conversation
CHANGELOG.md
Outdated
@@ -35,7 +35,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `# | |||
- We added a minimal height for the entry editor so that it can no longer be hidden by accident. [#4279](https://github.com/JabRef/jabref/issues/4279) | |||
- We added a new keyboard shortcut so that the entry editor could be closed by <kbd>Ctrl<kbd> + <kbd>E<kbd>. [#4222] (https://github.com/JabRef/jabref/issues/4222) | |||
- We added an option in the preference dialog box, that allows user to pick the dark or light theme option. [#4130] (https://github.com/JabRef/jabref/issues/4130) | |||
|
|||
- Allow the user to choose behavior after dragging and dropping files in Entry Editor using Preferences. [#4356] |
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.
Please follow the convention of the other log entries
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.
Please let me know if this d57beda looks good
Also, I have logged an issue to help.jabref.org to update the documentation for this new preference option - https://github.com/JabRef/help.jabref.org/issues/194
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.
Thanks for your contribution 👍 Codewise looks good. Please adapt the changelog entry and then we can merge it.
Codacy seems to have stuck in Pending/Analyzing state. Is there something that I need to do from my side so that its analysis is completed? |
Hit it was probably stuck because you had a merge conflict in the changelog.md file. |
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.
LGTM! Thanks for your contribution!
Thanks! |
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.
Thanks for your PR.
The code changes look good to me, however, your solution has the drawback that one can no longer use the modifier keys (Shift/Alt/Ctrl) to control the behavior of the drop. The preference value should only be treated as the default action (when no modifier is pressed). It would be nice if you could revise this part again.
|
||
if (dragboard.hasContent(DragAndDropDataFormats.LINKED_FILE)) { | ||
|
||
LinkedFile linkedFile = (LinkedFile) dragboard.getContent(DragAndDropDataFormats.LINKED_FILE); |
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.
It is ok to remove the code related to drag & drop of external files, because this is handled by the entry editor as you have noted. However, it should still be possible to resort the linked files using drag & drop.
@@ -114,6 +122,21 @@ public EntryEditorPrefsTab(JabRefPreferences prefs) { | |||
builder.add(firstNameModeAbbr, 1, 20); | |||
builder.add(firstNameModeFull, 1, 21); | |||
builder.add(firstNameModeBoth, 1, 22); | |||
|
|||
final ToggleGroup group = new ToggleGroup(); | |||
Label linkFileOptions = new Label(Localization.lang("Options to add file")); |
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 reformulate to Default drag & drop action
?
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.
final ToggleGroup group = new ToggleGroup(); | ||
Label linkFileOptions = new Label(Localization.lang("Options to add file")); | ||
linkFileOptions.getStyleClass().add("sectionHeader"); | ||
copyFile = new RadioButton(Localization.lang("Copy file to current location")); |
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.
Suggestion: Copy file to default file folder
(or location instead of folder)
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.
private boolean linkFile; | ||
private boolean renameCopyFile; | ||
|
||
public FileDragDropPreferences(boolean copyFile, boolean linkFile, boolean renameCopyFile) { |
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.
At this point, it appears to be cleaner to introduce an enum for the three different behaviors, especially since they are mutually exclusive.
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.
Switched to enum:
66443c0#diff-65271fca5ef3c430d80bc31ef69fdf56R3
@tobiasdiez Thanks for reviewing. For:
I don't think there is a straightforward solution using the DragEvent used in the code. This is because I wont be able to detect the modifiers pressed or confirm whether no modifier is pressed. I will keep looking into this, let me know if you have any guidance to resolve it. |
The code you edited had this functionality before. You can get the modifier using |
What will happen in a case where the TransferMode is |
Its probably not possible to differentiate between move = no modifier and move = shift. Thus, I would suggest the following behavior: In this way, the user can configure the default action on windows and linux, but is also possible to only link the file if he wants to. |
Just need some clarification on the behavior for 'link'. I got that if the transfer mode is link, then we should allow the user to link file. But if the preference is set to 'link' with 'link' as the transfer mode then why should we move, rename and link file? Shouldn't we follow move, rename and link when preference is set to 'move, rename and link' and not when it is set 'link'? |
I wasn't sure about this either. My rationale was to allow for the following behavior:
Because otherwise the users has no option to perform "Move & Rename" if he selected "Link" as the default action. But I'm very open for suggestions if this behavior is counter intuitive. |
I think your option is good. But I just feel that it should be documented that what keys would be used for each option in preferences tab in brackets. One more suggestion that we can consider is as follows:
Let me know your thoughts on this. |
@shahamish150294 Please be aware that the keys differ on other operating systems, e.g. Linux or Mac. and not all operating systems differ between all modifiers. See my code comment regarding Ubuntu somewhere |
50657f1
to
b4d4b2d
Compare
…op preference with enums
b4d4b2d
to
ca4ac4f
Compare
I have added the logic we discussed above and fixed the LinkedFilesEditor to allow moving of the files within the File Editor. I also updated the issue on help.jabref to follow the behavior as we have discussed here for documentation. |
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.
LGTM , thanks for your contribution!
If @tobiasdiez gives his okay, we can merge this! |
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.
Sorry for the late review. Was a bit busy the last days. Thanks a lot for the follow-up! The code looks very good now and I'll hence press the magic button ;-)
* upstream/master: New Crowdin translations (#4454) Fix error in l10n file: Toogle -> Toggle (#4453) Remove depandabot Bump junit-pioneer from 0.2.2 to 0.3.0 (#4451) Add Depandabot badge Emphasize that users should try out the newest version before reporting a bug Add a preference to add files in entry editor (#4408) Add submodule pull to circle ci and fix theme loading css (#4443) fix groups drag and drop (#4439)
* upstream/master: New Crowdin translations (#4454) Fix error in l10n file: Toogle -> Toggle (#4453) Remove depandabot Bump junit-pioneer from 0.2.2 to 0.3.0 (#4451) Add Depandabot badge Emphasize that users should try out the newest version before reporting a bug Add a preference to add files in entry editor (#4408) Add submodule pull to circle ci and fix theme loading css (#4443) fix groups drag and drop (#4439) Convert merge entries dialog to JavaFX (#4410) Fix ArrayIndexOutOfBoundsException on second pdf import (#4426) Fix radiobuttons in preference menu (#4409) Add citation styles as git submodule (#4431) Fix highlight color of selected text and progress bar (#4420) Fix two new issues Fix Violations of Always Use Braces (#4400) Delete PreferencesService.java.orig Add JabRef icon to installer and change watermark to JabRef (#4421) Checkstyle: force braces around code blocks
This PR for #4356 mainly involves
Fixes #4356
I will log an issue to help.jabref.org if these changes are approved. Please feel free to suggest any changes. Thank you!