use of javafx.beans.binding.IntegerBinding 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;
}
use of javafx.beans.binding.IntegerBinding in project arquivoProject by fader-azevedo.
the class PdfViewerController method bindPaginationToCurrentFile.
private void bindPaginationToCurrentFile() {
currentFile.addListener(new ChangeListener<PDFFile>() {
@Override
public void changed(ObservableValue<? extends PDFFile> observable, PDFFile oldFile, PDFFile newFile) {
if (newFile != null) {
pagination.setCurrentPageIndex(0);
}
}
});
pagination.pageCountProperty().bind(new IntegerBinding() {
{
super.bind(currentFile);
}
@Override
protected int computeValue() {
return currentFile.get() == null ? 0 : currentFile.get().getNumPages();
}
});
pagination.disableProperty().bind(Bindings.isNull(currentFile));
}
Aggregations