Search in sources :

Example 11 with SortedList

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);
}
Also used : java.util(java.util) Initializable(javafx.fxml.Initializable) TradeName(eu.ggnet.dwoss.rules.TradeName) javafx.scene.control(javafx.scene.control) URL(java.net.URL) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) LoggerFactory(org.slf4j.LoggerFactory) FXCollections(javafx.collections.FXCollections) MULTIPLE(javafx.scene.control.SelectionMode.MULTIPLE) Ui(eu.ggnet.saft.Ui) FxController(eu.ggnet.saft.api.ui.FxController) java.time(java.time) ProductTask(eu.ggnet.dwoss.uniqueunit.ui.ProductTask) SortedList(javafx.collections.transformation.SortedList) PicoProduct(eu.ggnet.dwoss.uniqueunit.api.PicoProduct) DateFormats(eu.ggnet.dwoss.util.DateFormats) javafx.scene.input(javafx.scene.input) Logger(org.slf4j.Logger) PropertyValueFactory(javafx.scene.control.cell.PropertyValueFactory) Predicate(java.util.function.Predicate) ProductGroup(eu.ggnet.dwoss.rules.ProductGroup) FilteredList(javafx.collections.transformation.FilteredList) ClosedListener(eu.ggnet.saft.api.ui.ClosedListener) Collectors(java.util.stream.Collectors) FXML(javafx.fxml.FXML) ActionEvent(javafx.event.ActionEvent) FxSaft(eu.ggnet.saft.core.ui.FxSaft) Product(eu.ggnet.dwoss.uniqueunit.ee.entity.Product) SortedList(javafx.collections.transformation.SortedList) PicoProduct(eu.ggnet.dwoss.uniqueunit.api.PicoProduct) Product(eu.ggnet.dwoss.uniqueunit.ee.entity.Product) PicoProduct(eu.ggnet.dwoss.uniqueunit.api.PicoProduct)

Example 12 with SortedList

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);
}
Also used : CategoryDTO(org.phoenicis.repository.dto.CategoryDTO) ApplicationSidebar(org.phoenicis.javafx.components.application.control.ApplicationSidebar) CombinedListWidget(org.phoenicis.javafx.components.common.widgets.control.CombinedListWidget) StringBindings(org.phoenicis.javafx.utils.StringBindings) ObjectExpression(javafx.beans.binding.ObjectExpression) MappedList(org.phoenicis.javafx.collections.MappedList) Bindings(javafx.beans.binding.Bindings) SidebarBase(org.phoenicis.javafx.components.common.control.SidebarBase) ListWidgetElement(org.phoenicis.javafx.components.common.widgets.utils.ListWidgetElement) None(org.phoenicis.javafx.components.common.panelstates.None) FeaturePanelSkin(org.phoenicis.javafx.components.common.skin.FeaturePanelSkin) SwitchBinding(org.phoenicis.javafx.utils.SwitchBinding) SortedList(javafx.collections.transformation.SortedList) ListWidgetType(org.phoenicis.javafx.components.common.widgets.utils.ListWidgetType) CategoryDTO(org.phoenicis.repository.dto.CategoryDTO) ObjectProperty(javafx.beans.property.ObjectProperty) Node(javafx.scene.Node) FilteredList(javafx.collections.transformation.FilteredList) ApplicationsFeaturePanel(org.phoenicis.javafx.components.application.control.ApplicationsFeaturePanel) ApplicationInformationPanel(org.phoenicis.javafx.components.application.control.ApplicationInformationPanel) ApplicationInformation(org.phoenicis.javafx.components.application.panelstates.ApplicationInformation) ApplicationDTO(org.phoenicis.repository.dto.ApplicationDTO) JavaFxSettingsManager(org.phoenicis.javafx.settings.JavaFxSettingsManager) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) OpenDetailsPanel(org.phoenicis.javafx.components.common.panelstates.OpenDetailsPanel) DetailsPanel(org.phoenicis.javafx.components.common.control.DetailsPanel) Optional(java.util.Optional) ObservableList(javafx.collections.ObservableList) ConcatenatedList(org.phoenicis.javafx.collections.ConcatenatedList) Comparator(java.util.Comparator) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) ApplicationSidebar(org.phoenicis.javafx.components.application.control.ApplicationSidebar) JavaFxSettingsManager(org.phoenicis.javafx.settings.JavaFxSettingsManager)

