diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e097a402317..27af59ebdea0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `# - The entry editor is now open by default when JabRef starts up. [#5460](https://github.com/JabRef/jabref/issues/5460) - We added a new ADS fetcher to use the new ADS API [#4949](https://github.com/JabRef/jabref/issues/4949) - We added support of the [X11 primary selection](https://unix.stackexchange.com/a/139193/18033) [#2389](https://github.com/JabRef/jabref/issues/2389) +- We added support to switch between biblatex and bibtex library types. [#5550](https://github.com/JabRef/jabref/issues/5550) ### Fixed diff --git a/src/main/java/org/jabref/gui/JabRefFrame.java b/src/main/java/org/jabref/gui/JabRefFrame.java index e5bb490340dc..71f05f986332 100644 --- a/src/main/java/org/jabref/gui/JabRefFrame.java +++ b/src/main/java/org/jabref/gui/JabRefFrame.java @@ -61,6 +61,7 @@ import org.jabref.gui.edit.ManageKeywordsAction; import org.jabref.gui.edit.MassSetFieldsAction; import org.jabref.gui.edit.OpenBrowserAction; +import org.jabref.gui.editmode.EditModeAction; import org.jabref.gui.exporter.ExportCommand; import org.jabref.gui.exporter.ExportToClipboardAction; import org.jabref.gui.exporter.ManageCustomExportsAction; @@ -737,7 +738,11 @@ private MenuBar createMenu() { factory.createMenuItem(StandardActions.EDIT_PREAMBLE, new PreambleEditor(stateManager, undoManager, this.getDialogService())), factory.createMenuItem(StandardActions.EDIT_STRINGS, new BibtexStringEditorAction(stateManager)), factory.createMenuItem(StandardActions.MANAGE_CITE_KEY_PATTERNS, new BibtexKeyPatternAction(this, stateManager)), - factory.createMenuItem(StandardActions.MASS_SET_FIELDS, new MassSetFieldsAction(stateManager, dialogService, undoManager)) + factory.createMenuItem(StandardActions.MASS_SET_FIELDS, new MassSetFieldsAction(stateManager, dialogService, undoManager)), + + new SeparatorMenuItem(), + + factory.createMenuItem(StandardActions.CHANGE_LIBRARY_TYPE, new EditModeAction(dialogService, stateManager)) ); Menu lookupIdentifiers = factory.createSubMenu(StandardActions.LOOKUP_DOC_IDENTIFIER); diff --git a/src/main/java/org/jabref/gui/actions/StandardActions.java b/src/main/java/org/jabref/gui/actions/StandardActions.java index 87f48f1b4a53..5b879662e45a 100644 --- a/src/main/java/org/jabref/gui/actions/StandardActions.java +++ b/src/main/java/org/jabref/gui/actions/StandardActions.java @@ -124,6 +124,7 @@ public enum StandardActions implements Action { LIBRARY_PROPERTIES(Localization.lang("Library properties")), EDIT_PREAMBLE(Localization.lang("Edit preamble")), EDIT_STRINGS(Localization.lang("Edit string constants"), IconTheme.JabRefIcons.EDIT_STRINGS, KeyBinding.EDIT_STRINGS), + CHANGE_LIBRARY_TYPE(Localization.lang("Change library type (biblatex/bibtex)")), FIND_DUPLICATES(Localization.lang("Find duplicates"), IconTheme.JabRefIcons.FIND_DUPLICATES), MERGE_ENTRIES(Localization.lang("Merge entries"), IconTheme.JabRefIcons.MERGE_ENTRIES), diff --git a/src/main/java/org/jabref/gui/editmode/EditModeAction.java b/src/main/java/org/jabref/gui/editmode/EditModeAction.java new file mode 100644 index 000000000000..2c242b926b6f --- /dev/null +++ b/src/main/java/org/jabref/gui/editmode/EditModeAction.java @@ -0,0 +1,47 @@ +package org.jabref.gui.editmode; + +import org.jabref.gui.DialogService; +import org.jabref.gui.StateManager; +import org.jabref.gui.actions.SimpleCommand; +import org.jabref.logic.l10n.Localization; +import org.jabref.model.database.BibDatabaseContext; +import org.jabref.model.database.BibDatabaseMode; + +import java.util.Optional; + +import static org.jabref.gui.actions.ActionHelper.needsDatabase; + +public class EditModeAction extends SimpleCommand { + + private final DialogService dialogService; + private StateManager stateManager; + + public EditModeAction(DialogService dialogService, StateManager stateManager) { + this.dialogService = dialogService; + this.stateManager = stateManager; + + this.executable.bind(needsDatabase(stateManager)); + } + + @Override + public void execute() { + Optional currentDatabase = stateManager.getActiveDatabase(); + if (currentDatabase.isEmpty()) { + return; + } + + BibDatabaseMode newMode = currentDatabase.get().getMode() + .getOppositeMode(); + + boolean result = dialogService.showConfirmationDialogAndWait( + Localization.lang("Library Type Change"), + Localization.lang("Are you sure you want to change your library type to '%0'?", newMode.getAsString()), + Localization.lang("Convert")); + + if (!result) { + return; + } + + currentDatabase.get().setMode(newMode); + } +} diff --git a/src/main/resources/l10n/JabRef_en.properties b/src/main/resources/l10n/JabRef_en.properties index 9325f1421b6c..d50f4a45765f 100644 --- a/src/main/resources/l10n/JabRef_en.properties +++ b/src/main/resources/l10n/JabRef_en.properties @@ -2126,3 +2126,7 @@ Start\ on\ second\ duplicate\ key\ with\ letter\ B\ (b,\ c,\ ...)=Start on secon Always\ add\ letter\ (a,\ b,\ ...)\ to\ generated\ keys=Always add letter (a, b, ...) to generated keys Default\ pattern=Default pattern Reset\ %s\ to\ default\ value=Reset %s to default value + +Library\ Type\ Change=Library Type Change +Are\ you\ sure\ you\ want\ to\ change\ your\ library\ type\ to\ '%0'?=Are you sure you want to change your library type to '%0'? +Change\ library\ type\ (biblatex/bibtex)=Change library type (biblatex/bibtex)