Search in sources :

Example 6 with ContainerCategoryDTO

use of org.phoenicis.containers.dto.ContainerCategoryDTO in project POL-POM-5 by PlayOnLinux.

the class GenericContainersManager method fetchContainers.

/**
 * {@inheritDoc}
 */
@Override
public void fetchContainers(Consumer<List<ContainerCategoryDTO>> onSuccess, Consumer<Exception> onError) {
    final File containersFile = new File(containersPath);
    containersFile.mkdirs();
    final File[] engineDirectories = containersFile.listFiles();
    if (engineDirectories == null) {
        onSuccess.accept(Collections.emptyList());
    } else {
        final List<ContainerCategoryDTO> containerCategories = new ArrayList<>();
        for (File engineDirectory : engineDirectories) {
            final List<ContainerDTO> containers = fetchContainers(engineDirectory);
            if (!CollectionUtils.isEmpty(containers)) {
                containerCategories.add(new ContainerCategoryDTO.Builder().withName(engineDirectory.getName()).withContainers(containers).build());
            }
        }
        onSuccess.accept(containerCategories);
    }
}
Also used : ContainerCategoryDTO(org.phoenicis.containers.dto.ContainerCategoryDTO) ArrayList(java.util.ArrayList) ContainerDTO(org.phoenicis.containers.dto.ContainerDTO) WinePrefixContainerDTO(org.phoenicis.containers.dto.WinePrefixContainerDTO) File(java.io.File) ConfigFile(org.phoenicis.tools.config.ConfigFile)

Aggregations

ContainerCategoryDTO (org.phoenicis.containers.dto.ContainerCategoryDTO)6 File (java.io.File)4 ArrayList (java.util.ArrayList)4 ContainerDTO (org.phoenicis.containers.dto.ContainerDTO)4 WinePrefixContainerDTO (org.phoenicis.containers.dto.WinePrefixContainerDTO)4 ConfigFile (org.phoenicis.tools.config.ConfigFile)4 SimpleObjectProperty (javafx.beans.property.SimpleObjectProperty)1 ContainerSidebar (org.phoenicis.javafx.components.container.control.ContainerSidebar)1 ContainersSidebarToggleGroup (org.phoenicis.javafx.components.container.control.ContainersSidebarToggleGroup)1 JavaFxSettingsManager (org.phoenicis.javafx.settings.JavaFxSettingsManager)1