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

Preferences ui cleanup B #9866

Merged
merged 37 commits into from
May 15, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
cf5f82b
Introduced library preferences tab
calixtus May 8, 2023
d555ffa
Moved language setting to AppearanceTab
calixtus May 9, 2023
75e551a
Changed theme radio buttons to combobox
calixtus May 9, 2023
0d5f846
Moved four settings to AppearanceTab
calixtus May 9, 2023
c1bf900
Removed GeneralTab, moved memory stick button to prefs toolbar
calixtus May 9, 2023
949bff2
Moved default library to EntryTab
calixtus May 9, 2023
ea38b9b
Moved telemetry prefs to AppearanceTab
calixtus May 9, 2023
6cf3d9d
Moved default library to LibraryTab
calixtus May 9, 2023
6dd2c76
Fixed AppearancePreferences
calixtus May 9, 2023
7ea1fdc
Moved memory stick mode to InternalPreferences
calixtus May 9, 2023
70571ba
Moved language to AppearancePreferences
calixtus May 9, 2023
c889560
Renamed GeneralPreferences to LibraryPreferences, moved reformatting …
calixtus May 9, 2023
adf7cdb
Fixed ui
calixtus May 9, 2023
4ce19e4
CHANGELOG.md
calixtus May 9, 2023
137710a
Fixed backup branch merge conflicts
calixtus May 9, 2023
455edf5
Fixed backup branch merge conflicts
calixtus May 9, 2023
5cd19df
Fixed checkstyle
calixtus May 9, 2023
8cf533a
Reworded getGeneralPreferences
calixtus May 9, 2023
0b69aa4
Fixed ThemeManagerTest
calixtus May 9, 2023
8332684
Polished KeyBindingsTab
calixtus May 10, 2023
8106f87
Added missing symbols in CustomImporter/ExporterTab
calixtus May 10, 2023
cbc76f0
Added small border to combobox popups
calixtus May 10, 2023
f857059
Merge remote-tracking branch 'upstream/main' into library_prefs
calixtus May 10, 2023
47e4ef1
CHANGELOG.md
calixtus May 10, 2023
e178ef4
l10n
calixtus May 10, 2023
cb02a2e
Merge remote-tracking branch 'upstream/main' into library_prefs
calixtus May 10, 2023
4a54aa0
Reworded AppearanceTab to WorkspaceTab
calixtus May 10, 2023
aabf62d
Reworded AppearanceTab to WorkspaceTab
calixtus May 10, 2023
c0e52fe
Merged WorkspaceTab and LibraryTab
calixtus May 10, 2023
bc5c4fc
Moved Autocompletion to new tab and moved Custom tab editor to EntryE…
calixtus May 10, 2023
cb5ce9f
CHANGELOG.md
calixtus May 10, 2023
d81d37f
Merge branch 'main' into library_prefs
koppor May 12, 2023
beb59e2
Readded Hint on 9839
koppor May 12, 2023
e488e3b
Merge branch 'main' into library_prefs
calixtus May 15, 2023
57b0649
Renamed workspace tab back to general tab
calixtus May 15, 2023
df6e42f
Update Javadoc
calixtus May 15, 2023
baf2947
Merge branch 'main' into library_prefs
calixtus May 15, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Renamed GeneralPreferences to LibraryPreferences, moved reformatting …
…and autosave to LibraryTab
  • Loading branch information
