Search in sources :

Example 6 with MappedList

use of org.phoenicis.javafx.collections.MappedList in project POL-POM-5 by PhoenicisOrg.

the class MainWindow method createInstallationsTab.

private Tab createInstallationsTab(InstallationsFeaturePanel installationsFeaturePanel) {
    final Tab installationsTab = new Tab(tr("Installations"), installationsFeaturePanel);
    installationsTab.setClosable(false);
    final ConcatenatedList<InstallationDTO> installations = ConcatenatedList.create(new MappedList<>(installationsFeaturePanel.getInstallationCategories(), InstallationCategoryDTO::getInstallations));
    // a binding containing the number of currently active installations
    final IntegerBinding openInstallations = Bindings.createIntegerBinding(installations::size, installations);
    final TabIndicator indicator = new TabIndicator();
    indicator.textProperty().bind(StringBindings.map(openInstallations, numberOfInstallations -> {
        if (numberOfInstallations.intValue() < 10) {
            return String.valueOf(numberOfInstallations);
        } else {
            return "+";
        }
    }));
    // only show the tab indicator if at least one active installation exists
    installationsTab.graphicProperty().bind(Bindings.when(Bindings.notEqual(openInstallations, 0)).then(indicator).otherwise(new SimpleObjectProperty<>()));
    return installationsTab;
}
Also used : Scene(javafx.scene.Scene) LibraryFeaturePanel(org.phoenicis.javafx.components.library.control.LibraryFeaturePanel) TabIndicator(org.phoenicis.javafx.components.common.control.TabIndicator) IntegerBinding(javafx.beans.binding.IntegerBinding) StringBindings(org.phoenicis.javafx.utils.StringBindings) MappedList(org.phoenicis.javafx.collections.MappedList) Bindings(javafx.beans.binding.Bindings) ErrorDialog(org.phoenicis.javafx.dialogs.ErrorDialog) InstallationDTO(org.phoenicis.javafx.views.mainwindow.installations.dto.InstallationDTO) TabPane(javafx.scene.control.TabPane) JavaFXApplication(org.phoenicis.javafx.JavaFXApplication) ContainersFeaturePanel(org.phoenicis.javafx.components.container.control.ContainersFeaturePanel) InstallationsFeaturePanel(org.phoenicis.javafx.components.installation.control.InstallationsFeaturePanel) SettingsView(org.phoenicis.javafx.views.mainwindow.settings.SettingsView) ApplicationsFeaturePanel(org.phoenicis.javafx.components.application.control.ApplicationsFeaturePanel) InstallationCategoryDTO(org.phoenicis.javafx.views.mainwindow.installations.dto.InstallationCategoryDTO) Localisation.tr(org.phoenicis.configuration.localisation.Localisation.tr) Platform(javafx.application.Platform) JavaFxSettingsManager(org.phoenicis.javafx.settings.JavaFxSettingsManager) Stage(javafx.stage.Stage) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) Tab(javafx.scene.control.Tab) ThemeManager(org.phoenicis.javafx.themes.ThemeManager) ConcatenatedList(org.phoenicis.javafx.collections.ConcatenatedList) PhoenicisScene(org.phoenicis.javafx.views.common.PhoenicisScene) Image(javafx.scene.image.Image) EnginesView(org.phoenicis.javafx.views.mainwindow.engines.EnginesView) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) Tab(javafx.scene.control.Tab) InstallationDTO(org.phoenicis.javafx.views.mainwindow.installations.dto.InstallationDTO) IntegerBinding(javafx.beans.binding.IntegerBinding) TabIndicator(org.phoenicis.javafx.components.common.control.TabIndicator)

Example 7 with MappedList

use of org.phoenicis.javafx.collections.MappedList in project POL-POM-5 by PhoenicisOrg.

the class EnginesView method createEngineSubCategoryTabs.

