Skip to content

Commit

Permalink
Add switch to change from biblatex to bibtex and vice versa (fi… (#5565)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ka0o0 authored and koppor committed Nov 13, 2019
1 parent 04015b0 commit 7236581
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 39 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ 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)
- We changed the save action buttons to be easier to understand. [#5565](https://github.com/JabRef/jabref/issues/5565)
- 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)

### Fixed
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/org/jabref/gui/cleanup/CleanupPresetPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import javafx.scene.layout.VBox;

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.field.StandardField;
Expand Down Expand Up @@ -64,7 +63,7 @@ private void init(CleanupPreset cleanupPreset, FilePreferences filePreferences)

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

cleanUpFormatters = new FieldFormatterCleanupsPanel(Localization.lang("Run field formatter:"), Cleanups.DEFAULT_SAVE_ACTIONS);
cleanUpFormatters = new FieldFormatterCleanupsPanel(Localization.lang("Run field formatter:"));
formatterContainer.getChildren().setAll(cleanUpFormatters);

String currentPattern = Localization.lang("Filename format pattern")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,19 @@ public class FieldFormatterCleanupsPanel extends GridPane {

private static final String DESCRIPTION = Localization.lang("Description") + ": ";
private final CheckBox cleanupEnabled;
private final FieldFormatterCleanups defaultFormatters;
private final List<Formatter> availableFormatters;
private FieldFormatterCleanups fieldFormatterCleanups;
private ListView<FieldFormatterCleanup> actionsList;
private ComboBox<Formatter> formattersCombobox;
private ComboBox<String> selectFieldCombobox;
private Button addButton;
private Label descriptionAreaText;
private Button removeButton;
private Button resetButton;
private Button removeSelectedButton;
private Button removeAllButton;
private Button recommendButton;
private ObservableList<FieldFormatterCleanup> actions;

public FieldFormatterCleanupsPanel(String description, FieldFormatterCleanups defaultFormatters) {
this.defaultFormatters = Objects.requireNonNull(defaultFormatters);
public FieldFormatterCleanupsPanel(String description) {
cleanupEnabled = new CheckBox(description);
availableFormatters = Cleanups.getBuiltInFormatters();
availableFormatters.add(new ProtectTermsFormatter(Globals.protectedTermsLoader));
Expand Down Expand Up @@ -110,12 +108,12 @@ private void buildLayout() {
.install(actionsList);
add(actionsList, 1, 1, 3, 1);

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

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

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

recommendButton.setOnAction(e -> {
Expand All @@ -126,14 +124,14 @@ private void buildLayout() {
}
});

removeButton = new Button(Localization.lang("Remove selected"));
removeButton.setOnAction(e -> actions.remove(actionsList.getSelectionModel().getSelectedItem()));
removeSelectedButton = new Button(Localization.lang("Remove selected"));
removeSelectedButton.setOnAction(e -> actions.remove(actionsList.getSelectionModel().getSelectedItem()));
descriptionAreaText = new Label(DESCRIPTION);
descriptionAreaText.setWrapText(true);

add(removeButton, 3, 2, 1, 1);
add(resetButton, 1, 2, 1, 1);
add(recommendButton, 2, 2, 1, 1);
add(recommendButton, 1, 2, 1, 1);
add(removeSelectedButton, 2, 2, 1, 1);
add(removeAllButton, 3, 2, 1, 1);
add(getSelectorPanel(), 1, 3, 3, 1);
add(descriptionAreaText, 1, 4, 3, 1);

Expand Down Expand Up @@ -234,8 +232,8 @@ private void setStatus(boolean status) {
selectFieldCombobox.setDisable(!status);
formattersCombobox.setDisable(!status);
addButton.setDisable(!status);
removeButton.setDisable(!status);
resetButton.setDisable(!status);
removeSelectedButton.setDisable(!status);
removeAllButton.setDisable(!status);
recommendButton.setDisable(!status);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.Button?>
<?import javafx.scene.control.ButtonType?>
<?import javafx.scene.control.CheckBox?>
<?import javafx.scene.control.ComboBox?>
<?import javafx.scene.control.DialogPane?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.RowConstraints?>
<?import javafx.scene.layout.VBox?>
<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">
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>

<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">
<content>
<VBox fx:id="contentVbox" minHeight="-Infinity" prefHeight="200.0" prefWidth="100.0">
<children>
Expand All @@ -22,7 +14,7 @@
<ColumnConstraints hgrow="SOMETIMES" maxWidth="797.0" minWidth="10.0" prefWidth="100.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="25.0" prefHeight="65.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="-Infinity" prefHeight="50.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="ALWAYS" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="ALWAYS" />
Expand All @@ -32,8 +24,26 @@
<RowConstraints minHeight="-Infinity" prefHeight="50.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<Label text="%Library encoding" />
<ComboBox fx:id="encoding" prefWidth="250.0" GridPane.columnIndex="1" GridPane.hgrow="ALWAYS" />
<GridPane vgap="5.0" GridPane.columnSpan="3" GridPane.hgrow="ALWAYS">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="218.0" minWidth="10.0" prefWidth="200.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="797.0" minWidth="10.0" prefWidth="529.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="797.0" minWidth="10.0" prefWidth="100.0" />
</columnConstraints>
<Label text="%Library encoding" />
<ComboBox fx:id="encoding" prefWidth="250.0" GridPane.columnIndex="1" GridPane.hgrow="ALWAYS" />
<Label text="%Library mode" GridPane.rowIndex="2" />
<ComboBox fx:id="databaseMode" prefWidth="250.0" GridPane.columnIndex="1" GridPane.hgrow="ALWAYS" GridPane.rowIndex="2" />
<columnConstraints>
<ColumnConstraints />
<ColumnConstraints />
</columnConstraints>
<rowConstraints>
<RowConstraints />
<RowConstraints />
<RowConstraints />
</rowConstraints>
</GridPane>
<Label text="%General file directory" GridPane.rowIndex="2" />
<TextField fx:id="generalFileDirectory" GridPane.columnIndex="1" GridPane.rowIndex="2" />
<Button fx:id="browseGeneralFileDir" mnemonicParsing="false" onAction="#browseGeneralFileDirectory" text="%Browse" GridPane.columnIndex="2" GridPane.rowIndex="2" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
import org.jabref.gui.SaveOrderConfigDisplayView;
import org.jabref.gui.cleanup.FieldFormatterCleanupsPanel;
import org.jabref.gui.util.BaseDialog;
import org.jabref.logic.cleanup.Cleanups;
import org.jabref.logic.l10n.Localization;
import org.jabref.model.database.BibDatabaseMode;
import org.jabref.model.metadata.MetaData;
import org.jabref.model.metadata.SaveOrderConfig;
import org.jabref.preferences.PreferencesService;
Expand All @@ -33,6 +33,7 @@ public class LibraryPropertiesDialogView extends BaseDialog<Void> {

@FXML private VBox contentVbox;
@FXML private ComboBox<Charset> encoding;
@FXML private ComboBox<String> databaseMode;
@FXML private TextField generalFileDirectory;
@FXML private Button browseGeneralFileDir;
@FXML private TextField userSpecificFileDirectory;
Expand Down Expand Up @@ -79,13 +80,15 @@ private void initialize() {
encoding.disableProperty().bind(viewModel.encodingDisableProperty());
protect.disableProperty().bind(viewModel.protectDisableProperty());

databaseMode.itemsProperty().bind(viewModel.databaseModesProperty());
databaseMode.valueProperty().bindBidirectional(viewModel.selectedDatabaseModeProperty());

saveOrderConfigDisplayView = new SaveOrderConfigDisplayView();
Optional<SaveOrderConfig> storedSaveOrderConfig = panel.getBibDatabaseContext().getMetaData().getSaveOrderConfig();
oldSaveOrderConfig = storedSaveOrderConfig.orElseGet(preferencesService::loadExportSaveOrder);

saveOrderConfigDisplayView.changeExportDescriptionToSave();
fieldFormatterCleanupsPanel = new FieldFormatterCleanupsPanel(Localization.lang("Enable save actions"),
Cleanups.DEFAULT_SAVE_ACTIONS);
fieldFormatterCleanupsPanel = new FieldFormatterCleanupsPanel(Localization.lang("Enable save actions"));
Label saveActions = new Label(Localization.lang("Save actions"));
saveActions.getStyleClass().add("sectionHeader");

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

BibDatabaseMode newMode = BibDatabaseMode.parse(viewModel.selectedDatabaseModeProperty().getValue());
metaData.setMode(newMode);

String text = viewModel.generalFileDirectoryPropertyProperty().getValue().trim();
if (text.isEmpty()) {
metaData.clearDefaultFileDirectory();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import java.nio.charset.Charset;
import java.nio.file.Path;
import java.util.Arrays;
import java.util.Optional;
import java.util.stream.Collectors;

import javafx.beans.property.BooleanProperty;
import javafx.beans.property.ListProperty;
Expand All @@ -18,6 +20,7 @@
import org.jabref.gui.DialogService;
import org.jabref.gui.util.DirectoryDialogConfiguration;
import org.jabref.logic.l10n.Encodings;
import org.jabref.model.database.BibDatabaseMode;
import org.jabref.model.database.shared.DatabaseLocation;
import org.jabref.model.metadata.MetaData;
import org.jabref.preferences.PreferencesService;
Expand All @@ -29,6 +32,7 @@ public class LibraryPropertiesDialogViewModel {
private final StringProperty laTexFileDirectoryProperty = new SimpleStringProperty("");
private final ListProperty<Charset> encodingsProperty = new SimpleListProperty<>(FXCollections.observableArrayList(Encodings.getCharsets()));
private final ObjectProperty<Charset> selectedEncodingPropety = new SimpleObjectProperty<>(Encodings.getCharsets().get(0));
private final SimpleStringProperty selectedDatabaseModeProperty = new SimpleStringProperty(BibDatabaseMode.BIBLATEX.getFormattedName());
private final BooleanProperty libraryProtectedProperty = new SimpleBooleanProperty();
private final BooleanProperty encodingDisableProperty = new SimpleBooleanProperty();
private final BooleanProperty protectDisableProperty = new SimpleBooleanProperty();
Expand All @@ -55,6 +59,7 @@ public LibraryPropertiesDialogViewModel(BasePanel panel, DialogService dialogSer

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

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

public ListProperty<String> databaseModesProperty() {
return new SimpleListProperty<>(FXCollections.observableArrayList(
Arrays.stream(BibDatabaseMode.values())
.map(BibDatabaseMode::getFormattedName)
.collect(Collectors.toList())
));
}

public SimpleStringProperty selectedDatabaseModeProperty() {
return this.selectedDatabaseModeProperty;
}

public ObjectProperty<Charset> selectedEncodingProperty() {
return this.selectedEncodingPropety;
}
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/org/jabref/model/metadata/MetaData.java
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@ public Optional<BibDatabaseMode> getMode() {
}

public void setMode(BibDatabaseMode mode) {
if (mode == this.mode) {
return;
}

this.mode = Objects.requireNonNull(mode);
postChange();
}
Expand Down
8 changes: 4 additions & 4 deletions src/main/resources/l10n/JabRef_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -997,8 +997,6 @@ MIME\ type=MIME type
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.
Run\ fetcher=Run fetcher

Reset=Reset

Use\ IEEE\ LaTeX\ abbreviations=Use IEEE LaTeX abbreviations

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
Expand Down Expand Up @@ -1770,7 +1768,6 @@ A\ backup\ file\ for\ '%0'\ was\ found.=A backup file for '%0' was found.
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.
Do\ you\ want\ to\ recover\ the\ library\ from\ the\ backup\ file?=Do you want to recover the library from the backup file?
Recommended\ for\ %0=Recommended for %0
Show\ 'Related\ Articles'\ tab=Show 'Related Articles' tab
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).
Expand Down Expand Up @@ -2096,7 +2093,10 @@ 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\ mode=Library mode
Reset\ to\ recommended=Reset to recommended
Remove\ all=Remove all
Column\ type\ %0\ is\ unknown.=Column type %0 is unknown.
Linked\ identifiers=Linked identifiers
Special\ field\ type\ %0\ is\ unknown.\ Using\ normal\ column\ type.=Special field type %0 is unknown. Using normal column type.

0 comments on commit 7236581

Please sign in to comment.