Skip to content

Commit

Permalink
Groups: Searching for keywords field mandatory value not checked
Browse files Browse the repository at this point in the history
Fixes #6108
  • Loading branch information
stefan-kolb committed Mar 13, 2020
1 parent 23034ce commit 3bd8a82
Show file tree
Hide file tree
Showing 2 changed files with 112 additions and 36 deletions.
1 change: 1 addition & 0 deletions src/main/java/org/jabref/gui/groups/GroupDialogView.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ 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.
Expand Down
147 changes: 111 additions & 36 deletions src/main/java/org/jabref/gui/groups/GroupDialogViewModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ public class GroupDialogViewModel {
private Validator nameContainsDelimiterValidator;
private Validator sameNameValidator;
private Validator keywordRegexValidator;
private Validator keywordFieldEmptyValidator;
private Validator keywordSearchTermEmptyValidator;
private Validator searchRegexValidator;
private Validator searchSearchTermEmptyValidator;
Expand Down Expand Up @@ -173,6 +174,11 @@ private void setupValidation() {
Localization.lang("Keywords"),
Localization.lang("Invalid regular expression."))));

keywordFieldEmptyValidator = new FunctionBasedValidator<>(
keywordGroupSearchFieldProperty,
StringUtil::isNotBlank,
ValidationMessage.error(Localization.lang("Please enter a field name to search for keywords.")));

