private void populateView(RepositoryDTO repositoryDTO, Map<String, Engine> engines) { this.repositoryCache = repositoryDTO; this.enginesCache = engines; // show a waiting screen until the engines are loaded Platform.runLater(enginesView::showWait); // fetch all categories consisting of engines that are contained in the repository final List<CategoryDTO> categoryDTOS = repositoryDTO.getTypes().stream() .filter(type -> type.getId().equals("engines")) .flatMap(type -> type.getCategories().stream()) .collect(Collectors.toList()); Platform.runLater(() -> { // generate the necessary css for the engine categories setDefaultEngineIcons(categoryDTOS); }); // fetch the engine categories objects contained in the engine categories final Queue<EngineCategoryDTO> engineCategories = new ArrayDeque<>( enginesManager.getAvailableEngines(categoryDTOS)); // insert the missing engine subcategories into the engine categories fetchEngineSubcategories(engineCategories, ImmutableMap.of(), subcategoryMap -> { final List<EngineCategoryDTO> categories = subcategoryMap.entrySet().stream() .map(entry -> new EngineCategoryDTO.Builder(entry.getKey()) .withSubCategories(entry.getValue()) .build()) .collect(Collectors.toList()); Platform.runLater(() -> { // update the view enginesView.populate(categories, engines); }); }); }