List of usage examples for javafx.scene.layout BorderPane setPrefWidth
public final void setPrefWidth(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; }/*from ww w . j a v a 2s. c o m*/ 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; }
From source file:org.sleuthkit.autopsy.timeline.ui.detailview.AggregateEventNode.java
public AggregateEventNode(final AggregateEvent event, AggregateEventNode parentEventNode, EventDetailChart chart) {/*w ww. j a v a2s . com*/ this.event = event; descLOD.set(event.getLOD()); this.parentEventNode = parentEventNode; this.chart = chart; final Region region = new Region(); HBox.setHgrow(region, Priority.ALWAYS); final HBox hBox = new HBox(descrLabel, countLabel, region, minusButton, plusButton); hBox.setPrefWidth(USE_COMPUTED_SIZE); hBox.setMinWidth(USE_PREF_SIZE); hBox.setPadding(new Insets(2, 5, 2, 5)); hBox.setAlignment(Pos.CENTER_LEFT); minusButton.setVisible(false); plusButton.setVisible(false); minusButton.setManaged(false); plusButton.setManaged(false); final BorderPane borderPane = new BorderPane(subNodePane, hBox, null, null, null); BorderPane.setAlignment(subNodePane, Pos.TOP_LEFT); borderPane.setPrefWidth(USE_COMPUTED_SIZE); getChildren().addAll(spanRegion, borderPane); setAlignment(Pos.TOP_LEFT); setMinHeight(24); minWidthProperty().bind(spanRegion.widthProperty()); setPrefHeight(USE_COMPUTED_SIZE); setMaxHeight(USE_PREF_SIZE); //set up subnode pane sizing contraints subNodePane.setPrefHeight(USE_COMPUTED_SIZE); subNodePane.setMinHeight(USE_PREF_SIZE); subNodePane.setMinWidth(USE_PREF_SIZE); subNodePane.setMaxHeight(USE_PREF_SIZE); subNodePane.setMaxWidth(USE_PREF_SIZE); subNodePane.setPickOnBounds(false); //setup description label eventTypeImageView.setImage(event.getType().getFXImage()); descrLabel.setGraphic(eventTypeImageView); descrLabel.setPrefWidth(USE_COMPUTED_SIZE); descrLabel.setTextOverrun(OverrunStyle.CENTER_ELLIPSIS); descrLabel.setMouseTransparent(true); setDescriptionVisibility(chart.getDescrVisibility().get()); //setup backgrounds final Color evtColor = event.getType().getColor(); spanFill = new Background( new BackgroundFill(evtColor.deriveColor(0, 1, 1, .1), CORNER_RADII, Insets.EMPTY)); setBackground( new Background(new BackgroundFill(evtColor.deriveColor(0, 1, 1, .1), CORNER_RADII, Insets.EMPTY))); setCursor(Cursor.HAND); spanRegion.setStyle("-fx-border-width:2 0 2 2; -fx-border-radius: 2; -fx-border-color: " + ColorUtilities.getRGBCode(evtColor) + ";"); // NON-NLS spanRegion.setBackground(spanFill); //set up mouse hover effect and tooltip setOnMouseEntered((MouseEvent e) -> { //defer tooltip creation till needed, this had a surprisingly large impact on speed of loading the chart installTooltip(); spanRegion.setEffect(new DropShadow(10, evtColor)); minusButton.setVisible(true); plusButton.setVisible(true); minusButton.setManaged(true); plusButton.setManaged(true); toFront(); }); setOnMouseExited((MouseEvent e) -> { spanRegion.setEffect(null); minusButton.setVisible(false); plusButton.setVisible(false); minusButton.setManaged(false); plusButton.setManaged(false); }); setOnMouseClicked(new EventMouseHandler()); plusButton.disableProperty().bind(descLOD.isEqualTo(DescriptionLOD.FULL)); minusButton.disableProperty().bind(descLOD.isEqualTo(event.getLOD())); plusButton.setOnMouseClicked(e -> { final DescriptionLOD next = descLOD.get().next(); if (next != null) { loadSubClusters(next); descLOD.set(next); } }); minusButton.setOnMouseClicked(e -> { final DescriptionLOD previous = descLOD.get().previous(); if (previous != null) { loadSubClusters(previous); descLOD.set(previous); } }); }