use of org.phoenicis.engines.dto.EngineCategoryDTO in project POL-POM-5 by PlayOnLinux.
the class EnginesController method fetchEngineSubcategories.
/**
* Fetches all engine subcategories that belong to a given list of engine categories
*
* @param engineCategories The engine categories
* @param result The temporary transport variable
* @param callback A callback method, which is called after all engine subcategories have been fetched
*/
private void fetchEngineSubcategories(Queue<EngineCategoryDTO> engineCategories, Map<EngineCategoryDTO, List<EngineSubCategoryDTO>> result, Consumer<Map<EngineCategoryDTO, List<EngineSubCategoryDTO>>> callback) {
final Queue<EngineCategoryDTO> queue = new ArrayDeque<>(engineCategories);
if (queue.isEmpty()) {
// recursion anchor
callback.accept(result);
} else {
final EngineCategoryDTO engineCategory = queue.poll();
final String engineId = engineCategory.getName().toLowerCase();
enginesManager.fetchAvailableVersions(engineId, versions -> {
// recursively process the remaining engine categories
fetchEngineSubcategories(queue, ImmutableMap.<EngineCategoryDTO, List<EngineSubCategoryDTO>>builder().putAll(result).put(engineCategory, versions).build(), callback);
}, e -> Platform.runLater(() -> {
final ErrorDialog errorDialog = ErrorDialog.builder().withMessage(tr("Error")).withException(e).withOwner(this.enginesView.getContent().getScene().getWindow()).build();
errorDialog.showAndWait();
}));
}
}
use of org.phoenicis.engines.dto.EngineCategoryDTO in project POL-POM-5 by PlayOnLinux.
the class EnginesSource method fetchAvailableEngines.
public void fetchAvailableEngines(Consumer<List<EngineCategoryDTO>> callback) {
final InteractiveScriptSession interactiveScriptSession = scriptInterpreter.createInteractiveSession();
List<EngineCategoryDTO> engines = new ArrayList<>();
interactiveScriptSession.eval("include([\"Functions\", \"Engines\", \"Wine\"]);", ignored -> interactiveScriptSession.eval("new Wine().getAvailableVersions()", output -> {
EngineCategoryDTO wine = new EngineCategoryDTO.Builder().withName("Wine").withDescription("Wine").withSubCategories(unSerialize(output)).build();
engines.add(wine);
callback.accept(engines);
}, this::throwError), this::throwError);
}
use of org.phoenicis.engines.dto.EngineCategoryDTO in project phoenicis by PhoenicisOrg.
the class EnginesSource method fetchAvailableEngines.
public void fetchAvailableEngines(List<CategoryDTO> categoryDTOS, Consumer<List<EngineCategoryDTO>> callback) {
final InteractiveScriptSession interactiveScriptSession = scriptInterpreter.createInteractiveSession();
StringBuilder includesBuilder = new StringBuilder();
StringBuilder constructorsBuilder = new StringBuilder();
constructorsBuilder.append("function fetchEngines() {\n");
constructorsBuilder.append("var engines = [];\n");
for (CategoryDTO categoryDTO : categoryDTOS) {
final String engineName = categoryDTO.getName();
includesBuilder.append("include([\"Engines\", \"" + engineName + "\", \"Engine\", \"Object\"]);\n");
constructorsBuilder.append("engines[\"" + engineName + "\"] = new " + engineName + "().getAvailableVersions();\n");
}
constructorsBuilder.append("return engines;\n");
constructorsBuilder.append("}\n");
constructorsBuilder.append("fetchEngines();");
interactiveScriptSession.eval(includesBuilder.toString(), ignored -> interactiveScriptSession.eval(constructorsBuilder.toString(), output -> {
List<EngineCategoryDTO> engines = new ArrayList<>();
for (Map.Entry<String, Object> entry : ((Map<String, Object>) output).entrySet()) {
final EngineCategoryDTO engineCategoryDTO = new EngineCategoryDTO.Builder().withName(entry.getKey()).withDescription(entry.getKey()).withSubCategories(unSerialize(entry.getValue())).build();
engines.add(engineCategoryDTO);
}
callback.accept(engines);
}, this::throwError), this::throwError);
}
use of org.phoenicis.engines.dto.EngineCategoryDTO in project POL-POM-5 by PlayOnLinux.
the class EngineSidebarSkin method createSidebarToggleGroup.
/**
* Creates the {@link EnginesSidebarToggleGroup} which contains all known engine categories
*/
private EnginesSidebarToggleGroup createSidebarToggleGroup() {
final FilteredList<EngineCategoryDTO> filteredEngineCategories = getControl().getItems().filtered(getControl().getFilter()::filter);
filteredEngineCategories.predicateProperty().bind(Bindings.createObjectBinding(() -> getControl().getFilter()::filter, getControl().searchTermProperty(), getControl().showInstalledProperty(), getControl().showNotInstalledProperty()));
final EnginesSidebarToggleGroup categoryView = new EnginesSidebarToggleGroup(tr("Engines"), filteredEngineCategories);
getControl().selectedEngineCategoryProperty().bind(categoryView.selectedElementProperty());
return categoryView;
}
Aggregations