Search in sources :

Example 1 with ShortcutCreation

use of org.phoenicis.javafx.components.library.panelstates.ShortcutCreation in project POL-POM-5 by PlayOnLinux.

the class LibraryFeaturePanelSkin method createSidebar.

/**
 * {@inheritDoc}
 */
@Override
public ObjectExpression<SidebarBase<?, ?, ?>> createSidebar() {
    final SortedList<ShortcutCategoryDTO> sortedCategories = getControl().getCategories().sorted(Comparator.comparing(ShortcutCategoryDTO::getName));
    final LibrarySidebar sidebar = new LibrarySidebar(getControl().getFilter(), sortedCategories, this.selectedListWidget);
    sidebar.applicationNameProperty().bind(getControl().applicationNameProperty());
    sidebar.javaFxSettingsManagerProperty().bind(getControl().javaFxSettingsManagerProperty());
    sidebar.setOnCreateShortcut(() -> {
        // deselect the currently selected shortcut
        getControl().setSelectedShortcut(null);
        // open the shortcut creation details panel
        getControl().setOpenedDetailsPanel(new ShortcutCreation());
    });
    sidebar.setOnOpenConsole(getControl()::openConsole);
    // set the default selection
    sidebar.setSelectedListWidget(Optional.ofNullable(getControl().getJavaFxSettingsManager()).map(JavaFxSettingsManager::getLibraryListType).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.setLibraryListType(newValue);
            javaFxSettingsManager.save();
        }
    });
    return new SimpleObjectProperty<>(sidebar);
}
Also used : SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) ShortcutCreation(org.phoenicis.javafx.components.library.panelstates.ShortcutCreation) ShortcutCategoryDTO(org.phoenicis.library.dto.ShortcutCategoryDTO) JavaFxSettingsManager(org.phoenicis.javafx.settings.JavaFxSettingsManager)

Aggregations

SimpleObjectProperty (javafx.beans.property.SimpleObjectProperty)1 ShortcutCreation (org.phoenicis.javafx.components.library.panelstates.ShortcutCreation)1 JavaFxSettingsManager (org.phoenicis.javafx.settings.JavaFxSettingsManager)1 ShortcutCategoryDTO (org.phoenicis.library.dto.ShortcutCategoryDTO)1