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 #9839

Merged
merged 12 commits into from
May 5, 2023
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
- We moved the preferences menu command from the options menu to the file menu. [#9768](https://github.com/JabRef/jabref/pull/9768)
- 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)

### Fixed

Expand Down Expand Up @@ -75,7 +75,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
- We removed the support of BibTeXML. [#9540](https://github.com/JabRef/jabref/issues/9540)
- We removed support for Markdown syntax for strikethrough and task lists in comment fields. [#9726](https://github.com/JabRef/jabref/pull/9726)
- We removed the options menu, because the two contents were moved to the File menu or the properties of the library. [#9768](https://github.com/JabRef/jabref/pull/9768)

- We removed the 'File' tab in the preferences and moved its contents to the 'Export' tab. [#9839](https://github.com/JabRef/jabref/pull/9839)



Expand Down
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.getImportExportPreferences().shouldAlwaysReformatOnSave());
.withReformatOnSave(preferencesService.getExportPreferences().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.getImportExportPreferences().shouldAutoSave()))
&& preferencesService.getExportPreferences().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.getImportExportPreferences().shouldAutoSave();
boolean isAutosaveEnabled = preferencesService.getExportPreferences().shouldAutoSave();

DatabaseLocation databaseLocation = bibDatabaseContext.getLocation();
Optional<Path> file = bibDatabaseContext.getDatabasePath();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void execute() {
List<BibEntry> entries = stateManager.getSelectedEntries();

DirectoryDialogConfiguration dirDialogConfiguration = new DirectoryDialogConfiguration.Builder()
.withInitialDirectory(preferencesService.getImportExportPreferences().getExportWorkingDirectory())
.withInitialDirectory(preferencesService.getExportPreferences().getExportWorkingDirectory())
.build();
Optional<Path> exportPath = dialogService.showDirectorySelectionDialog(dirDialogConfiguration);
exportPath.ifPresent(path -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public CreateModifyExporterDialogViewModel(ExporterViewModel exporter,
public ExporterViewModel saveExporter() {
Path layoutFileDir = Path.of(layoutFile.get()).getParent();
if (layoutFileDir != null) {
preferences.getImportExportPreferences().setExportWorkingDirectory(layoutFileDir);
preferences.getExportPreferences().setExportWorkingDirectory(layoutFileDir);
}

// Check that there are no empty strings.
Expand All @@ -85,7 +85,7 @@ public void browse() {
FileDialogConfiguration fileDialogConfiguration = new FileDialogConfiguration.Builder()
.addExtensionFilter(Localization.lang("Custom layout file"), StandardFileType.LAYOUT)
.withDefaultExtension(Localization.lang("Custom layout file"), StandardFileType.LAYOUT)
.withInitialDirectory(preferences.getImportExportPreferences().getExportWorkingDirectory()).build();
.withInitialDirectory(preferences.getExportPreferences().getExportWorkingDirectory()).build();
dialogService.showFileOpenDialog(fileDialogConfiguration).ifPresent(f -> layoutFile.set(f.toAbsolutePath().toString()));
}

Expand Down
8 changes: 4 additions & 4 deletions src/main/java/org/jabref/gui/exporter/ExportCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ public void execute() {

FileDialogConfiguration fileDialogConfiguration = new FileDialogConfiguration.Builder()
.addExtensionFilter(FileFilterConverter.exporterToExtensionFilter(exporters))
.withDefaultExtension(preferences.getImportExportPreferences().getLastExportExtension())
.withInitialDirectory(preferences.getImportExportPreferences().getExportWorkingDirectory())
.withDefaultExtension(preferences.getExportPreferences().getLastExportExtension())
.withInitialDirectory(preferences.getExportPreferences().getExportWorkingDirectory())
.build();
dialogService.showFileSaveDialog(fileDialogConfiguration)
.ifPresent(path -> export(path, fileDialogConfiguration.getSelectedExtensionFilter(), exporters));
Expand Down Expand Up @@ -110,8 +110,8 @@ private void export(Path file, FileChooser.ExtensionFilter selectedExtensionFilt

// Make sure we remember which filter was used, to set
// the default for next time:
preferences.getImportExportPreferences().setLastExportExtension(format.getName());
preferences.getImportExportPreferences().setExportWorkingDirectory(file.getParent());
preferences.getExportPreferences().setLastExportExtension(format.getName());
preferences.getExportPreferences().setExportWorkingDirectory(file.getParent());

final List<BibEntry> finEntries = entries;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public void execute() {

// Find default choice, if any
Exporter defaultChoice = exporters.stream()
.filter(exporter -> exporter.getName().equals(preferences.getImportExportPreferences().getLastExportExtension()))
.filter(exporter -> exporter.getName().equals(preferences.getExportPreferences().getLastExportExtension()))
.findAny()
.orElse(null);

Expand All @@ -107,7 +107,7 @@ private ExportResult exportToClipboard(Exporter exporter) throws Exception {
.orElse(List.of(preferences.getFilePreferences().getWorkingDirectory()));

// Add chosen export type to last used preference, to become default
preferences.getImportExportPreferences().setLastExportExtension(exporter.getName());
preferences.getExportPreferences().setLastExportExtension(exporter.getName());

Path tmp = null;
try {
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.getImportExportPreferences().shouldAlwaysReformatOnSave());
.withReformatOnSave(preferences.getExportPreferences().shouldAlwaysReformatOnSave());
BibDatabaseContext bibDatabaseContext = libraryTab.getBibDatabaseContext();
synchronized (bibDatabaseContext) {
try (AtomicFileWriter fileWriter = new AtomicFileWriter(file, encoding, saveConfiguration.shouldMakeBackup())) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/jabref/gui/importer/ImportCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public void execute() {
.addExtensionFilter(FileFilterConverter.ANY_FILE)
.addExtensionFilter(FileFilterConverter.forAllImporters(importers))
.addExtensionFilter(FileFilterConverter.importerToExtensionFilter(importers))
.withInitialDirectory(preferences.getImportExportPreferences().getImportWorkingDirectory())
.withInitialDirectory(preferences.getImporterPreferences().getImportWorkingDirectory())
.build();
dialogService.showFileOpenDialog(fileDialogConfiguration)
.ifPresent(path -> doImport(path, importers, fileDialogConfiguration.getSelectedExtensionFilter()));
Expand All @@ -71,6 +71,6 @@ private void doImport(Path file, SortedSet<Importer> importers, FileChooser.Exte
ImportAction importMenu = new ImportAction(frame, openInNew, format.orElse(null), preferences);
importMenu.automatedImport(Collections.singletonList(file.toString()));
// Set last working dir for import
preferences.getImportExportPreferences().setImportWorkingDirectory(file.getParent());
preferences.getImporterPreferences().setImportWorkingDirectory(file.getParent());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public boolean hasDuplicate(BibEntry entry) {
public void importEntries(List<BibEntry> entriesToImport, boolean shouldDownloadFiles) {
// Check if we are supposed to warn about duplicates.
// If so, then see if there are duplicates, and warn if yes.
if (preferences.getImportExportPreferences().shouldWarnAboutDuplicatesOnImport()) {
if (preferences.getImporterPreferences().shouldWarnAboutDuplicatesOnImport()) {
BackgroundTask.wrap(() -> entriesToImport.stream()
.anyMatch(this::hasDuplicate)).onSuccess(duplicateFound -> {
if (duplicateFound) {
Expand All @@ -135,7 +135,7 @@ public void importEntries(List<BibEntry> entriesToImport, boolean shouldDownload
Localization.lang("Continue with import"),
Localization.lang("Cancel import"),
Localization.lang("Do not ask again"),
optOut -> preferences.getImportExportPreferences().setWarnAboutDuplicatesOnImport(!optOut));
optOut -> preferences.getImporterPreferences().setWarnAboutDuplicatesOnImport(!optOut));

if (!continueImport) {
dialogService.notify(Localization.lang("Import canceled"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public SavingPropertiesViewModel(BibDatabaseContext databaseContext, Preferences
this.preferencesService = preferencesService;
this.initialMetaData = databaseContext.getMetaData();
this.exportSaveOrder = initialMetaData.getSaveOrderConfig()
.orElseGet(() -> preferencesService.getImportExportPreferences().getExportSaveOrder());
.orElseGet(() -> preferencesService.getExportPreferences().getExportSaveOrder());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,12 @@
import org.jabref.gui.preferences.customimporter.CustomImporterTab;
import org.jabref.gui.preferences.entry.EntryTab;
import org.jabref.gui.preferences.entryeditor.EntryEditorTab;
import org.jabref.gui.preferences.entryeditortabs.CustomEditorFieldsTab;
import org.jabref.gui.preferences.entryeditortabs.EntryEditorTabsTab;
import org.jabref.gui.preferences.export.ExportTab;
import org.jabref.gui.preferences.external.ExternalTab;
import org.jabref.gui.preferences.externalfiletypes.ExternalFileTypesTab;
import org.jabref.gui.preferences.file.FileTab;
import org.jabref.gui.preferences.general.GeneralTab;
import org.jabref.gui.preferences.groups.GroupsTab;
import org.jabref.gui.preferences.importexport.ImportExportTab;
import org.jabref.gui.preferences.journals.JournalAbbreviationsTab;
import org.jabref.gui.preferences.keybindings.KeyBindingsTab;
import org.jabref.gui.preferences.linkedfiles.LinkedFilesTab;
Expand All @@ -34,6 +33,7 @@
import org.jabref.gui.preferences.preview.PreviewTab;
import org.jabref.gui.preferences.protectedterms.ProtectedTermsTab;
import org.jabref.gui.preferences.table.TableTab;
import org.jabref.gui.preferences.websearch.WebSearchTab;
import org.jabref.gui.preferences.xmp.XmpPrivacyTab;
import org.jabref.gui.util.FileDialogConfiguration;
import org.jabref.logic.JabRefException;
Expand Down Expand Up @@ -62,7 +62,6 @@ public PreferencesDialogViewModel(DialogService dialogService, PreferencesServic
preferenceTabs = FXCollections.observableArrayList(
new GeneralTab(),
new KeyBindingsTab(),
new FileTab(),
new EntryTab(),
new TableTab(),
new PreviewTab(),
Expand All @@ -72,8 +71,9 @@ public PreferencesDialogViewModel(DialogService dialogService, PreferencesServic
new JournalAbbreviationsTab(),
new GroupsTab(),
new EntryEditorTab(),
new ImportExportTab(),
new CustomEditorFieldsTab(),
new WebSearchTab(),
new ExportTab(),
new EntryEditorTabsTab(),
new CitationKeyPatternTab(),
new LinkedFilesTab(),
new NameFormatterTab(),
Expand Down
23 changes: 22 additions & 1 deletion src/main/java/org/jabref/gui/preferences/entry/EntryTab.fxml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?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.Label?>
Expand All @@ -12,9 +13,29 @@
fx:controller="org.jabref.gui.preferences.entry.EntryTab">
<Label styleClass="titleHeader" text="%Entry"/>

<Label styleClass="sectionHeader" text="%Field"/>
<HBox spacing="4" alignment="CENTER_LEFT">
<Label text="%Keyword separator"/>
<TextField fx:id="keywordSeparator" minWidth="30.0" maxWidth="30.0"/>
<TextField fx:id="keywordSeparator" minWidth="30.0" maxWidth="30.0" alignment="CENTER"/>
</HBox>

<CheckBox fx:id="resolveStrings" text="%Resolve BibTeX strings"/>
<HBox alignment="CENTER_LEFT" spacing="10.0">
<Label text="%Affected fields"/>
<TextField fx:id="resolveStringsForFields" HBox.hgrow="ALWAYS"
disable="${!resolveStrings.selected}">
<HBox.margin>
<Insets top="-4.0"/>
</HBox.margin>
</TextField>
<padding>
<Insets left="20.0"/>
</padding>
</HBox>

<HBox alignment="CENTER_LEFT" spacing="10.0">
<Label text="%Do not wrap when saving"/>
<TextField fx:id="nonWrappableFields" HBox.hgrow="ALWAYS"/>
</HBox>

<Label styleClass="sectionHeader" text="%Entry owner"/>
Expand Down
13 changes: 9 additions & 4 deletions src/main/java/org/jabref/gui/preferences/entry/EntryTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ public class EntryTab extends AbstractPreferenceTabView<EntryTabViewModel> imple

@FXML private TextField keywordSeparator;

@FXML private CheckBox resolveStrings;
@FXML private TextField resolveStringsForFields;
@FXML private TextField nonWrappableFields;

@FXML private CheckBox markOwner;
@FXML private TextField markOwnerName;
@FXML private CheckBox markOwnerOverwrite;
Expand All @@ -38,13 +42,14 @@ public EntryTab() {
}

public void initialize() {
this.viewModel = new EntryTabViewModel(
preferencesService.getBibEntryPreferences(),
preferencesService.getOwnerPreferences(),
preferencesService.getTimestampPreferences());
this.viewModel = new EntryTabViewModel(preferencesService);

keywordSeparator.textProperty().bindBidirectional(viewModel.keywordSeparatorProperty());

resolveStrings.selectedProperty().bindBidirectional(viewModel.resolveStringsProperty());
resolveStringsForFields.textProperty().bindBidirectional(viewModel.resolveStringsForFieldsProperty());
nonWrappableFields.textProperty().bindBidirectional(viewModel.nonWrappableFieldsProperty());

markOwner.selectedProperty().bindBidirectional(viewModel.markOwnerProperty());
markOwnerName.textProperty().bindBidirectional(viewModel.markOwnerNameProperty());
markOwnerName.disableProperty().bind(markOwner.selectedProperty().not());
Expand Down
Loading