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

FullTextSearch: Make check of existing PDFs optional #673

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv
### Added

- When importing entries form the "Citation relations" tab, the field [cites](https://docs.jabref.org/advanced/entryeditor/entrylinks) is now filled according to the relationship between the entries. [#10572](https://github.com/JabRef/jabref/pull/10752)
- Added a configuration option to enable fulltext search not checking all attached files upon start for modifications (disabled as default).

### Changed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@

<Label styleClass="sectionHeader" text="%Fulltext Index"/>
<CheckBox fx:id="fulltextIndex" text="%Automatically index all linked files for fulltext search"/>
<CheckBox fx:id="fulltextIndexLinkedFilesShouldCheckForModifications" text="%Indexed files should be checked for modifications on startup"/>

<Label styleClass="sectionHeader" text="%Linked file name conventions"/>
<GridPane hgap="4.0" vgap="4.0">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public class LinkedFilesTab extends AbstractPreferenceTabView<LinkedFilesTabView
@FXML private TextField autolinkRegexKey;

@FXML private CheckBox fulltextIndex;
@FXML private CheckBox fulltextIndexLinkedFilesShouldCheckForModifications;

@FXML private ComboBox<String> fileNamePattern;
@FXML private TextField fileDirectoryPattern;
Expand Down Expand Up @@ -66,6 +67,8 @@ public void initialize() {
autolinkRegexKey.textProperty().bindBidirectional(viewModel.autolinkRegexKeyProperty());
autolinkRegexKey.disableProperty().bind(autolinkUseRegex.selectedProperty().not());
fulltextIndex.selectedProperty().bindBidirectional(viewModel.fulltextIndexProperty());
fulltextIndexLinkedFilesShouldCheckForModifications.selectedProperty().bindBidirectional(viewModel.fulltextIndexLinkedFilesShouldCheckForModificationsProperty());
fulltextIndexLinkedFilesShouldCheckForModifications.disableProperty().bind(fulltextIndex.selectedProperty().not());
fileNamePattern.valueProperty().bindBidirectional(viewModel.fileNamePatternProperty());
fileNamePattern.itemsProperty().bind(viewModel.defaultFileNamePatternsProperty());
fileDirectoryPattern.textProperty().bindBidirectional(viewModel.fileDirectoryPatternProperty());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public class LinkedFilesTabViewModel implements PreferenceTabViewModel {
private final ListProperty<String> defaultFileNamePatternsProperty =
new SimpleListProperty<>(FXCollections.observableArrayList(FilePreferences.DEFAULT_FILENAME_PATTERNS));
private final BooleanProperty fulltextIndex = new SimpleBooleanProperty();
private final BooleanProperty fulltextIndexLinkedFilesShouldCheckForModifications = new SimpleBooleanProperty();
private final StringProperty fileNamePatternProperty = new SimpleStringProperty();
private final StringProperty fileDirectoryPatternProperty = new SimpleStringProperty();

Expand Down Expand Up @@ -78,6 +79,7 @@ public void setValues() {
useMainFileDirectoryProperty.setValue(!filePreferences.shouldStoreFilesRelativeToBibFile());
useBibLocationAsPrimaryProperty.setValue(filePreferences.shouldStoreFilesRelativeToBibFile());
fulltextIndex.setValue(filePreferences.shouldFulltextIndexLinkedFiles());
fulltextIndexLinkedFilesShouldCheckForModifications.setValue(filePreferences.shouldFulltextIndexLinkedFilesShouldCheckForModifications());
fileNamePatternProperty.setValue(filePreferences.getFileNamePattern());
fileDirectoryPatternProperty.setValue(filePreferences.getFileDirectoryPattern());

Expand All @@ -99,6 +101,7 @@ public void storeSettings() {
filePreferences.setFileNamePattern(fileNamePatternProperty.getValue());
filePreferences.setFileDirectoryPattern(fileDirectoryPatternProperty.getValue());
filePreferences.setFulltextIndexLinkedFiles(fulltextIndex.getValue());
filePreferences.setFulltextIndexLinkedFilesShouldCheckForModifications(fulltextIndexLinkedFilesShouldCheckForModifications.getValue());

// Autolink preferences
if (autolinkFileStartsBibtexProperty.getValue()) {
Expand Down Expand Up @@ -163,6 +166,10 @@ public BooleanProperty fulltextIndexProperty() {
return fulltextIndex;
}

public BooleanProperty fulltextIndexLinkedFilesShouldCheckForModificationsProperty() {
return fulltextIndexLinkedFilesShouldCheckForModifications;
}

public ListProperty<String> defaultFileNamePatternsProperty() {
return defaultFileNamePatternsProperty;
}
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/org/jabref/preferences/FilePreferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class FilePreferences {
private final StringProperty fileDirectoryPattern = new SimpleStringProperty();
private final BooleanProperty downloadLinkedFiles = new SimpleBooleanProperty();
private final BooleanProperty fulltextIndexLinkedFiles = new SimpleBooleanProperty();
private final BooleanProperty fulltextIndexLinkedFilesShouldCheckForModifications = new SimpleBooleanProperty();
private final ObjectProperty<Path> workingDirectory = new SimpleObjectProperty<>();
private final ObservableSet<ExternalFileType> externalFileTypes = FXCollections.observableSet(new TreeSet<>(Comparator.comparing(ExternalFileType::getName)));
private final BooleanProperty createBackup = new SimpleBooleanProperty();
Expand All @@ -44,6 +45,7 @@ public FilePreferences(String userAndHost,
String fileDirectoryPattern,
boolean downloadLinkedFiles,
boolean fulltextIndexLinkedFiles,
boolean fulltextIndexLinkedFilesShouldCheckForModifications,
Path workingDirectory,
Set<ExternalFileType> externalFileTypes,
boolean createBackup,
Expand All @@ -55,6 +57,7 @@ public FilePreferences(String userAndHost,
this.fileDirectoryPattern.setValue(fileDirectoryPattern);
this.downloadLinkedFiles.setValue(downloadLinkedFiles);
this.fulltextIndexLinkedFiles.setValue(fulltextIndexLinkedFiles);
this.fulltextIndexLinkedFilesShouldCheckForModifications.setValue(fulltextIndexLinkedFilesShouldCheckForModifications);
this.workingDirectory.setValue(workingDirectory);
this.externalFileTypes.addAll(externalFileTypes);
this.createBackup.setValue(createBackup);
Expand Down Expand Up @@ -141,6 +144,18 @@ public void setFulltextIndexLinkedFiles(boolean shouldFulltextIndexLinkedFiles)
this.fulltextIndexLinkedFiles.set(shouldFulltextIndexLinkedFiles);
}

public boolean shouldFulltextIndexLinkedFilesShouldCheckForModifications() {
return fulltextIndexLinkedFilesShouldCheckForModifications.get();
}

public BooleanProperty fulltextIndexLinkedFilesShouldCheckForModifications() {
return fulltextIndexLinkedFilesShouldCheckForModifications;
}

public void setFulltextIndexLinkedFilesShouldCheckForModifications(boolean shouldFulltextIndexLinkedFilesShouldCheckForModifications) {
this.fulltextIndexLinkedFilesShouldCheckForModifications.set(shouldFulltextIndexLinkedFilesShouldCheckForModifications);
}

public Path getWorkingDirectory() {
return workingDirectory.get();
}
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/org/jabref/preferences/JabRefPreferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,9 @@ public class JabRefPreferences implements PreferencesService {
// Dialog states
private static final String PREFS_EXPORT_PATH = "prefsExportPath";
private static final String DOWNLOAD_LINKED_FILES = "downloadLinkedFiles";

private static final String FULLTEXT_INDEX_LINKED_FILES = "fulltextIndexLinkedFiles";
private static final String FULLTEXT_INDEX_LINKED_FILES_SHOULD_CHECK_FOR_MODIFICATIONS = "fulltextIndexLinkedFilesShouldCheckForModifications";

// Helper string
private static final String USER_HOME = System.getProperty("user.home");
Expand Down Expand Up @@ -764,6 +766,8 @@ private JabRefPreferences() {
defaults.put(DOWNLOAD_LINKED_FILES, true);
// Create Fulltext-Index by default
defaults.put(FULLTEXT_INDEX_LINKED_FILES, true);
// On JabRef startup, do not check for modifications by default
defaults.put(FULLTEXT_INDEX_LINKED_FILES_SHOULD_CHECK_FOR_MODIFICATIONS, false);

String defaultExpression = "**/.*[citationkey].*\\\\.[extension]";
defaults.put(AUTOLINK_REG_EXP_SEARCH_EXPRESSION_KEY, defaultExpression);
Expand Down Expand Up @@ -2186,6 +2190,7 @@ public FilePreferences getFilePreferences() {
get(IMPORT_FILEDIRPATTERN),
getBoolean(DOWNLOAD_LINKED_FILES),
getBoolean(FULLTEXT_INDEX_LINKED_FILES),
getBoolean(FULLTEXT_INDEX_LINKED_FILES_SHOULD_CHECK_FOR_MODIFICATIONS),
Path.of(get(WORKING_DIRECTORY)),
ExternalFileTypes.fromString(get(EXTERNAL_FILE_TYPES)),
getBoolean(CREATE_BACKUP),
Expand All @@ -2198,6 +2203,7 @@ public FilePreferences getFilePreferences() {
EasyBind.listen(filePreferences.fileDirectoryPatternProperty(), (obs, oldValue, newValue) -> put(IMPORT_FILEDIRPATTERN, newValue));
EasyBind.listen(filePreferences.downloadLinkedFilesProperty(), (obs, oldValue, newValue) -> putBoolean(DOWNLOAD_LINKED_FILES, newValue));
EasyBind.listen(filePreferences.fulltextIndexLinkedFilesProperty(), (obs, oldValue, newValue) -> putBoolean(FULLTEXT_INDEX_LINKED_FILES, newValue));
EasyBind.listen(filePreferences.fulltextIndexLinkedFilesShouldCheckForModifications(), (obs, oldValue, newValue) -> putBoolean(FULLTEXT_INDEX_LINKED_FILES_SHOULD_CHECK_FOR_MODIFICATIONS, newValue));
EasyBind.listen(filePreferences.workingDirectoryProperty(), (obs, oldValue, newValue) -> put(WORKING_DIRECTORY, newValue.toString()));
filePreferences.getExternalFileTypes().addListener((SetChangeListener<ExternalFileType>) c ->
put(EXTERNAL_FILE_TYPES, ExternalFileTypes.toStringList(filePreferences.getExternalFileTypes())));
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/l10n/JabRef_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2459,6 +2459,7 @@ Select\ directory=Select directory

Fulltext\ Index=Fulltext Index
Automatically\ index\ all\ linked\ files\ for\ fulltext\ search=Automatically index all linked files for fulltext search
Indexed\ files\ should\ be\ checked\ for\ modifications\ on\ startup=Indexed files should be checked for modifications on startup
Rebuild\ fulltext\ search\ index=Rebuild fulltext search index
Rebuild\ fulltext\ search\ index\ for\ current\ library?=Rebuild fulltext search index for current library?
Rebuilding\ fulltext\ search\ index...=Rebuilding fulltext search index...
Expand Down
Loading