Search in sources :

Example 1 with ContainerInformation

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

the class ContainersFeaturePanelSkin method createContent.

/**
 * {@inheritDoc}
 */
@Override
public ObjectExpression<Node> createContent() {
    /*
         * initialize the container lists by:
         * 1. sorting the containers by their name
         * 2. filtering the containers
         */
    final FilteredList<ContainerDTO> filteredContainers = ConcatenatedList.create(new MappedList<>(getControl().getCategories().sorted(Comparator.comparing(ContainerCategoryDTO::getName)), ContainerCategoryDTO::getContainers)).sorted(Comparator.comparing(ContainerDTO::getName)).filtered(getControl().getFilter()::filter);
    filteredContainers.predicateProperty().bind(Bindings.createObjectBinding(() -> getControl().getFilter()::filter, getControl().getFilter().searchTermProperty()));
    final ObservableList<ListWidgetElement<ContainerDTO>> listWidgetEntries = new MappedList<>(filteredContainers, ListWidgetElement::create);
    final CombinedListWidget<ContainerDTO> combinedListWidget = new CombinedListWidget<>(listWidgetEntries, this.selectedListWidget);
    // bind direction: controller property -> skin property
    getControl().selectedContainerProperty().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 ContainerDTO selectedItem = newValue.getItem();
            getControl().setSelectedContainer(selectedItem);
            getControl().setOpenedDetailsPanel(new ContainerInformation(selectedItem));
        } else {
            getControl().setSelectedContainer(null);
            getControl().setOpenedDetailsPanel(new None());
        }
    });
    return new SimpleObjectProperty<>(combinedListWidget);
}
Also used : MappedList(org.phoenicis.javafx.collections.MappedList) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) CombinedListWidget(org.phoenicis.javafx.components.common.widgets.control.CombinedListWidget) ListWidgetElement(org.phoenicis.javafx.components.common.widgets.utils.ListWidgetElement) ContainerInformation(org.phoenicis.javafx.components.container.panelstates.ContainerInformation) ContainerDTO(org.phoenicis.containers.dto.ContainerDTO) None(org.phoenicis.javafx.components.common.panelstates.None)

Aggregations

SimpleObjectProperty (javafx.beans.property.SimpleObjectProperty)1 ContainerDTO (org.phoenicis.containers.dto.ContainerDTO)1 MappedList (org.phoenicis.javafx.collections.MappedList)1 None (org.phoenicis.javafx.components.common.panelstates.None)1 CombinedListWidget (org.phoenicis.javafx.components.common.widgets.control.CombinedListWidget)1 ListWidgetElement (org.phoenicis.javafx.components.common.widgets.utils.ListWidgetElement)1 ContainerInformation (org.phoenicis.javafx.components.container.panelstates.ContainerInformation)1