use of javafx.collections.transformation.SortedList in project dwoss by gg-net.
the class ProductListController method initialize.
/**
* Adding the filters to the combo box. Setting the cell values and the
* filtered list containing the data.
*/
@Override
public void initialize(URL url, ResourceBundle rb) {
tableView.getSelectionModel().setSelectionMode(MULTIPLE);
menuTradeName.getItems().addAll(FXCollections.observableArrayList(TradeName.values()));
menuProductGroup.getItems().addAll(ProductGroup.values());
tableView.setOnDragDetected((MouseEvent event) -> {
ArrayList<Product> selectedProducts = new ArrayList<>();
selectedProducts.addAll(tableView.getSelectionModel().getSelectedItems());
ArrayList<PicoProduct> selectedPicoProducts = new ArrayList<>();
if (selectedProducts.isEmpty())
return;
Dragboard db = tableView.startDragAndDrop(TransferMode.ANY);
ClipboardContent content = new ClipboardContent();
selectedPicoProducts.addAll(selectedProducts.stream().map(p -> new PicoProduct(p.getId(), p.getName())).collect(Collectors.toList()));
content.put(PICO_PRODUCT_DATA_FORMAT, selectedPicoProducts);
db.setContent(content);
event.consume();
});
setCellValues();
progressBar.progressProperty().bind(LOADING_TASK.progressProperty());
progressBar.visibleProperty().bind(LOADING_TASK.runningProperty());
filteredProducts = new FilteredList<>(LOADING_TASK.getPartialResults(), p -> true);
// filteredList does not allow sorting so it needs to be wrapped in a sortedList
SortedList<Product> sortedProducts = new SortedList<>(filteredProducts);
sortedProducts.comparatorProperty().bind(tableView.comparatorProperty());
tableView.setItems(sortedProducts);
editButton.disableProperty().bind(tableView.getSelectionModel().selectedItemProperty().isNull());
Ui.progress().observe(LOADING_TASK);
Ui.exec(LOADING_TASK);
}
use of javafx.collections.transformation.SortedList in project POL-POM-5 by PlayOnLinux.
the class ApplicationsFeaturePanelSkin method createSidebar.
/**
* {@inheritDoc}
*/
@Override
public ObjectExpression<SidebarBase<?, ?, ?>> createSidebar() {
/*
* initialize the category lists by:
* 1. filtering by installer categories
* 2. sorting the remaining categories by their name
*/
final SortedList<CategoryDTO> sortedCategories = getControl().getCategories().filtered(category -> category.getType() == CategoryDTO.CategoryType.INSTALLERS).sorted(Comparator.comparing(CategoryDTO::getName));
final ApplicationSidebar sidebar = new ApplicationSidebar(sortedCategories, this.selectedListWidget);
sidebar.operatingSystemProperty().bind(getControl().operatingSystemProperty());
sidebar.fuzzySearchRatioProperty().bind(getControl().fuzzySearchRatioProperty());
getControl().searchTermProperty().bind(sidebar.searchTermProperty());
getControl().filterCategoryProperty().bind(sidebar.selectedItemProperty());
getControl().containCommercialApplicationsProperty().bind(sidebar.containCommercialApplicationsProperty());
getControl().containRequiresPatchApplicationsProperty().bind(sidebar.containRequiresPatchApplicationsProperty());
getControl().containTestingApplicationsProperty().bind(sidebar.containTestingApplicationsProperty());
getControl().containAllOSCompatibleApplicationsProperty().bind(sidebar.containAllOSCompatibleApplicationsProperty());
// set the default selection
sidebar.setSelectedListWidget(Optional.ofNullable(getControl().getJavaFxSettingsManager()).map(JavaFxSettingsManager::getAppsListType).orElse(ListWidgetType.ICONS_LIST));
// save changes to the list widget selection to the hard drive
sidebar.selectedListWidgetProperty().addListener((observable, oldValue, newValue) -> {
final JavaFxSettingsManager javaFxSettingsManager = getControl().getJavaFxSettingsManager();
if (newValue != null) {
javaFxSettingsManager.setAppsListType(newValue);
javaFxSettingsManager.save();
}
});
return new SimpleObjectProperty<>(sidebar);
}
use of javafx.collections.transformation.SortedList in project POL-POM-5 by PhoenicisOrg.
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;
}
Aggregations