Search in sources :

Example 1 with ContainerSidebar

use of org.phoenicis.javafx.components.container.control.ContainerSidebar in project POL-POM-5 by PlayOnLinux.

the class ContainersFeaturePanelSkin method createSidebar.

/**
 * {@inheritDoc}
 */
@Override
public ObjectExpression<SidebarBase<?, ?, ?>> createSidebar() {
    /*
         * initialize the container categories by sorting them
         */
    final SortedList<ContainerCategoryDTO> sortedCategories = getControl().getCategories().sorted(Comparator.comparing(ContainerCategoryDTO::getName));
    final ContainerSidebar sidebar = new ContainerSidebar(getControl().getFilter(), sortedCategories, this.selectedListWidget);
    // set the default selection
    sidebar.setSelectedListWidget(Optional.ofNullable(getControl().getJavaFxSettingsManager()).map(JavaFxSettingsManager::getContainersListType).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.setContainersListType(newValue);
            javaFxSettingsManager.save();
        }
    });
    return new SimpleObjectProperty<>(sidebar);
}
Also used : SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) ContainerCategoryDTO(org.phoenicis.containers.dto.ContainerCategoryDTO) ContainerSidebar(org.phoenicis.javafx.components.container.control.ContainerSidebar) JavaFxSettingsManager(org.phoenicis.javafx.settings.JavaFxSettingsManager)

Aggregations

SimpleObjectProperty (javafx.beans.property.SimpleObjectProperty)1 ContainerCategoryDTO (org.phoenicis.containers.dto.ContainerCategoryDTO)1 ContainerSidebar (org.phoenicis.javafx.components.container.control.ContainerSidebar)1 JavaFxSettingsManager (org.phoenicis.javafx.settings.JavaFxSettingsManager)1