calixtus committed May 9, 2023
commit c889560038f0e318c2a1c4ad500100351867c96b
2 changes: 1 addition & 1 deletion src/main/java/org/jabref/cli/ArgumentProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ private void saveDatabase(BibDatabase newBase, String subName) {
try (AtomicFileWriter fileWriter = new AtomicFileWriter(Path.of(subName), StandardCharsets.UTF_8)) {
BibWriter bibWriter = new BibWriter(fileWriter, OS.NEWLINE);
SaveConfiguration saveConfiguration = new SaveConfiguration()
.withReformatOnSave(preferencesService.getExportPreferences().shouldAlwaysReformatOnSave());
.withReformatOnSave(preferencesService.getGeneralPreferences().shouldAlwaysReformatOnSave());

BibDatabaseWriter databaseWriter = new BibtexDatabaseWriter(
bibWriter,
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/jabref/gui/LibraryTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ public void installAutosaveManagerAndBackupManager() {
private boolean isDatabaseReadyForAutoSave(BibDatabaseContext context) {
return ((context.getLocation() == DatabaseLocation.SHARED)
|| ((context.getLocation() == DatabaseLocation.LOCAL)
&& preferencesService.getExportPreferences().shouldAutoSave()))
&& preferencesService.getGeneralPreferences().shouldAutoSave()))
&& context.getDatabasePath().isPresent();
}

Expand All @@ -313,7 +313,7 @@ private boolean isDatabaseReadyForBackup(BibDatabaseContext context) {
* Example: *jabref-authors.bib – testbib
*/
public void updateTabTitle(boolean isChanged) {
boolean isAutosaveEnabled = preferencesService.getExportPreferences().shouldAutoSave();
boolean isAutosaveEnabled = preferencesService.getGeneralPreferences().shouldAutoSave();

DatabaseLocation databaseLocation = bibDatabaseContext.getLocation();
Optional<Path> file = bibDatabaseContext.getDatabasePath();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ private boolean saveDatabase(Path file, boolean selectedOnly, Charset encoding,

SaveConfiguration saveConfiguration = new SaveConfiguration()
.withSaveType(saveType)
.withReformatOnSave(preferences.getExportPreferences().shouldAlwaysReformatOnSave());
.withReformatOnSave(preferences.getGeneralPreferences().shouldAlwaysReformatOnSave());
BibDatabaseContext bibDatabaseContext = libraryTab.getBibDatabaseContext();
synchronized (bibDatabaseContext) {
try (AtomicFileWriter fileWriter = new AtomicFileWriter(file, encoding, saveConfiguration.shouldMakeBackup())) {
Expand Down
10 changes: 0 additions & 10 deletions src/main/java/org/jabref/gui/preferences/export/ExportTab.fxml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.Button?>
<?import javafx.scene.control.CheckBox?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.VBox?>
<?import org.jabref.gui.commonfxcontrols.SaveOrderConfigPanel?>
<fx:root spacing="10.0" type="VBox"
Expand All @@ -13,11 +10,4 @@

<Label styleClass="sectionHeader" text="%Export sort order"/>
<SaveOrderConfigPanel fx:id="exportOrderPanel"/>

<Label styleClass="sectionHeader" text="%Saving"/>
<CheckBox fx:id="alwaysReformatBib" text="%Always reformat BIB file on save and export"/>
<HBox alignment="CENTER_LEFT" spacing="10.0">
<CheckBox fx:id="autosaveLocalLibraries" text="%Autosave local libraries"/>
<Button fx:id="autosaveLocalLibrariesHelp"/>
</HBox>
</fx:root>
16 changes: 0 additions & 16 deletions src/main/java/org/jabref/gui/preferences/export/ExportTab.java
Original file line number Diff line number Diff line change
@@ -1,28 +1,17 @@
package org.jabref.gui.preferences.export;

import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;

import org.jabref.gui.Globals;
import org.jabref.gui.actions.ActionFactory;
import org.jabref.gui.actions.StandardActions;
import org.jabref.gui.commonfxcontrols.SaveOrderConfigPanel;
import org.jabref.gui.help.HelpAction;
import org.jabref.gui.preferences.AbstractPreferenceTabView;
import org.jabref.gui.preferences.PreferencesTab;
import org.jabref.logic.help.HelpFile;
import org.jabref.logic.l10n.Localization;

import com.airhacks.afterburner.views.ViewLoader;

public class ExportTab extends AbstractPreferenceTabView<ExportTabViewModel> implements PreferencesTab {
@FXML private SaveOrderConfigPanel exportOrderPanel;

@FXML private CheckBox alwaysReformatBib;
@FXML private CheckBox autosaveLocalLibraries;
@FXML private Button autosaveLocalLibrariesHelp;

public ExportTab() {
ViewLoader.view(this)
.root(this)
Expand All @@ -43,10 +32,5 @@ public void initialize() {
exportOrderPanel.sortableFieldsProperty().bind(viewModel.sortableFieldsProperty());
exportOrderPanel.sortCriteriaProperty().bindBidirectional(viewModel.sortCriteriaProperty());
exportOrderPanel.setCriteriaLimit(3);

alwaysReformatBib.selectedProperty().bindBidirectional(viewModel.alwaysReformatBibProperty());
autosaveLocalLibraries.selectedProperty().bindBidirectional(viewModel.autosaveLocalLibrariesProperty());
ActionFactory actionFactory = new ActionFactory(Globals.getKeyPrefs());
actionFactory.configureIconButton(StandardActions.HELP, new HelpAction(HelpFile.AUTOSAVE, dialogService), autosaveLocalLibrariesHelp);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ public class ExportTabViewModel implements PreferenceTabViewModel {
private final ListProperty<Field> sortableFieldsProperty = new SimpleListProperty<>(FXCollections.observableArrayList());
private final ListProperty<SortCriterionViewModel> sortCriteriaProperty = new SimpleListProperty<>(FXCollections.observableArrayList(new ArrayList<>()));

private final BooleanProperty alwaysReformatBibProperty = new SimpleBooleanProperty();
private final BooleanProperty autosaveLocalLibraries = new SimpleBooleanProperty();

private final ExportPreferences exportPreferences;

public ExportTabViewModel(ExportPreferences exportPreferences) {
Expand All @@ -50,9 +47,6 @@ public void setValues() {
List<Field> fieldNames = new ArrayList<>(FieldFactory.getCommonFields());
fieldNames.sort(Comparator.comparing(Field::getDisplayName));
sortableFieldsProperty.addAll(fieldNames);

alwaysReformatBibProperty.setValue(exportPreferences.shouldAlwaysReformatOnSave());
autosaveLocalLibraries.setValue(exportPreferences.shouldAutoSave());
}

@Override
Expand All @@ -61,9 +55,6 @@ public void storeSettings() {
SaveOrder.OrderType.fromBooleans(exportInSpecifiedOrderProperty.getValue(), exportInOriginalProperty.getValue()),
sortCriteriaProperty.stream().map(SortCriterionViewModel::getCriterion).toList());
exportPreferences.setExportSaveOrder(newSaveOrder);

exportPreferences.setAlwaysReformatOnSave(alwaysReformatBibProperty.getValue());
exportPreferences.setAutoSave(autosaveLocalLibraries.getValue());
}

public BooleanProperty saveInOriginalProperty() {
Expand All @@ -85,12 +76,4 @@ public ListProperty<Field> sortableFieldsProperty() {
public ListProperty<SortCriterionViewModel> sortCriteriaProperty() {
return sortCriteriaProperty;
}

public BooleanProperty alwaysReformatBibProperty() {
return alwaysReformatBibProperty;
}

public BooleanProperty autosaveLocalLibrariesProperty() {
return autosaveLocalLibraries;
}
}
14 changes: 14 additions & 0 deletions src/main/java/org/jabref/gui/preferences/library/LibraryTab.fxml
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.CheckBox?>
<?import javafx.scene.control.ComboBox?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.VBox?>
<fx:root spacing="10.0" type="VBox"
xmlns="http://javafx.com/javafx" xmlns:fx="http://javafx.com/fxml"
Expand All @@ -18,4 +22,14 @@
<Label text="%Default library mode"/>
<ComboBox fx:id="biblatexMode" prefWidth="200.0" GridPane.columnIndex="1"/>
</GridPane>

<Label styleClass="sectionHeader" text="%Saving"/>
<CheckBox fx:id="alwaysReformatBib" text="%Always reformat BIB file on save and export"/>
<HBox alignment="CENTER_LEFT" spacing="4.0">
<CheckBox fx:id="autosaveLocalLibraries" text="%Autosave local libraries"/>
<Button fx:id="autosaveLocalLibrariesHelp"/>
<padding>
<Insets top="-8.0"/>
</padding>
</HBox>
</fx:root>
15 changes: 15 additions & 0 deletions src/main/java/org/jabref/gui/preferences/library/LibraryTab.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
package org.jabref.gui.preferences.library;

import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
import javafx.scene.control.ComboBox;

import org.jabref.gui.Globals;
import org.jabref.gui.actions.ActionFactory;
import org.jabref.gui.actions.StandardActions;
import org.jabref.gui.help.HelpAction;
import org.jabref.gui.preferences.AbstractPreferenceTabView;
import org.jabref.gui.preferences.PreferencesTab;
import org.jabref.gui.util.ViewModelListCellFactory;
import org.jabref.logic.help.HelpFile;
import org.jabref.logic.l10n.Localization;
import org.jabref.model.database.BibDatabaseMode;

Expand All @@ -14,6 +21,9 @@
public class LibraryTab extends AbstractPreferenceTabView<LibraryTabViewModel> implements PreferencesTab {

@FXML private ComboBox<BibDatabaseMode> biblatexMode;
@FXML private CheckBox alwaysReformatBib;
@FXML private CheckBox autosaveLocalLibraries;
@FXML private Button autosaveLocalLibrariesHelp;

public LibraryTab() {
ViewLoader.view(this)
Expand All @@ -34,5 +44,10 @@ public void initialize() {
.install(biblatexMode);
biblatexMode.itemsProperty().bind(viewModel.biblatexModeListProperty());
biblatexMode.valueProperty().bindBidirectional(viewModel.selectedBiblatexModeProperty());

alwaysReformatBib.selectedProperty().bindBidirectional(viewModel.alwaysReformatBibProperty());
autosaveLocalLibraries.selectedProperty().bindBidirectional(viewModel.autosaveLocalLibrariesProperty());
ActionFactory actionFactory = new ActionFactory(Globals.getKeyPrefs());
actionFactory.configureIconButton(StandardActions.HELP, new HelpAction(HelpFile.AUTOSAVE, dialogService), autosaveLocalLibrariesHelp);
}
}
Original file line number Diff line number Diff line change
@@ -1,37 +1,48 @@
package org.jabref.gui.preferences.library;

import javafx.beans.property.BooleanProperty;
import javafx.beans.property.ListProperty;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.property.SimpleListProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.collections.FXCollections;

import org.jabref.gui.DialogService;
import org.jabref.gui.preferences.PreferenceTabViewModel;
import org.jabref.model.database.BibDatabaseMode;
import org.jabref.preferences.GeneralPreferences;
import org.jabref.preferences.LibraryPreferences;
import org.jabref.preferences.TelemetryPreferences;

public class LibraryTabViewModel implements PreferenceTabViewModel {

private final ListProperty<BibDatabaseMode> bibliographyModeListProperty = new SimpleListProperty<>();
private final ObjectProperty<BibDatabaseMode> selectedBiblatexModeProperty = new SimpleObjectProperty<>();

private final BooleanProperty alwaysReformatBibProperty = new SimpleBooleanProperty();
private final BooleanProperty autosaveLocalLibraries = new SimpleBooleanProperty();

private final DialogService dialogService;
private final GeneralPreferences generalPreferences;
private final LibraryPreferences libraryPreferences;

public LibraryTabViewModel(DialogService dialogService, GeneralPreferences generalPreferences, TelemetryPreferences telemetryPreferences) {
public LibraryTabViewModel(DialogService dialogService, LibraryPreferences libraryPreferences, TelemetryPreferences telemetryPreferences) {
this.dialogService = dialogService;
this.generalPreferences = generalPreferences;
this.libraryPreferences = libraryPreferences;
}

public void setValues() {
bibliographyModeListProperty.setValue(FXCollections.observableArrayList(BibDatabaseMode.values()));
selectedBiblatexModeProperty.setValue(generalPreferences.getDefaultBibDatabaseMode());
selectedBiblatexModeProperty.setValue(libraryPreferences.getDefaultBibDatabaseMode());

alwaysReformatBibProperty.setValue(libraryPreferences.shouldAlwaysReformatOnSave());
autosaveLocalLibraries.setValue(libraryPreferences.shouldAutoSave());
}

public void storeSettings() {
generalPreferences.setDefaultBibDatabaseMode(selectedBiblatexModeProperty.getValue());
libraryPreferences.setDefaultBibDatabaseMode(selectedBiblatexModeProperty.getValue());

libraryPreferences.setAlwaysReformatOnSave(alwaysReformatBibProperty.getValue());
libraryPreferences.setAutoSave(autosaveLocalLibraries.getValue());
}

public ListProperty<BibDatabaseMode> biblatexModeListProperty() {
Expand All @@ -41,4 +52,12 @@ public ListProperty<BibDatabaseMode> biblatexModeListProperty() {
public ObjectProperty<BibDatabaseMode> selectedBiblatexModeProperty() {
return this.selectedBiblatexModeProperty;
}

public BooleanProperty alwaysReformatBibProperty() {
return alwaysReformatBibProperty;
}

public BooleanProperty autosaveLocalLibrariesProperty() {
return autosaveLocalLibraries;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ void performBackup(Path backupPath) {
// code similar to org.jabref.gui.exporter.SaveDatabaseAction.saveDatabase
SaveConfiguration saveConfiguration = new SaveConfiguration()
.withMakeBackup(false)
.withReformatOnSave(preferences.getExportPreferences().shouldAlwaysReformatOnSave());
.withReformatOnSave(preferences.getGeneralPreferences().shouldAlwaysReformatOnSave());

Charset encoding = bibDatabaseContext.getMetaData().getEncoding().orElse(StandardCharsets.UTF_8);
// We want to have successful backups only
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ private void generateCiteKeys(BibDatabaseContext existingEntries, BibDatabase ta
private void writeResultToFile(Path pathToFile, BibDatabase entries) throws SaveException {
try (AtomicFileWriter fileWriter = new AtomicFileWriter(pathToFile, StandardCharsets.UTF_8)) {
SaveConfiguration saveConfiguration = new SaveConfiguration()
.withReformatOnSave(preferencesService.getExportPreferences().shouldAlwaysReformatOnSave());
.withReformatOnSave(preferencesService.getGeneralPreferences().shouldAlwaysReformatOnSave());
BibWriter bibWriter = new BibWriter(fileWriter, OS.NEWLINE);
BibtexDatabaseWriter databaseWriter = new BibtexDatabaseWriter(
bibWriter,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import org.jabref.model.texparser.LatexBibEntriesResolverResult;
import org.jabref.model.texparser.LatexParserResult;
import org.jabref.model.util.FileUpdateMonitor;
import org.jabref.preferences.GeneralPreferences;
import org.jabref.preferences.LibraryPreferences;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -27,13 +27,13 @@ public class TexBibEntriesResolver {
private static final Logger LOGGER = LoggerFactory.getLogger(TexBibEntriesResolver.class);

private final BibDatabase masterDatabase;
private final GeneralPreferences generalPreferences;
private final LibraryPreferences libraryPreferences;
private final ImportFormatPreferences importFormatPreferences;
private final FileUpdateMonitor fileMonitor;

public TexBibEntriesResolver(BibDatabase masterDatabase, GeneralPreferences generalPreferences, ImportFormatPreferences importFormatPreferences, FileUpdateMonitor fileMonitor) {
public TexBibEntriesResolver(BibDatabase masterDatabase, LibraryPreferences libraryPreferences, ImportFormatPreferences importFormatPreferences, FileUpdateMonitor fileMonitor) {
this.masterDatabase = masterDatabase;
this.generalPreferences = generalPreferences;
this.libraryPreferences = libraryPreferences;
this.importFormatPreferences = importFormatPreferences;
this.fileMonitor = fileMonitor;
}
Expand Down
38 changes: 4 additions & 34 deletions src/main/java/org/jabref/preferences/ExportPreferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,26 @@

import java.nio.file.Path;

import javafx.beans.property.BooleanProperty;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;

import org.jabref.model.metadata.SaveOrder;

public class ExportPreferences {
private final BooleanProperty alwaysReformatOnSave;

private final StringProperty lastExportExtension;
private final ObjectProperty<Path> exportWorkingDirectory;
private final ObjectProperty<SaveOrder> exportSaveOrder;
private final BooleanProperty autoSave;

public ExportPreferences(boolean alwaysReformatOnSave,
String lastExportExtension,
public ExportPreferences(String lastExportExtension,
Path exportWorkingDirectory,
SaveOrder exportSaveOrder,
boolean autoSave) {
this.alwaysReformatOnSave = new SimpleBooleanProperty(alwaysReformatOnSave);
SaveOrder exportSaveOrder) {

this.lastExportExtension = new SimpleStringProperty(lastExportExtension);
this.exportWorkingDirectory = new SimpleObjectProperty<>(exportWorkingDirectory);
this.exportSaveOrder = new SimpleObjectProperty<>(exportSaveOrder);
this.autoSave = new SimpleBooleanProperty(autoSave);
}

public boolean shouldAlwaysReformatOnSave() {
return alwaysReformatOnSave.get();
}

public BooleanProperty alwaysReformatOnSaveProperty() {
return alwaysReformatOnSave;
}

public void setAlwaysReformatOnSave(boolean alwaysReformatOnSave) {
this.alwaysReformatOnSave.set(alwaysReformatOnSave);
}

public String getLastExportExtension() {
Expand Down Expand Up @@ -77,16 +59,4 @@ public ObjectProperty<SaveOrder> exportSaveOrderProperty() {
public void setExportSaveOrder(SaveOrder exportSaveOrder) {
this.exportSaveOrder.set(exportSaveOrder);
}

public boolean shouldAutoSave() {
return autoSave.get();
}

public BooleanProperty autoSaveProperty() {
return autoSave;
}

public void setAutoSave(boolean shouldAutoSave) {
this.autoSave.set(shouldAutoSave);
}
}
Loading