diff --git a/CHANGELOG.md b/CHANGELOG.md index f2119c71557..1067763a760 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,11 +11,19 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `# ## [Unreleased] ### Changed +- We changed the location of some fields in the entry editor (you might need to reset your preferences for these changes to come into effect) + - Journal/Year/Month in biblatex mode -> Deprecated (if filled) + - DOI/URL: General -> Optional + - Internal fields like ranking, read status and priority: Other -> General + - Moreover, empty deprecated fields are no longer shown +- Added server timezone parameter when connecting to a shared database. - We updated the dialog for setting up general fields. - URL field formatting is updated. All whitespace chars, located at the beginning/ending of the url, are trimmed automatically - We changed the behavior of the field formatting dialog such that the `bibtexkey` is not changed when formatting all fields or all text fields. - We added a "Move file to file directory and rename file" option for simultaneously moving and renaming of document file. [#4166](https://github.com/JabRef/jabref/issues/4166) - Use integrated graphics card instead of discrete on macOS [#4070](https://github.com/JabRef/jabref/issues/4070) +- We added a cleanup operation that detects an arXiv identifier in the note, journal or url field and moves it to the `eprint` field. + Because of this change, the last-used cleanup operations were reset. - We changed the minimum required version of Java to 1.8.0_171, as this is the latest release for which the automatic Java update works. [4093](https://github.com/JabRef/jabref/issues/4093) - The special fields like `Printed` and `Read status` now show gray icons when the row is hovered. - We added a button in the tab header which allows you to close the database with one click. https://github.com/JabRef/jabref/issues/494 @@ -28,6 +36,8 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `# - We changed the default keyboard shortcuts for moving between entries when the entry editor is active to ̀alt + up/down. - Opening a new file now prompts the directory of the currently selected file, instead of the directory of the last opened file. - Window state is saved on close and restored on start. +- We made the MathSciNet fetcher more reliable. +- We added the ISBN fetcher to the list of fetcher available under "Update with bibliographic information from the web" in the entry editor toolbar. - Files without a defined external file type are now directly opened with the default application of the operating system - We streamlined the process to rename and move files by removing the confirmation dialogs. - We removed the redundant new lines of markings and wrapped the summary in the File annotation tab. [#3823](https://github.com/JabRef/jabref/issues/3823) @@ -76,7 +86,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `# - We fixed an issue where the list of XMP Exclusion fields in the preferences was not be saved [#4072](https://github.com/JabRef/jabref/issues/4072) - We fixed an issue where the ArXiv Fetcher did not support HTTP URLs [koppor#328](https://github.com/koppor/jabref/issues/328) - We fixed an issue where only one PDF file could be imported [#4422](https://github.com/JabRef/jabref/issues/4422) - +- We fixed an issue where "Move to group" would always move the first entry in the library and not the selected [#4414](https://github.com/JabRef/jabref/issues/4414) diff --git a/README.md b/README.md index 98b6397a8cc..cec54b33f74 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,6 @@ [![Build Status](https://travis-ci.org/JabRef/jabref.svg?branch=master)](https://travis-ci.org/JabRef/jabref) [![codecov.io](https://codecov.io/github/JabRef/jabref/coverage.svg?branch=master)](https://codecov.io/github/JabRef/jabref?branch=master) -[![Dependabot Status](https://api.dependabot.com/badges/status?host=github&repo=JabRef/jabref)](https://dependabot.com) [![Donation](https://img.shields.io/badge/donate%20to-jabref-orange.svg)](https://donations.jabref.org) JabRef is an open-source, cross-platform citation and reference management tool licensed under the [MIT license](https://tldrlegal.com/license/mit-license). diff --git a/build.gradle b/build.gradle index 24665d8c2be..f364470d047 100644 --- a/build.gradle +++ b/build.gradle @@ -157,8 +157,8 @@ dependencies { errorproneJavac 'com.google.errorprone:javac:1.8.0-u20' - compile group: 'com.microsoft.azure', name: 'applicationinsights-core', version: '2.2.0' - compile group: 'com.microsoft.azure', name: 'applicationinsights-logging-log4j2', version: '2.2.0' + compile group: 'com.microsoft.azure', name: 'applicationinsights-core', version: '2.2.1' + compile group: 'com.microsoft.azure', name: 'applicationinsights-logging-log4j2', version: '2.2.1' testImplementation 'org.junit.jupiter:junit-jupiter-api:5.3.1' testCompile 'org.junit.jupiter:junit-jupiter-params:5.3.1' @@ -174,8 +174,8 @@ dependencies { testCompile 'org.reflections:reflections:0.9.11' testCompile 'org.xmlunit:xmlunit-core:2.6.2' testCompile 'org.xmlunit:xmlunit-matchers:2.6.2' - testCompile 'com.tngtech.archunit:archunit-junit5-api:0.9.1' - testRuntime 'com.tngtech.archunit:archunit-junit5-engine:0.9.1' + testCompile 'com.tngtech.archunit:archunit-junit5-api:0.9.2' + testRuntime 'com.tngtech.archunit:archunit-junit5-engine:0.9.2' testCompile "org.testfx:testfx-core:4.0.+" testCompile "org.testfx:testfx-junit5:4.0.+" diff --git a/src/main/java/org/jabref/gui/actions/CleanupAction.java b/src/main/java/org/jabref/gui/actions/CleanupAction.java index a4814735c8d..648af8313b7 100644 --- a/src/main/java/org/jabref/gui/actions/CleanupAction.java +++ b/src/main/java/org/jabref/gui/actions/CleanupAction.java @@ -10,7 +10,6 @@ import org.jabref.gui.undo.NamedCompound; import org.jabref.gui.undo.UndoableFieldChange; import org.jabref.gui.util.BackgroundTask; -import org.jabref.gui.util.DefaultTaskExecutor; import org.jabref.logic.cleanup.CleanupPreset; import org.jabref.logic.cleanup.CleanupWorker; import org.jabref.logic.l10n.Localization; @@ -23,11 +22,6 @@ public class CleanupAction implements BaseAction { private final BasePanel panel; private final DialogService dialogService; - /** - * Global variable to count unsuccessful renames - */ - private int unsuccessfulRenames; - private boolean isCanceled; private int modifiedEntriesCount; private final JabRefPreferences preferences; @@ -44,13 +38,31 @@ public void action() { if (isCanceled) { return; } - CleanupDialog cleanupDialog = new CleanupDialog(panel.getBibDatabaseContext(), preferences.getCleanupPreset()); + CleanupDialog cleanupDialog = new CleanupDialog(panel.getBibDatabaseContext(), preferences.getCleanupPreset(), preferences.getFilePreferences()); Optional chosenPreset = cleanupDialog.showAndWait(); - chosenPreset.ifPresent(cleanupPreset -> - BackgroundTask.wrap(() -> cleanup(cleanupPreset)) - .onSuccess(x -> showResults()) - .executeWith(Globals.TASK_EXECUTOR)); + + if (chosenPreset.isPresent()) { + if (chosenPreset.get().isRenamePDFActive() && preferences.getBoolean(JabRefPreferences.ASK_AUTO_NAMING_PDFS_AGAIN)) { + boolean confirmed = dialogService.showConfirmationDialogWithOptOutAndWait(Localization.lang("Autogenerate PDF Names"), + Localization.lang("Auto-generating PDF-Names does not support undo. Continue?"), + Localization.lang("Autogenerate PDF Names"), + Localization.lang("Cancel"), + Localization.lang("Disable this confirmation dialog"), + optOut -> Globals.prefs.putBoolean(JabRefPreferences.ASK_AUTO_NAMING_PDFS_AGAIN, !optOut)); + + if (!confirmed) { + isCanceled = true; + return; + } + } + + preferences.setCleanupPreset(chosenPreset.get()); + + BackgroundTask.wrap(() -> cleanup(chosenPreset.get())) + .onSuccess(result -> showResults()) + .executeWith(Globals.TASK_EXECUTOR); + } } public void init() { @@ -111,21 +123,6 @@ private void showResults() { private void cleanup(CleanupPreset cleanupPreset) { preferences.setCleanupPreset(cleanupPreset); - if (cleanupPreset.isRenamePDF() && preferences.getBoolean(JabRefPreferences.ASK_AUTO_NAMING_PDFS_AGAIN)) { - - boolean confirmed = DefaultTaskExecutor.runInJavaFXThread(() -> dialogService.showConfirmationDialogWithOptOutAndWait(Localization.lang("Autogenerate PDF Names"), - Localization.lang("Auto-generating PDF-Names does not support undo. Continue?"), - Localization.lang("Autogenerate PDF Names"), - Localization.lang("Cancel"), - Localization.lang("Disable this confirmation dialog"), - optOut -> Globals.prefs.putBoolean(JabRefPreferences.ASK_AUTO_NAMING_PDFS_AGAIN, !optOut))); - - if (!confirmed) { - isCanceled = true; - return; - } - } - for (BibEntry entry : panel.getSelectedEntries()) { // undo granularity is on entry level NamedCompound ce = new NamedCompound(Localization.lang("Cleanup entry")); diff --git a/src/main/java/org/jabref/gui/cleanup/CleanupDialog.java b/src/main/java/org/jabref/gui/cleanup/CleanupDialog.java index 4e672761366..83d9e810b05 100644 --- a/src/main/java/org/jabref/gui/cleanup/CleanupDialog.java +++ b/src/main/java/org/jabref/gui/cleanup/CleanupDialog.java @@ -6,15 +6,16 @@ import org.jabref.logic.cleanup.CleanupPreset; import org.jabref.logic.l10n.Localization; import org.jabref.model.database.BibDatabaseContext; +import org.jabref.model.metadata.FilePreferences; public class CleanupDialog extends BaseDialog { - public CleanupDialog(BibDatabaseContext databaseContext, CleanupPreset initialPreset) { + public CleanupDialog(BibDatabaseContext databaseContext, CleanupPreset initialPreset, FilePreferences filePreferences) { setTitle(Localization.lang("Cleanup entries")); getDialogPane().setPrefSize(600, 600); getDialogPane().getButtonTypes().setAll(ButtonType.OK, ButtonType.CANCEL); - CleanupPresetPanel presetPanel = new CleanupPresetPanel(databaseContext, initialPreset); + CleanupPresetPanel presetPanel = new CleanupPresetPanel(databaseContext, initialPreset, filePreferences); getDialogPane().setContent(presetPanel); setResultConverter(button -> { if (button == ButtonType.OK) { diff --git a/src/main/java/org/jabref/gui/cleanup/CleanupPresetPanel.fxml b/src/main/java/org/jabref/gui/cleanup/CleanupPresetPanel.fxml new file mode 100644 index 00000000000..1ca9d6ebafa --- /dev/null +++ b/src/main/java/org/jabref/gui/cleanup/CleanupPresetPanel.fxml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/org/jabref/gui/cleanup/CleanupPresetPanel.java b/src/main/java/org/jabref/gui/cleanup/CleanupPresetPanel.java index 4bd64ec1f62..9149ef4a5f0 100644 --- a/src/main/java/org/jabref/gui/cleanup/CleanupPresetPanel.java +++ b/src/main/java/org/jabref/gui/cleanup/CleanupPresetPanel.java @@ -6,124 +6,103 @@ import java.util.Optional; import java.util.Set; -import javafx.scene.Group; +import javafx.fxml.FXML; import javafx.scene.control.CheckBox; import javafx.scene.control.Label; -import javafx.scene.control.ScrollPane; -import javafx.scene.layout.GridPane; +import javafx.scene.layout.VBox; -import org.jabref.Globals; import org.jabref.logic.cleanup.CleanupPreset; import org.jabref.logic.cleanup.Cleanups; import org.jabref.logic.l10n.Localization; import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.entry.FieldName; -import org.jabref.preferences.JabRefPreferences; +import org.jabref.model.metadata.FilePreferences; -public class CleanupPresetPanel extends ScrollPane { +import com.airhacks.afterburner.views.ViewLoader; + +public class CleanupPresetPanel extends VBox { private final BibDatabaseContext databaseContext; - private CheckBox cleanUpDOI; - private CheckBox cleanUpISSN; - private CheckBox cleanUpMovePDF; - private CheckBox cleanUpMakePathsRelative; - private CheckBox cleanUpRenamePDF; - private CheckBox cleanUpRenamePDFonlyRelativePaths; - private CheckBox cleanUpUpgradeExternalLinks; - private CheckBox cleanUpBiblatex; - private CheckBox cleanUpBibtex; + @FXML private Label cleanupRenamePDFLabel; + @FXML private CheckBox cleanUpDOI; + @FXML private CheckBox cleanUpEprint; + @FXML private CheckBox cleanUpISSN; + @FXML private CheckBox cleanUpMovePDF; + @FXML private CheckBox cleanUpMakePathsRelative; + @FXML private CheckBox cleanUpRenamePDF; + @FXML private CheckBox cleanUpRenamePDFonlyRelativePaths; + @FXML private CheckBox cleanUpUpgradeExternalLinks; + @FXML private CheckBox cleanUpBiblatex; + @FXML private CheckBox cleanUpBibtex; + @FXML private VBox formatterContainer; private FieldFormatterCleanupsPanel cleanUpFormatters; - private CleanupPreset cleanupPreset; - - public CleanupPresetPanel(BibDatabaseContext databaseContext, CleanupPreset cleanupPreset) { - this.cleanupPreset = Objects.requireNonNull(cleanupPreset); + public CleanupPresetPanel(BibDatabaseContext databaseContext, CleanupPreset cleanupPreset, FilePreferences filePreferences) { this.databaseContext = Objects.requireNonNull(databaseContext); - init(); + + // Load FXML + ViewLoader.view(this) + .root(this) + .load(); + + init(cleanupPreset, filePreferences); } - private void init() { - cleanUpDOI = new CheckBox( - Localization.lang("Move DOIs from note and URL field to DOI field and remove http prefix")); - cleanUpISSN = new CheckBox(Localization.lang("Reformat ISSN")); - Optional firstExistingDir = databaseContext - .getFirstExistingFileDir(JabRefPreferences.getInstance().getFilePreferences()); + private void init(CleanupPreset cleanupPreset, FilePreferences filePreferences) { + Optional firstExistingDir = databaseContext.getFirstExistingFileDir(filePreferences); if (firstExistingDir.isPresent()) { - cleanUpMovePDF = new CheckBox(Localization.lang("Move linked files to default file directory %0", - firstExistingDir.get().toString())); + cleanUpMovePDF.setText(Localization.lang("Move linked files to default file directory %0", firstExistingDir.get().toString())); } else { - cleanUpMovePDF = new CheckBox(Localization.lang("Move linked files to default file directory %0", "...")); - cleanUpMovePDF.setDisable(true); + cleanUpMovePDF.setText(Localization.lang("Move linked files to default file directory %0", "...")); + // Since the directory does not exist, we cannot move it to there. So, this option is not checked - regardless of the presets stored in the preferences. + cleanUpMovePDF.setDisable(true); cleanUpMovePDF.setSelected(false); } - cleanUpMakePathsRelative = new CheckBox( - Localization.lang("Make paths of linked files relative (if possible)")); - cleanUpRenamePDF = new CheckBox(Localization.lang("Rename PDFs to given filename format pattern")); - cleanUpRenamePDF.selectedProperty().addListener( - event -> cleanUpRenamePDFonlyRelativePaths.setDisable(!cleanUpRenamePDF.isSelected())); - cleanUpRenamePDFonlyRelativePaths = new CheckBox(Localization.lang("Rename only PDFs having a relative path")); - cleanUpUpgradeExternalLinks = new CheckBox( - Localization.lang("Upgrade external PDF/PS links to use the '%0' field.", FieldName.FILE)); - cleanUpBiblatex = new CheckBox(Localization.lang( - "Convert to biblatex format (for example, move the value of the 'journal' field to 'journaltitle')")); - cleanUpBibtex = new CheckBox(Localization.lang( - "Convert to BibTeX format (for example, move the value of the 'journaltitle' field to 'journal')")); - Group biblatexConversion = new Group(); // Only make "to Biblatex" or "to BibTeX" selectable - biblatexConversion.getChildren().add(cleanUpBiblatex); - biblatexConversion.getChildren().add(cleanUpBibtex); - - cleanUpFormatters = new FieldFormatterCleanupsPanel(Localization.lang("Run field formatter:"), - Cleanups.DEFAULT_SAVE_ACTIONS); - updateDisplay(cleanupPreset); + cleanUpRenamePDFonlyRelativePaths.disableProperty().bind(cleanUpRenamePDF.selectedProperty().not()); - GridPane container = new GridPane(); - container.add(cleanUpDOI, 0, 0); - container.add(cleanUpUpgradeExternalLinks, 0, 1); - container.add(cleanUpMovePDF, 0, 2); - container.add(cleanUpMakePathsRelative, 0, 3); - container.add(cleanUpRenamePDF, 0, 4); - String currentPattern = Localization.lang("Filename format pattern").concat(": "); - currentPattern = currentPattern.concat(Globals.prefs.get(JabRefPreferences.IMPORT_FILENAMEPATTERN)); - container.add(new Label(currentPattern), 0, 5); - container.add(cleanUpRenamePDFonlyRelativePaths, 0, 6); - container.add(cleanUpBibtex, 0, 7); - container.add(cleanUpBiblatex, 0, 8); - container.add(cleanUpISSN, 0, 9); - container.add(cleanUpFormatters, 0, 10); - - setContent(container); - setVbarPolicy(ScrollBarPolicy.AS_NEEDED); + cleanUpUpgradeExternalLinks.setText(Localization.lang("Upgrade external PDF/PS links to use the '%0' field.", FieldName.FILE)); + + cleanUpFormatters = new FieldFormatterCleanupsPanel(Localization.lang("Run field formatter:"), Cleanups.DEFAULT_SAVE_ACTIONS); + formatterContainer.getChildren().setAll(cleanUpFormatters); + + String currentPattern = Localization.lang("Filename format pattern") + .concat(": ") + .concat(filePreferences.getFileNamePattern()); + cleanupRenamePDFLabel.setText(currentPattern); + + updateDisplay(cleanupPreset); } private void updateDisplay(CleanupPreset preset) { - cleanUpDOI.setSelected(preset.isCleanUpDOI()); + cleanUpDOI.setSelected(preset.isActive(CleanupPreset.CleanupStep.CLEAN_UP_DOI)); + cleanUpEprint.setSelected(preset.isActive(CleanupPreset.CleanupStep.CLEANUP_EPRINT)); if (!cleanUpMovePDF.isDisabled()) { - cleanUpMovePDF.setSelected(preset.isMovePDF()); + cleanUpMovePDF.setSelected(preset.isActive(CleanupPreset.CleanupStep.MOVE_PDF)); } - cleanUpMakePathsRelative.setSelected(preset.isMakePathsRelative()); - cleanUpRenamePDF.setSelected(preset.isRenamePDF()); - cleanUpRenamePDFonlyRelativePaths.setSelected(preset.isRenamePdfOnlyRelativePaths()); - cleanUpRenamePDFonlyRelativePaths.setDisable(!cleanUpRenamePDF.isSelected()); - cleanUpUpgradeExternalLinks.setSelected(preset.isCleanUpUpgradeExternalLinks()); - cleanUpBiblatex.setSelected(preset.isConvertToBiblatex()); - cleanUpBibtex.setSelected(preset.isConvertToBibtex()); - cleanUpISSN.setSelected(preset.isCleanUpISSN()); + cleanUpMakePathsRelative.setSelected(preset.isActive(CleanupPreset.CleanupStep.MAKE_PATHS_RELATIVE)); + cleanUpRenamePDF.setSelected(preset.isRenamePDFActive()); + cleanUpRenamePDFonlyRelativePaths.setSelected(preset.isActive(CleanupPreset.CleanupStep.RENAME_PDF_ONLY_RELATIVE_PATHS)); + cleanUpUpgradeExternalLinks.setSelected(preset.isActive(CleanupPreset.CleanupStep.CLEAN_UP_UPGRADE_EXTERNAL_LINKS)); + cleanUpBiblatex.setSelected(preset.isActive(CleanupPreset.CleanupStep.CONVERT_TO_BIBLATEX)); + cleanUpBibtex.setSelected(preset.isActive(CleanupPreset.CleanupStep.CONVERT_TO_BIBTEX)); + cleanUpISSN.setSelected(preset.isActive(CleanupPreset.CleanupStep.CLEAN_UP_ISSN)); cleanUpFormatters.setValues(preset.getFormatterCleanups()); } public CleanupPreset getCleanupPreset() { - Set activeJobs = EnumSet.noneOf(CleanupPreset.CleanupStep.class); if (cleanUpMovePDF.isSelected()) { activeJobs.add(CleanupPreset.CleanupStep.MOVE_PDF); } - if (cleanUpDOI.isSelected()) { activeJobs.add(CleanupPreset.CleanupStep.CLEAN_UP_DOI); } + if (cleanUpEprint.isSelected()) { + activeJobs.add(CleanupPreset.CleanupStep.CLEANUP_EPRINT); + } if (cleanUpISSN.isSelected()) { activeJobs.add(CleanupPreset.CleanupStep.CLEAN_UP_ISSN); } @@ -149,7 +128,6 @@ public CleanupPreset getCleanupPreset() { activeJobs.add(CleanupPreset.CleanupStep.FIX_FILE_LINKS); - cleanupPreset = new CleanupPreset(activeJobs, cleanUpFormatters.getFormatterCleanups()); - return cleanupPreset; + return new CleanupPreset(activeJobs, cleanUpFormatters.getFormatterCleanups()); } } diff --git a/src/main/java/org/jabref/gui/cleanup/FieldFormatterCleanupsPanel.java b/src/main/java/org/jabref/gui/cleanup/FieldFormatterCleanupsPanel.java index b2aaec4108c..ab544366e0d 100644 --- a/src/main/java/org/jabref/gui/cleanup/FieldFormatterCleanupsPanel.java +++ b/src/main/java/org/jabref/gui/cleanup/FieldFormatterCleanupsPanel.java @@ -103,7 +103,7 @@ private void buildLayout() { actionsList = new ListView<>(actions); actionsList.getSelectionModel().setSelectionMode(SelectionMode.SINGLE); new ViewModelListCellFactory() - .withText(action -> action.getFormatter().getName()) + .withText(action -> action.getField() + ": " + action.getFormatter().getName()) .withTooltip(action -> action.getFormatter().getDescription()) .install(actionsList); add(actionsList, 1, 1, 3, 1); diff --git a/src/main/java/org/jabref/gui/entryeditor/DeprecatedFieldsTab.java b/src/main/java/org/jabref/gui/entryeditor/DeprecatedFieldsTab.java index 3b3c1c66438..2e372e7a42c 100644 --- a/src/main/java/org/jabref/gui/entryeditor/DeprecatedFieldsTab.java +++ b/src/main/java/org/jabref/gui/entryeditor/DeprecatedFieldsTab.java @@ -1,6 +1,7 @@ package org.jabref.gui.entryeditor; import java.util.Collection; +import java.util.stream.Collectors; import javax.swing.undo.UndoManager; @@ -25,6 +26,9 @@ public DeprecatedFieldsTab(BibDatabaseContext databaseContext, SuggestionProvide @Override protected Collection determineFieldsToShow(BibEntry entry, EntryType entryType) { - return entryType.getDeprecatedFields(); + return entryType.getDeprecatedFields() + .stream() + .filter(entry::hasField) + .collect(Collectors.toList()); } } diff --git a/src/main/java/org/jabref/gui/exporter/SaveDatabaseAction.java b/src/main/java/org/jabref/gui/exporter/SaveDatabaseAction.java index 60d43a613cb..ecd1d7e6a2f 100644 --- a/src/main/java/org/jabref/gui/exporter/SaveDatabaseAction.java +++ b/src/main/java/org/jabref/gui/exporter/SaveDatabaseAction.java @@ -163,7 +163,14 @@ public boolean save() { panel.frame().output(Localization.lang("Saving library") + "..."); panel.setSaving(true); return doSave(); + } else { + Optional savePath = getSavePath(); + if (savePath.isPresent()) { + saveAs(savePath.get()); + return true; + } } + return false; } diff --git a/src/main/java/org/jabref/gui/groups/GroupAddRemoveDialog.java b/src/main/java/org/jabref/gui/groups/GroupAddRemoveDialog.java index 9cfc6d32bef..870af219e7b 100644 --- a/src/main/java/org/jabref/gui/groups/GroupAddRemoveDialog.java +++ b/src/main/java/org/jabref/gui/groups/GroupAddRemoveDialog.java @@ -4,6 +4,7 @@ import java.awt.Color; import java.awt.Component; import java.awt.event.ActionEvent; +import java.util.ArrayList; import java.util.List; import java.util.Optional; @@ -57,9 +58,9 @@ public void action() throws Exception { selection = panel.getSelectedEntries(); final JDialog diag = new JDialog((JFrame) null, - (add ? (move ? Localization.lang("Move to group") : Localization.lang("Add to group")) : Localization - .lang("Remove from group")), - true); + (add ? (move ? Localization.lang("Move to group") : Localization.lang("Add to group")) : Localization + .lang("Remove from group")), + true); JButton ok = new JButton(Localization.lang("OK")); JButton cancel = new JButton(Localization.lang("Cancel")); tree = new JTree(new GroupTreeNodeViewModel(groups.get())); @@ -166,7 +167,9 @@ private boolean doAddOrRemove() { GroupTreeNodeViewModel node = (GroupTreeNodeViewModel) path.getLastPathComponent(); if (checkGroupEnable(node)) { - List entries = Globals.stateManager.getSelectedEntries(); + //we need to copy the contents of the observable list here, because when removeFromEntries is called, + //probably the focus changes to the first entry in the all entries group and thus getSelectedEntries() no longer contains our entry we want to move + List entries = new ArrayList<>(Globals.stateManager.getSelectedEntries()); if (move) { recuriveRemoveFromNode((GroupTreeNodeViewModel) tree.getModel().getRoot(), entries); @@ -175,7 +178,7 @@ private boolean doAddOrRemove() { if (add) { node.addEntriesToGroup(entries); } else { - node.removeEntriesFromGroup(Globals.stateManager.getSelectedEntries()); + node.removeEntriesFromGroup(entries); } return true; @@ -187,7 +190,7 @@ private boolean doAddOrRemove() { private void recuriveRemoveFromNode(GroupTreeNodeViewModel node, List entries) { node.removeEntriesFromGroup(entries); - for (GroupTreeNodeViewModel child: node.getChildren()) { + for (GroupTreeNodeViewModel child : node.getChildren()) { recuriveRemoveFromNode(child, entries); } } @@ -207,7 +210,7 @@ class AddRemoveGroupTreeCellRenderer extends GroupTreeCellRenderer { @Override public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, - boolean leaf, int row, boolean hasFocus) { + boolean leaf, int row, boolean hasFocus) { Component c = super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus); GroupTreeNodeViewModel node = (GroupTreeNodeViewModel) value; diff --git a/src/main/java/org/jabref/gui/groups/GroupModeViewModel.java b/src/main/java/org/jabref/gui/groups/GroupModeViewModel.java index d88565f82ba..022941a97d5 100644 --- a/src/main/java/org/jabref/gui/groups/GroupModeViewModel.java +++ b/src/main/java/org/jabref/gui/groups/GroupModeViewModel.java @@ -8,7 +8,7 @@ public class GroupModeViewModel { - private GroupViewMode mode; + private final GroupViewMode mode; public GroupModeViewModel(GroupViewMode mode) { this.mode = mode; @@ -27,9 +27,9 @@ public Node getUnionIntersectionGraphic() { public Tooltip getUnionIntersectionTooltip() { if (mode == GroupViewMode.UNION) { - return new Tooltip(Localization.lang("Toogle intersection")); + return new Tooltip(Localization.lang("Toggle intersection")); } else if (mode == GroupViewMode.INTERSECTION) { - return new Tooltip(Localization.lang("Toogle union")); + return new Tooltip(Localization.lang("Toggle union")); } return new Tooltip(); } diff --git a/src/main/java/org/jabref/gui/preferences/GeneralTab.java b/src/main/java/org/jabref/gui/preferences/GeneralTab.java index 2cb74aca865..d2c27c1a97c 100644 --- a/src/main/java/org/jabref/gui/preferences/GeneralTab.java +++ b/src/main/java/org/jabref/gui/preferences/GeneralTab.java @@ -26,6 +26,8 @@ import org.jabref.model.entry.InternalBibtexFields; import org.jabref.preferences.JabRefPreferences; +import static javafx.beans.binding.Bindings.not; + class GeneralTab extends Pane implements PrefsTab { private final CheckBox useOwner; @@ -59,10 +61,7 @@ public GeneralTab(DialogService dialogService, JabRefPreferences prefs) { updateTimeStamp = new CheckBox(Localization.lang("Update timestamp on modification")); useTimeStamp = new CheckBox(Localization.lang("Mark new entries with addition date") + ". " + Localization.lang("Date format") + ':'); - if (!useTimeStamp.isSelected()) { - updateTimeStamp.setDisable(true); - } - useTimeStamp.setOnAction(e->updateTimeStamp.setDisable(!useTimeStamp.isSelected())); + updateTimeStamp.disableProperty().bind(not(useTimeStamp.selectedProperty())); overwriteOwner = new CheckBox(Localization.lang("Overwrite")); overwriteTimeStamp = new CheckBox(Localization.lang("If a pasted or imported entry already has the field set, overwrite.")); enforceLegalKeys = new CheckBox(Localization.lang("Enforce legal characters in BibTeX keys")); @@ -140,7 +139,6 @@ public void setValues() { useTimeStamp.setSelected(prefs.getBoolean(JabRefPreferences.USE_TIME_STAMP)); overwriteTimeStamp.setSelected(prefs.getBoolean(JabRefPreferences.OVERWRITE_TIME_STAMP)); updateTimeStamp.setSelected(prefs.getBoolean(JabRefPreferences.UPDATE_TIMESTAMP)); - updateTimeStamp.setSelected(useTimeStamp.isSelected()); enforceLegalKeys.setSelected(prefs.getBoolean(JabRefPreferences.ENFORCE_LEGAL_BIBTEX_KEY)); shouldCollectTelemetry.setSelected(prefs.shouldCollectTelemetry()); memoryStick.setSelected(prefs.getBoolean(JabRefPreferences.MEMORY_STICK_MODE)); @@ -182,9 +180,9 @@ public void storeSettings() { // Update name of the time stamp field based on preferences InternalBibtexFields.updateTimeStampField(prefs.get(JabRefPreferences.TIME_STAMP_FIELD)); prefs.setDefaultEncoding(encodings.getValue()); - prefs.putBoolean(JabRefPreferences.BIBLATEX_DEFAULT_MODE, biblatexMode.getValue().equals(BibDatabaseMode.BIBLATEX)); + prefs.putBoolean(JabRefPreferences.BIBLATEX_DEFAULT_MODE, biblatexMode.getValue() == BibDatabaseMode.BIBLATEX); - if (!languageSelection.getValue().equals(prefs.getLanguage())) { + if (languageSelection.getValue() != prefs.getLanguage()) { prefs.setLanguage(languageSelection.getValue()); Localization.setLanguage(languageSelection.getValue()); diff --git a/src/main/java/org/jabref/gui/shared/SharedDatabaseLoginDialog.fxml b/src/main/java/org/jabref/gui/shared/SharedDatabaseLoginDialog.fxml index c8c3d49729c..30808026c50 100644 --- a/src/main/java/org/jabref/gui/shared/SharedDatabaseLoginDialog.fxml +++ b/src/main/java/org/jabref/gui/shared/SharedDatabaseLoginDialog.fxml @@ -52,6 +52,8 @@