Skip to content
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

Merged
merged 6 commits into from
Mar 17, 2018

Conversation

tobiasdiez
Copy link
Member

@tobiasdiez tobiasdiez commented Mar 9, 2018

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!


  • Change in CHANGELOG.md described
  • Tests created for changes
  • Manually tested changed features in running JabRef
  • Screenshots added in PR description (for bigger UI changes)
  • Ensured that the git commit message is a good one
  • Check documentation status (Issue created for outdated help page at help.jabref.org?)

@tobiasdiez tobiasdiez added the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Mar 9, 2018
} else {
directory = fileDirectories.get(0);
}
final Path suggestDir = directory == null ? Paths.get(System.getProperty("user.home")) : directory;
Copy link
Member

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

Copy link
Member Author

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("\\?|\\*|\\<|\\>|\\||\\\"|\\:|\\.$|\\[|\\]", "");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extract to a matcher?

Copy link
Member Author

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) {
Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member

@Siedlerchr Siedlerchr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM now

@Siedlerchr
Copy link
Member

If you fix checkstyle we can merge

@clarity-bot
Copy link

clarity-bot bot commented Mar 15, 2018

I generated a structure-diff below from pulling 19945df on JabRef:downloadLinks into 988fb54 on JabRef:master.

Structure Diff

Copy link
Member

@koppor koppor left a 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);
Copy link
Member

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
Copy link
Member

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.

Copy link
Member Author

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,
Copy link
Member

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.

Copy link
Member Author

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,
Copy link
Member

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

@koppor koppor removed the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Mar 16, 2018
@tobiasdiez tobiasdiez merged commit 2cdf085 into master Mar 17, 2018
@tobiasdiez tobiasdiez deleted the downloadLinks branch March 17, 2018 10:18
Siedlerchr added a commit that referenced this pull request Mar 17, 2018
* 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
Siedlerchr added a commit that referenced this pull request Mar 18, 2018
* 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
Siedlerchr added a commit that referenced this pull request Mar 18, 2018
…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
Siedlerchr added a commit that referenced this pull request Mar 26, 2018
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants