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

Fix for issue 6966: open all files of multiple entries #7709

Merged
merged 20 commits into from
May 13, 2021

Conversation

XDZhelheim
Copy link
Contributor

@XDZhelheim XDZhelheim commented May 7, 2021

Fixes #6966

  • Change in CHANGELOG.md described in a way that is understandable for the average user (if applicable)
  • Tests created for changes (if applicable)
  • Manually tested changed features in running JabRef (always required)
  • Screenshots added in PR description (for UI changes)
  • Checked documentation: Is the information available and up to date? If not created an issue at https://github.com/JabRef/user-documentation/issues or, even better, submitted a pull request to the documentation repository.

Added a new function to "Open file" option in the right-click menu.

Now we can open all linked files of the selected entries.

Test videos:

Single entry selected: the behavior remains unchanged

6966-1.mp4

Multiple entries selected

  • All of them have linked files: open them all
6966-2.mp4
  • Some have and some not: pop out a dialog to ask the user whether to continue, if yes, only open the former and skip the latter
6966-3.mp4
  • None of them have any linked file: option will be disabled
6966-4.mp4

To implement these functions, I modified OpenExternalFileAction and added a new method hasPresentFileForSelectedEntries to check if at least one of the selected entries has linked files in ActionHelper.

@Siedlerchr
Copy link
Member

Idea for usabilty: As a user I expect to open the file using "open all files" also when I select one entry. So if I only select one entry => same beahviour as now

@tobiasdiez
Copy link
Member

tobiasdiez commented May 7, 2021

In line with @Siedlerchr comment above, what do you think about adding the functionality to the existing "open file" action? So if a user has only a single entry selected, then the linked file of this entry is opened; but if multiple files are selected, then all linked files are opened.

@XDZhelheim
Copy link
Contributor Author

XDZhelheim commented May 7, 2021

I agree. When one entry selected, if "open all files" has the same behavior as "open file" as @Siedlerchr suggested, which means the function of the new added option totally covers the original one, then why not merge them as one option, just as you proposed.

So should I delete OpenAllExternalFileAction class and add its function to OpenExternalFileAction?

@tobiasdiez
Copy link
Member

Yes, please!

…if there is any linked file present; modified CHANGELOG.md; added javadoc
@XDZhelheim
Copy link
Contributor Author

Done.

I will update detailed description later.

@XDZhelheim XDZhelheim marked this pull request as ready for review May 7, 2021 13:56
@XDZhelheim XDZhelheim changed the title (WIP) Fix for issue 6966: open all files of multiple entries Fix for issue 6966: open all files of multiple entries May 7, 2021
@XDZhelheim
Copy link
Contributor Author

XDZhelheim commented May 7, 2021

May I ask why these tests are failing?

All these failures have the exactly same error:

/home/runner/work/jabref/jabref/src/test/java/org/jabref/logic/integrity/EditionCheckerTest.java:59: error: cannot find symbol
        assertEquals(Optional.empty(), checker.checkValue(""));
                                       ^
  symbol:   variable checker
  location: class EditionCheckerTest
/home/runner/work/jabref/jabref/src/test/java/org/jabref/logic/integrity/EditionCheckerTest.java:64: error: cannot find symbol
        assertEquals(Optional.empty(), checker.checkValue(null));
                                       ^
  symbol:   variable checker
  location: class EditionCheckerTest
/home/runner/work/jabref/jabref/src/test/java/org/jabref/logic/integrity/EditionCheckerTest.java:69: error: cannot find symbol
        var editionChecker = new EditionChecker(bibtex, false);
                                                ^
  symbol:   variable bibtex
  location: class EditionCheckerTest
/home/runner/work/jabref/jabref/src/test/java/org/jabref/logic/integrity/EditionCheckerTest.java:75: error: cannot find symbol
        var editionChecker = new EditionChecker(bibtex, false);
                                                ^
  symbol:   variable bibtex
  location: class EditionCheckerTest

But I didn't change anything in EditionChecker.

Same as #7705 (comment).

@XDZhelheim
Copy link
Contributor Author

I noticed that the tests are fixed.

So, is there still anything more I need to change in my code?

@Siedlerchr
Copy link
Member

You need to push the commit after merging as well, because the tests are still failing

