use of com.faforever.client.query.LogicalNodeController in project downlords-faf-client by FAForever.
the class SearchControllerTest method setUp.
@Before
public void setUp() throws Exception {
when(uiService.loadFxml("theme/vault/search/logical_node.fxml")).thenAnswer(invocation -> {
LogicalNodeController controller = mock(LogicalNodeController.class);
controller.logicalOperatorField = new ChoiceBox<>();
controller.specificationController = mock(SpecificationController.class);
controller.specificationController.propertyField = new ComboBox<>();
controller.specificationController.operationField = new ChoiceBox<>();
controller.specificationController.valueField = new ComboBox<>();
when(controller.getRoot()).thenReturn(new Pane());
return controller;
});
when(preferencesService.getPreferences()).thenReturn(new Preferences());
instance = new SearchController(uiService, i18n, preferencesService);
loadFxml("theme/vault/search/search.fxml", clazz -> {
if (SpecificationController.class.isAssignableFrom(clazz)) {
return specificationController;
}
if (LogicalNodeController.class.isAssignableFrom(clazz)) {
return logicalNodeController;
}
return instance;
});
instance.setSearchableProperties(SearchableProperties.GAME_PROPERTIES);
instance.setSortConfig(preferencesService.getPreferences().getVaultPrefs().onlineReplaySortConfigProperty());
}
use of com.faforever.client.query.LogicalNodeController in project downlords-faf-client by FAForever.
the class SearchController method onAddCriteriaButtonClicked.
public void onAddCriteriaButtonClicked() {
LogicalNodeController controller = uiService.loadFxml("theme/vault/search/logical_node.fxml");
controller.logicalOperatorField.valueProperty().addListener(queryInvalidationListener);
controller.specificationController.setRootType(rootType);
controller.specificationController.setProperties(searchableProperties);
controller.setRemoveCriteriaButtonListener(() -> {
criteriaPane.getChildren().remove(controller.getRoot());
queryNodes.remove(controller);
if (queryNodes.isEmpty()) {
initialLogicalNodeController.logicalOperatorField.setVisible(false);
}
});
addInvalidationListener(controller);
criteriaPane.getChildren().add(controller.getRoot());
queryNodes.add(controller);
initialLogicalNodeController.logicalOperatorField.setVisible(true);
}
use of com.faforever.client.query.LogicalNodeController in project downlords-faf-client by FAForever.
the class SearchController method buildQuery.
/**
* Builds the query string if possible, returns empty string if not. A query string can not be built if the user
* selected no or invalid values.
*/
private String buildQuery(SpecificationController initialSpecification, List<LogicalNodeController> queryNodes) {
QBuilder qBuilder = new QBuilder();
Optional<Condition> condition = initialSpecification.appendTo(qBuilder);
if (!condition.isPresent()) {
return "";
}
for (LogicalNodeController queryNode : queryNodes) {
Optional<Condition> currentCondition = queryNode.appendTo(condition.get());
if (!currentCondition.isPresent()) {
break;
}
condition = currentCondition;
}
return (String) condition.get().query(new RSQLVisitor());
}
Aggregations