Search in sources :

Example 1 with ContainerCategoryDTO

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

the class GenericContainersManager method fetchContainers.

/**
 * {@inheritDoc}
 * @param callback
 * @param errorCallback
 */
@Override
public void fetchContainers(Consumer<List<ContainerCategoryDTO>> callback, Consumer<Exception> errorCallback) {
    final File containersFile = new File(containersPath);
    containersFile.mkdirs();
    final File[] engineDirectories = containersFile.listFiles();
    if (engineDirectories == null) {
        callback.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());
            }
        }
        callback.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)

Example 2 with ContainerCategoryDTO

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

the class WinePrefixContainersManager method fetchContainers.

@Override
public void fetchContainers(Consumer<List<ContainerCategoryDTO>> callback, Consumer<Exception> errorCallback) {
    final File winePrefixesFile = new File(winePrefixPath);
    winePrefixesFile.mkdirs();
    final File[] winePrefixes = winePrefixesFile.listFiles();
    if (winePrefixes == null) {
        callback.accept(Collections.emptyList());
    } else {
        final List<ContainerCategoryDTO> containerCategories = new ArrayList<>();
        final List<ContainerDTO> containers = new ArrayList<>();
        for (File winePrefix : winePrefixes) {
            final ConfigFile configFile = compatibleConfigFileFormatFactory.open(new File(winePrefix, "phoenicis.cfg"));
            final File userRegistryFile = new File(winePrefix, "user.reg");
            containers.add(new WinePrefixContainerDTO.Builder().withName(winePrefix.getName()).withPath(winePrefix.getAbsolutePath()).withArchitecture(configFile.readValue("wineArchitecture", "")).withDistribution(configFile.readValue("wineDistribution", "")).withVersion(configFile.readValue("wineVersion", "")).withGlslValue(winePrefixContainerDisplayConfiguration.getGLSL(userRegistryFile)).withDirectDrawRenderer(winePrefixContainerDisplayConfiguration.getDirectDrawRenderer(userRegistryFile)).withVideoMemorySize(winePrefixContainerDisplayConfiguration.getVideoMemorySize(userRegistryFile)).withOffscreenRenderingMode(winePrefixContainerDisplayConfiguration.getOffscreenRenderingMode(userRegistryFile)).withMultisampling(winePrefixContainerDisplayConfiguration.getMultisampling(userRegistryFile)).withAlwaysOffscreen(winePrefixContainerDisplayConfiguration.getAlwaysOffscreen(userRegistryFile)).withStrictDrawOrdering(winePrefixContainerDisplayConfiguration.getStrictDrawOrdering(userRegistryFile)).withRenderTargetModeLock(winePrefixContainerDisplayConfiguration.getRenderTargetModeLock(userRegistryFile)).withMouseWarpOverride(winePrefixContainerInputConfiguration.getMouseWarpOverride(userRegistryFile)).build());
        }
        containers.sort(ContainerDTO.nameComparator());
        containerCategories.add(new ContainerCategoryDTO.Builder().withName("Wine").withContainers(containers).build());
        callback.accept(containerCategories);
    }
}
Also used : ContainerCategoryDTO(org.phoenicis.containers.dto.ContainerCategoryDTO) ConfigFile(org.phoenicis.tools.config.ConfigFile) ArrayList(java.util.ArrayList) WinePrefixContainerDTO(org.phoenicis.containers.dto.WinePrefixContainerDTO) ContainerDTO(org.phoenicis.containers.dto.ContainerDTO) File(java.io.File) ConfigFile(org.phoenicis.tools.config.ConfigFile)

Example 3 with ContainerCategoryDTO

use of org.phoenicis.containers.dto.ContainerCategoryDTO in project phoenicis by PhoenicisOrg.

the class GenericContainersManager method fetchContainers.

/**
 * {@inheritDoc}
 * @param callback
 * @param errorCallback
 */
@Override
public void fetchContainers(Consumer<List<ContainerCategoryDTO>> callback, Consumer<Exception> errorCallback) {
    final File containersFile = new File(containersPath);
    containersFile.mkdirs();
    final File[] engineDirectories = containersFile.listFiles();
    if (engineDirectories == null) {
        callback.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());
            }
        }
        callback.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)

Example 4 with ContainerCategoryDTO

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

the class ContainerSidebarSkin method createSidebarToggleGroup.

/**
 * Creates a {@link ContainersSidebarToggleGroup} object containing all installed containers
 */
private ContainersSidebarToggleGroup createSidebarToggleGroup() {
    final FilteredList<ContainerCategoryDTO> filteredContainerCategories = getControl().getItems().filtered(getControl().getFilter()::filter);
    filteredContainerCategories.predicateProperty().bind(Bindings.createObjectBinding(() -> getControl().getFilter()::filter, getControl().searchTermProperty(), getControl().selectedContainerCategoryProperty()));
    final ContainersSidebarToggleGroup sidebarToggleGroup = new ContainersSidebarToggleGroup(tr("Containers"), filteredContainerCategories);
    getControl().selectedContainerCategoryProperty().bind(sidebarToggleGroup.selectedElementProperty());
    return sidebarToggleGroup;
}
Also used : ContainerCategoryDTO(org.phoenicis.containers.dto.ContainerCategoryDTO) ContainersSidebarToggleGroup(org.phoenicis.javafx.components.container.control.ContainersSidebarToggleGroup)

Example 5 with ContainerCategoryDTO

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

the class ContainersFeaturePanelSkin method createSidebar.

/**
 * {@inheritDoc}
 */
@Override
public ObjectExpression<SidebarBase<?, ?, ?>> createSidebar() {
    /*
         * initialize the container categories by sorting them
         */
    final SortedList<ContainerCategoryDTO> sortedCategories = getControl().getCategories().sorted(Comparator.comparing(ContainerCategoryDTO::getName));
    final ContainerSidebar sidebar = new ContainerSidebar(getControl().getFilter(), sortedCategories, this.selectedListWidget);
    // set the default selection
    sidebar.setSelectedListWidget(Optional.ofNullable(getControl().getJavaFxSettingsManager()).map(JavaFxSettingsManager::getContainersListType).orElse(ListWidgetType.ICONS_LIST));
    // save changes to the list widget selection to the hard drive
    sidebar.selectedListWidgetProperty().addListener((observable, oldValue, newValue) -> {
        final JavaFxSettingsManager javaFxSettingsManager = getControl().getJavaFxSettingsManager();
        if (newValue != null) {
            javaFxSettingsManager.setContainersListType(newValue);
            javaFxSettingsManager.save();
        }
    });
    return new SimpleObjectProperty<>(sidebar);
}
Also used : SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) ContainerCategoryDTO(org.phoenicis.containers.dto.ContainerCategoryDTO) ContainerSidebar(org.phoenicis.javafx.components.container.control.ContainerSidebar) JavaFxSettingsManager(org.phoenicis.javafx.settings.JavaFxSettingsManager)

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