private ObservableList<Tab> createEngineSubCategoryTabs(EngineSidebar sidebar) {
    // initialize the engines sub category panels
    final MappedList<List<EngineSubCategoryPanel>, EngineCategoryDTO> engineSubCategoryPanelGroups = new MappedList<>(this.engineCategories, engineCategory -> engineCategory.getSubCategories().stream().map(engineSubCategory -> {
        final EngineSubCategoryPanel engineSubCategoryPanel = new EngineSubCategoryPanel();
        engineSubCategoryPanel.setEngineCategory(engineCategory);
        engineSubCategoryPanel.setEngineSubCategory(engineSubCategory);
        engineSubCategoryPanel.setEnginesPath(this.enginesPath);
        engineSubCategoryPanel.setFilter(this.filter);
        engineSubCategoryPanel.setEngine(this.engines.get(engineCategory.getName().toLowerCase()));
        engineSubCategoryPanel.selectedListWidgetProperty().bind(sidebar.selectedListWidgetProperty());
        engineSubCategoryPanel.setOnEngineSelect(this::showEngineDetails);
        return engineSubCategoryPanel;
    }).collect(Collectors.toList()));
    final ConcatenatedList<EngineSubCategoryPanel> engineSubCategoryPanels = ConcatenatedList.create(engineSubCategoryPanelGroups);
    final FilteredList<EngineSubCategoryPanel> filteredEngineSubCategoryPanels = engineSubCategoryPanels.sorted(Comparator.comparing(engineSubCategoryPanel -> engineSubCategoryPanel.getEngineSubCategory().getName())).filtered(this.filter::filter);
    filteredEngineSubCategoryPanels.predicateProperty().bind(Bindings.createObjectBinding(() -> this.filter::filter, this.filter.searchTermProperty(), this.filter.showInstalledProperty(), this.filter.showNotInstalledProperty()));
    // map the panels to tabs
    return new MappedList<>(filteredEngineSubCategoryPanels, engineSubCategoryPanel -> new Tab(engineSubCategoryPanel.getEngineSubCategory().getDescription(), engineSubCategoryPanel));
}
Also used : MappedList(org.phoenicis.javafx.collections.MappedList) Tab(javafx.scene.control.Tab) EngineCategoryDTO(org.phoenicis.engines.dto.EngineCategoryDTO) MappedList(org.phoenicis.javafx.collections.MappedList) FilteredList(javafx.collections.transformation.FilteredList) ObservableList(javafx.collections.ObservableList) ConcatenatedList(org.phoenicis.javafx.collections.ConcatenatedList) EngineSubCategoryPanel(org.phoenicis.javafx.components.engine.control.EngineSubCategoryPanel)

Example 8 with MappedList

use of org.phoenicis.javafx.collections.MappedList in project POL-POM-5 by PhoenicisOrg.

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)

Example 9 with MappedList

use of org.phoenicis.javafx.collections.MappedList in project POL-POM-5 by PhoenicisOrg.

the class EngineSubCategoryPanelSkin method createListWidget.

/**
 * Creates a new {@link CombinedListWidget} object containing all {@link EngineVersionDTO} objects in the given
 * {@link ObservableList filteredEngineVersions}
 *
 * @param filteredEngineVersions An {@link ObservableList} containing all to be shown {@link EngineVersionDTO}
 *            objects
 * @return A new {@link CombinedListWidget} object containing all {@link EngineVersionDTO} objects in the given
 *         {@link ObservableList filteredEngineVersions}
 */
private CombinedListWidget<EngineVersionDTO> createListWidget(ObservableList<EngineVersionDTO> filteredEngineVersions) {
    final ObservableList<ListWidgetElement<EngineVersionDTO>> listWidgetEntries = new MappedList<>(filteredEngineVersions, engineVersion -> ListWidgetElement.create(engineVersion, Files.exists(Paths.get(getControl().getEnginesPath(), getControl().getEngineCategory().getName().toLowerCase(), getControl().getEngineSubCategory().getName(), engineVersion.getVersion()))));
    final CombinedListWidget<EngineVersionDTO> listWidget = new CombinedListWidget<>(listWidgetEntries);
    listWidget.selectedListWidgetProperty().bind(getControl().selectedListWidgetProperty());
    listWidget.selectedElementProperty().addListener((observable, oldValue, newValue) -> {
        if (newValue != null) {
            final EngineVersionDTO engineItem = newValue.getItem();
            Map<String, String> userData = new HashMap<>();
            userData.put("Mono", engineItem.getMonoFile());
            userData.put("Gecko", engineItem.getGeckoFile());
            EngineDTO engineDTO = new EngineDTO.Builder().withCategory(getControl().getEngineCategory().getName()).withSubCategory(getControl().getEngineSubCategory().getName()).withVersion(engineItem.getVersion()).withUserData(userData).build();
            Optional.ofNullable(getControl().getOnEngineSelect()).ifPresent(onEngineSelect -> onEngineSelect.accept(engineDTO, getControl().getEngine()));
        }
    });
    return listWidget;
}
Also used : MappedList(org.phoenicis.javafx.collections.MappedList) CombinedListWidget(org.phoenicis.javafx.components.common.widgets.control.CombinedListWidget) EngineDTO(org.phoenicis.engines.dto.EngineDTO) EngineVersionDTO(org.phoenicis.engines.dto.EngineVersionDTO) HashMap(java.util.HashMap) ListWidgetElement(org.phoenicis.javafx.components.common.widgets.utils.ListWidgetElement)

