-
-
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
Provides download option in context menu and fixes #3614 #3824
Conversation
} else { | ||
directory = fileDirectories.get(0); | ||
} | ||
final Path suggestDir = directory == null ? Paths.get(System.getProperty("user.home")) : 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.
There is a method which always returns a file dir: getfirstExistingFileDir
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.
Good observation. Thanks for the hint.
* https://support.apple.com/en-us/HT202808 | ||
*/ | ||
if (OS.WINDOWS) { | ||
plannedName = plannedName.replaceAll("\\?|\\*|\\<|\\>|\\||\\\"|\\:|\\.$|\\[|\\]", ""); |
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.
extract to a matcher?
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 turns out that this code is not needed since the FileUtil
class already handles cleanup of file names
|
||
public LinkedFilesEditorViewModel(String fieldName, AutoCompleteSuggestionProvider<?> suggestionProvider, DialogService dialogService, BibDatabaseContext databaseContext, TaskExecutor taskExecutor, FieldCheckers fieldCheckers) { | ||
public LinkedFilesEditorViewModel(String fieldName, AutoCompleteSuggestionProvider<?> suggestionProvider, DialogService dialogService, BibDatabaseContext databaseContext, TaskExecutor taskExecutor, FieldCheckers fieldCheckers, JabRefPreferences preferences) { |
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.
I know that's its not taht good style to have methods with long params, but why not directly use the FileDirectoryPreferences and ImportFormatPrefernces as args?
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.
Mhhh, I tried to collect all the preferences accesses and even for the LinkedFileViewModel it were 5 different settings that are needed. Thus I prefer to keep the general preferences class as dependency.
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 now
If you fix checkstyle we can merge |
I generated a structure-diff below from pulling |
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.
Some comments on "Globals", otherwise: LGTM. Did not try out locally though 😇
@@ -51,7 +51,7 @@ public static FieldEditorFX getForField(String fieldName, TaskExecutor taskExecu | |||
} else if (fieldExtras.contains(FieldProperty.OWNER)) { | |||
return new OwnerEditor(fieldName, preferences, suggestionProvider, fieldCheckers); | |||
} else if (fieldExtras.contains(FieldProperty.FILE_EDITOR)) { | |||
return new LinkedFilesEditor(fieldName, dialogService, databaseContext, taskExecutor, suggestionProvider, fieldCheckers); | |||
return new LinkedFilesEditor(fieldName, dialogService, databaseContext, taskExecutor, suggestionProvider, fieldCheckers, preferences); |
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 really the whole preferences need to be passed? Didn't we want to implement information hiding here? 😇
|
||
@Deprecated |
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 add a JavaDoc pointing to the method one should use from now on.
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.
Good observation. Fixed.
} | ||
|
||
protected LinkedFileViewModel(LinkedFile linkedFile, BibEntry entry, BibDatabaseContext databaseContext, | ||
TaskExecutor taskExecutor, DialogService dialogService) { | ||
public LinkedFileViewModel(LinkedFile linkedFile, BibEntry entry, BibDatabaseContext databaseContext, |
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.
I think, only the IMPORT_FILENAMEPATTERN
and preferences.getFileDirectoryPreferences()
are needed. Why not pass them both (as quick fix regarding the information hiding). OK, a new preference object would even be better, but that costs more time.
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 auto-link preferences as well as the import preferences are needed. You are definitely right, a custom preference object unifying them all would be nice. To be honest, I don't have the motivation right now to create one (especially since the focus of this PR is a different one).
Globals.prefs.getLayoutFormatterPreferences(Globals.journalAbbreviationLoader), | ||
Globals.prefs.getFileDirectoryPreferences(), linkedFile); | ||
cleanupPreferences.getFileNamePattern(), | ||
layoutFormatterPreferences, |
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.
Actually layoutFormatterPrefernces can be removed from all cleanup ops (did this the maintable beta), but out of scope for this pr
* upstream/master: Provides download option in context menu and fixes #3614 (#3824) Minor refactoring # Conflicts: # src/main/java/org/jabref/gui/fieldeditors/LinkedFileViewModel.java # src/main/java/org/jabref/gui/fieldeditors/LinkedFilesEditorViewModel.java # src/test/java/org/jabref/architecture/TestArchitectureTests.java # src/test/java/org/jabref/gui/fieldeditors/LinkedFileViewModelTest.java
* upstream/master: Provides download option in context menu and fixes #3614 (#3824) Minor refactoring # Conflicts: # src/main/java/org/jabref/gui/fieldeditors/LinkedFileViewModel.java # src/main/java/org/jabref/gui/fieldeditors/LinkedFilesEditorViewModel.java # src/test/java/org/jabref/architecture/TestArchitectureTests.java # src/test/java/org/jabref/gui/fieldeditors/LinkedFileViewModelTest.java
…esDlg * upstream/maintable-beta: Get rid of journal abbrev loader in linkedFiles (#3862) fix build, remove layout prefs, pass journal abbrev loader and prefs where necessary Watch main css file for change and reapply automatically (#3847) Provides download option in context menu and fixes #3614 (#3824) Minor refactoring # Conflicts: # src/main/java/org/jabref/gui/fieldeditors/LinkedFileViewModel.java
* javafx replacement for file dialog * Add some core structure for selectFilesDialog * Add Properties for binding * add getters * Renaming, use properties in controller open dialog with attach file action * port some more code * Asssign combobox selected value property * fix some formatting * make getController public to get viewModel * add enum with config values instead of booleans * Fix depdendency injection * Rework * Merge remote-tracking branch 'upstream/master' into maintable-beta * upstream/master: Provides download option in context menu and fixes #3614 (#3824) Minor refactoring # Conflicts: # src/main/java/org/jabref/gui/fieldeditors/LinkedFileViewModel.java # src/main/java/org/jabref/gui/fieldeditors/LinkedFilesEditorViewModel.java # src/test/java/org/jabref/architecture/TestArchitectureTests.java # src/test/java/org/jabref/gui/fieldeditors/LinkedFileViewModelTest.java * Create Wrapper to pass LinkedFile around TODO: what do to on edit? How to save the new file? * fix some indentations update File after Edit * remove open unknown external file type dialog convert ImportInspectionDialog to use new file edit dialog * fix indentation * convert attachFileDialog to javafx show file open dialog on attach file show dialog for editing file afterwards * reformat * Mark old filelist as deprecated Pass Preferences Service instead of Preferences * fix checkstyle remove unused parameter entry * fix checkstyle again * add changelog Move fxml to resources rework layout to grid * adjust indentation * convert to new FXML dialog model funcionality still some NPEs * fix empty lines * fix checkstyle * Fix viewModel NPE in copyFiles Action and linkedfilesEditDialog * Add close button in copy linked files * fix checkstyle * Rename and reformat * remove changelog move fxml to java package remove wrapper class pass externalFileType to viewModel renammings * remove close method Add ok button to dialog pane * change some odd looking assigments * renaming * forgotten rename
Inspired by the discussion in #3818, I added a "Download file" option in the context menu of a linked file (if it is an online link). Moreover, the bug #3614 is fixed.
This PR was brought to you with the support of coffee from the JabRef cup!