Search in sources :

Example 1 with ApplicationSidebar

use of org.phoenicis.javafx.components.application.control.ApplicationSidebar 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)

Aggregations

Comparator (java.util.Comparator)1 Optional (java.util.Optional)1 Bindings (javafx.beans.binding.Bindings)1 ObjectExpression (javafx.beans.binding.ObjectExpression)1 ObjectProperty (javafx.beans.property.ObjectProperty)1 SimpleObjectProperty (javafx.beans.property.SimpleObjectProperty)1 ObservableList (javafx.collections.ObservableList)1 FilteredList (javafx.collections.transformation.FilteredList)1 SortedList (javafx.collections.transformation.SortedList)1 Node (javafx.scene.Node)1 ConcatenatedList (org.phoenicis.javafx.collections.ConcatenatedList)1 MappedList (org.phoenicis.javafx.collections.MappedList)1 ApplicationInformationPanel (org.phoenicis.javafx.components.application.control.ApplicationInformationPanel)1 ApplicationSidebar (org.phoenicis.javafx.components.application.control.ApplicationSidebar)1 ApplicationsFeaturePanel (org.phoenicis.javafx.components.application.control.ApplicationsFeaturePanel)1 ApplicationInformation (org.phoenicis.javafx.components.application.panelstates.ApplicationInformation)1 DetailsPanel (org.phoenicis.javafx.components.common.control.DetailsPanel)1 SidebarBase (org.phoenicis.javafx.components.common.control.SidebarBase)1 None (org.phoenicis.javafx.components.common.panelstates.None)1 OpenDetailsPanel (org.phoenicis.javafx.components.common.panelstates.OpenDetailsPanel)1