List of usage examples for javafx.scene.layout BorderPane setPrefHeight
public final void setPrefHeight(double value)
From source file:cz.lbenda.rcp.DialogHelper.java
/** Show unsaved object if aren't saved. if user want cancel the closing then return false, elserwhere return true * @param savableRegistry register which hold unsaved data * @return true if window/object can be closed */ public boolean showUnsavedObjectDialog(SavableRegistry savableRegistry) { Set<Savable> savables = savableRegistry.dirtySavables(); if (savables.size() == 0) { return true; }/* w ww . j a va 2s . c om*/ Dialog<?> dialog = new Dialog<>(); dialog.setResizable(false); dialog.setTitle(msgNotSavedObjectsTitle); dialog.setHeaderText(msgNotSavedObjectsHeader); BorderPane pane = new BorderPane(); pane.setPrefHeight(400); pane.setPrefWidth(300); ListView<DialogHelper.Item> listView = new ListView<>(); listView.getItems() .addAll(savables.stream().map(savable -> new Item(savable, true)).collect(Collectors.toList())); listView.setCellFactory(CheckBoxListCell.forListView(DialogHelper.Item::onProperty)); pane.setCenter(listView); dialog.getDialogPane().setContent(pane); ButtonType btCancel = new ButtonType(button_cancel, ButtonBar.ButtonData.CANCEL_CLOSE); ButtonType btSaveClose = new ButtonType(button_saveAndClose, ButtonBar.ButtonData.OK_DONE); ButtonType btClose = new ButtonType(button_closeWithoutSave); dialog.getDialogPane().getButtonTypes().addAll(btClose, btSaveClose, btCancel); Optional<?> result = dialog.showAndWait(); if (result.isPresent()) { if (btCancel == result.get()) { return false; } if (btSaveClose == result.get()) { listView.getItems().stream().filter(Item::isOn).forEach(item -> item.getSavable().save()); } } else { return false; } return true; }