Search in sources :

Example 21 with CategoryDTO

use of org.phoenicis.repository.dto.CategoryDTO in project POL-POM-5 by PlayOnLinux.

the class EngineToolsManager method fetchAvailableEngineTools.

/**
 * Fetches the available engine tools
 *
 * @param repositoryDTO The repository containing the engine tools
 * @param callback The callback taking the fetched engine tools
 */
public void fetchAvailableEngineTools(RepositoryDTO repositoryDTO, Consumer<Map<String, ApplicationDTO>> callback) {
    // get engine CategoryDTOs
    List<CategoryDTO> categoryDTOS = new ArrayList<>();
    for (TypeDTO typeDTO : repositoryDTO.getTypes()) {
        if (typeDTO.getId().equals("engines")) {
            categoryDTOS = typeDTO.getCategories();
        }
    }
    Map<String, ApplicationDTO> tools = new HashMap<>();
    for (CategoryDTO engine : categoryDTOS) {
        for (ApplicationDTO applicationDTO : engine.getApplications()) {
            if (applicationDTO.getId().equals(engine.getId() + ".tools")) {
                tools.put(engine.getId().replaceAll("^.*\\.", ""), applicationDTO);
            }
        }
    }
    callback.accept(tools);
}
Also used : CategoryDTO(org.phoenicis.repository.dto.CategoryDTO) ApplicationDTO(org.phoenicis.repository.dto.ApplicationDTO) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) TypeDTO(org.phoenicis.repository.dto.TypeDTO)

Example 22 with CategoryDTO

use of org.phoenicis.repository.dto.CategoryDTO in project POL-POM-5 by PlayOnLinux.

the class VerbsManager method fetchAvailableVerbs.

/**
 * Fetches the available Verbs
 *
 * @param repositoryDTO
 * @param callback
 */
public void fetchAvailableVerbs(RepositoryDTO repositoryDTO, Consumer<Map<String, ApplicationDTO>> callback) {
    Map<String, ApplicationDTO> verbs = new HashMap<>();
    // get engine CategoryDTOs
    List<CategoryDTO> categoryDTOS = new ArrayList<>();
    for (TypeDTO typeDTO : repositoryDTO.getTypes()) {
        if (typeDTO.getId().equals("engines")) {
            categoryDTOS = typeDTO.getCategories();
        }
    }
    for (CategoryDTO engine : categoryDTOS) {
        for (ApplicationDTO applicationDTO : engine.getApplications()) {
            if (applicationDTO.getId().equals(engine.getId() + ".verbs")) {
                verbs.put(engine.getId().replaceAll("^.*\\.", ""), applicationDTO);
            }
        }
    }
    callback.accept(verbs);
}
Also used : CategoryDTO(org.phoenicis.repository.dto.CategoryDTO) ApplicationDTO(org.phoenicis.repository.dto.ApplicationDTO) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) TypeDTO(org.phoenicis.repository.dto.TypeDTO)

Example 23 with CategoryDTO

use of org.phoenicis.repository.dto.CategoryDTO in project POL-POM-5 by PlayOnLinux.

the class ApplicationsFeaturePanelSkin method createSidebar.

/**
 * {@inheritDoc}
 */
@Override
public ObjectExpression<SidebarBase<?, ?, ?>> createSidebar() {
    /*
         * initialize the category lists by:
         * 1. filtering by installer categories
         * 2. sorting the remaining categories by their name
         */
    final SortedList<CategoryDTO> sortedCategories = getControl().getCategories().filtered(category -> category.getType() == CategoryDTO.CategoryType.INSTALLERS).sorted(Comparator.comparing(CategoryDTO::getName));
    final ApplicationSidebar sidebar = new ApplicationSidebar(sortedCategories, this.selectedListWidget);
    sidebar.operatingSystemProperty().bind(getControl().operatingSystemProperty());
    sidebar.fuzzySearchRatioProperty().bind(getControl().fuzzySearchRatioProperty());
    getControl().searchTermProperty().bind(sidebar.searchTermProperty());
    getControl().filterCategoryProperty().bind(sidebar.selectedItemProperty());
    getControl().containCommercialApplicationsProperty().bind(sidebar.containCommercialApplicationsProperty());
    getControl().containRequiresPatchApplicationsProperty().bind(sidebar.containRequiresPatchApplicationsProperty());
    getControl().containTestingApplicationsProperty().bind(sidebar.containTestingApplicationsProperty());
    getControl().containAllOSCompatibleApplicationsProperty().bind(sidebar.containAllOSCompatibleApplicationsProperty());
    // set the default selection
    sidebar.setSelectedListWidget(Optional.ofNullable(getControl().getJavaFxSettingsManager()).map(JavaFxSettingsManager::getAppsListType).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.setAppsListType(newValue);
            javaFxSettingsManager.save();
        }
    });
    return new SimpleObjectProperty<>(sidebar);
}
Also used : CategoryDTO(org.phoenicis.repository.dto.CategoryDTO) ApplicationSidebar(org.phoenicis.javafx.components.application.control.ApplicationSidebar) CombinedListWidget(org.phoenicis.javafx.components.common.widgets.control.CombinedListWidget) StringBindings(org.phoenicis.javafx.utils.StringBindings) ObjectExpression(javafx.beans.binding.ObjectExpression) MappedList(org.phoenicis.javafx.collections.MappedList) Bindings(javafx.beans.binding.Bindings) SidebarBase(org.phoenicis.javafx.components.common.control.SidebarBase) ListWidgetElement(org.phoenicis.javafx.components.common.widgets.utils.ListWidgetElement) None(org.phoenicis.javafx.components.common.panelstates.None) FeaturePanelSkin(org.phoenicis.javafx.components.common.skin.FeaturePanelSkin) SwitchBinding(org.phoenicis.javafx.utils.SwitchBinding) SortedList(javafx.collections.transformation.SortedList) ListWidgetType(org.phoenicis.javafx.components.common.widgets.utils.ListWidgetType) CategoryDTO(org.phoenicis.repository.dto.CategoryDTO) ObjectProperty(javafx.beans.property.ObjectProperty) Node(javafx.scene.Node) FilteredList(javafx.collections.transformation.FilteredList) ApplicationsFeaturePanel(org.phoenicis.javafx.components.application.control.ApplicationsFeaturePanel) ApplicationInformationPanel(org.phoenicis.javafx.components.application.control.ApplicationInformationPanel) ApplicationInformation(org.phoenicis.javafx.components.application.panelstates.ApplicationInformation) ApplicationDTO(org.phoenicis.repository.dto.ApplicationDTO) JavaFxSettingsManager(org.phoenicis.javafx.settings.JavaFxSettingsManager) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) OpenDetailsPanel(org.phoenicis.javafx.components.common.panelstates.OpenDetailsPanel) DetailsPanel(org.phoenicis.javafx.components.common.control.DetailsPanel) Optional(java.util.Optional) ObservableList(javafx.collections.ObservableList) ConcatenatedList(org.phoenicis.javafx.collections.ConcatenatedList) Comparator(java.util.Comparator) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) ApplicationSidebar(org.phoenicis.javafx.components.application.control.ApplicationSidebar) JavaFxSettingsManager(org.phoenicis.javafx.settings.JavaFxSettingsManager)

