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());
}
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();
}
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;
}
Aggregations