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

Groups: Searching for keywords field mandatory value not checked #6110

Merged
merged 3 commits into from
Mar 31, 2020
Merged
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
15 changes: 11 additions & 4 deletions src/main/java/org/jabref/gui/groups/GroupDialogView.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import java.util.EnumMap;

import javafx.application.Platform;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.ButtonType;
import javafx.scene.control.CheckBox;
import javafx.scene.control.ColorPicker;
Expand Down Expand Up @@ -59,8 +61,8 @@ public class GroupDialogView extends BaseDialog<AbstractGroup> {

@FXML private TextField texGroupFilePath;

private final EnumMap<GroupHierarchyType,String> hierarchyText = new EnumMap<>(GroupHierarchyType.class);
private final EnumMap<GroupHierarchyType,String> hierarchyToolTip = new EnumMap<>(GroupHierarchyType.class);
private final EnumMap<GroupHierarchyType, String> hierarchyText = new EnumMap<>(GroupHierarchyType.class);
private final EnumMap<GroupHierarchyType, String> hierarchyToolTip = new EnumMap<>(GroupHierarchyType.class);

private final ControlsFxVisualizer validationVisualizer = new ControlsFxVisualizer();
private final GroupDialogViewModel viewModel;
Expand All @@ -80,6 +82,10 @@ public GroupDialogView(DialogService dialogService, BibDatabaseContext currentDa

setResultConverter(viewModel::resultConverter);
getDialogPane().getButtonTypes().setAll(ButtonType.OK, ButtonType.CANCEL);

final Button confirmDialogButton = (Button) getDialogPane().lookupButton(ButtonType.OK);
// handle validation before closing dialog and calling resultConverter
confirmDialogButton.addEventFilter(ActionEvent.ACTION, viewModel::validationHandler);
}

@FXML
Expand Down Expand Up @@ -135,11 +141,12 @@ public void initialize() {
validationVisualizer.initVisualization(viewModel.searchSearchTermEmptyValidationStatus(), searchGroupSearchTerm);
validationVisualizer.initVisualization(viewModel.keywordRegexValidationStatus(), keywordGroupSearchTerm);
validationVisualizer.initVisualization(viewModel.keywordSearchTermEmptyValidationStatus(), keywordGroupSearchTerm);
validationVisualizer.initVisualization(viewModel.keywordFieldEmptyValidationStatus(), keywordGroupSearchField);
});

// Binding to the button throws a NPE, since it doesn't exist yet. Working around.
viewModel.validationStatus().validProperty().addListener((obs, oldValue, newValue) -> {
if (newValue) {
viewModel.validationStatus().validProperty().addListener((obs, _oldValue, validationStatus) -> {
if (validationStatus) {
getDialogPane().lookupButton(ButtonType.OK).setDisable(false);
} else {
getDialogPane().lookupButton(ButtonType.OK).setDisable(true);
Expand Down
Loading