Example 24 with CategoryDTO

use of org.phoenicis.repository.dto.CategoryDTO in project POL-POM-5 by PhoenicisOrg.

the class EngineToolsManager method fetchAvailableEngineTools.

/**
 * Fetches the available engine tools
 *
 * @param repositoryDTO The repository containing the engine tools
 * @param callback The callback taking the fetched engine tools
 */
public void fetchAvailableEngineTools(RepositoryDTO repositoryDTO, Consumer<Map<String, ApplicationDTO>> callback) {
    // get engine CategoryDTOs
    List<CategoryDTO> categoryDTOS = new ArrayList<>();
    for (TypeDTO typeDTO : repositoryDTO.getTypes()) {
        if (typeDTO.getId().equals("engines")) {
            categoryDTOS = typeDTO.getCategories();
        }
    }
    Map<String, ApplicationDTO> tools = new HashMap<>();
    for (CategoryDTO engine : categoryDTOS) {
        for (ApplicationDTO applicationDTO : engine.getApplications()) {
            if (applicationDTO.getId().equals(engine.getId() + ".tools")) {
                tools.put(engine.getId().replaceAll("^.*\\.", ""), applicationDTO);
            }
        }
    }
    callback.accept(tools);
}
Also used : CategoryDTO(org.phoenicis.repository.dto.CategoryDTO) ApplicationDTO(org.phoenicis.repository.dto.ApplicationDTO) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) TypeDTO(org.phoenicis.repository.dto.TypeDTO)

Example 25 with CategoryDTO

use of org.phoenicis.repository.dto.CategoryDTO in project POL-POM-5 by PhoenicisOrg.

the class ApplicationSidebarSkin method createSidebarToggleGroup.

private ApplicationSidebarToggleGroup createSidebarToggleGroup() {
    final FilteredList<CategoryDTO> filteredCategories = getControl().getItems().filtered(getControl()::filterCategory);
    filteredCategories.predicateProperty().bind(Bindings.createObjectBinding(() -> getControl()::filterCategory, getControl().searchTermProperty(), getControl().fuzzySearchRatioProperty(), getControl().operatingSystemProperty(), getControl().containAllOSCompatibleApplicationsProperty(), getControl().containCommercialApplicationsProperty(), getControl().containRequiresPatchApplicationsProperty(), getControl().containTestingApplicationsProperty()));
    final ApplicationSidebarToggleGroup applicationSidebarToggleGroup = new ApplicationSidebarToggleGroup(filteredCategories);
    applicationSidebarToggleGroup.setTitle(tr("Categories"));
    getControl().selectedItemProperty().bind(applicationSidebarToggleGroup.selectedElementProperty());
    return applicationSidebarToggleGroup;
}
Also used : CategoryDTO(org.phoenicis.repository.dto.CategoryDTO) ApplicationSidebarToggleGroup(org.phoenicis.javafx.components.application.control.ApplicationSidebarToggleGroup)

Aggregations

CategoryDTO (org.phoenicis.repository.dto.CategoryDTO)27 IOException (java.io.IOException)10 ArrayList (java.util.ArrayList)10 ApplicationDTO (org.phoenicis.repository.dto.ApplicationDTO)10 File (java.io.File)7 URI (java.net.URI)7 Path (java.nio.file.Path)6 List (java.util.List)6 TypeDTO (org.phoenicis.repository.dto.TypeDTO)6 HashMap (java.util.HashMap)5 Optional (java.util.Optional)5 EngineCategoryDTO (org.phoenicis.engines.dto.EngineCategoryDTO)4 EngineSubCategoryDTO (org.phoenicis.engines.dto.EngineSubCategoryDTO)4 ApplicationsFeaturePanel (org.phoenicis.javafx.components.application.control.ApplicationsFeaturePanel)4 Collections (java.util.Collections)3 Consumer (java.util.function.Consumer)3 Logger (org.slf4j.Logger)3 LoggerFactory (org.slf4j.LoggerFactory)3 TypeReference (com.fasterxml.jackson.core.type.TypeReference)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2