Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into jabrefonline
Browse files Browse the repository at this point in the history
* upstream/main:
  Added auto-key-generation task to task-progress (JabRef#7797)
  cleanup temporary files, use prefix "jabref-" (JabRef#7811)
  Add easier how-to for checklist (JabRef#7813)
  Fix annotation + package of ACMPortalParserTest (JabRef#7812)
  Implemented a select all button for the library import function (issue JabRef#7786) (JabRef#7808)
  Fix for issue 4682 : Restructuring the side pane structure having additional functionality and merging the remove group menus (JabRef#7714)
  • Loading branch information
Siedlerchr committed Jun 11, 2021
2 parents 6388a41 + 475b298 commit d5d4ed6
Show file tree
Hide file tree
Showing 19 changed files with 208 additions and 88 deletions.
14 changes: 7 additions & 7 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ The title of the PR must not reference an issue, because GitHub does not support


<!--
- Go through the list below. If a task has been completed, mark it done by using `[x]`.
- Please don't remove any items, just leave them unchecked if they are not applicable.
- Go through the list below. Please don't remove any items.
- [x] done; [ ] not done / not applicable
-->

- [ ] 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](https://docs.jabref.org/): 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.
- [] 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](https://docs.jabref.org/): 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.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,12 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
- We added two new fields to track the creation and most recent modification date and time for each entry. [koppor#130](https://github.com/koppor/jabref/issues/130)
- We added a feature that allows the user to copy highlighted text in the preview window. [#6962](https://github.com/JabRef/jabref/issues/6962)
- We added a feature that allows you to create new BibEntry via paste arxivId [#2292](https://github.com/JabRef/jabref/issues/2292)
- We added a add group functionality at the bottom of the side pane. [#4682](https://github.com/JabRef/jabref/issues/4682)
- We added a feature that allows the user to choose whether to trust the target site when unable to find a valid certification path from the file download site. [#7616](https://github.com/JabRef/jabref/issues/7616)
- We added a feature that allows the user to open all linked files of multiple selected entries by "Open file" option. [#6966](https://github.com/JabRef/jabref/issues/6966)
- We added a keybinding preset for new entries. [#7705](https://github.com/JabRef/jabref/issues/7705)
- We added a select all button for the library import function. [#7786](https://github.com/JabRef/jabref/issues/7786)
- We added auto-key-generation progress to the background task list. [#7267](https://github.com/JabRef/jabref/issues/7267)

### Changed

Expand All @@ -38,6 +41,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
- We improved the linking of the `python3` interpreter via the shebang to dynamically use the systems default Python. Related to [JabRef-Browser-Extension #177](https://github.com/JabRef/JabRef-Browser-Extension/issues/177)
- Automatically found pdf files now have the linking button to the far left and uses a link icon with a plus instead of a briefcase. The file name also has lowered opacity(70%) until added. [#3607](https://github.com/JabRef/jabref/issues/3607)
- We simplified the select entry type form by splitting it into two parts ("Recommended" and "Others") based on internal usage data. [#6730](https://github.com/JabRef/jabref/issues/6730)
- We improved the submenu list by merging the'Remove group' having two options, with or without subgroups. [#4682](https://github.com/JabRef/jabref/issues/4682)
- The export to MS Office XML now uses the month name for the field `Month` instead of the two digit number [forum#2685](https://discourse.jabref.org/t/export-month-as-text-not-number/2685)
- We reintroduced missing default keybindings for new entries. [#7346](https://github.com/JabRef/jabref/issues/7346) [#7439](https://github.com/JabRef/jabref/issues/7439)
- Lists of available fields are now sorted alphabetically. [#7716](https://github.com/JabRef/jabref/issues/7716)
Expand Down Expand Up @@ -88,6 +92,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
- We fixed an issue where font size of the preferences dialog does not update with the rest of the GUI. [#7416](https://github.com/JabRef/jabref/issues/7416)
- We fixed an issue in which a linked online file consisting of a web page was saved as an invalid pdf file upon being downloaded. The user is now notified when downloading a linked file results in an HTML file. [#7452](https://github.com/JabRef/jabref/issues/7452)
- We fixed an issue where opening BibTex file (doubleclick) from Folder with spaces not working. [#6487](https://github.com/JabRef/jabref/issues/6487)
- We fixed the header title in the Add Group/Subgroup Dialog box. [#4682](https://github.com/JabRef/jabref/issues/4682)
- We fixed an issue with saving large `.bib` files [#7265](https://github.com/JabRef/jabref/issues/7265)
- We fixed an issue with very large page numbers [#7590](https://github.com/JabRef/jabref/issues/7590)
- We fixed an issue where the file extension is missing on saving the library file on linux [#7451](https://github.com/JabRef/jabref/issues/7451)
Expand All @@ -108,6 +113,8 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve

### Removed

- We removed add group button beside the filter group tab. [#4682](https://github.com/JabRef/jabref/issues/4682)

## [5.2] – 2020-12-24

### Added
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/jabref/gui/JabRefFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ private Node createToolbar() {

new HBox(
pushToApplicationButton,
factory.createIconButton(StandardActions.GENERATE_CITE_KEYS, new GenerateCitationKeyAction(this, dialogService, stateManager)),
factory.createIconButton(StandardActions.GENERATE_CITE_KEYS, new GenerateCitationKeyAction(this, dialogService, stateManager, taskExecutor, prefs)),
factory.createIconButton(StandardActions.CLEANUP_ENTRIES, new CleanupAction(this, prefs, dialogService, stateManager))
),

Expand Down Expand Up @@ -727,7 +727,7 @@ private MenuBar createMenu() {
new SeparatorMenuItem(),

factory.createMenuItem(StandardActions.REPLACE_ALL, new ReplaceStringAction(this, stateManager)),
factory.createMenuItem(StandardActions.GENERATE_CITE_KEYS, new GenerateCitationKeyAction(this, dialogService, stateManager)),
factory.createMenuItem(StandardActions.GENERATE_CITE_KEYS, new GenerateCitationKeyAction(this, dialogService, stateManager, taskExecutor, prefs)),

new SeparatorMenuItem(),

Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
package org.jabref.gui.citationkeypattern;

import java.util.List;
import java.util.function.Consumer;

import org.jabref.gui.DialogService;
import org.jabref.gui.Globals;
import org.jabref.gui.JabRefFrame;
import org.jabref.gui.StateManager;
import org.jabref.gui.actions.ActionHelper;
import org.jabref.gui.actions.SimpleCommand;
import org.jabref.gui.undo.NamedCompound;
import org.jabref.gui.undo.UndoableKeyChange;
import org.jabref.gui.util.BackgroundTask;
import org.jabref.gui.util.DefaultTaskExecutor;
import org.jabref.gui.util.TaskExecutor;
import org.jabref.logic.citationkeypattern.CitationKeyGenerator;
import org.jabref.logic.l10n.Localization;
import org.jabref.model.entry.BibEntry;
import org.jabref.preferences.PreferencesService;

public class GenerateCitationKeyAction extends SimpleCommand {

Expand All @@ -24,10 +27,15 @@ public class GenerateCitationKeyAction extends SimpleCommand {
private List<BibEntry> entries;
private boolean isCanceled;

public GenerateCitationKeyAction(JabRefFrame frame, DialogService dialogService, StateManager stateManager) {
private final TaskExecutor taskExecutor;
private final PreferencesService preferencesService;

public GenerateCitationKeyAction(JabRefFrame frame, DialogService dialogService, StateManager stateManager, TaskExecutor taskExecutor, PreferencesService preferencesService) {
this.frame = frame;
this.dialogService = dialogService;
this.stateManager = stateManager;
this.taskExecutor = taskExecutor;
this.preferencesService = preferencesService;

this.executable.bind(ActionHelper.needsEntriesSelected(stateManager));
}
Expand All @@ -45,20 +53,26 @@ public void execute() {

checkOverwriteKeysChosen();

BackgroundTask.wrap(this::generateKeys)
.executeWith(Globals.TASK_EXECUTOR);
if (!this.isCanceled) {
BackgroundTask backgroundTask = this.generateKeysInBackground();
backgroundTask.showToUser(true);
backgroundTask.titleProperty().set(Localization.lang("Autogenerate citation keys"));
backgroundTask.messageProperty().set(Localization.lang("%0/%1 entries", 0, entries.size()));

backgroundTask.executeWith(this.taskExecutor);
}
}

public static boolean confirmOverwriteKeys(DialogService dialogService) {
if (Globals.prefs.getCitationKeyPatternPreferences().shouldWarnBeforeOverwriteCiteKey()) {
public static boolean confirmOverwriteKeys(DialogService dialogService, PreferencesService preferencesService) {
if (preferencesService.getCitationKeyPatternPreferences().shouldWarnBeforeOverwriteCiteKey()) {
return dialogService.showConfirmationDialogWithOptOutAndWait(
Localization.lang("Overwrite keys"),
Localization.lang("One or more keys will be overwritten. Continue?"),
Localization.lang("Overwrite keys"),
Localization.lang("Cancel"),
Localization.lang("Do not ask again"),
optOut -> Globals.prefs.storeCitationKeyPatternPreferences(
Globals.prefs.getCitationKeyPatternPreferences().withWarnBeforeOverwriteCiteKey(!optOut)));
optOut -> preferencesService.storeCitationKeyPatternPreferences(
preferencesService.getCitationKeyPatternPreferences().withWarnBeforeOverwriteCiteKey(!optOut)));
} else {
// Always overwrite keys by default
return true;
Expand All @@ -67,11 +81,11 @@ public static boolean confirmOverwriteKeys(DialogService dialogService) {

private void checkOverwriteKeysChosen() {
// We don't want to generate keys for entries which already have one thus remove the entries
if (Globals.prefs.getCitationKeyPatternPreferences().shouldAvoidOverwriteCiteKey()) {
if (this.preferencesService.getCitationKeyPatternPreferences().shouldAvoidOverwriteCiteKey()) {
entries.removeIf(BibEntry::hasCitationKey);
// if we're going to override some citation keys warn the user about it
} else if (entries.parallelStream().anyMatch(BibEntry::hasCitationKey)) {
boolean overwriteKeys = confirmOverwriteKeys(dialogService);
boolean overwriteKeys = confirmOverwriteKeys(dialogService, this.preferencesService);

// The user doesn't want to override citation keys
if (!overwriteKeys) {
Expand All @@ -80,30 +94,54 @@ private void checkOverwriteKeysChosen() {
}
}

private void generateKeys() {
if (isCanceled) {
return;
}

stateManager.getActiveDatabase().ifPresent(databaseContext -> {
// generate the new citation keys for each entry
final NamedCompound compound = new NamedCompound(Localization.lang("Autogenerate citation keys"));
CitationKeyGenerator keyGenerator =
new CitationKeyGenerator(databaseContext, Globals.prefs.getCitationKeyPatternPreferences());
for (BibEntry entry : entries) {
keyGenerator.generateAndSetKey(entry)
.ifPresent(fieldChange -> compound.addEdit(new UndoableKeyChange(fieldChange)));
private BackgroundTask generateKeysInBackground() {
return new BackgroundTask<Void>() {

private NamedCompound compound;

@Override
protected Void call() {
if (isCanceled) {
return null;
}
DefaultTaskExecutor.runInJavaFXThread(() -> {
updateProgress(0, entries.size());
messageProperty().set(Localization.lang("%0/%1 entries", 0, entries.size()));
});
stateManager.getActiveDatabase().ifPresent(databaseContext -> {
// generate the new citation keys for each entry
compound = new NamedCompound(Localization.lang("Autogenerate citation keys"));
CitationKeyGenerator keyGenerator =
new CitationKeyGenerator(databaseContext, preferencesService.getCitationKeyPatternPreferences());
int entriesDone = 0;
for (BibEntry entry : entries) {
keyGenerator.generateAndSetKey(entry)
.ifPresent(fieldChange -> compound.addEdit(new UndoableKeyChange(fieldChange)));
entriesDone++;
int finalEntriesDone = entriesDone;
DefaultTaskExecutor.runInJavaFXThread(() -> {
updateProgress(finalEntriesDone, entries.size());
messageProperty().set(Localization.lang("%0/%1 entries", finalEntriesDone, entries.size()));
});
}
compound.end();
});
return null;
}
compound.end();

// register the undo event only if new citation keys were generated
if (compound.hasEdits()) {
frame.getUndoManager().addEdit(compound);
@Override
public BackgroundTask<Void> onSuccess(Consumer<Void> onSuccess) {
// register the undo event only if new citation keys were generated
if (compound.hasEdits()) {
frame.getUndoManager().addEdit(compound);
}

frame.getCurrentLibraryTab().markBaseChanged();
dialogService.notify(formatOutputMessage(Localization.lang("Generated citation key for"), entries.size()));
return super.onSuccess(onSuccess);
}
};

frame.getCurrentLibraryTab().markBaseChanged();
dialogService.notify(formatOutputMessage(Localization.lang("Generated citation key for"), entries.size()));
});
}

private String formatOutputMessage(String start, int count) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public GenerateCitationKeySingleAction(BibEntry entry, BibDatabaseContext databa

@Override
public void execute() {
if (!entry.hasCitationKey() || GenerateCitationKeyAction.confirmOverwriteKeys(dialogService)) {
if (!entry.hasCitationKey() || GenerateCitationKeyAction.confirmOverwriteKeys(dialogService, preferencesService)) {
new CitationKeyGenerator(databaseContext, preferencesService.getCitationKeyPatternPreferences())
.generateAndSetKey(entry)
.ifPresent(change -> undoManager.addEdit(new UndoableKeyChange(change)));
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/org/jabref/gui/groups/GroupDialogHeader.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package org.jabref.gui.groups;

public enum GroupDialogHeader {
GROUP, SUBGROUP
}
10 changes: 7 additions & 3 deletions src/main/java/org/jabref/gui/groups/GroupDialogView.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,19 @@ public class GroupDialogView extends BaseDialog<AbstractGroup> {
private final ControlsFxVisualizer validationVisualizer = new ControlsFxVisualizer();
private final GroupDialogViewModel viewModel;

public GroupDialogView(DialogService dialogService, BibDatabaseContext currentDatabase, PreferencesService preferencesService, AbstractGroup editedGroup) {
viewModel = new GroupDialogViewModel(dialogService, currentDatabase, preferencesService, editedGroup);
public GroupDialogView(DialogService dialogService, BibDatabaseContext currentDatabase, PreferencesService preferencesService, AbstractGroup editedGroup, GroupDialogHeader groupDialogHeader) {
viewModel = new GroupDialogViewModel(dialogService, currentDatabase, preferencesService, editedGroup, groupDialogHeader);

ViewLoader.view(this)
.load()
.setAsDialogPane(this);

if (editedGroup == null) {
this.setTitle(Localization.lang("Add subgroup"));
if (groupDialogHeader == GroupDialogHeader.GROUP) {
this.setTitle(Localization.lang("Add group"));
} else if (groupDialogHeader == GroupDialogHeader.SUBGROUP) {
this.setTitle(Localization.lang("Add subgroup"));
}
} else {
this.setTitle(Localization.lang("Edit group") + " " + editedGroup.getName());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,14 @@ public class GroupDialogViewModel {
private final PreferencesService preferencesService;
private final BibDatabaseContext currentDatabase;
private final AbstractGroup editedGroup;
private final GroupDialogHeader groupDialogHeader;

public GroupDialogViewModel(DialogService dialogService, BibDatabaseContext currentDatabase, PreferencesService preferencesService, AbstractGroup editedGroup) {
public GroupDialogViewModel(DialogService dialogService, BibDatabaseContext currentDatabase, PreferencesService preferencesService, AbstractGroup editedGroup, GroupDialogHeader groupDialogHeader) {
this.dialogService = dialogService;
this.preferencesService = preferencesService;
this.currentDatabase = currentDatabase;
this.editedGroup = editedGroup;
this.groupDialogHeader = groupDialogHeader;

setupValidation();
setValues();
Expand Down
18 changes: 16 additions & 2 deletions src/main/java/org/jabref/gui/groups/GroupTree.css
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,18 @@
-fx-translate-x: -0.4em;
}

#newGroupButton {
-fx-padding: 0.1em 1.5em 0.1em 1.5em;
#addNewGroup:active {
-fx-border-width: 0px;
-fx-background-color: -jr-theme;
-fx-padding: 0.5em;
-fx-text-fill: -jr-white;
}

#addNewGroup:inactive {
-fx-border-width: 0px;
-fx-background-color: -jr-icon-background-active;
-fx-padding: 0.5em;
-fx-text-fill:-jr-black;
}

#groupFilterBar {
Expand All @@ -116,3 +126,7 @@
#groupFilterBar .glyph-icon {
-fx-font-size: 2em;
}

#groupBar .glyph-icon {
-fx-font-size: 2em;
}
Loading

0 comments on commit d5d4ed6

Please sign in to comment.