Search in sources :

Example 1 with ModelPageEditor

use of com.sri.ai.praise.sgsolver.demo.editor.ModelPageEditor in project aic-praise by aic-sri-international.

the class AbstractPerspective method addPage.

@Override
public void addPage(Integer atPageIndex) {
    Platform.runLater(() -> {
        final ModelPageEditor currentPage = modelPageEditors.get(atPageIndex).get();
        Supplier<ModelPageEditor> addSupplier = new ModelPageEditorSupplier(currentPage.getCurrentPageContents(), currentPage.getCurrentQueries());
        addPage(atPageIndex, addSupplier);
        pageChanges.emit(new AddPageChange(atPageIndex, addSupplier));
    });
}
Also used : ModelPageEditor(com.sri.ai.praise.sgsolver.demo.editor.ModelPageEditor)

Example 2 with ModelPageEditor

use of com.sri.ai.praise.sgsolver.demo.editor.ModelPageEditor in project aic-praise by aic-sri-international.

the class HOGMPerspective method create.

@Override
protected ModelPageEditor create(String model, List<String> defaultQueries) {
    ModelPageEditor result = null;
    FXMLLoader loader = HOGMPageEditorController.newLoader();
    try {
        loader.load();
        result = loader.getController();
        result.setPage(model, defaultQueries);
    } catch (Throwable t) {
        FXUtil.exception(t);
    }
    return result;
}
Also used : FXMLLoader(javafx.fxml.FXMLLoader) ModelPageEditor(com.sri.ai.praise.sgsolver.demo.editor.ModelPageEditor)

Example 3 with ModelPageEditor

use of com.sri.ai.praise.sgsolver.demo.editor.ModelPageEditor in project aic-praise by aic-sri-international.

the class SGSolverDemoController method callCurrentModelPageEditor.

private void callCurrentModelPageEditor(Consumer<ModelPageEditor> caller) {
    int currentPageIdx = modelPagination.getCurrentPageIndex();
    if (perspective.getModelPageEditors().containsKey(currentPageIdx)) {
        ModelPageEditor modelPage = perspective.getModelPageEditors().get(currentPageIdx).get();
        caller.accept(modelPage);
    }
}
Also used : ModelPageEditor(com.sri.ai.praise.sgsolver.demo.editor.ModelPageEditor)

Example 4 with ModelPageEditor

use of com.sri.ai.praise.sgsolver.demo.editor.ModelPageEditor in project aic-praise by aic-sri-international.

the class AbstractPerspective method bindModelPageEditorUndoManager.

protected void bindModelPageEditorUndoManager(Integer currentPageIdx) {
    if (modelPageEditors.containsKey(currentPageIdx)) {
        ModelPageEditor mpe = modelPageEditors.get().get(currentPageIdx).get();
        canUndoModelPageEdit.unbind();
        canRedoModelPageEdit.unbind();
        canUndoModelPageEdit.bind(mpe.getUndoManager().undoAvailableProperty());
        canRedoModelPageEdit.bind(mpe.getUndoManager().redoAvailableProperty());
    }
}
Also used : ModelPageEditor(com.sri.ai.praise.sgsolver.demo.editor.ModelPageEditor)

Example 5 with ModelPageEditor

use of com.sri.ai.praise.sgsolver.demo.editor.ModelPageEditor in project aic-praise by aic-sri-international.

the class AbstractPerspective method saveAs.

@Override
public void saveAs(File file) {
    List<Pair<String, List<String>>> pageContents = new ArrayList<>();
    this.modelPageEditors.values().forEach(mes -> {
        ModelPageEditorSupplier mpeSupplier = (ModelPageEditorSupplier) mes;
        if (mpeSupplier.modelPageEditor == null) {
            pageContents.add(new Pair<>(mpeSupplier.modelPage, mpeSupplier.defaultQueries));
        } else {
            ModelPageEditor mpe = mpeSupplier.get();
            pageContents.add(new Pair<>(mpe.getCurrentPageContents(), mpe.getCurrentQueries()));
        }
    });
    String model = getPagedModelInternalContainerRepresentation(pageContents);
    try {
        Files.write(model.getBytes(PagedModelContainer.FILE_CHARSET), file);
        // If saving to a different file
        if (file != getModelFile()) {
            modelFile.set(file);
        }
        // Once saved we can clear the undo histories
        undoManagersForgetHistory();
    } catch (IOException ioe) {
        FXUtil.exception(ioe);
    }
}
Also used : ArrayList(java.util.ArrayList) IOException(java.io.IOException) Pair(com.sri.ai.util.base.Pair) ModelPageEditor(com.sri.ai.praise.sgsolver.demo.editor.ModelPageEditor)

Aggregations

ModelPageEditor (com.sri.ai.praise.sgsolver.demo.editor.ModelPageEditor)6 Pair (com.sri.ai.util.base.Pair)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 FXMLLoader (javafx.fxml.FXMLLoader)1 Node (javafx.scene.Node)1