use of org.phoenicis.repository.dto.ApplicationDTO in project POL-POM-5 by PlayOnLinux.
the class MergeableRepository method mergeCategories.
protected CategoryDTO mergeCategories(CategoryDTO leftCategory, CategoryDTO rightCategory) {
final Map<String, ApplicationDTO> leftApplications = createSortedMap(leftCategory.getApplications(), ApplicationDTO::getName);
final Map<String, ApplicationDTO> rightApplications = createSortedMap(rightCategory.getApplications(), ApplicationDTO::getName);
final SortedMap<String, ApplicationDTO> mergedApps = new TreeMap<>(rightApplications);
for (String applicationName : leftApplications.keySet()) {
final ApplicationDTO application = leftApplications.get(applicationName);
if (mergedApps.containsKey(applicationName)) {
mergedApps.put(applicationName, mergeApplications(mergedApps.get(applicationName), application));
} else {
mergedApps.put(applicationName, application);
}
}
final List<ApplicationDTO> applications = new ArrayList<>(mergedApps.values());
applications.sort(ApplicationDTO.nameComparator());
return new CategoryDTO.Builder().withApplications(applications).withType(leftCategory.getType()).withIcon(leftCategory.getIcon()).withName(leftCategory.getName()).build();
}
use of org.phoenicis.repository.dto.ApplicationDTO in project POL-POM-5 by PlayOnLinux.
the class FilterRepository method fetchInstallableApplications.
@Override
public List<CategoryDTO> fetchInstallableApplications() {
final OperatingSystem currentOperatingSystem = operatingSystemFetcher.fetchCurrentOperationSystem();
final List<CategoryDTO> categories = repository.fetchInstallableApplications();
return categories.stream().map(category -> {
final List<ApplicationDTO> applications = new ArrayList<>();
for (ApplicationDTO application : category.getApplications()) {
List<ScriptDTO> scripts = application.getScripts();
if (!enforceIncompatibleOperatingSystems) {
scripts = application.getScripts().stream().filter(script -> script.getCompatibleOperatingSystems() == null || script.getCompatibleOperatingSystems().contains(currentOperatingSystem)).collect(Collectors.toList());
}
if (!scripts.isEmpty()) {
applications.add(new ApplicationDTO.Builder(application).withScripts(scripts).build());
}
}
return new CategoryDTO.Builder(category).withApplications(applications).build();
}).filter(category -> !category.getApplications().isEmpty()).collect(Collectors.toList());
}
use of org.phoenicis.repository.dto.ApplicationDTO in project POL-POM-5 by PlayOnLinux.
the class ClasspathRepository method buildApplications.
private List<ApplicationDTO> buildApplications(String categoryFileName) throws IOException {
final String categoryScanClassPath = packagePath + "/" + categoryFileName;
Resource[] resources = resourceResolver.getResources(categoryScanClassPath + "/*");
final List<ApplicationDTO> applicationDTOS = new ArrayList<>();
for (Resource resource : resources) {
final String fileName = resource.getFilename();
if (!"icon.png".equals(fileName) && !"category.json".equals(fileName)) {
final ApplicationDTO application = buildApplication(categoryFileName, fileName);
if (!application.getScripts().isEmpty()) {
applicationDTOS.add(application);
}
}
}
Collections.sort(applicationDTOS, Comparator.comparing(ApplicationDTO::getName));
return applicationDTOS;
}
use of org.phoenicis.repository.dto.ApplicationDTO in project POL-POM-5 by PlayOnLinux.
the class ApplicationsFeaturePanelSkin method createContent.
/**
* {@inheritDoc}
*/
@Override
public ObjectExpression<Node> createContent() {
/*
* initialising the application lists by:
* 1. sorting the applications by their name
* 2. filtering them
*/
final FilteredList<ApplicationDTO> filteredApplications = ConcatenatedList.create(new MappedList<>(getControl().getCategories().filtered(category -> category.getType() == CategoryDTO.CategoryType.INSTALLERS), CategoryDTO::getApplications)).sorted(Comparator.comparing(ApplicationDTO::getName)).filtered(getControl()::filterApplication);
filteredApplications.predicateProperty().bind(Bindings.createObjectBinding(() -> getControl()::filterApplication, getControl().searchTermProperty(), getControl().fuzzySearchRatioProperty(), getControl().operatingSystemProperty(), getControl().filterCategoryProperty(), getControl().containAllOSCompatibleApplicationsProperty(), getControl().containCommercialApplicationsProperty(), getControl().containRequiresPatchApplicationsProperty(), getControl().containTestingApplicationsProperty()));
final ObservableList<ListWidgetElement<ApplicationDTO>> listWidgetEntries = new MappedList<>(filteredApplications, ListWidgetElement::create);
final CombinedListWidget<ApplicationDTO> combinedListWidget = new CombinedListWidget<>(listWidgetEntries, this.selectedListWidget);
// bind direction: controller property -> skin property
getControl().selectedApplicationProperty().addListener((observable, oldValue, newValue) -> {
if (newValue != null) {
combinedListWidget.select(newValue);
} else {
combinedListWidget.deselect();
}
});
// bind direction: skin property -> controller properties
combinedListWidget.selectedElementProperty().addListener((observable, oldValue, newValue) -> {
if (newValue != null) {
final ApplicationDTO selectedItem = newValue.getItem();
getControl().setSelectedApplication(selectedItem);
getControl().setOpenedDetailsPanel(new ApplicationInformation(selectedItem));
} else {
getControl().setSelectedApplication(null);
getControl().setOpenedDetailsPanel(new None());
}
});
return new SimpleObjectProperty<>(combinedListWidget);
}
use of org.phoenicis.repository.dto.ApplicationDTO in project POL-POM-5 by PlayOnLinux.
the class ApplicationInformationPanelSkin method updateApplication.
/**
* Update the content of the details panel when the to be shown application changes
*/
private void updateApplication() {
final ApplicationDTO application = getControl().getApplication();
if (application != null) {
scripts.setAll(application.getScripts());
miniatureUris.setAll(application.getMiniatures());
}
}
Aggregations