Search in sources :

Example 11 with InstallationCategoryDTO

use of org.phoenicis.javafx.views.mainwindow.installations.dto.InstallationCategoryDTO in project POL-POM-5 by PlayOnLinux.

the class InstallationsUtils method addInstallationToList.

/**
 * Adds a new {@link InstallationDTO} object to an existing list of {@link InstallationDTO} objects
 *
 * @param list The list of existing installations
 * @param toAdd The new installation
 * @return A new list of installations containing the existing and new installations
 */
public static List<InstallationCategoryDTO> addInstallationToList(List<InstallationCategoryDTO> list, InstallationDTO toAdd) {
    final String newInstallationCategory = toAdd.getCategory().toString();
    final InstallationCategoryDTO newCategory = new InstallationCategoryDTO.Builder().withId(newInstallationCategory).withName(tr(newInstallationCategory)).withInstallations(Collections.singletonList(toAdd)).build();
    final SortedMap<String, InstallationCategoryDTO> mergedCategories = new TreeMap<>(createSortedMap(list, InstallationCategoryDTO::getId));
    if (mergedCategories.containsKey(newCategory.getId())) {
        final InstallationCategoryDTO tempMergedCategory = mergedCategories.get(newCategory.getId());
        mergedCategories.put(newCategory.getId(), mergeCategories(tempMergedCategory, newCategory));
    } else {
        mergedCategories.put(newCategory.getId(), newCategory);
    }
    return mergedCategories.values().stream().sorted(InstallationCategoryDTO.nameComparator()).collect(Collectors.toList());
}
Also used : InstallationCategoryDTO(org.phoenicis.javafx.views.mainwindow.installations.dto.InstallationCategoryDTO)

Example 12 with InstallationCategoryDTO

use of org.phoenicis.javafx.views.mainwindow.installations.dto.InstallationCategoryDTO in project POL-POM-5 by PlayOnLinux.

the class InstallationsUtils method mergeCategories.

private static InstallationCategoryDTO mergeCategories(InstallationCategoryDTO leftCategory, InstallationCategoryDTO rightCategory) {
    final Map<String, InstallationDTO> leftInstallations = createSortedMap(leftCategory.getInstallations(), InstallationDTO::getId);
    final Map<String, InstallationDTO> rightInstallations = createSortedMap(rightCategory.getInstallations(), InstallationDTO::getId);
    final SortedMap<String, InstallationDTO> mergedInstallations = new TreeMap<>(rightInstallations);
    for (Map.Entry<String, InstallationDTO> entry : leftInstallations.entrySet()) {
        final InstallationDTO application = entry.getValue();
        if (mergedInstallations.containsKey(entry.getKey())) {
            LOGGER.error(String.format("Installation %s exists already!", entry.getKey()));
        } else {
            mergedInstallations.put(entry.getKey(), application);
        }
    }
    final List<InstallationDTO> installations = mergedInstallations.values().stream().sorted(InstallationDTO.nameComparator()).collect(Collectors.toList());
    return new InstallationCategoryDTO.Builder().withId(leftCategory.getId()).withName(leftCategory.getName()).withInstallations(installations).withIcon(leftCategory.getIcon()).build();
}
Also used : InstallationDTO(org.phoenicis.javafx.views.mainwindow.installations.dto.InstallationDTO) InstallationCategoryDTO(org.phoenicis.javafx.views.mainwindow.installations.dto.InstallationCategoryDTO)

Example 13 with InstallationCategoryDTO

use of org.phoenicis.javafx.views.mainwindow.installations.dto.InstallationCategoryDTO in project POL-POM-5 by PlayOnLinux.

the class InstallationSidebarSkin method createSidebarToggleGroup.

/**
 * Creates the {@link InstallationsSidebarToggleGroup} which contains all active installation categories
 */
private InstallationsSidebarToggleGroup createSidebarToggleGroup() {
    final FilteredList<InstallationCategoryDTO> filteredInstallationCategories = getControl().getItems().filtered(getControl().getFilter()::filter);
    filteredInstallationCategories.predicateProperty().bind(Bindings.createObjectBinding(() -> getControl().getFilter()::filter, getControl().searchTermProperty()));
    final InstallationsSidebarToggleGroup categoryView = new InstallationsSidebarToggleGroup(tr("Categories"), filteredInstallationCategories);
    getControl().selectedInstallationCategoryProperty().bind(categoryView.selectedElementProperty());
    return categoryView;
}
Also used : InstallationsSidebarToggleGroup(org.phoenicis.javafx.components.installation.control.InstallationsSidebarToggleGroup) InstallationCategoryDTO(org.phoenicis.javafx.views.mainwindow.installations.dto.InstallationCategoryDTO)

Aggregations

InstallationCategoryDTO (org.phoenicis.javafx.views.mainwindow.installations.dto.InstallationCategoryDTO)13 InstallationDTO (org.phoenicis.javafx.views.mainwindow.installations.dto.InstallationDTO)5 SimpleObjectProperty (javafx.beans.property.SimpleObjectProperty)3 MappedList (org.phoenicis.javafx.collections.MappedList)2 JavaFxSettingsManager (org.phoenicis.javafx.settings.JavaFxSettingsManager)2 Platform (javafx.application.Platform)1 Bindings (javafx.beans.binding.Bindings)1 IntegerBinding (javafx.beans.binding.IntegerBinding)1 Scene (javafx.scene.Scene)1 Tab (javafx.scene.control.Tab)1 TabPane (javafx.scene.control.TabPane)1 Image (javafx.scene.image.Image)1 Stage (javafx.stage.Stage)1 Localisation.tr (org.phoenicis.configuration.localisation.Localisation.tr)1 JavaFXApplication (org.phoenicis.javafx.JavaFXApplication)1 ConcatenatedList (org.phoenicis.javafx.collections.ConcatenatedList)1 ApplicationsFeaturePanel (org.phoenicis.javafx.components.application.control.ApplicationsFeaturePanel)1 TabIndicator (org.phoenicis.javafx.components.common.control.TabIndicator)1 None (org.phoenicis.javafx.components.common.panelstates.None)1 CombinedListWidget (org.phoenicis.javafx.components.common.widgets.control.CombinedListWidget)1