Search in sources :

Example 1 with HOGMQueryError

use of com.sri.ai.praise.sgsolver.solver.HOGMQueryError in project aic-praise by aic-sri-international.

the class QueryController method displayQueryErrors.

private void displayQueryErrors(String query, List<HOGMQueryError> queryErrors, ParsedHOGModel parsedModel, long millisecondsToCompute) {
    String title = "Query '" + query + "' encountered " + queryErrors.size() + " error(s) when attempting to compute answer (" + duration("took ", millisecondsToCompute) + ")";
    ListView<HOGMQueryError> errors = new ListView<>(FXCollections.observableList(queryErrors));
    //errors.setFixedCellSize(24);
    errors.setPrefHeight(24 * 5);
    errors.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
    errors.getSelectionModel().selectedIndexProperty().addListener((obs, oldValue, newValue) -> {
        if (newValue.intValue() >= 0) {
            HOGMQueryError qError = errors.getItems().get(newValue.intValue());
            if (qError.getContext() == HOGMQueryError.Context.MODEL) {
                modelPageEditor.highlight(qError.getStartContextIndex(), qError.getEndContextIndex());
            } else if (qError.getContext() == HOGMQueryError.Context.QUERY) {
                queryComboBox.getEditor().selectAll();
            }
        }
    });
    Node resultContent = null;
    if (SGSolverDemoController.isInDebugMode()) {
        HOGMCodeArea parsedModelArea = createParsedModelView(parsedModel);
        TabPane resultTabs = new TabPane();
        resultTabs.getTabs().add(new Tab("Errors", errors));
        resultTabs.getTabs().add(new Tab("Parsed As", parsedModelArea));
        resultContent = resultTabs;
    } else {
        resultContent = errors;
    }
    TitledPane resultPane = new TitledPane(title, resultContent);
    FXUtil.setTitledPaneIcon(resultPane, FontAwesomeIcons.TIMES);
    showResultPane(resultPane);
    errors.getSelectionModel().selectFirst();
}
Also used : TitledPane(javafx.scene.control.TitledPane) TabPane(javafx.scene.control.TabPane) ListView(javafx.scene.control.ListView) HOGMCodeArea(com.sri.ai.praise.sgsolver.demo.editor.HOGMCodeArea) Tab(javafx.scene.control.Tab) HOGMQueryError(com.sri.ai.praise.sgsolver.solver.HOGMQueryError) Node(javafx.scene.Node)

Aggregations

HOGMCodeArea (com.sri.ai.praise.sgsolver.demo.editor.HOGMCodeArea)1 HOGMQueryError (com.sri.ai.praise.sgsolver.solver.HOGMQueryError)1 Node (javafx.scene.Node)1 ListView (javafx.scene.control.ListView)1 Tab (javafx.scene.control.Tab)1 TabPane (javafx.scene.control.TabPane)1 TitledPane (javafx.scene.control.TitledPane)1