keywordSearchTermEmptyValidator = new FunctionBasedValidator<>(
keywordGroupSearchTermProperty,
input -> !StringUtil.isNullOrEmpty(input),
Expand Down Expand Up @@ -214,15 +220,15 @@ private void setupValidation() {

validator.addValidators(nameValidator, sameNameValidator);

typeSearchProperty.addListener((obs,oldVal,newVal) -> {
typeSearchProperty.addListener((obs, oldVal, newVal) -> {
if (newVal) {
validator.addValidators(searchRegexValidator, searchSearchTermEmptyValidator);
} else {
validator.removeValidators(searchRegexValidator, searchSearchTermEmptyValidator);
}
});

typeKeywordsProperty.addListener((obs,oldVal,newVal) -> {
typeKeywordsProperty.addListener((obs, oldVal, newVal) -> {
if (newVal) {
validator.addValidators(keywordRegexValidator, keywordSearchTermEmptyValidator);
} else {
Expand Down Expand Up @@ -304,7 +310,6 @@ public AbstractGroup resultConverter(ButtonType button) {
} else {
return null;
}

} catch (IllegalArgumentException | IOException exception) {
dialogService.showErrorDialogAndWait(exception.getLocalizedMessage(), exception);
return null;
Expand Down Expand Up @@ -397,69 +402,139 @@ private List<Path> getFileDirectoriesAsPaths() {
return fileDirs;
}

public ValidationStatus validationStatus() { return validator.getValidationStatus(); }
public ValidationStatus validationStatus() {
return validator.getValidationStatus();
}

public ValidationStatus nameValidationStatus() { return nameValidator.getValidationStatus(); }
public ValidationStatus nameValidationStatus() {
return nameValidator.getValidationStatus();
}

public ValidationStatus nameContainsDelimiterValidationStatus() { return nameContainsDelimiterValidator.getValidationStatus(); }
public ValidationStatus nameContainsDelimiterValidationStatus() {
return nameContainsDelimiterValidator.getValidationStatus();
}

public ValidationStatus sameNameValidationStatus() { return sameNameValidator.getValidationStatus(); }
public ValidationStatus sameNameValidationStatus() {
return sameNameValidator.getValidationStatus();
}

public ValidationStatus searchRegexValidationStatus() { return searchRegexValidator.getValidationStatus(); }
public ValidationStatus searchRegexValidationStatus() {
return searchRegexValidator.getValidationStatus();
}

public ValidationStatus searchSearchTermEmptyValidationStatus() { return searchSearchTermEmptyValidator.getValidationStatus(); }
public ValidationStatus searchSearchTermEmptyValidationStatus() {
return searchSearchTermEmptyValidator.getValidationStatus();
}

public ValidationStatus keywordRegexValidationStatus() { return keywordRegexValidator.getValidationStatus(); }
public ValidationStatus keywordRegexValidationStatus() {
return keywordRegexValidator.getValidationStatus();
}

public ValidationStatus keywordSearchTermEmptyValidationStatus() { return keywordSearchTermEmptyValidator.getValidationStatus(); }
public ValidationStatus keywordFieldEmptyValidationStatus() {
return keywordFieldEmptyValidator.getValidationStatus();
}

public StringProperty nameProperty() { return nameProperty; }
public ValidationStatus keywordSearchTermEmptyValidationStatus() {
return keywordSearchTermEmptyValidator.getValidationStatus();
}

public StringProperty descriptionProperty() { return descriptionProperty; }
public StringProperty nameProperty() {
return nameProperty;
}

public StringProperty iconProperty() { return iconProperty; }
public StringProperty descriptionProperty() {
return descriptionProperty;
}

public ObjectProperty<Color> colorFieldProperty() { return colorProperty; }
public StringProperty iconProperty() {
return iconProperty;
}

public ListProperty<GroupHierarchyType> groupHierarchyListProperty() { return groupHierarchyListProperty; }
public ObjectProperty<Color> colorFieldProperty() {
return colorProperty;
}

public ListProperty<GroupHierarchyType> groupHierarchyListProperty() {
return groupHierarchyListProperty;
}

public ObjectProperty<GroupHierarchyType> groupHierarchySelectedProperty() { return groupHierarchySelectedProperty; }
public ObjectProperty<GroupHierarchyType> groupHierarchySelectedProperty() {
return groupHierarchySelectedProperty;
}

public BooleanProperty typeExplicitProperty() { return typeExplicitProperty; }
public BooleanProperty typeExplicitProperty() {
return typeExplicitProperty;
}

public BooleanProperty typeKeywordsProperty() { return typeKeywordsProperty; }
public BooleanProperty typeKeywordsProperty() {
return typeKeywordsProperty;
}

public BooleanProperty typeSearchProperty() { return typeSearchProperty; }
public BooleanProperty typeSearchProperty() {
return typeSearchProperty;
}

public BooleanProperty typeAutoProperty() { return typeAutoProperty; }
public BooleanProperty typeAutoProperty() {
return typeAutoProperty;
}

public BooleanProperty typeTexProperty() { return typeTexProperty; }
public BooleanProperty typeTexProperty() {
return typeTexProperty;
}

public StringProperty keywordGroupSearchTermProperty() { return keywordGroupSearchTermProperty; }
public StringProperty keywordGroupSearchTermProperty() {
return keywordGroupSearchTermProperty;
}

public StringProperty keywordGroupSearchFieldProperty() { return keywordGroupSearchFieldProperty; }
public StringProperty keywordGroupSearchFieldProperty() {
return keywordGroupSearchFieldProperty;
}

public BooleanProperty keywordGroupCaseSensitiveProperty() { return keywordGroupCaseSensitiveProperty; }
public BooleanProperty keywordGroupCaseSensitiveProperty() {
return keywordGroupCaseSensitiveProperty;
}

public BooleanProperty keywordGroupRegexProperty() { return keywordGroupRegexProperty; }
public BooleanProperty keywordGroupRegexProperty() {
return keywordGroupRegexProperty;
}

public StringProperty searchGroupSearchTermProperty() { return searchGroupSearchTermProperty; }
public StringProperty searchGroupSearchTermProperty() {
return searchGroupSearchTermProperty;
}

public BooleanProperty searchGroupCaseSensitiveProperty() { return searchGroupCaseSensitiveProperty; }
public BooleanProperty searchGroupCaseSensitiveProperty() {
return searchGroupCaseSensitiveProperty;
}

public BooleanProperty searchGroupRegexProperty() { return searchGroupRegexProperty; }
public BooleanProperty searchGroupRegexProperty() {
return searchGroupRegexProperty;
}

public BooleanProperty autoGroupKeywordsOptionProperty() { return autoGroupKeywordsOptionProperty; }
public BooleanProperty autoGroupKeywordsOptionProperty() {
return autoGroupKeywordsOptionProperty;
}

public StringProperty autoGroupKeywordsFieldProperty() { return autoGroupKeywordsFieldProperty; }
public StringProperty autoGroupKeywordsFieldProperty() {
return autoGroupKeywordsFieldProperty;
}

public StringProperty autoGroupKeywordsDeliminatorProperty() { return autoGroupKeywordsDelimiterProperty; }
public StringProperty autoGroupKeywordsDeliminatorProperty() {
return autoGroupKeywordsDelimiterProperty;
}

public StringProperty autoGroupKeywordsHierarchicalDeliminatorProperty() { return autoGroupKeywordsHierarchicalDelimiterProperty; }
public StringProperty autoGroupKeywordsHierarchicalDeliminatorProperty() {
return autoGroupKeywordsHierarchicalDelimiterProperty;
}

public BooleanProperty autoGroupPersonsOptionProperty() { return autoGroupPersonsOptionProperty; }
public BooleanProperty autoGroupPersonsOptionProperty() {
return autoGroupPersonsOptionProperty;
}

public StringProperty autoGroupPersonsFieldProperty() { return autoGroupPersonsFieldProperty; }
public StringProperty autoGroupPersonsFieldProperty() {
return autoGroupPersonsFieldProperty;
}

public StringProperty texGroupFilePathProperty() { return texGroupFilePathProperty; }
public StringProperty texGroupFilePathProperty() {
return texGroupFilePathProperty;
}
}

0 comments on commit 3bd8a82

Please sign in to comment.