Example 10 with MappedList

use of org.phoenicis.javafx.collections.MappedList in project POL-POM-5 by PhoenicisOrg.

the class InstallationsFeaturePanelSkin method createContent.

/**
 * {@inheritDoc}
 */
@Override
public ObjectExpression<Node> createContent() {
    final FilteredList<InstallationDTO> filteredInstallations = ConcatenatedList.create(new MappedList<>(getControl().getInstallationCategories().sorted(Comparator.comparing(InstallationCategoryDTO::getName)), InstallationCategoryDTO::getInstallations)).filtered(getControl().getFilter()::filter);
    filteredInstallations.predicateProperty().bind(Bindings.createObjectBinding(() -> getControl().getFilter()::filter, getControl().getFilter().searchTermProperty(), getControl().getFilter().selectedInstallationCategoryProperty()));
    final SortedList<InstallationDTO> sortedInstallations = filteredInstallations.sorted(Comparator.comparing(InstallationDTO::getName));
    final ObservableList<ListWidgetElement<InstallationDTO>> listWidgetEntries = new MappedList<>(sortedInstallations, ListWidgetElement::create);
    final CombinedListWidget<InstallationDTO> combinedListWidget = new CombinedListWidget<>(listWidgetEntries, this.selectedListWidget);
    // bind direction: controller property -> skin property
    getControl().selectedInstallationProperty().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 InstallationDTO selectedItem = newValue.getItem();
            getControl().setSelectedInstallation(selectedItem);
            getControl().setOpenedDetailsPanel(new Installation(selectedItem));
        } else {
            getControl().setSelectedInstallation(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) Installation(org.phoenicis.javafx.components.installation.panelstates.Installation) ListWidgetElement(org.phoenicis.javafx.components.common.widgets.utils.ListWidgetElement) InstallationDTO(org.phoenicis.javafx.views.mainwindow.installations.dto.InstallationDTO) InstallationCategoryDTO(org.phoenicis.javafx.views.mainwindow.installations.dto.InstallationCategoryDTO) None(org.phoenicis.javafx.components.common.panelstates.None)

Aggregations

MappedList (org.phoenicis.javafx.collections.MappedList)14 SimpleObjectProperty (javafx.beans.property.SimpleObjectProperty)10 CombinedListWidget (org.phoenicis.javafx.components.common.widgets.control.CombinedListWidget)10 ListWidgetElement (org.phoenicis.javafx.components.common.widgets.utils.ListWidgetElement)10 None (org.phoenicis.javafx.components.common.panelstates.None)8 Tab (javafx.scene.control.Tab)6 ConcatenatedList (org.phoenicis.javafx.collections.ConcatenatedList)6 Bindings (javafx.beans.binding.Bindings)4 ObservableList (javafx.collections.ObservableList)4 FilteredList (javafx.collections.transformation.FilteredList)4 TabPane (javafx.scene.control.TabPane)4 Localisation.tr (org.phoenicis.configuration.localisation.Localisation.tr)4 JavaFxSettingsManager (org.phoenicis.javafx.settings.JavaFxSettingsManager)4 StringBindings (org.phoenicis.javafx.utils.StringBindings)4 InstallationCategoryDTO (org.phoenicis.javafx.views.mainwindow.installations.dto.InstallationCategoryDTO)4 InstallationDTO (org.phoenicis.javafx.views.mainwindow.installations.dto.InstallationDTO)4 Comparator (java.util.Comparator)2 HashMap (java.util.HashMap)2 Optional (java.util.Optional)2 Platform (javafx.application.Platform)2