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

move "Warn about duplicates on import" preferences option #8937

Merged
merged 6 commits into from
Jul 3, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
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
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve

### Changed

- Change in the color of the selection entries and the color of the summary in the Import Entries Dialog. [#7927](https://github.com/JabRef/jabref/issues/7927)
- The file column in the main table now shows the corresponding defined icon for the linked file [8930](https://github.com/JabRef/jabref/issues/8930).
- We improved the color of the selected entries and the color of the summary in the Import Entries Dialog in the dark theme. [#7927](https://github.com/JabRef/jabref/issues/7927)
- We upgraded to Lucene 9.2 for the fulltext search.
Thus, the now created search index cannot be read from older versions of JabRef anylonger.
⚠️ JabRef will recreate the index in a new folder for new files and this will take a long time for a huge library.
Expand All @@ -37,6 +38,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve

### Fixed

- 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)
- We fixed the unnecessary horizontal scroll bar in group panel [#8467](https://github.com/JabRef/jabref/issues/8467)
Expand All @@ -48,6 +50,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
- We fixed an issue where the exception that there are invalid characters in filename. [#8786](https://github.com/JabRef/jabref/issues/8786)
- When the proxy configuration removed the proxy user/password, this change is applied immediately.
- We fixed an issue where removing several groups deletes only one of them. [#8390](https://github.com/JabRef/jabref/issues/8390)
- We fixed an issue where "Warn about duplicates on import" option now under Perferences -> Import and Export. [kopper#570](https://github.com/koppor/jabref/issues/570)

### Removed

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