Skip to content

Commit 7236581

Browse files
Ka0o0koppor
authored andcommitted
Add switch to change from biblatex to bibtex and vice versa (fi… (#5565)
1 parent 04015b0 commit 7236581

File tree

8 files changed

+75
-39
lines changed

8 files changed

+75
-39
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ 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)
24+
- We changed the save action buttons to be easier to understand. [#5565](https://github.com/JabRef/jabref/issues/5565)
2325
- We made the columns for groups, files and uri in the main table reorderable and merged the clickable icon columns for uri, url, doi and eprint. [#5544](https://github.com/JabRef/jabref/pull/5544)
2426

2527
### Fixed

src/main/java/org/jabref/gui/cleanup/CleanupPresetPanel.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import javafx.scene.layout.VBox;
1313

1414
import org.jabref.logic.cleanup.CleanupPreset;
15-
import org.jabref.logic.cleanup.Cleanups;
1615
import org.jabref.logic.l10n.Localization;
1716
import org.jabref.model.database.BibDatabaseContext;
1817
import org.jabref.model.entry.field.StandardField;
@@ -64,7 +63,7 @@ private void init(CleanupPreset cleanupPreset, FilePreferences filePreferences)
6463

6564
cleanUpUpgradeExternalLinks.setText(Localization.lang("Upgrade external PDF/PS links to use the '%0' field.", StandardField.FILE.getDisplayName()));
6665

67-
cleanUpFormatters = new FieldFormatterCleanupsPanel(Localization.lang("Run field formatter:"), Cleanups.DEFAULT_SAVE_ACTIONS);
66+
cleanUpFormatters = new FieldFormatterCleanupsPanel(Localization.lang("Run field formatter:"));
6867
formatterContainer.getChildren().setAll(cleanUpFormatters);
6968

7069
String currentPattern = Localization.lang("Filename format pattern")

src/main/java/org/jabref/gui/cleanup/FieldFormatterCleanupsPanel.java

+13-15
Original file line numberDiff line numberDiff line change
@@ -42,21 +42,19 @@ public class FieldFormatterCleanupsPanel extends GridPane {
4242

4343
private static final String DESCRIPTION = Localization.lang("Description") + ": ";
4444
private final CheckBox cleanupEnabled;
45-
private final FieldFormatterCleanups defaultFormatters;
4645
private final List<Formatter> availableFormatters;
4746
private FieldFormatterCleanups fieldFormatterCleanups;
4847
private ListView<FieldFormatterCleanup> actionsList;
4948
private ComboBox<Formatter> formattersCombobox;
5049
private ComboBox<String> selectFieldCombobox;
5150
private Button addButton;
5251
private Label descriptionAreaText;
53-
private Button removeButton;
54-
private Button resetButton;
52+
private Button removeSelectedButton;
53+
private Button removeAllButton;
5554
private Button recommendButton;
5655
private ObservableList<FieldFormatterCleanup> actions;
5756

58-
public FieldFormatterCleanupsPanel(String description, FieldFormatterCleanups defaultFormatters) {
59-
this.defaultFormatters = Objects.requireNonNull(defaultFormatters);
57+
public FieldFormatterCleanupsPanel(String description) {
6058
cleanupEnabled = new CheckBox(description);
6159
availableFormatters = Cleanups.getBuiltInFormatters();
6260
availableFormatters.add(new ProtectTermsFormatter(Globals.protectedTermsLoader));
@@ -110,12 +108,12 @@ private void buildLayout() {
110108
.install(actionsList);
111109
add(actionsList, 1, 1, 3, 1);
112110

113-
resetButton = new Button(Localization.lang("Reset"));
114-
resetButton.setOnAction(e -> actions.setAll(defaultFormatters.getConfiguredActions()));
111+
removeAllButton = new Button(Localization.lang("Remove all"));
112+
removeAllButton.setOnAction(e -> actions.clear());
115113

116114
BibDatabaseContext databaseContext = JabRefGUI.getMainFrame().getCurrentBasePanel().getBibDatabaseContext();
117115

118-
recommendButton = new Button(Localization.lang("Recommended for %0", databaseContext.getMode().getFormattedName()));
116+
recommendButton = new Button(Localization.lang("Reset to recommended"));
119117
boolean isBiblatex = databaseContext.isBiblatexMode();
120118

121119
recommendButton.setOnAction(e -> {
@@ -126,14 +124,14 @@ private void buildLayout() {
126124
}
127125
});
128126

129-
removeButton = new Button(Localization.lang("Remove selected"));
130-
removeButton.setOnAction(e -> actions.remove(actionsList.getSelectionModel().getSelectedItem()));
127+
removeSelectedButton = new Button(Localization.lang("Remove selected"));
128+
removeSelectedButton.setOnAction(e -> actions.remove(actionsList.getSelectionModel().getSelectedItem()));
131129
descriptionAreaText = new Label(DESCRIPTION);
132130
descriptionAreaText.setWrapText(true);
133131

134-
add(removeButton, 3, 2, 1, 1);
135-
add(resetButton, 1, 2, 1, 1);
136-
add(recommendButton, 2, 2, 1, 1);
132+
add(recommendButton, 1, 2, 1, 1);
133+
add(removeSelectedButton, 2, 2, 1, 1);
134+
add(removeAllButton, 3, 2, 1, 1);
137135
add(getSelectorPanel(), 1, 3, 3, 1);
138136
add(descriptionAreaText, 1, 4, 3, 1);
139137

@@ -234,8 +232,8 @@ private void setStatus(boolean status) {
234232
selectFieldCombobox.setDisable(!status);
235233
formattersCombobox.setDisable(!status);
236234
addButton.setDisable(!status);
237-
removeButton.setDisable(!status);
238-
resetButton.setDisable(!status);
235+
removeSelectedButton.setDisable(!status);
236+
removeAllButton.setDisable(!status);
239237
recommendButton.setDisable(!status);
240238
}
241239

src/main/java/org/jabref/gui/libraryproperties/LibraryPropertiesDialog.fxml

+25-15
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,9 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22

3-
<?import javafx.scene.control.Button?>
4-
<?import javafx.scene.control.ButtonType?>
5-
<?import javafx.scene.control.CheckBox?>
6-
<?import javafx.scene.control.ComboBox?>
7-
<?import javafx.scene.control.DialogPane?>
8-
<?import javafx.scene.control.Label?>
9-
<?import javafx.scene.control.TextField?>
10-
<?import javafx.scene.layout.ColumnConstraints?>
11-
<?import javafx.scene.layout.GridPane?>
12-
<?import javafx.scene.layout.RowConstraints?>
13-
<?import javafx.scene.layout.VBox?>
14-
<DialogPane minHeight="-Infinity" prefHeight="784.0" prefWidth="921.0" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="org.jabref.gui.libraryproperties.LibraryPropertiesDialogView">
3+
<?import javafx.scene.control.*?>
4+
<?import javafx.scene.layout.*?>
5+
6+
<DialogPane minHeight="-Infinity" prefHeight="784.0" prefWidth="921.0" xmlns="http://javafx.com/javafx/10.0.2-internal" xmlns:fx="http://javafx.com/fxml/1" fx:controller="org.jabref.gui.libraryproperties.LibraryPropertiesDialogView">
157
<content>
168
<VBox fx:id="contentVbox" minHeight="-Infinity" prefHeight="200.0" prefWidth="100.0">
179
<children>
@@ -22,7 +14,7 @@
2214
<ColumnConstraints hgrow="SOMETIMES" maxWidth="797.0" minWidth="10.0" prefWidth="100.0" />
2315
</columnConstraints>
2416
<rowConstraints>
25-
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
17+
<RowConstraints minHeight="25.0" prefHeight="65.0" vgrow="SOMETIMES" />
2618
<RowConstraints minHeight="-Infinity" prefHeight="50.0" vgrow="SOMETIMES" />
2719
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="ALWAYS" />
2820
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="ALWAYS" />
@@ -32,8 +24,26 @@
3224
<RowConstraints minHeight="-Infinity" prefHeight="50.0" vgrow="SOMETIMES" />
3325
</rowConstraints>
3426
<children>
35-
<Label text="%Library encoding" />
36-
<ComboBox fx:id="encoding" prefWidth="250.0" GridPane.columnIndex="1" GridPane.hgrow="ALWAYS" />
27+
<GridPane vgap="5.0" GridPane.columnSpan="3" GridPane.hgrow="ALWAYS">
28+
<columnConstraints>
29+
<ColumnConstraints hgrow="SOMETIMES" maxWidth="218.0" minWidth="10.0" prefWidth="200.0" />
30+
<ColumnConstraints hgrow="SOMETIMES" maxWidth="797.0" minWidth="10.0" prefWidth="529.0" />
31+
<ColumnConstraints hgrow="SOMETIMES" maxWidth="797.0" minWidth="10.0" prefWidth="100.0" />
32+
</columnConstraints>
33+
<Label text="%Library encoding" />
34+
<ComboBox fx:id="encoding" prefWidth="250.0" GridPane.columnIndex="1" GridPane.hgrow="ALWAYS" />
35+
<Label text="%Library mode" GridPane.rowIndex="2" />
36+
<ComboBox fx:id="databaseMode" prefWidth="250.0" GridPane.columnIndex="1" GridPane.hgrow="ALWAYS" GridPane.rowIndex="2" />
37+
<columnConstraints>
38+
<ColumnConstraints />
39+
<ColumnConstraints />
40+
</columnConstraints>
41+
<rowConstraints>
42+
<RowConstraints />
43+
<RowConstraints />
44+
<RowConstraints />
45+
</rowConstraints>
46+
</GridPane>
3747
<Label text="%General file directory" GridPane.rowIndex="2" />
3848
<TextField fx:id="generalFileDirectory" GridPane.columnIndex="1" GridPane.rowIndex="2" />
3949
<Button fx:id="browseGeneralFileDir" mnemonicParsing="false" onAction="#browseGeneralFileDirectory" text="%Browse" GridPane.columnIndex="2" GridPane.rowIndex="2" />

src/main/java/org/jabref/gui/libraryproperties/LibraryPropertiesDialogView.java

+9-3
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
import org.jabref.gui.SaveOrderConfigDisplayView;
2222
import org.jabref.gui.cleanup.FieldFormatterCleanupsPanel;
2323
import org.jabref.gui.util.BaseDialog;
24-
import org.jabref.logic.cleanup.Cleanups;
2524
import org.jabref.logic.l10n.Localization;
25+
import org.jabref.model.database.BibDatabaseMode;
2626
import org.jabref.model.metadata.MetaData;
2727
import org.jabref.model.metadata.SaveOrderConfig;
2828
import org.jabref.preferences.PreferencesService;
@@ -33,6 +33,7 @@ public class LibraryPropertiesDialogView extends BaseDialog<Void> {
3333

3434
@FXML private VBox contentVbox;
3535
@FXML private ComboBox<Charset> encoding;
36+
@FXML private ComboBox<String> databaseMode;
3637
@FXML private TextField generalFileDirectory;
3738
@FXML private Button browseGeneralFileDir;
3839
@FXML private TextField userSpecificFileDirectory;
@@ -79,13 +80,15 @@ private void initialize() {
7980
encoding.disableProperty().bind(viewModel.encodingDisableProperty());
8081
protect.disableProperty().bind(viewModel.protectDisableProperty());
8182

83+
databaseMode.itemsProperty().bind(viewModel.databaseModesProperty());
84+
databaseMode.valueProperty().bindBidirectional(viewModel.selectedDatabaseModeProperty());
85+
8286
saveOrderConfigDisplayView = new SaveOrderConfigDisplayView();
8387
Optional<SaveOrderConfig> storedSaveOrderConfig = panel.getBibDatabaseContext().getMetaData().getSaveOrderConfig();
8488
oldSaveOrderConfig = storedSaveOrderConfig.orElseGet(preferencesService::loadExportSaveOrder);
8589

8690
saveOrderConfigDisplayView.changeExportDescriptionToSave();
87-
fieldFormatterCleanupsPanel = new FieldFormatterCleanupsPanel(Localization.lang("Enable save actions"),
88-
Cleanups.DEFAULT_SAVE_ACTIONS);
91+
fieldFormatterCleanupsPanel = new FieldFormatterCleanupsPanel(Localization.lang("Enable save actions"));
8992
Label saveActions = new Label(Localization.lang("Save actions"));
9093
saveActions.getStyleClass().add("sectionHeader");
9194

@@ -124,6 +127,9 @@ private void storeSettings() {
124127
Charset newEncoding = viewModel.selectedEncodingProperty().getValue();
125128
metaData.setEncoding(newEncoding);
126129

130+
BibDatabaseMode newMode = BibDatabaseMode.parse(viewModel.selectedDatabaseModeProperty().getValue());
131+
metaData.setMode(newMode);
132+
127133
String text = viewModel.generalFileDirectoryPropertyProperty().getValue().trim();
128134
if (text.isEmpty()) {
129135
metaData.clearDefaultFileDirectory();

src/main/java/org/jabref/gui/libraryproperties/LibraryPropertiesDialogViewModel.java

+17
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
import java.nio.charset.Charset;
44
import java.nio.file.Path;
5+
import java.util.Arrays;
56
import java.util.Optional;
7+
import java.util.stream.Collectors;
68

79
import javafx.beans.property.BooleanProperty;
810
import javafx.beans.property.ListProperty;
@@ -18,6 +20,7 @@
1820
import org.jabref.gui.DialogService;
1921
import org.jabref.gui.util.DirectoryDialogConfiguration;
2022
import org.jabref.logic.l10n.Encodings;
23+
import org.jabref.model.database.BibDatabaseMode;
2124
import org.jabref.model.database.shared.DatabaseLocation;
2225
import org.jabref.model.metadata.MetaData;
2326
import org.jabref.preferences.PreferencesService;
@@ -29,6 +32,7 @@ public class LibraryPropertiesDialogViewModel {
2932
private final StringProperty laTexFileDirectoryProperty = new SimpleStringProperty("");
3033
private final ListProperty<Charset> encodingsProperty = new SimpleListProperty<>(FXCollections.observableArrayList(Encodings.getCharsets()));
3134
private final ObjectProperty<Charset> selectedEncodingPropety = new SimpleObjectProperty<>(Encodings.getCharsets().get(0));
35+
private final SimpleStringProperty selectedDatabaseModeProperty = new SimpleStringProperty(BibDatabaseMode.BIBLATEX.getFormattedName());
3236
private final BooleanProperty libraryProtectedProperty = new SimpleBooleanProperty();
3337
private final BooleanProperty encodingDisableProperty = new SimpleBooleanProperty();
3438
private final BooleanProperty protectDisableProperty = new SimpleBooleanProperty();
@@ -55,6 +59,7 @@ public LibraryPropertiesDialogViewModel(BasePanel panel, DialogService dialogSer
5559

5660
Optional<Charset> charset = metaData.getEncoding();
5761
selectedEncodingPropety.setValue(charset.orElse(preferencesService.getDefaultEncoding()));
62+
selectedDatabaseModeProperty.setValue(metaData.getMode().orElse(BibDatabaseMode.BIBLATEX).getFormattedName());
5863

5964
Optional<String> fileD = metaData.getDefaultFileDirectory();
6065
fileD.ifPresent(path -> generalFileDirectoryProperty.setValue(path.trim()));
@@ -88,6 +93,18 @@ public ListProperty<Charset> encodingsProperty() {
8893
return this.encodingsProperty;
8994
}
9095

96+
public ListProperty<String> databaseModesProperty() {
97+
return new SimpleListProperty<>(FXCollections.observableArrayList(
98+
Arrays.stream(BibDatabaseMode.values())
99+
.map(BibDatabaseMode::getFormattedName)
100+
.collect(Collectors.toList())
101+
));
102+
}
103+
104+
public SimpleStringProperty selectedDatabaseModeProperty() {
105+
return this.selectedDatabaseModeProperty;
106+
}
107+
91108
public ObjectProperty<Charset> selectedEncodingProperty() {
92109
return this.selectedEncodingPropety;
93110
}

src/main/java/org/jabref/model/metadata/MetaData.java

+4
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,10 @@ public Optional<BibDatabaseMode> getMode() {
149149
}
150150

151151
public void setMode(BibDatabaseMode mode) {
152+
if (mode == this.mode) {
153+
return;
154+
}
155+
152156
this.mode = Objects.requireNonNull(mode);
153157
postChange();
154158
}

src/main/resources/l10n/JabRef_en.properties

+4-4
Original file line numberDiff line numberDiff line change
@@ -997,8 +997,6 @@ MIME\ type=MIME type
997997
This\ feature\ lets\ new\ files\ be\ opened\ or\ imported\ into\ an\ already\ running\ instance\ of\ JabRef\ instead\ of\ opening\ a\ new\ instance.\ For\ instance,\ this\ is\ useful\ when\ you\ open\ a\ file\ in\ JabRef\ from\ your\ web\ browser.\ Note\ that\ this\ will\ prevent\ you\ from\ running\ more\ than\ one\ instance\ of\ JabRef\ at\ a\ time.=This feature lets new files be opened or imported into an already running instance of JabRef instead of opening a new instance. For instance, this is useful when you open a file in JabRef from your web browser. Note that this will prevent you from running more than one instance of JabRef at a time.
998998
Run\ fetcher=Run fetcher
999999

1000-
Reset=Reset
1001-
10021000
Use\ IEEE\ LaTeX\ abbreviations=Use IEEE LaTeX abbreviations
10031001

10041002
When\ opening\ file\ link,\ search\ for\ matching\ file\ if\ no\ link\ is\ defined=When opening file link, search for matching file if no link is defined
@@ -1770,7 +1768,6 @@ A\ backup\ file\ for\ '%0'\ was\ found.=A backup file for '%0' was found.
17701768
This\ could\ indicate\ that\ JabRef\ did\ not\ shut\ down\ cleanly\ last\ time\ the\ file\ was\ used.=This could indicate that JabRef did not shut down cleanly last time the file was used.
17711769
Do\ you\ want\ to\ recover\ the\ library\ from\ the\ backup\ file?=Do you want to recover the library from the backup file?
17721770
1773-
Recommended\ for\ %0=Recommended for %0
17741771
Show\ 'Related\ Articles'\ tab=Show 'Related Articles' tab
17751772
This\ might\ be\ caused\ by\ reaching\ the\ traffic\ limitation\ of\ Google\ Scholar\ (see\ 'Help'\ for\ details).=This might be caused by reaching the traffic limitation of Google Scholar (see 'Help' for details).
17761773
@@ -2096,7 +2093,10 @@ Start\ on\ second\ duplicate\ key\ with\ letter\ B\ (b,\ c,\ ...)=Start on secon
20962093
Always\ add\ letter\ (a,\ b,\ ...)\ to\ generated\ keys=Always add letter (a, b, ...) to generated keys
20972094
Default\ pattern=Default pattern
20982095
Reset\ %s\ to\ default\ value=Reset %s to default value
2099-
2096+
Library\ mode=Library mode
2097+
Reset\ to\ recommended=Reset to recommended
2098+
Remove\ all=Remove all
21002099
Column\ type\ %0\ is\ unknown.=Column type %0 is unknown.
21012100
Linked\ identifiers=Linked identifiers
21022101
Special\ field\ type\ %0\ is\ unknown.\ Using\ normal\ column\ type.=Special field type %0 is unknown. Using normal column type.
2102+

0 commit comments

Comments
 (0)