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

Add "Do not ask again" for empty entry confirmation #8297

Closed
wants to merge 20 commits into from

Conversation

ruoyu-qian
Copy link
Contributor

@ruoyu-qian ruoyu-qian commented Dec 5, 2021

Fixes #8296, a follow-up from #8096 (comment)

  • 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, I created an issue at https://github.com/JabRef/user-documentation/issues or, even better, I submitted a pull request to the documentation repository.

@Siedlerchr Siedlerchr added the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Dec 5, 2021
Comment on lines 90 to 142
/**
* Get the preference of whether to give a confirmation dialog when empty entries are detected in the library
*
* @return true if the preference is set as yes
*/
public boolean shouldConfirmEmptyEntries() {
return confirmEmptyEntries.get();
}

/**
* Get the BooleanProperty of the preference of whether to give a confirmation dialog when empty entries are detected in the library
*
* @return BooleanProperty
*/
public BooleanProperty confirmEmptyEntriesProperty() {
return confirmEmptyEntries;
}

/**
* Set the preference of whether to give a confirmation dialog when empty entries are detected in the library
*
* @param confirmEmptyEntries boolean for the preference
*/
public void setConfirmEmptyEntries(boolean confirmEmptyEntries) {
this.confirmEmptyEntries.set(confirmEmptyEntries);
}

/**
* Get the preference of whether to delete the empty entries detected in the library if confirmation dialog is opted out
*
* @return true if the preference is set as yes (delete)
*/
public boolean shouldDeleteEmptyEntries() {
return deleteEmptyEntries.get();
}

/**
* Get the BooleanProperty of the preference of whether to delete the empty entries detected in the library if confirmation dialog is opted out
*
* @return BooleanProperty
*/
public BooleanProperty deleteEmptyEntriesProperty() {
return deleteEmptyEntries;
}

/**
* Set the preference of whether to delete the empty entries detected in the library if confirmation dialog is opted out
*
* @param deleteEmptyEntries boolean for the preference
*/
public void setDeleteEmptyEntries(boolean deleteEmptyEntries) {
this.deleteEmptyEntries.set(deleteEmptyEntries);
}
Copy link
Member

Choose a reason for hiding this comment

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

This javadoc is superfluous. Please comment on the the variable or the property, but not on every getter and setter

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry about this. I removed these comments. Let me know if you would like have any other changes.

@@ -1181,11 +1191,22 @@ private Boolean confirmEmptyEntry(LibraryTab libraryTab, BibDatabaseContext cont
ButtonType keepEmptyEntries = new ButtonType(Localization.lang("Keep empty entries"), ButtonBar.ButtonData.NO);
ButtonType cancel = new ButtonType(Localization.lang("Return to JabRef"), ButtonBar.ButtonData.CANCEL_CLOSE);

Optional<ButtonType> response = dialogService.showCustomButtonDialogAndWait(Alert.AlertType.CONFIRMATION,
Optional<ButtonType> response = dialogService.showCustomButtonDialogWithOptOutAndWait(Alert.AlertType.CONFIRMATION,
Copy link
Member

Choose a reason for hiding this comment

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

Why don't you use the showConfirmationDialogWithOptOutAndWait? The AlertType.CONFIRMATION is used there too.
This looks to me like unnecessary code duplication, or didn't I see anything?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The reason I added showCustomButtonDialogWithOptOutAndWait is because I would like to include the 'Return to JabRef' option as it has now. I believe showConfirmationDialogWithOptOutAndWait only allows for Yes/No choice, but not the third option.

@ThiloteE
Copy link
Member

Would this make it into stable 5.4?

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.

From my point of view it's good to go. Waiting for final approval from @calixtus

@Siedlerchr Siedlerchr added status: changes required Pull requests that are not yet complete and removed status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers labels Dec 19, 2021
Copy link
Member

@calixtus calixtus left a comment

Choose a reason for hiding this comment

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

Hi, I took a look into your PR again, there is still an issue with some code duplication.
Also I tested your PR manually and it did not work as expected.

  1. Create file with just @Article{, }
  2. Import as new library
  3. Close again
  4. Dialog shows up
  5. Select return to JabRef
  6. Close tab
  7. Tab wont close
  8. Select other tab
  9. Tab cannot be selected again

Please look into these issues.

Comment on lines +263 to +271
@Override
public Optional<ButtonType> showCustomButtonDialogWithOptOutAndWait(Alert.AlertType type, String title, String content,
String optOutMessage, Consumer<Boolean> optOutAction,
ButtonType... buttonTypes) {
FXDialog alert = createDialogWithOptOut(AlertType.CONFIRMATION, title, content, optOutMessage, optOutAction);
alert.getButtonTypes().setAll(buttonTypes);
return alert.showAndWait();
}

Copy link
Member

Choose a reason for hiding this comment

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

There still seems to be some code duplication with showConfirmationDialogWithOptOutAndWait, which is basically now a subset of this method here. Should call this instead.
Also the method argument type in the method signature, but is not used in the method.

Copy link
Member

@calixtus calixtus left a comment

Choose a reason for hiding this comment

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

.

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.

The tab gets blocked. Please investigate

@calixtus
Copy link
Member

calixtus commented Mar 29, 2022

Closing this pull request due to inactivity 💤
Please reopen this PR if you are going to fix the bugs if you like, we would love to see this feature finally implemented.

@ThiloteE
Copy link
Member

ThiloteE commented May 6, 2022

Another issue with the current implementation: #8645
Maybe 8645 could also be addressed, when finalizing this pull-request. Could of course also be done in a separate pull-request.

LIM0000 added a commit to LIM0000/jabref that referenced this pull request May 9, 2022
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.

Add "Do not ask again" for empty entry confirmation in JabRef
4 participants