backShadow.setStyle("-fx-background-color: "+CSSHelper.toCssColor(backColor)+";");
target.getChildren().add(backShadow);
String blackOrWhiteDependingFromBack ="ladder("+CSSHelper.toCssColor(backColor)+", white 49%, black 50%);";
final VBox back = new VBox(3);
StackPane.setMargin(back, new Insets(150));
back.setStyle("-fx-border-color: "+blackOrWhiteDependingFromBack +"; -fx-border-width: 1px; -fx-padding: 3; -fx-background-color: derive("+CSSHelper.toCssColor(backColor)+",-50%);");
back.setAlignment(Pos.CENTER_RIGHT);
final Label label = new Label(message);
label.prefWidthProperty().bind(target.widthProperty());
StackPane.setMargin(back, new Insets(150));
label.setStyle("-fx-text-fill: "+blackOrWhiteDependingFromBack +";");
label.setWrapText(true);
label.setGraphic(icon);
back.getChildren().add(label);
final TextArea area = new TextArea();
area.setPrefRowCount(10);
if (e!=null){
area.setText(Throwables.getStackTraceAsString(e));
}
area.setOpacity(0.4);
area.setEditable(false);
VBox.setVgrow(area, Priority.ALWAYS);
back.getChildren().add(area);
area.getStyleClass().add("consoleFont");
ContextMenu menue = new ContextMenu();
MenuItem item = new MenuItem("copy to clipboard");
item.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
final Clipboard clipboard = Clipboard.getSystemClipboard();
final ClipboardContent content = new ClipboardContent();
content.putString(area.getText());
clipboard.setContent(content);
}
});
menue.getItems().add(item);
area.setContextMenu(menue);
Button ok = new Button("OK");
ok.setPrefWidth(100);
ok.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
target.getChildren().remove(back);
target.getChildren().remove(backShadow);
if (okOnAction!=null){
okOnAction.run();
}
}
});
back.getChildren().add(ok);
target.getChildren().add(back);
}
});
}