Skip to content

Commit

Permalink
Merge branch 'main' into fixReflection
Browse files Browse the repository at this point in the history
  • Loading branch information
LoayGhreeb committed Aug 15, 2024
2 parents 3a298ef + b397e1d commit d1bb125
Show file tree
Hide file tree
Showing 29 changed files with 414 additions and 31 deletions.
2 changes: 1 addition & 1 deletion src/main/java/org/jabref/gui/preferences/ai/AiTab.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
<Label styleClass="sectionHeader" text="%Expert settings" />
<VBox>
<children>
<Label text="%These parameters affect how the AI will answer you questions." />
<Label text="%These parameters affect how the AI will answer your questions." />
<Label text="%Leave these fields as is, if you are not sure of their purpose." />
</children>
</VBox>
Expand Down
51 changes: 29 additions & 22 deletions src/main/java/org/jabref/gui/search/GlobalSearchBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
import org.jabref.preferences.PreferencesService;
import org.jabref.preferences.SearchPreferences;

import com.tobiasdiez.easybind.EasyBind;
import impl.org.controlsfx.skin.AutoCompletePopup;
import org.controlsfx.control.textfield.AutoCompletionBinding;
import org.controlsfx.control.textfield.CustomTextField;
Expand All @@ -90,14 +91,15 @@ public class GlobalSearchBar extends HBox {
private final ToggleButton keepSearchString;
private final ToggleButton filterModeButton;
private final Tooltip searchFieldTooltip = new Tooltip();
private final Label currentResults = new Label("");
private final StateManager stateManager;
private final PreferencesService preferencesService;
private final UndoManager undoManager;
private final LibraryTabContainer tabContainer;
private final SearchPreferences searchPreferences;
private final DialogService dialogService;
private final BooleanProperty globalSearchActive = new SimpleBooleanProperty(false);
private final BooleanProperty illegalSearch = new SimpleBooleanProperty(false);
private final BooleanProperty invalidRegex = new SimpleBooleanProperty(false);
private GlobalSearchResultDialog globalSearchResultDialog;
private final SearchType searchType;

Expand All @@ -121,19 +123,29 @@ public GlobalSearchBar(LibraryTabContainer tabContainer,
searchField = SearchTextField.create(keyBindingRepository);
searchField.disableProperty().bind(needsDatabase(stateManager).not());

Label currentResults = new Label();
// fits the standard "found x entries"-message thus hinders the searchbar to jump around while searching if the tabContainer width is too small
currentResults.setPrefWidth(150);
currentResults.visibleProperty().bind(stateManager.activeSearchQuery(searchType).isPresent());
currentResults.textProperty().bind(Bindings.createStringBinding(() -> {
int matched = stateManager.searchResultSize(searchType).get();
if (matched == 0) {
searchField.pseudoClassStateChanged(CLASS_NO_RESULTS, true);
return Localization.lang("No results found.");
} else {
searchField.pseudoClassStateChanged(CLASS_RESULTS_FOUND, true);
return Localization.lang("Found %0 results.", String.valueOf(matched));
}
}, stateManager.searchResultSize(searchType)));

currentResults.textProperty().bind(EasyBind.combine(
stateManager.searchResultSize(searchType), illegalSearch, invalidRegex,
(matched, illegal, invalid) -> {
if (illegal) {
searchField.pseudoClassStateChanged(CLASS_NO_RESULTS, true);
return Localization.lang("Search failed: illegal search expression");
} else if (invalid) {
searchField.pseudoClassStateChanged(CLASS_NO_RESULTS, true);
return Localization.lang("Invalid regular expression");
} else if (matched.intValue() == 0) {
searchField.pseudoClassStateChanged(CLASS_NO_RESULTS, true);
return Localization.lang("No results found.");
} else {
searchField.pseudoClassStateChanged(CLASS_RESULTS_FOUND, true);
return Localization.lang("Found %0 results.", String.valueOf(matched));
}
}
));

searchField.setTooltip(searchFieldTooltip);
searchFieldTooltip.setContentDisplay(ContentDisplay.GRAPHIC_ONLY);
Expand Down Expand Up @@ -331,14 +343,18 @@ public void updateSearchQuery() {

// Invalid regular expression
if (regularExpressionButton.isSelected() && !validRegex()) {
currentResults.setText(Localization.lang("Invalid regular expression"));
invalidRegex.setValue(true);
return;
} else {
invalidRegex.setValue(false);
}

SearchQuery searchQuery = new SearchQuery(this.searchField.getText(), searchPreferences.getSearchFlags());
if (!searchQuery.isValid()) {
informUserAboutInvalidSearchQuery();
illegalSearch.set(true);
return;
} else {
illegalSearch.set(false);
}
stateManager.activeSearchQuery(searchType).set(Optional.of(searchQuery));
}
Expand All @@ -353,15 +369,6 @@ private boolean validRegex() {
return true;
}

private void informUserAboutInvalidSearchQuery() {
searchField.pseudoClassStateChanged(CLASS_NO_RESULTS, true);

stateManager.activeSearchQuery(searchType).set(Optional.empty());

String illegalSearch = Localization.lang("Search failed: illegal search expression");
currentResults.setText(illegalSearch);
}

public void setAutoCompleter(SuggestionProvider<Author> searchCompleter) {
if (preferencesService.getAutoCompletePreferences().shouldAutoComplete()) {
AutoCompletionTextInputBinding<Author> autoComplete = AutoCompletionTextInputBinding.autoComplete(searchField,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public GenerateEmbeddingsTask(String citationKey,
this.bibDatabaseContext = bibDatabaseContext;
this.filePreferences = filePreferences;

titleProperty().set(Localization.lang("Generating embeddings for for %0", citationKey));
titleProperty().set(Localization.lang("Generating embeddings for %0", citationKey));
showToUser(true);

progressCounter.listenToAllProperties(this::updateProgress);
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/l10n/JabRef_ar.properties
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,9 @@ Swap\ content=مبادلة المحتوى
Copy\ or\ move\ the\ content\ of\ one\ field\ to\ another=نسخ أو نقل محتوى حقل إلى آخر


# AI





Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/l10n/JabRef_da.properties
Original file line number Diff line number Diff line change
Expand Up @@ -990,6 +990,9 @@ Default\ pattern=Standardmønster





# AI



Expand Down
Loading

0 comments on commit d1bb125

Please sign in to comment.