Search in sources :

Example 1 with TabIndicator

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

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)

Aggregations

Platform (javafx.application.Platform)1 Bindings (javafx.beans.binding.Bindings)1 IntegerBinding (javafx.beans.binding.IntegerBinding)1 SimpleObjectProperty (javafx.beans.property.SimpleObjectProperty)1 Scene (javafx.scene.Scene)1 Tab (javafx.scene.control.Tab)1 TabPane (javafx.scene.control.TabPane)1 Image (javafx.scene.image.Image)1 Stage (javafx.stage.Stage)1 Localisation.tr (org.phoenicis.configuration.localisation.Localisation.tr)1 JavaFXApplication (org.phoenicis.javafx.JavaFXApplication)1 ConcatenatedList (org.phoenicis.javafx.collections.ConcatenatedList)1 MappedList (org.phoenicis.javafx.collections.MappedList)1 ApplicationsFeaturePanel (org.phoenicis.javafx.components.application.control.ApplicationsFeaturePanel)1 TabIndicator (org.phoenicis.javafx.components.common.control.TabIndicator)1 ContainersFeaturePanel (org.phoenicis.javafx.components.container.control.ContainersFeaturePanel)1 InstallationsFeaturePanel (org.phoenicis.javafx.components.installation.control.InstallationsFeaturePanel)1 LibraryFeaturePanel (org.phoenicis.javafx.components.library.control.LibraryFeaturePanel)1 ErrorDialog (org.phoenicis.javafx.dialogs.ErrorDialog)1 JavaFxSettingsManager (org.phoenicis.javafx.settings.JavaFxSettingsManager)1