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

Add query validation for web search #7809

Merged
merged 18 commits into from
Jun 21, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Fix CSS
Co-authored-by: Carl Christian Snethlage <50491877+calixtus@users.noreply.github.com>
Co-authored-by: Christoph <siedlerkiller@gmail.com>
  • Loading branch information
3 people committed Jun 21, 2021
commit 28cf9cb8e2d5243da99622436272d67093d7751e
4 changes: 4 additions & 0 deletions src/main/java/org/jabref/gui/Base.css
Original file line number Diff line number Diff line change
Expand Up @@ -1236,3 +1236,7 @@ TextFlow * {
.fontsizeSpinner{
-fx-pref-width: 5em;
}

.text-field:invalid {
-fx-background-color: rgba(240, 128, 128, 0.5);
}
13 changes: 6 additions & 7 deletions src/main/java/org/jabref/gui/importer/fetcher/WebSearchPane.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import javafx.scene.control.Button;
import javafx.scene.control.ComboBox;
import javafx.scene.control.TextField;
import javafx.scene.control.Tooltip;
import javafx.scene.input.KeyCode;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Priority;
Expand Down Expand Up @@ -78,17 +79,15 @@ protected Node createContentPane() {
TextField query = SearchTextField.create();
query.getStyleClass().add("searchBar");

// Weird issue: viewModel.queryValidationStatus().not() does not work...
BindingsHelper.includePseudoClassWhen(query, QUERY_INVALID, viewModel.queryValidationStatus().validProperty().not());

viewModel.queryProperty().bind(query.textProperty());
TextField queryValid = new TextField();
EasyBind.subscribe(viewModel.queryValidationStatus().validProperty(),
valid -> {
if (!valid && viewModel.queryValidationStatus().getHighestMessage().isPresent()) {
queryValid.setText(viewModel.queryValidationStatus().getHighestMessage().get().getMessage());
query.setTooltip(new Tooltip(viewModel.queryValidationStatus().getHighestMessage().get().getMessage()));
query.pseudoClassStateChanged(QUERY_INVALID, true);
} else {
queryValid.setText("");
query.setTooltip(null);
query.pseudoClassStateChanged(QUERY_INVALID, false);
}
});

Expand All @@ -107,7 +106,7 @@ protected Node createContentPane() {
// Put everything together
VBox container = new VBox();
container.setAlignment(Pos.CENTER);
container.getChildren().addAll(fetcherContainer, query, search, queryValid);
container.getChildren().addAll(fetcherContainer, query, search);
return container;
}

Expand Down