Skip to content

Commit

Permalink
Add switch to change from biblatex to bibtex and vice versa (fix #5550)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ka0o0 committed Nov 3, 2019
1 parent 7e98453 commit 97de30c
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 6 additions & 1 deletion src/main/java/org/jabref/gui/JabRefFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/jabref/gui/actions/StandardActions.java
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
47 changes: 47 additions & 0 deletions src/main/java/org/jabref/gui/editmode/EditModeAction.java
Original file line number Diff line number Diff line change
@@ -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<BibDatabaseContext> 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);
}
}
4 changes: 4 additions & 0 deletions src/main/resources/l10n/JabRef_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 97de30c

Please sign in to comment.