Example 13 with SortedList

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;
}
Also used : CombinedListWidget(org.phoenicis.javafx.components.common.widgets.control.CombinedListWidget) ShortcutCategoryDTO(org.phoenicis.library.dto.ShortcutCategoryDTO) StringBindings(org.phoenicis.javafx.utils.StringBindings) ObjectExpression(javafx.beans.binding.ObjectExpression) MappedList(org.phoenicis.javafx.collections.MappedList) MouseEvent(javafx.scene.input.MouseEvent) ShortcutEditing(org.phoenicis.javafx.components.library.panelstates.ShortcutEditing) Bindings(javafx.beans.binding.Bindings) SidebarBase(org.phoenicis.javafx.components.common.control.SidebarBase) org.phoenicis.javafx.components.library.control(org.phoenicis.javafx.components.library.control) ListWidgetElement(org.phoenicis.javafx.components.common.widgets.utils.ListWidgetElement) ShortcutInformation(org.phoenicis.javafx.components.library.panelstates.ShortcutInformation) ShortcutCreation(org.phoenicis.javafx.components.library.panelstates.ShortcutCreation) TabPane(javafx.scene.control.TabPane) None(org.phoenicis.javafx.components.common.panelstates.None) FeaturePanelSkin(org.phoenicis.javafx.components.common.skin.FeaturePanelSkin) ShortcutDTO(org.phoenicis.library.dto.ShortcutDTO) SwitchBinding(org.phoenicis.javafx.utils.SwitchBinding) SortedList(javafx.collections.transformation.SortedList) ListWidgetType(org.phoenicis.javafx.components.common.widgets.utils.ListWidgetType) ObjectProperty(javafx.beans.property.ObjectProperty) Node(javafx.scene.Node) FilteredList(javafx.collections.transformation.FilteredList) Localisation.tr(org.phoenicis.configuration.localisation.Localisation.tr) Observable(javafx.beans.Observable) JavaFxSettingsManager(org.phoenicis.javafx.settings.JavaFxSettingsManager) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) Tab(javafx.scene.control.Tab) OpenDetailsPanel(org.phoenicis.javafx.components.common.panelstates.OpenDetailsPanel) DetailsPanel(org.phoenicis.javafx.components.common.control.DetailsPanel) Optional(java.util.Optional) ObjectBindings(org.phoenicis.javafx.utils.ObjectBindings) ObservableList(javafx.collections.ObservableList) ConcatenatedList(org.phoenicis.javafx.collections.ConcatenatedList) Comparator(java.util.Comparator) CombinedListWidget(org.phoenicis.javafx.components.common.widgets.control.CombinedListWidget) MouseEvent(javafx.scene.input.MouseEvent) ListWidgetElement(org.phoenicis.javafx.components.common.widgets.utils.ListWidgetElement) ShortcutInformation(org.phoenicis.javafx.components.library.panelstates.ShortcutInformation) ShortcutDTO(org.phoenicis.library.dto.ShortcutDTO) MappedList(org.phoenicis.javafx.collections.MappedList) ShortcutCategoryDTO(org.phoenicis.library.dto.ShortcutCategoryDTO) None(org.phoenicis.javafx.components.common.panelstates.None)

Aggregations

SortedList (javafx.collections.transformation.SortedList)13 FilteredList (javafx.collections.transformation.FilteredList)11 ObservableList (javafx.collections.ObservableList)9 ReadOnlyObjectWrapper (javafx.beans.property.ReadOnlyObjectWrapper)6 Optional (java.util.Optional)5 URL (java.net.URL)4 DateFormat (java.text.DateFormat)4 ParseException (java.text.ParseException)4 SimpleDateFormat (java.text.SimpleDateFormat)4 Date (java.util.Date)4 TimeUnit (java.util.concurrent.TimeUnit)4 ChangeListener (javafx.beans.value.ChangeListener)4 ListChangeListener (javafx.collections.ListChangeListener)4 Insets (javafx.geometry.Insets)4 Callback (javafx.util.Callback)4 Inject (javax.inject.Inject)4 EasyBind (org.fxmisc.easybind.EasyBind)4 Subscription (org.fxmisc.easybind.Subscription)4 ObjectProperty (javafx.beans.property.ObjectProperty)3 SimpleStringProperty (javafx.beans.property.SimpleStringProperty)3