Search in sources :

Example 36 with SimpleObjectProperty

use of javafx.beans.property.SimpleObjectProperty in project POL-POM-5 by PhoenicisOrg.

the class ApplicationsFeaturePanelSkin method createContent.

/**
 * {@inheritDoc}
 */
@Override
public ObjectExpression<Node> createContent() {
    /*
         * initialising the application lists by:
         * 1. sorting the applications by their name
         * 2. filtering them
         */
    final FilteredList<ApplicationDTO> filteredApplications = ConcatenatedList.create(new MappedList<>(getControl().getCategories().filtered(category -> category.getType() == CategoryDTO.CategoryType.INSTALLERS), CategoryDTO::getApplications)).sorted(Comparator.comparing(ApplicationDTO::getName)).filtered(getControl()::filterApplication);
    filteredApplications.predicateProperty().bind(Bindings.createObjectBinding(() -> getControl()::filterApplication, getControl().searchTermProperty(), getControl().fuzzySearchRatioProperty(), getControl().operatingSystemProperty(), getControl().filterCategoryProperty(), getControl().containAllOSCompatibleApplicationsProperty(), getControl().containCommercialApplicationsProperty(), getControl().containRequiresPatchApplicationsProperty(), getControl().containTestingApplicationsProperty()));
    final ObservableList<ListWidgetElement<ApplicationDTO>> listWidgetEntries = new MappedList<>(filteredApplications, ListWidgetElement::create);
    final CombinedListWidget<ApplicationDTO> combinedListWidget = new CombinedListWidget<>(listWidgetEntries, this.selectedListWidget);
    // bind direction: controller property -> skin property
    getControl().selectedApplicationProperty().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 ApplicationDTO selectedItem = newValue.getItem();
            getControl().setSelectedApplication(selectedItem);
            getControl().setOpenedDetailsPanel(new ApplicationInformation(selectedItem));
        } else {
            getControl().setSelectedApplication(null);
            getControl().setOpenedDetailsPanel(new None());
        }
    });
    return new SimpleObjectProperty<>(combinedListWidget);
}
Also used : MappedList(org.phoenicis.javafx.collections.MappedList) ApplicationDTO(org.phoenicis.repository.dto.ApplicationDTO) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) CombinedListWidget(org.phoenicis.javafx.components.common.widgets.control.CombinedListWidget) ListWidgetElement(org.phoenicis.javafx.components.common.widgets.utils.ListWidgetElement) None(org.phoenicis.javafx.components.common.panelstates.None) ApplicationInformation(org.phoenicis.javafx.components.application.panelstates.ApplicationInformation)

Example 37 with SimpleObjectProperty

use of javafx.beans.property.SimpleObjectProperty in project POL-POM-5 by PhoenicisOrg.

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)37 TableColumn (javafx.scene.control.TableColumn)12 MappedList (org.phoenicis.javafx.collections.MappedList)10 JavaFxSettingsManager (org.phoenicis.javafx.settings.JavaFxSettingsManager)10 BigDecimal (java.math.BigDecimal)9 None (org.phoenicis.javafx.components.common.panelstates.None)8 CombinedListWidget (org.phoenicis.javafx.components.common.widgets.control.CombinedListWidget)8 ListWidgetElement (org.phoenicis.javafx.components.common.widgets.utils.ListWidgetElement)8 Bindings (javafx.beans.binding.Bindings)7 Button (javafx.scene.control.Button)7 SimpleStringProperty (javafx.beans.property.SimpleStringProperty)6 LocalDate (java.time.LocalDate)5 Optional (java.util.Optional)5 ObjectProperty (javafx.beans.property.ObjectProperty)5 ObservableList (javafx.collections.ObservableList)5 FXML (javafx.fxml.FXML)5 Scene (javafx.scene.Scene)5 TableCell (javafx.scene.control.TableCell)5 ArrayList (java.util.ArrayList)4 List (java.util.List)4