Skip to content

Commit 97de30c

Browse files
committed
Add switch to change from biblatex to bibtex and vice versa (fix JabRef#5550)
1 parent 7e98453 commit 97de30c

File tree

5 files changed

+59
-1
lines changed

5 files changed

+59
-1
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#
2020
- The entry editor is now open by default when JabRef starts up. [#5460](https://github.com/JabRef/jabref/issues/5460)
2121
- We added a new ADS fetcher to use the new ADS API [#4949](https://github.com/JabRef/jabref/issues/4949)
2222
- We added support of the [X11 primary selection](https://unix.stackexchange.com/a/139193/18033) [#2389](https://github.com/JabRef/jabref/issues/2389)
23+
- We added support to switch between biblatex and bibtex library types. [#5550](https://github.com/JabRef/jabref/issues/5550)
2324

2425
### Fixed
2526

src/main/java/org/jabref/gui/JabRefFrame.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
import org.jabref.gui.edit.ManageKeywordsAction;
6262
import org.jabref.gui.edit.MassSetFieldsAction;
6363
import org.jabref.gui.edit.OpenBrowserAction;
64+
import org.jabref.gui.editmode.EditModeAction;
6465
import org.jabref.gui.exporter.ExportCommand;
6566
import org.jabref.gui.exporter.ExportToClipboardAction;
6667
import org.jabref.gui.exporter.ManageCustomExportsAction;
@@ -737,7 +738,11 @@ private MenuBar createMenu() {
737738
factory.createMenuItem(StandardActions.EDIT_PREAMBLE, new PreambleEditor(stateManager, undoManager, this.getDialogService())),
738739
factory.createMenuItem(StandardActions.EDIT_STRINGS, new BibtexStringEditorAction(stateManager)),
739740
factory.createMenuItem(StandardActions.MANAGE_CITE_KEY_PATTERNS, new BibtexKeyPatternAction(this, stateManager)),
740-
factory.createMenuItem(StandardActions.MASS_SET_FIELDS, new MassSetFieldsAction(stateManager, dialogService, undoManager))
741+
factory.createMenuItem(StandardActions.MASS_SET_FIELDS, new MassSetFieldsAction(stateManager, dialogService, undoManager)),
742+
743+
new SeparatorMenuItem(),
744+
745+
factory.createMenuItem(StandardActions.CHANGE_LIBRARY_TYPE, new EditModeAction(dialogService, stateManager))
741746
);
742747

743748
Menu lookupIdentifiers = factory.createSubMenu(StandardActions.LOOKUP_DOC_IDENTIFIER);

src/main/java/org/jabref/gui/actions/StandardActions.java

+1
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ public enum StandardActions implements Action {
124124
LIBRARY_PROPERTIES(Localization.lang("Library properties")),
125125
EDIT_PREAMBLE(Localization.lang("Edit preamble")),
126126
EDIT_STRINGS(Localization.lang("Edit string constants"), IconTheme.JabRefIcons.EDIT_STRINGS, KeyBinding.EDIT_STRINGS),
127+
CHANGE_LIBRARY_TYPE(Localization.lang("Change library type (biblatex/bibtex)")),
127128

128129
FIND_DUPLICATES(Localization.lang("Find duplicates"), IconTheme.JabRefIcons.FIND_DUPLICATES),
129130
MERGE_ENTRIES(Localization.lang("Merge entries"), IconTheme.JabRefIcons.MERGE_ENTRIES),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package org.jabref.gui.editmode;
2+
3+
import org.jabref.gui.DialogService;
4+
import org.jabref.gui.StateManager;
5+
import org.jabref.gui.actions.SimpleCommand;
6+
import org.jabref.logic.l10n.Localization;
7+
import org.jabref.model.database.BibDatabaseContext;
8+
import org.jabref.model.database.BibDatabaseMode;
9+
10+
import java.util.Optional;
11+
12+
import static org.jabref.gui.actions.ActionHelper.needsDatabase;
13+
14+
public class EditModeAction extends SimpleCommand {
15+
16+
private final DialogService dialogService;
17+
private StateManager stateManager;
18+
19+
public EditModeAction(DialogService dialogService, StateManager stateManager) {
20+
this.dialogService = dialogService;
21+
this.stateManager = stateManager;
22+
23+
this.executable.bind(needsDatabase(stateManager));
24+
}
25+
26+
@Override
27+
public void execute() {
28+
Optional<BibDatabaseContext> currentDatabase = stateManager.getActiveDatabase();
29+
if (currentDatabase.isEmpty()) {
30+
return;
31+
}
32+
33+
BibDatabaseMode newMode = currentDatabase.get().getMode()
34+
.getOppositeMode();
35+
36+
boolean result = dialogService.showConfirmationDialogAndWait(
37+
Localization.lang("Library Type Change"),
38+
Localization.lang("Are you sure you want to change your library type to '%0'?", newMode.getAsString()),
39+
Localization.lang("Convert"));
40+
41+
if (!result) {
42+
return;
43+
}
44+
45+
currentDatabase.get().setMode(newMode);
46+
}
47+
}

src/main/resources/l10n/JabRef_en.properties

+4
Original file line numberDiff line numberDiff line change
@@ -2126,3 +2126,7 @@ Start\ on\ second\ duplicate\ key\ with\ letter\ B\ (b,\ c,\ ...)=Start on secon
21262126
Always\ add\ letter\ (a,\ b,\ ...)\ to\ generated\ keys=Always add letter (a, b, ...) to generated keys
21272127
Default\ pattern=Default pattern
21282128
Reset\ %s\ to\ default\ value=Reset %s to default value
2129+
2130+
Library\ Type\ Change=Library Type Change
2131+
Are\ you\ sure\ you\ want\ to\ change\ your\ library\ type\ to\ '%0'?=Are you sure you want to change your library type to '%0'?
2132+
Change\ library\ type\ (biblatex/bibtex)=Change library type (biblatex/bibtex)

0 commit comments

Comments
 (0)