use of org.phoenicis.javafx.collections.MappedList 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.javafx.collections.MappedList in project POL-POM-5 by PlayOnLinux.
the class EngineSubCategoryPanelSkin method createListWidget.
/**
* Creates a new {@link CombinedListWidget} object containing all {@link EngineVersionDTO} objects in the given
* {@link ObservableList filteredEngineVersions}
*
* @param filteredEngineVersions An {@link ObservableList} containing all to be shown {@link EngineVersionDTO}
* objects
* @return A new {@link CombinedListWidget} object containing all {@link EngineVersionDTO} objects in the given
* {@link ObservableList filteredEngineVersions}
*/
private CombinedListWidget<EngineVersionDTO> createListWidget(ObservableList<EngineVersionDTO> filteredEngineVersions) {
final ObservableList<ListWidgetElement<EngineVersionDTO>> listWidgetEntries = new MappedList<>(filteredEngineVersions, engineVersion -> ListWidgetElement.create(engineVersion, Files.exists(Paths.get(getControl().getEnginesPath(), getControl().getEngineCategory().getName().toLowerCase(), getControl().getEngineSubCategory().getName(), engineVersion.getVersion()))));
final CombinedListWidget<EngineVersionDTO> listWidget = new CombinedListWidget<>(listWidgetEntries);
listWidget.selectedListWidgetProperty().bind(getControl().selectedListWidgetProperty());
listWidget.selectedElementProperty().addListener((observable, oldValue, newValue) -> {
if (newValue != null) {
final EngineVersionDTO engineItem = newValue.getItem();
Map<String, String> userData = new HashMap<>();
userData.put("Mono", engineItem.getMonoFile());
userData.put("Gecko", engineItem.getGeckoFile());
EngineDTO engineDTO = new EngineDTO.Builder().withCategory(getControl().getEngineCategory().getName()).withSubCategory(getControl().getEngineSubCategory().getName()).withVersion(engineItem.getVersion()).withUserData(userData).build();
Optional.ofNullable(getControl().getOnEngineSelect()).ifPresent(onEngineSelect -> onEngineSelect.accept(engineDTO, getControl().getEngine()));
}
});
return listWidget;
}
use of org.phoenicis.javafx.collections.MappedList in project POL-POM-5 by PlayOnLinux.
the class EnginesView method createEngineSubCategoryTabs.
private ObservableList<Tab> createEngineSubCategoryTabs(EngineSidebar sidebar) {
// initialize the engines sub category panels
final MappedList<List<EngineSubCategoryPanel>, EngineCategoryDTO> engineSubCategoryPanelGroups = new MappedList<>(this.engineCategories, engineCategory -> engineCategory.getSubCategories().stream().map(engineSubCategory -> {
final EngineSubCategoryPanel engineSubCategoryPanel = new EngineSubCategoryPanel();
engineSubCategoryPanel.setEngineCategory(engineCategory);
engineSubCategoryPanel.setEngineSubCategory(engineSubCategory);
engineSubCategoryPanel.setEnginesPath(this.enginesPath);
engineSubCategoryPanel.setFilter(this.filter);
engineSubCategoryPanel.setEngine(this.engines.get(engineCategory.getName().toLowerCase()));
engineSubCategoryPanel.selectedListWidgetProperty().bind(sidebar.selectedListWidgetProperty());
engineSubCategoryPanel.setOnEngineSelect(this::showEngineDetails);
return engineSubCategoryPanel;
}).collect(Collectors.toList()));
final ConcatenatedList<EngineSubCategoryPanel> engineSubCategoryPanels = ConcatenatedList.create(engineSubCategoryPanelGroups);
final FilteredList<EngineSubCategoryPanel> filteredEngineSubCategoryPanels = engineSubCategoryPanels.sorted(Comparator.comparing(engineSubCategoryPanel -> engineSubCategoryPanel.getEngineSubCategory().getName())).filtered(this.filter::filter);
filteredEngineSubCategoryPanels.predicateProperty().bind(Bindings.createObjectBinding(() -> this.filter::filter, this.filter.searchTermProperty(), this.filter.showInstalledProperty(), this.filter.showNotInstalledProperty()));
// map the panels to tabs
return new MappedList<>(filteredEngineSubCategoryPanels, engineSubCategoryPanel -> new Tab(engineSubCategoryPanel.getEngineSubCategory().getDescription(), engineSubCategoryPanel));
}
use of org.phoenicis.javafx.collections.MappedList in project POL-POM-5 by PlayOnLinux.
the class LibraryFeaturePanelSkin method createCombinedListWidget.
private CombinedListWidget<ShortcutDTO> createCombinedListWidget() {
final FilteredList<ShortcutDTO> filteredShortcuts = ConcatenatedList.create(new MappedList<>(getControl().getCategories().sorted(Comparator.comparing(ShortcutCategoryDTO::getName)), ShortcutCategoryDTO::getShortcuts)).filtered(getControl().getFilter()::filter);
filteredShortcuts.predicateProperty().bind(Bindings.createObjectBinding(() -> getControl().getFilter()::filter, getControl().getFilter().searchTermProperty(), getControl().getFilter().selectedShortcutCategoryProperty()));
final SortedList<ShortcutDTO> sortedShortcuts = filteredShortcuts.sorted(Comparator.comparing(shortcut -> shortcut.getInfo().getName()));
final ObservableList<ListWidgetElement<ShortcutDTO>> listWidgetEntries = new MappedList<>(sortedShortcuts, ListWidgetElement::create);
final CombinedListWidget<ShortcutDTO> combinedListWidget = new CombinedListWidget<>(listWidgetEntries, this.selectedListWidget);
// bind direction: controller property -> skin property
getControl().selectedShortcutProperty().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 ShortcutDTO selectedItem = newValue.getItem();
final MouseEvent event = newValue.getEvent();
getControl().setSelectedShortcut(selectedItem);
getControl().setOpenedDetailsPanel(new ShortcutInformation(selectedItem));
if (event.getClickCount() == 2) {
getControl().runShortcut(selectedItem);
}
} else {
getControl().setSelectedShortcut(null);
getControl().setOpenedDetailsPanel(new None());
}
});
return combinedListWidget;
}
use of org.phoenicis.javafx.collections.MappedList in project POL-POM-5 by PlayOnLinux.
the class MainWindow method createInstallationsTab.
private Tab createInstallationsTab(InstallationsFeaturePanel installationsFeaturePanel) {
final Tab installationsTab = new Tab(tr("Installations"), installationsFeaturePanel);
installationsTab.setClosable(false);
final ConcatenatedList<InstallationDTO> installations = ConcatenatedList.create(new MappedList<>(installationsFeaturePanel.getInstallationCategories(), InstallationCategoryDTO::getInstallations));
// a binding containing the number of currently active installations
final IntegerBinding openInstallations = Bindings.createIntegerBinding(installations::size, installations);
final TabIndicator indicator = new TabIndicator();
indicator.textProperty().bind(StringBindings.map(openInstallations, numberOfInstallations -> {
if (numberOfInstallations.intValue() < 10) {
return String.valueOf(numberOfInstallations);
} else {
return "+";
}
}));
// only show the tab indicator if at least one active installation exists
installationsTab.graphicProperty().bind(Bindings.when(Bindings.notEqual(openInstallations, 0)).then(indicator).otherwise(new SimpleObjectProperty<>()));
return installationsTab;
}
Aggregations