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;
}
Aggregations