for (BibEntry entry:selectedEntries) {
if (entry.getFiles().isEmpty()) {
if (!asked) {
boolean continu = dialogService.showConfirmationDialogAndWait(Localization.lang("Missing file"),
Copy link
Member

Choose a reason for hiding this comment

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

I, personally, don't think it's necessary to present a dialog here to the user. To me it seems obvious that only the files will open from entries that have associated files
So just ignore them.

@Siedlerchr Siedlerchr added the status: changes required Pull requests that are not yet complete label May 10, 2021
@XDZhelheim
Copy link
Contributor Author

Done.

Removed dialog and resolved a conflict in CHANGELOG.md

files = entry.getFiles();

if ((entry.getFiles().size() > 0) && stateManager.getActiveDatabase().isPresent()) {
if (files.get(0).isOnlineLink()) {
Copy link
Member

@Siedlerchr Siedlerchr May 13, 2021

Choose a reason for hiding this comment

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

I would exclude online file links. Otherwise you will suddenly have 300 Tabs open in your browser f you select 300 entries and they have at least one link

Copy link
Member

Choose a reason for hiding this comment

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

What's the difference to selecting 300 entries that have pdf attached?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should we set a limit?
For example, if a user is trying to open 100 files, pop out a dialog to ask the user whether to continue or cancel.
But how to determine the limit.

Copy link
Member

Choose a reason for hiding this comment

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

Yep, that's a good idea. "You are about to open more than 10 files". Continue?
I would simply create a constant with 10. I think that's appropriate.

  • Continue / Cancel

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK.

return true;
}

Optional<Path> filename = FileHelper.find(
Copy link
Member

Choose a reason for hiding this comment

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

No need to check the filename for presence here, just later on try to open the file. Either it works or not.

LinkedFileViewModel linkedFileViewModel;

for (BibEntry entry:selectedEntries) {
if (!entry.getFiles().isEmpty()) {
Copy link
Member

Choose a reason for hiding this comment

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

An entry can have multiple files linked. I would suggest you open all

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.

some improvements necessary

@XDZhelheim
Copy link
Contributor Author

OK. I will fix it.

…inding; question: open a large number of files
@XDZhelheim
Copy link
Contributor Author

Two changes:

  1. open all linked files of an entry
  2. modify boolean binding

Under discussion: how to handle opening a large number of files?

@XDZhelheim
Copy link
Contributor Author

Yep, that's a good idea. "You are about to open more than 10 files". Continue?
I would simply create a constant with 10. I think that's appropriate.

  • Continue / Cancel

Done.

P.S. Online links are included.

Test video:

6966-5.mp4

Copy link
Member

@tobiasdiez tobiasdiez left a comment

Choose a reason for hiding this comment

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

Thanks, changle look good to me. Two smaller suggestions

@Siedlerchr Siedlerchr merged commit 84c8849 into JabRef:main May 13, 2021
@Siedlerchr Siedlerchr mentioned this pull request May 13, 2021
5 tasks
Siedlerchr added a commit that referenced this pull request May 15, 2021
* upstream/main: (71 commits)
  [Bot] Update CSL styles (#7735)
  Fix for issue 6966: open all files of multiple entries (#7709)
  Add simple unit tests (#7696)
  Add simple unit tests (#7543)
  Update check-outdated-dependencies.yml
  Added preset for new entry keybindings and reintroduced defaults (#7705)
  Select the entry which has smaller dictonary order when merge (#7708)
  Update CHANGELOG.md
  fix: make more fields, fomatters, ids and languages sorted by alphabetical order (#7717)
  Bump libreoffice from 7.1.2 to 7.1.3 (#7721)
  Bump unoloader from 7.1.2 to 7.1.3 (#7724)
  Bump org.beryx.jlink from 2.23.7 to 2.23.8 (#7723)
  Bump org.openjfx.javafxplugin from 0.0.9 to 0.0.10 (#7725)
  fix: make fields sorted by lexicographical order (#7711)
  Fix tests
  Refactoring existing unit tests (#7687)
  Refactoring and addition of unit tests (#7581)
  Refactor simple Unit Tests (#7571)
  Add simple unit tests (#7544)
  add and extend unit tests (#7685)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: changes required Pull requests that are not yet complete
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bulk Copy/Open files
3 participants