Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reorganized "General tab" (preamble still here) and "String constants… #9836

Merged
merged 8 commits into from
May 6, 2023
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
- We moved the custom entry types dialog into the preferences dialog. [#9760](https://github.com/JabRef/jabref/pull/9760)
- We moved the manage content selectors dialog to the library properties. [#9768](https://github.com/JabRef/jabref/pull/9768)
- We moved the preferences menu command from the options menu to the file menu. [#9768](https://github.com/JabRef/jabref/pull/9768)
- We reorganized the order of tabs and settings in the library properties. [#9836](https://github.com/JabRef/jabref/pull/9836)
- We changed the handling of an "overflow" of authors at `[authIniN]`: JabRef uses `+` to indicate an overflow. Example: `[authIni2]` produces `A+` (instead of `AB`) for `Aachen and Berlin and Chemnitz`. [#9703](https://github.com/JabRef/jabref/pull/9703)
- We moved the preferences option to open the last edited files on startup to the 'General' tab. [#9808](https://github.com/JabRef/jabref/pull/9808)
- We split the 'Import and Export' tab into 'Web Search' and 'Export'. [#9839](https://github.com/JabRef/jabref/pull/9839)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.jabref.gui.libraryproperties.contentselectors.ContentSelectorView;
import org.jabref.gui.libraryproperties.general.GeneralPropertiesView;
import org.jabref.gui.libraryproperties.keypattern.KeyPatternPropertiesView;
import org.jabref.gui.libraryproperties.preamble.PreamblePropertiesView;
import org.jabref.gui.libraryproperties.saving.SavingPropertiesView;
import org.jabref.model.database.BibDatabaseContext;

Expand All @@ -17,9 +18,10 @@ public LibraryPropertiesViewModel(BibDatabaseContext databaseContext) {
propertiesTabs = List.of(
new GeneralPropertiesView(databaseContext),
new SavingPropertiesView(databaseContext),
new ConstantsPropertiesView(databaseContext),
new KeyPatternPropertiesView(databaseContext),
new ContentSelectorView(databaseContext)
new ConstantsPropertiesView(databaseContext),
new ContentSelectorView(databaseContext),
new PreamblePropertiesView(databaseContext)
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.ComboBox?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.TextArea?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.control.Tooltip?>
<?import javafx.scene.layout.ColumnConstraints?>
Expand All @@ -30,26 +29,15 @@
<RowConstraints/>
</rowConstraints>

<Label styleClass="sectionHeader" text="%General"
GridPane.columnSpan="3" GridPane.rowIndex="0"/>
<Label text="%Library encoding"
GridPane.columnIndex="0" GridPane.rowIndex="1"/>
<ComboBox fx:id="encoding" prefWidth="150.0"
GridPane.columnIndex="1" GridPane.hgrow="ALWAYS" GridPane.rowIndex="1"/>
<Label text="%Library mode"
GridPane.columnIndex="0" GridPane.rowIndex="2"/>
<ComboBox fx:id="databaseMode" prefWidth="150.0"
GridPane.columnIndex="1" GridPane.hgrow="ALWAYS" GridPane.rowIndex="2"/>

<Label styleClass="sectionHeader" text="%Override default file directories"
GridPane.columnSpan="3" GridPane.rowIndex="3"/>
GridPane.columnSpan="3" GridPane.rowIndex="0"/>
<Label text="%General file directory"
GridPane.columnIndex="0" GridPane.rowIndex="4"/>
GridPane.columnIndex="0" GridPane.rowIndex="1"/>
<TextField fx:id="generalFileDirectory"
GridPane.columnIndex="1" GridPane.rowIndex="4"/>
GridPane.columnIndex="1" GridPane.rowIndex="1"/>
<Button onAction="#browseGeneralFileDirectory"
styleClass="icon-button,narrow" prefHeight="20.0" prefWidth="20.0"
GridPane.columnIndex="2" GridPane.rowIndex="4">
GridPane.columnIndex="2" GridPane.rowIndex="1">
<graphic>
<JabRefIconView glyph="OPEN"/>
</graphic>
Expand All @@ -59,12 +47,12 @@
</Button>

<Label text="%User-specific file directory"
GridPane.columnIndex="0" GridPane.rowIndex="5"/>
GridPane.columnIndex="0" GridPane.rowIndex="2"/>
<TextField fx:id="userSpecificFileDirectory"
GridPane.columnIndex="1" GridPane.rowIndex="5"/>
GridPane.columnIndex="1" GridPane.rowIndex="2"/>
<Button onAction="#browseUserSpecificFileDirectory"
styleClass="icon-button,narrow" prefHeight="20.0" prefWidth="20.0"
GridPane.columnIndex="2" GridPane.rowIndex="5">
GridPane.columnIndex="2" GridPane.rowIndex="2">
<graphic>
<JabRefIconView glyph="OPEN"/>
</graphic>
Expand All @@ -74,20 +62,30 @@
</Button>

<Label text="%LaTeX file directory"
GridPane.columnIndex="0" GridPane.rowIndex="6"/>
GridPane.columnIndex="0" GridPane.rowIndex="3"/>
<TextField fx:id="laTexFileDirectory"
GridPane.columnIndex="1" GridPane.rowIndex="6"/>
GridPane.columnIndex="1" GridPane.rowIndex="3"/>
<Button onAction="#browseLatexFileDirectory"
styleClass="icon-button,narrow" prefHeight="20.0" prefWidth="20.0"
GridPane.columnIndex="2" GridPane.rowIndex="6">
GridPane.columnIndex="2" GridPane.rowIndex="3">
<graphic>
<JabRefIconView glyph="OPEN"/>
</graphic>
<tooltip>
<Tooltip text="%Browse"/>
</tooltip>
</Button>

<Label styleClass="sectionHeader" text="%General"
GridPane.columnSpan="3" GridPane.rowIndex="4"/>
<Label text="%Library mode"
GridPane.columnIndex="0" GridPane.rowIndex="5"/>
<ComboBox fx:id="databaseMode" prefWidth="150.0"
GridPane.columnIndex="1" GridPane.hgrow="ALWAYS" GridPane.rowIndex="5"/>
<Label text="%Library encoding"
GridPane.columnIndex="0" GridPane.rowIndex="6"/>
<ComboBox fx:id="encoding" prefWidth="150.0"
GridPane.columnIndex="1" GridPane.hgrow="ALWAYS" GridPane.rowIndex="6"/>

</GridPane>
<Label styleClass="sectionHeader" text="%Preamble"/>
<TextArea fx:id="preamble" minHeight="100" prefHeight="180" VBox.vgrow="ALWAYS"/>
</fx:root>
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@

import java.nio.charset.Charset;

import javax.swing.undo.UndoManager;

import javafx.fxml.FXML;
import javafx.scene.control.ComboBox;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;

import org.jabref.gui.libraryproperties.AbstractPropertiesTabView;
Expand All @@ -25,10 +22,8 @@ public class GeneralPropertiesView extends AbstractPropertiesTabView<GeneralProp
@FXML private TextField generalFileDirectory;
@FXML private TextField userSpecificFileDirectory;
@FXML private TextField laTexFileDirectory;
@FXML private TextArea preamble;

@Inject private PreferencesService preferencesService;
@Inject private UndoManager undoManager;

public GeneralPropertiesView(BibDatabaseContext databaseContext) {
this.databaseContext = databaseContext;
Expand All @@ -44,7 +39,7 @@ public String getTabName() {
}

public void initialize() {
this.viewModel = new GeneralPropertiesViewModel(databaseContext, dialogService, preferencesService, undoManager);
this.viewModel = new GeneralPropertiesViewModel(databaseContext, dialogService, preferencesService);

new ViewModelListCellFactory<Charset>()
.withText(Charset::displayName)
Expand All @@ -62,8 +57,6 @@ public void initialize() {
generalFileDirectory.textProperty().bindBidirectional(viewModel.generalFileDirectoryPropertyProperty());
userSpecificFileDirectory.textProperty().bindBidirectional(viewModel.userSpecificFileDirectoryProperty());
laTexFileDirectory.textProperty().bindBidirectional(viewModel.laTexFileDirectoryProperty());

preamble.textProperty().bindBidirectional(viewModel.preambleProperty());
}

@FXML
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;

import javax.swing.undo.UndoManager;

import javafx.beans.property.BooleanProperty;
import javafx.beans.property.ListProperty;
import javafx.beans.property.ObjectProperty;
Expand All @@ -18,7 +16,6 @@

import org.jabref.gui.DialogService;
import org.jabref.gui.libraryproperties.PropertiesTabViewModel;
import org.jabref.gui.undo.UndoablePreambleChange;
import org.jabref.gui.util.DirectoryDialogConfiguration;
import org.jabref.logic.l10n.Encodings;
import org.jabref.logic.shared.DatabaseLocation;
Expand All @@ -37,20 +34,17 @@ public class GeneralPropertiesViewModel implements PropertiesTabViewModel {
private final StringProperty generalFileDirectoryProperty = new SimpleStringProperty("");
private final StringProperty userSpecificFileDirectoryProperty = new SimpleStringProperty("");
private final StringProperty laTexFileDirectoryProperty = new SimpleStringProperty("");
private final StringProperty preambleProperty = new SimpleStringProperty("");

private final DialogService dialogService;
private final PreferencesService preferencesService;

private final BibDatabaseContext databaseContext;
private final MetaData metaData;
private final DirectoryDialogConfiguration directoryDialogConfiguration;
private final UndoManager undoManager;

GeneralPropertiesViewModel(BibDatabaseContext databaseContext, DialogService dialogService, PreferencesService preferencesService, UndoManager undoManager) {
GeneralPropertiesViewModel(BibDatabaseContext databaseContext, DialogService dialogService, PreferencesService preferencesService) {
this.dialogService = dialogService;
this.preferencesService = preferencesService;
this.undoManager = undoManager;
this.databaseContext = databaseContext;
this.metaData = databaseContext.getMetaData();

Expand All @@ -68,8 +62,6 @@ public void setValues() {
generalFileDirectoryProperty.setValue(metaData.getDefaultFileDirectory().orElse("").trim());
userSpecificFileDirectoryProperty.setValue(metaData.getUserFileDirectory(preferencesService.getFilePreferences().getUser()).orElse("").trim());
laTexFileDirectoryProperty.setValue(metaData.getLatexFileDirectory(preferencesService.getFilePreferences().getUser()).map(Path::toString).orElse(""));

preambleProperty.setValue(databaseContext.getDatabase().getPreamble().orElse(""));
}

@Override
Expand Down Expand Up @@ -101,12 +93,6 @@ public void storeSettings() {
}

databaseContext.setMetaData(newMetaData);

String newPreamble = preambleProperty.getValue();
if (!databaseContext.getDatabase().getPreamble().orElse("").equals(newPreamble)) {
undoManager.addEdit(new UndoablePreambleChange(databaseContext.getDatabase(), databaseContext.getDatabase().getPreamble().orElse(null), newPreamble));
databaseContext.getDatabase().setPreamble(newPreamble);
}
}

public void browseGeneralDir() {
Expand Down Expand Up @@ -155,8 +141,4 @@ public StringProperty userSpecificFileDirectoryProperty() {
public StringProperty laTexFileDirectoryProperty() {
return this.laTexFileDirectoryProperty;
}

public StringProperty preambleProperty() {
return this.preambleProperty;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.Label?>
<?import javafx.scene.control.TextArea?>
<?import javafx.scene.layout.VBox?>
<fx:root spacing="10.0" type="VBox"
xmlns="http://javafx.com/javafx" xmlns:fx="http://javafx.com/fxml"
fx:controller="org.jabref.gui.libraryproperties.preamble.PreamblePropertiesView">
<Label styleClass="sectionHeader" text="%Preamble"/>
<TextArea fx:id="preamble" minHeight="100" prefHeight="180" VBox.vgrow="ALWAYS"/>
</fx:root>
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package org.jabref.gui.libraryproperties.preamble;

import javax.swing.undo.UndoManager;

import javafx.fxml.FXML;
import javafx.scene.control.TextArea;

import org.jabref.gui.libraryproperties.AbstractPropertiesTabView;
import org.jabref.logic.l10n.Localization;
import org.jabref.model.database.BibDatabaseContext;

import com.airhacks.afterburner.views.ViewLoader;
import jakarta.inject.Inject;

public class PreamblePropertiesView extends AbstractPropertiesTabView<PreamblePropertiesViewModel> {
@FXML private TextArea preamble;

@Inject private UndoManager undoManager;

public PreamblePropertiesView(BibDatabaseContext databaseContext) {
this.databaseContext = databaseContext;

ViewLoader.view(this)
.root(this)
.load();
}

@Override
public String getTabName() {
return Localization.lang("Preamble");
}

public void initialize() {
this.viewModel = new PreamblePropertiesViewModel(databaseContext, undoManager);

preamble.textProperty().bindBidirectional(viewModel.preambleProperty());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package org.jabref.gui.libraryproperties.preamble;

import javax.swing.undo.UndoManager;

import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;

import org.jabref.gui.libraryproperties.PropertiesTabViewModel;
import org.jabref.gui.undo.UndoablePreambleChange;
import org.jabref.model.database.BibDatabaseContext;

public class PreamblePropertiesViewModel implements PropertiesTabViewModel {
private final StringProperty preambleProperty = new SimpleStringProperty("");

private final BibDatabaseContext databaseContext;
private final UndoManager undoManager;

PreamblePropertiesViewModel(BibDatabaseContext databaseContext, UndoManager undoManager) {
this.undoManager = undoManager;
this.databaseContext = databaseContext;
}

@Override
public void setValues() {
preambleProperty.setValue(databaseContext.getDatabase().getPreamble().orElse(""));
}

@Override
public void storeSettings() {
String newPreamble = preambleProperty.getValue();
if (!databaseContext.getDatabase().getPreamble().orElse("").equals(newPreamble)) {
undoManager.addEdit(new UndoablePreambleChange(databaseContext.getDatabase(), databaseContext.getDatabase().getPreamble().orElse(null), newPreamble));
databaseContext.getDatabase().setPreamble(newPreamble);
}
}

public StringProperty preambleProperty() {
return this.preambleProperty;
}
}