Skip to content

Commit

Permalink
move "Warn about duplicates on import" preferences option (#8937)
Browse files Browse the repository at this point in the history
  • Loading branch information
christinait2022 authored Jul 3, 2022
1 parent 050cd3f commit 1301384
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 13 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,11 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
- We improved group expansion arrow that prevent it from activating group when expanding or collapsing. [#7982](https://github.com/JabRef/jabref/issues/7982), [#3176](https://github.com/JabRef/jabref/issues/3176)
- When configured SSL certificates changed, JabRef warns the user to restart to apply the configuration.
- We improved the appearances and logic of the "Manage field names & content" dialog, and renamed it to "Automatic field editor". [#6536](https://github.com/JabRef/jabref/issues/6536)
- We fixed an issue that caused JabRef to sometimes open multiple instances when "Remote Operation" is enabled. [#8653](https://github.com/JabRef/jabref/issues/8653)
- We moved the preferences option "Warn about duplicates on import" option from the tab "File" to the tab "Import and Export". [kopper#570](https://github.com/koppor/jabref/issues/570)

### Fixed

- We fixed an issue that caused JabRef to sometimes open multiple instances when "Remote Operation" is enabled. [#8653](https://github.com/JabRef/jabref/issues/8653)
- We fixed an issue where linked files with the filetype "application/pdf" in an entry were not shown with the correct PDF-Icon in the main table [8930](https://github.com/JabRef/jabref/issues/8930)
- We fixed an issue where "open folder" for linked files did not open the folder and did not select the file unter certain Linux desktop environments [#8679](https://github.com/JabRef/jabref/issues/8679), [#8849](https://github.com/JabRef/jabref/issues/8849)
- We fixed an issue where the content of a big shared database library is not shown [#8788](https://github.com/JabRef/jabref/issues/8788)
Expand Down
1 change: 0 additions & 1 deletion src/main/java/org/jabref/gui/preferences/file/FileTab.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,4 @@
</HBox>

<CheckBox fx:id="alwaysReformatBib" text="%Always reformat BIB file on save and export"/>
<CheckBox fx:id="warnAboutDuplicatesOnImport" text="%Warn about duplicates on import"/>
</fx:root>
2 changes: 0 additions & 2 deletions src/main/java/org/jabref/gui/preferences/file/FileTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public class FileTab extends AbstractPreferenceTabView<FileTabViewModel> impleme
@FXML private RadioButton resolveStrings;
@FXML private TextField resolveStringsForFields;
@FXML private CheckBox alwaysReformatBib;
@FXML private CheckBox warnAboutDuplicatesOnImport;

@FXML private CheckBox autosaveLocalLibraries;
@FXML private Button autosaveLocalLibrariesHelp;
Expand All @@ -48,7 +47,6 @@ public void initialize() {
resolveStringsForFields.disableProperty().bind(doNotResolveStrings.selectedProperty());

alwaysReformatBib.selectedProperty().bindBidirectional(viewModel.alwaysReformatBibProperty());
warnAboutDuplicatesOnImport.selectedProperty().bindBidirectional(viewModel.warnAboutDuplicatesOnImportProperty());
autosaveLocalLibraries.selectedProperty().bindBidirectional(viewModel.autosaveLocalLibrariesProperty());

ActionFactory actionFactory = new ActionFactory(Globals.getKeyPrefs());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ public class FileTabViewModel implements PreferenceTabViewModel {
private final BooleanProperty resolveStringsProperty = new SimpleBooleanProperty();
private final StringProperty resolveStringsForFieldsProperty = new SimpleStringProperty("");
private final BooleanProperty alwaysReformatBibProperty = new SimpleBooleanProperty();
private final BooleanProperty warnAboutDuplicatesOnImportProperty = new SimpleBooleanProperty();
private final BooleanProperty autosaveLocalLibraries = new SimpleBooleanProperty();

private final ImportExportPreferences importExportPreferences;
Expand All @@ -34,7 +33,6 @@ public void setValues() {
resolveStringsProperty.setValue(importExportPreferences.resolveStrings());
resolveStringsForFieldsProperty.setValue(importExportPreferences.getResolvableFields());
alwaysReformatBibProperty.setValue(importExportPreferences.shouldAlwaysReformatOnSave());
warnAboutDuplicatesOnImportProperty.setValue(importExportPreferences.shouldWarnAboutDuplicatesOnImport());
autosaveLocalLibraries.setValue(importExportPreferences.shouldAutoSave());
}

Expand All @@ -45,7 +43,6 @@ public void storeSettings() {
importExportPreferences.setNonWrappableFields(noWrapFilesProperty.getValue().trim());
importExportPreferences.setResolvableFields(resolveStringsForFieldsProperty.getValue().trim());
importExportPreferences.setAlwaysReformatOnSave(alwaysReformatBibProperty.getValue());
importExportPreferences.setWarnAboutDuplicatesOnImport(warnAboutDuplicatesOnImportProperty.getValue());
importExportPreferences.setAutoSave(autosaveLocalLibraries.getValue());
}

Expand Down Expand Up @@ -77,10 +74,6 @@ public BooleanProperty alwaysReformatBibProperty() {
return alwaysReformatBibProperty;
}

public BooleanProperty warnAboutDuplicatesOnImportProperty() {
return warnAboutDuplicatesOnImportProperty;
}

// Autosave
public BooleanProperty autosaveLocalLibrariesProperty() {
return autosaveLocalLibraries;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

<Label styleClass="sectionHeader" text="%General"/>
<CheckBox fx:id="generateNewKeyOnImport" text="%Generate a new key for imported entries (overwriting their default)"/>
<CheckBox fx:id="warnAboutDuplicatesOnImport" text="%Warn about duplicates on import"/>

<Label styleClass="sectionHeader" text="%Custom DOI URI"/>
<HBox alignment="CENTER_LEFT" spacing="10.0">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public class ImportExportTab extends AbstractPreferenceTabView<ImportExportTabVi
@FXML private CheckBox grobidEnabled;
@FXML private TextField grobidURL;

@FXML private CheckBox warnAboutDuplicatesOnImport;

public ImportExportTab() {
ViewLoader.view(this)
.root(this)
Expand All @@ -44,7 +46,7 @@ public String getTabName() {
}

public void initialize() {
this.viewModel = new ImportExportTabViewModel(preferencesService, preferencesService.getDOIPreferences(), dialogService);
this.viewModel = new ImportExportTabViewModel(preferencesService, preferencesService.getDOIPreferences(), dialogService, preferencesService.getImportExportPreferences());

useCustomDOI.selectedProperty().bindBidirectional(viewModel.useCustomDOIProperty());
useCustomDOIName.textProperty().bindBidirectional(viewModel.useCustomDOINameProperty());
Expand Down Expand Up @@ -85,6 +87,8 @@ public void initialize() {

// Content is set later
viewModel.fetcherApiKeys().addListener((InvalidationListener) change -> apiKeySelector.getSelectionModel().selectFirst());

warnAboutDuplicatesOnImport.selectedProperty().bindBidirectional(viewModel.warnAboutDuplicatesOnImportProperty());
}

private void updateFetcherApiKey(FetcherApiKey apiKey) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.jabref.model.entry.field.Field;
import org.jabref.model.entry.field.FieldFactory;
import org.jabref.model.metadata.SaveOrderConfig;
import org.jabref.preferences.ImportExportPreferences;
import org.jabref.preferences.PreferencesService;

public class ImportExportTabViewModel implements PreferenceTabViewModel {
Expand All @@ -55,26 +56,30 @@ public class ImportExportTabViewModel implements PreferenceTabViewModel {

private final BooleanProperty grobidEnabledProperty = new SimpleBooleanProperty();
private final StringProperty grobidURLProperty = new SimpleStringProperty("");
private final BooleanProperty warnAboutDuplicatesOnImportProperty = new SimpleBooleanProperty();

private final DialogService dialogService;
private final PreferencesService preferencesService;
private final DOIPreferences doiPreferences;
private final ImporterPreferences importerPreferences;
private final SaveOrderConfig initialExportOrder;
private final ImportExportPreferences importExportPreferences;

public ImportExportTabViewModel(PreferencesService preferencesService, DOIPreferences doiPreferences, DialogService dialogService) {
public ImportExportTabViewModel(PreferencesService preferencesService, DOIPreferences doiPreferences, DialogService dialogService, ImportExportPreferences importExportPreferences) {
this.dialogService = dialogService;
this.preferencesService = preferencesService;
this.importerPreferences = preferencesService.getImporterPreferences();
this.doiPreferences = doiPreferences;
this.initialExportOrder = preferencesService.getExportSaveOrder();
this.importExportPreferences = importExportPreferences;
}

@Override
public void setValues() {
generateKeyOnImportProperty.setValue(importerPreferences.isGenerateNewKeyOnImport());
useCustomDOIProperty.setValue(doiPreferences.isUseCustom());
useCustomDOINameProperty.setValue(doiPreferences.getDefaultBaseURI());
warnAboutDuplicatesOnImportProperty.setValue(importExportPreferences.shouldWarnAboutDuplicatesOnImport());

switch (initialExportOrder.getOrderType()) {
case SPECIFIED -> exportInSpecifiedOrderProperty.setValue(true);
Expand Down Expand Up @@ -111,6 +116,8 @@ public void storeSettings() {
sortCriteriaProperty.stream().map(SortCriterionViewModel::getCriterion).toList());
preferencesService.storeExportSaveOrder(newSaveOrderConfig);

importExportPreferences.setWarnAboutDuplicatesOnImport(warnAboutDuplicatesOnImportProperty.getValue());

// API keys
preferencesService.getImporterPreferences().getApiKeys().clear();
preferencesService.getImporterPreferences().getApiKeys().addAll(apiKeys);
Expand Down Expand Up @@ -166,6 +173,10 @@ public ObjectProperty<FetcherApiKey> selectedApiKeyProperty() {
return selectedApiKeyProperty;
}

public BooleanProperty warnAboutDuplicatesOnImportProperty() {
return warnAboutDuplicatesOnImportProperty;
}

public void checkCustomApiKey() {
final String apiKeyName = selectedApiKeyProperty.get().getName();

Expand Down

0 comments on commit 1301384

Please sign in to comment.