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));
});
}
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;
}
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);
}
}
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());
}
}
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);
}
}
Aggregations