use of org.phoenicis.javafx.components.application.panelstates.ApplicationInformation 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);
}
Aggregations