Java Code Examples for javafx.scene.layout.GridPane#setMaxWidth()

The following examples show how to use javafx.scene.layout.GridPane#setMaxWidth() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AlertMaker.java    From Library-Assistant with Apache License 2.0 7 votes vote down vote up
public static void showErrorMessage(Exception ex, String title, String content) {
    Alert alert = new Alert(AlertType.ERROR);
    alert.setTitle("Error occured");
    alert.setHeaderText(title);
    alert.setContentText(content);

    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    ex.printStackTrace(pw);
    String exceptionText = sw.toString();

    Label label = new Label("The exception stacktrace was:");

    TextArea textArea = new TextArea(exceptionText);
    textArea.setEditable(false);
    textArea.setWrapText(true);

    textArea.setMaxWidth(Double.MAX_VALUE);
    textArea.setMaxHeight(Double.MAX_VALUE);
    GridPane.setVgrow(textArea, Priority.ALWAYS);
    GridPane.setHgrow(textArea, Priority.ALWAYS);

    GridPane expContent = new GridPane();
    expContent.setMaxWidth(Double.MAX_VALUE);
    expContent.add(label, 0, 0);
    expContent.add(textArea, 0, 1);

    alert.getDialogPane().setExpandableContent(expContent);
    alert.showAndWait();
}
 
Example 2
Source File: InterruptibleProcessController.java    From chvote-1-0 with GNU Affero General Public License v3.0 6 votes vote down vote up
private void showAlert(ProcessInterruptedException e) {
    Alert alert = new Alert(Alert.AlertType.ERROR);
    ResourceBundle resources = getResourceBundle();
    alert.setTitle(resources.getString("exception_alert.title"));
    alert.setHeaderText(resources.getString("exception_alert.header"));
    alert.setContentText(e.getMessage());

    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    e.printStackTrace(pw);
    String exceptionText = sw.toString();

    Label stackTraceLabel = new Label(resources.getString("exception_alert.label"));
    TextArea stackTraceTextArea = new TextArea(exceptionText);
    stackTraceTextArea.setEditable(false);
    stackTraceTextArea.setWrapText(true);
    GridPane.setVgrow(stackTraceTextArea, Priority.ALWAYS);
    GridPane.setHgrow(stackTraceTextArea, Priority.ALWAYS);

    GridPane expandableContent = new GridPane();
    expandableContent.setPrefSize(400, 400);
    expandableContent.setMaxWidth(Double.MAX_VALUE);
    expandableContent.add(stackTraceLabel, 0, 0);
    expandableContent.add(stackTraceTextArea, 0, 1);

    alert.getDialogPane().setExpandableContent(expandableContent);
    // Dirty Linux only fix...
    // Expandable zones cause the dialog not to resize correctly
    if (System.getProperty("os.name").matches(".*[Ll]inux.*")) {
        alert.getDialogPane().setPrefSize(600, 400);
        alert.setResizable(true);
        alert.getDialogPane().setExpanded(true);
    }

    alert.showAndWait();
}
 
Example 3
Source File: DialogUtils.java    From qiniu with MIT License 6 votes vote down vote up
public static Optional<ButtonType> showException(String header, Exception e) {
    // 获取一个警告对象
    Alert alert = getAlert(header, "错误信息追踪:", AlertType.ERROR);
    // 打印异常信息
    StringWriter stringWriter = new StringWriter();
    PrintWriter printWriter = new PrintWriter(stringWriter);
    e.printStackTrace(printWriter);
    String exception = stringWriter.toString();
    // 显示异常信息
    TextArea textArea = new TextArea(exception);
    textArea.setEditable(false);
    textArea.setWrapText(true);
    // 设置弹窗容器
    textArea.setMaxWidth(Double.MAX_VALUE);
    textArea.setMaxHeight(Double.MAX_VALUE);
    GridPane.setVgrow(textArea, Priority.ALWAYS);
    GridPane.setHgrow(textArea, Priority.ALWAYS);
    GridPane gridPane = new GridPane();
    gridPane.setMaxWidth(Double.MAX_VALUE);
    gridPane.add(textArea, 0, 0);
    alert.getDialogPane().setExpandableContent(gridPane);
    return alert.showAndWait();
}
 
Example 4
Source File: PatientView.java    From WorkbenchFX with Apache License 2.0 5 votes vote down vote up
@Override
public void layoutParts() {
  setSpacing(20);

  GridPane dashboard = new GridPane();
  RowConstraints growingRow = new RowConstraints();
  growingRow.setVgrow(Priority.ALWAYS);
  ColumnConstraints growingCol = new ColumnConstraints();
  growingCol.setHgrow(Priority.ALWAYS);
  dashboard.getRowConstraints().setAll(growingRow, growingRow);
  dashboard.getColumnConstraints().setAll(growingCol, growingCol);

  dashboard.setVgap(60);

  dashboard.setPrefHeight(800);
  dashboard.addRow(0, bloodPressureSystolicControl, bloodPressureDiastolicControl);
  dashboard.addRow(1, weightControl, tallnessControl);


  setHgrow(dashboard, Priority.ALWAYS);

  GridPane form = new GridPane();
  form.setHgap(10);
  form.setVgap(25);
  form.setMaxWidth(410);

  GridPane.setVgrow(imageView, Priority.ALWAYS);
  GridPane.setValignment(imageView, VPos.BOTTOM);

  form.add(firstNameField, 0, 0);
  form.add(lastNameField, 1, 0);
  form.add(yearOfBirthField, 0, 1);
  form.add(genderField, 1, 1);
  form.add(imageView, 0, 2, 2, 1);
  form.add(imgURLField, 0, 3, 2, 1);

  getChildren().addAll(form, dashboard);

}
 
Example 5
Source File: NewsView.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
private GridPane createBisqDAOOnTestnetContent() {
    GridPane gridPane = new GridPane();
    gridPane.setMaxWidth(370);

    int rowIndex = 0;

    TitledGroupBg titledGroupBg = addTitledGroupBg(gridPane, rowIndex, 14, Res.get("dao.news.DAOOnTestnet.title"));
    titledGroupBg.getStyleClass().addAll("last", "dao-news-titled-group");
    Label daoTestnetDescription = addMultilineLabel(gridPane, ++rowIndex, Res.get("dao.news.DAOOnTestnet.description"), 0, 370);
    GridPane.setMargin(daoTestnetDescription, new Insets(Layout.FLOATING_LABEL_DISTANCE, 0, 8, 0));
    daoTestnetDescription.getStyleClass().add("dao-news-content");

    rowIndex = addInfoSection(gridPane, rowIndex, Res.get("dao.news.DAOOnTestnet.firstSection.title"),
            Res.get("dao.news.DAOOnTestnet.firstSection.content"),
            "https://docs.bisq.network/getting-started-dao.html#switch-to-testnet-mode");
    rowIndex = addInfoSection(gridPane, rowIndex, Res.get("dao.news.DAOOnTestnet.secondSection.title"),
            Res.get("dao.news.DAOOnTestnet.secondSection.content"),
            "https://docs.bisq.network/getting-started-dao.html#acquire-some-bsq");
    rowIndex = addInfoSection(gridPane, rowIndex, Res.get("dao.news.DAOOnTestnet.thirdSection.title"),
            Res.get("dao.news.DAOOnTestnet.thirdSection.content"),
            "https://docs.bisq.network/getting-started-dao.html#participate-in-a-voting-cycle");
    rowIndex = addInfoSection(gridPane, rowIndex, Res.get("dao.news.DAOOnTestnet.fourthSection.title"),
            Res.get("dao.news.DAOOnTestnet.fourthSection.content"),
            "https://docs.bisq.network/getting-started-dao.html#explore-a-bsq-block-explorer");

    Hyperlink hyperlink = addHyperlinkWithIcon(gridPane, ++rowIndex, Res.get("dao.news.DAOOnTestnet.readMoreLink"),
            "https://bisq.network/docs/dao");
    hyperlink.getStyleClass().add("dao-news-link");

    return gridPane;
}
 
Example 6
Source File: GitFxDialog.java    From GitFx with Apache License 2.0 5 votes vote down vote up
@Override
public void gitExceptionDialog(String title, String header, String content, Exception e) {

    Alert alert = new Alert(AlertType.ERROR);
    alert.setTitle(title);
    alert.setHeaderText(header);
    alert.setContentText(content);

    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    e.printStackTrace(pw);
    String exceptionText = sw.toString();
    Label label = new Label("Exception stack trace:");

    TextArea textArea = new TextArea(exceptionText);
    textArea.setEditable(false);
    textArea.setWrapText(true);

    textArea.setMaxWidth(Double.MAX_VALUE);
    textArea.setMaxHeight(Double.MAX_VALUE);
    GridPane.setVgrow(textArea, Priority.ALWAYS);
    GridPane.setHgrow(textArea, Priority.ALWAYS);

    GridPane expContent = new GridPane();
    expContent.setMaxWidth(Double.MAX_VALUE);
    expContent.add(label, 0, 0);
    expContent.add(textArea, 0, 1);
    alert.getDialogPane().setExpandableContent(expContent);
    alert.showAndWait();
}
 
Example 7
Source File: LongMessagePopupView.java    From standalone-app with Apache License 2.0 5 votes vote down vote up
private Alert get() {
    Alert alert = new Alert(Alert.AlertType.ERROR);

    DialogHelper.enableClosing(alert);

    alert.getButtonTypes().clear();

    alert.getButtonTypes().add(ButtonType.OK);

    alert.setTitle(message.toString());
    alert.setHeaderText(null);
    alert.setContentText(message.name());
    alert.initOwner(stage);

    TextArea textArea = new TextArea(longMessage);
    textArea.setEditable(false);
    textArea.setWrapText(true);

    textArea.setMaxWidth(Double.MAX_VALUE);
    textArea.setMaxHeight(Double.MAX_VALUE);
    GridPane.setVgrow(textArea, Priority.ALWAYS);
    GridPane.setHgrow(textArea, Priority.ALWAYS);

    GridPane expContent = new GridPane();
    expContent.setMaxWidth(Double.MAX_VALUE);
    expContent.add(textArea, 0, 0);

    alert.getDialogPane().setExpandableContent(expContent);

    return alert;
}
 
Example 8
Source File: AlertMaker.java    From Library-Assistant with Apache License 2.0 5 votes vote down vote up
public static void showErrorMessage(Exception ex) {
    Alert alert = new Alert(AlertType.ERROR);
    alert.setTitle("Error occured");
    alert.setHeaderText("Error Occured");
    alert.setContentText(ex.getLocalizedMessage());

    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    ex.printStackTrace(pw);
    String exceptionText = sw.toString();

    Label label = new Label("The exception stacktrace was:");

    TextArea textArea = new TextArea(exceptionText);
    textArea.setEditable(false);
    textArea.setWrapText(true);

    textArea.setMaxWidth(Double.MAX_VALUE);
    textArea.setMaxHeight(Double.MAX_VALUE);
    GridPane.setVgrow(textArea, Priority.ALWAYS);
    GridPane.setHgrow(textArea, Priority.ALWAYS);

    GridPane expContent = new GridPane();
    expContent.setMaxWidth(Double.MAX_VALUE);
    expContent.add(label, 0, 0);
    expContent.add(textArea, 0, 1);

    alert.getDialogPane().setExpandableContent(expContent);

    styleAlert(alert);
    alert.showAndWait();
}
 
Example 9
Source File: ExceptionAlerter.java    From Lipi with MIT License 5 votes vote down vote up
public static void showException(Exception e) {

        if (e != null) {
            Alert alert = new Alert(Alert.AlertType.ERROR);
            alert.setTitle("Exception Alert!");
            alert.setHeaderText("An Exception was thrown.");
            alert.setContentText(e.getMessage());

// Create expandable Exception.
            StringWriter sw = new StringWriter();
            PrintWriter pw = new PrintWriter(sw);
            e.printStackTrace(pw);
            String exceptionText = sw.toString();

            Label stackTraceHeaderLabel = new Label("The exception stacktrace was:");

            TextArea stackTraceTextArea = new TextArea(exceptionText);
            stackTraceTextArea.setEditable(false);
            stackTraceTextArea.setWrapText(true);

            stackTraceTextArea.setMaxWidth(Double.MAX_VALUE);
            stackTraceTextArea.setMaxHeight(Double.MAX_VALUE);
            GridPane.setVgrow(stackTraceTextArea, Priority.ALWAYS);
            GridPane.setHgrow(stackTraceTextArea, Priority.ALWAYS);

            GridPane expContent = new GridPane();
            expContent.setMaxWidth(Double.MAX_VALUE);
            expContent.add(stackTraceHeaderLabel, 0, 0);
            expContent.add(stackTraceTextArea, 0, 1);

// Set expandable Exception into the dialog pane.
            alert.getDialogPane().setExpandableContent(expContent);
            alert.getDialogPane().setExpanded(true);

            alert.showAndWait();
        }
    }
 
Example 10
Source File: DialogPlus.java    From ApkToolPlus with Apache License 2.0 5 votes vote down vote up
/**
 *  显示Exception的Dialog
 *
 * @param ex  异常
 */
public static void exception(Exception ex){
    Alert alert = new Alert(Alert.AlertType.ERROR);
    alert.setTitle("Exception Dialog");
    alert.setHeaderText("Look, an Exception Dialog");
    alert.setContentText("Could not find file blabla.txt!");

    //Exception ex = new FileNotFoundException("Could not find file blabla.txt");

    // Create expandable Exception.
    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    ex.printStackTrace(pw);
    String exceptionText = sw.toString();

    Label label = new Label("The exception stacktrace was:");

    TextArea textArea = new TextArea(exceptionText);
    textArea.setEditable(false);
    textArea.setWrapText(true);

    textArea.setMaxWidth(Double.MAX_VALUE);
    textArea.setMaxHeight(Double.MAX_VALUE);
    GridPane.setVgrow(textArea, Priority.ALWAYS);
    GridPane.setHgrow(textArea, Priority.ALWAYS);

    GridPane expContent = new GridPane();
    expContent.setMaxWidth(Double.MAX_VALUE);
    expContent.add(label, 0, 0);
    expContent.add(textArea, 0, 1);

    // Set expandable Exception into the dialog pane.
    alert.getDialogPane().setExpandableContent(expContent);
    alert.showAndWait();
}
 
Example 11
Source File: AlertFactory.java    From Motion_Profile_Generator with MIT License 5 votes vote down vote up
public static Alert createExceptionAlert( Exception e, String msg )
{
    Alert alert = new Alert(Alert.AlertType.ERROR);
    alert.setTitle("Exception Dialog");
    alert.setHeaderText("Whoops!");
    alert.setContentText(msg);

    // Create expandable Exception.
    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    e.printStackTrace(pw);
    String exceptionText = sw.toString();

    Label label = new Label("The exception stacktrace was:");

    TextArea textArea = new TextArea(exceptionText);
    textArea.setEditable(false);
    textArea.setWrapText(true);

    textArea.setMaxWidth(Double.MAX_VALUE);
    textArea.setMaxHeight(Double.MAX_VALUE);
    GridPane.setVgrow(textArea, Priority.ALWAYS);
    GridPane.setHgrow(textArea, Priority.ALWAYS);

    GridPane expContent = new GridPane();
    expContent.setMaxWidth(Double.MAX_VALUE);
    expContent.add(label, 0, 0);
    expContent.add(textArea, 0, 1);

    // Set expandable Exception into the dialog pane.
    alert.getDialogPane().setExpandableContent(expContent);

    return alert;
}
 
Example 12
Source File: JFxBuilder.java    From Weather-Forecast with Apache License 2.0 5 votes vote down vote up
private void createAlertDialog(DialogObject dialog) {
    Alert alert = new Alert(dialog.getType());
    alert.setTitle(dialog.getTitle());
    alert.setHeaderText(dialog.getHeader());
    alert.setContentText(dialog.getContent());

    Optional<ButtonType> result = alert.showAndWait();
    if (result.get() == ButtonType.OK) {
        System.exit(0);
    } else {
        StringWriter sw = new StringWriter();
        PrintWriter pw = new PrintWriter(sw);
        dialog.getexception().printStackTrace(pw);
        String exceptionText = sw.toString();

        Label label = new Label("The exception stacktrace was:");

        TextArea textArea = new TextArea(exceptionText);
        textArea.setEditable(false);
        textArea.setWrapText(true);

        textArea.setMaxWidth(Double.MAX_VALUE);
        textArea.setMaxHeight(Double.MAX_VALUE);
        GridPane.setVgrow(textArea, Priority.ALWAYS);
        GridPane.setHgrow(textArea, Priority.ALWAYS);

        GridPane expContent = new GridPane();
        expContent.setMaxWidth(Double.MAX_VALUE);
        expContent.add(label, 0, 0);
        expContent.add(textArea, 0, 1);

        alert.getDialogPane().setExpandableContent(expContent);

        alert.showAndWait();
    }
}
 
Example 13
Source File: DocPage.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
private Node createSideBar(ObservableList<SamplePage> relatedSamples) {
    GridPane sidebar = new GridPane() {
        // stretch to allways fill height of scrollpane
        @Override protected double computePrefHeight(double width) {
            return Math.max(
                    super.computePrefHeight(width),
                    getParent().getBoundsInLocal().getHeight()
            );
        }
    };
    sidebar.getStyleClass().add("right-sidebar");
    sidebar.setMaxWidth(Double.MAX_VALUE);
    sidebar.setMaxHeight(Double.MAX_VALUE);
    int sideRow = 0;
    // create side bar content
    // description
    Label discTitle = new Label("Related Samples");
    discTitle.getStyleClass().add("right-sidebar-title");
    GridPane.setConstraints(discTitle, 0, sideRow++);
    sidebar.getChildren().add(discTitle);
    // add sample tiles
    for (SamplePage sp: relatedSamples) {
        Node tile = sp.createTile();
        GridPane.setConstraints(tile, 0, sideRow++);
        sidebar.getChildren().add(tile);
    }
    return sidebar;
}
 
Example 14
Source File: DocPage.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
private Node createSideBar(ObservableList<SamplePage> relatedSamples) {
    GridPane sidebar = new GridPane() {
        // stretch to allways fill height of scrollpane
        @Override protected double computePrefHeight(double width) {
            return Math.max(
                    super.computePrefHeight(width),
                    getParent().getBoundsInLocal().getHeight()
            );
        }
    };
    sidebar.getStyleClass().add("right-sidebar");
    sidebar.setMaxWidth(Double.MAX_VALUE);
    sidebar.setMaxHeight(Double.MAX_VALUE);
    int sideRow = 0;
    // create side bar content
    // description
    Label discTitle = new Label("Related Samples");
    discTitle.getStyleClass().add("right-sidebar-title");
    GridPane.setConstraints(discTitle, 0, sideRow++);
    sidebar.getChildren().add(discTitle);
    // add sample tiles
    for (SamplePage sp: relatedSamples) {
        Node tile = sp.createTile();
        GridPane.setConstraints(tile, 0, sideRow++);
        sidebar.getChildren().add(tile);
    }
    return sidebar;
}
 
Example 15
Source File: MainController.java    From Noexes with GNU General Public License v3.0 5 votes vote down vote up
public static void showMessage(Throwable ex) {
        Alert alert = new Alert(Alert.AlertType.ERROR);
        alert.setTitle(ex.getClass().getName());
        alert.setHeaderText(ex.getClass().getSimpleName());
        alert.setContentText(ex.getMessage());


// Create expandable Exception.
        StringWriter sw = new StringWriter();
        PrintWriter pw = new PrintWriter(sw);
        ex.printStackTrace(pw);
        String exceptionText = sw.toString();

        Label label = new Label("The exception stacktrace was:");

        TextArea textArea = new TextArea(exceptionText);
        textArea.setEditable(false);
        textArea.setWrapText(true);

        textArea.setMaxWidth(Double.MAX_VALUE);
        textArea.setMaxHeight(Double.MAX_VALUE);
        GridPane.setVgrow(textArea, Priority.ALWAYS);
        GridPane.setHgrow(textArea, Priority.ALWAYS);

        GridPane expContent = new GridPane();
        expContent.setMaxWidth(Double.MAX_VALUE);
        expContent.add(label, 0, 0);
        expContent.add(textArea, 0, 1);

// Set expandable Exception into the dialog pane.
        alert.getDialogPane().setExpandableContent(expContent);

        alert.showAndWait();
    }
 
Example 16
Source File: ExceptionDialog.java    From milkman with MIT License 5 votes vote down vote up
public ExceptionDialog(Throwable ex) {
	super(AlertType.ERROR);
	setTitle("Exception");
	setHeaderText("Exception during startup of application");
	setContentText(ex.getClass().getName() + ": " + ex.getMessage());


	// Create expandable Exception.
	StringWriter sw = new StringWriter();
	PrintWriter pw = new PrintWriter(sw);
	ex.printStackTrace(pw);
	String exceptionText = sw.toString();

	Label label = new Label("The exception stacktrace was:");

	TextArea textArea = new TextArea(exceptionText);
	textArea.setEditable(false);
	textArea.setWrapText(true);

	textArea.setMaxWidth(Double.MAX_VALUE);
	textArea.setMaxHeight(Double.MAX_VALUE);
	GridPane.setVgrow(textArea, Priority.ALWAYS);
	GridPane.setHgrow(textArea, Priority.ALWAYS);

	GridPane expContent = new GridPane();
	expContent.setMaxWidth(Double.MAX_VALUE);
	expContent.add(label, 0, 0);
	expContent.add(textArea, 0, 1);

	// Set expandable Exception into the dialog pane.
	getDialogPane().setExpandableContent(expContent);
}
 
Example 17
Source File: ExceptionAlert.java    From Recaf with MIT License 4 votes vote down vote up
private ExceptionAlert(Throwable t, String msg) {
	super(AlertType.ERROR);
	setTitle("An error occurred");
	String header = t.getMessage();
	if(header == null)
		header = "(" + translate("ui.noerrormsg") + ")";
	setHeaderText(header);
	setContentText(msg);
	// Get exception text
	StringWriter sw = new StringWriter();
	PrintWriter pw = new PrintWriter(sw);
	t.printStackTrace(pw);
	String exText = sw.toString();
	// Create expandable Exception.
	Label lbl = new Label("Exception stacktrace:");
	TextArea txt = new TextArea(exText);
	txt.setEditable(false);
	txt.setWrapText(false);
	txt.setMaxWidth(Double.MAX_VALUE);
	txt.setMaxHeight(Double.MAX_VALUE);
	Hyperlink link = new Hyperlink("[Bug report]");
	link.setOnAction(e -> {
		try {
			// Append suffix to bug report url for the issue title
			String suffix = t.getClass().getSimpleName();
			if (t.getMessage() != null)
				suffix = suffix + ": " + t.getMessage();
			suffix = URLEncoder.encode(suffix, "UTF-8");
			// Open link in default browser
			Desktop.getDesktop().browse(URI.create(BUG_REPORT_LINK + suffix));
		} catch(IOException exx) {
			error(exx, "Failed to open bug report link");
			show(exx, "Failed to open bug report link.");
		}
	});
	TextFlow prompt = new TextFlow(new Text(translate("ui.openissue")), link);
	GridPane.setVgrow(txt, Priority.ALWAYS);
	GridPane.setHgrow(txt, Priority.ALWAYS);
	GridPane grid = new GridPane();
	grid.setMaxWidth(Double.MAX_VALUE);
	grid.add(lbl, 0, 0);
	grid.add(txt, 0, 1);
	// If desktop is supported, allow click-able bug report link
	if (Desktop.isDesktopSupported())
		grid.add(prompt, 0, 2);
	getDialogPane().setExpandableContent(grid);
	getDialogPane().setExpanded(true);
	// Set icon
	Stage stage = (Stage) getDialogPane().getScene().getWindow();
	stage.getIcons().add(new Image(resource("icons/error.png")));
}
 
Example 18
Source File: Controller.java    From J-Kinopoisk2IMDB with Apache License 2.0 4 votes vote down vote up
private void showResultDialog(List<MovieHandler.Error> errors, int maximum, int successful, int failed) {
    Alert alert = new Alert(Alert.AlertType.NONE);

    if (errors.isEmpty()) {
        alert.setAlertType(Alert.AlertType.INFORMATION);
        alert.setTitle("Обработка успешно завершена");
        alert.setHeaderText("Обработка фильмов была успешно завершена.");

        if (successful == maximum) {
            alert.setContentText("Были обработаны все " + maximum + " фильмов, без ошибок");
        } else {
            alert.setContentText("Были обработаны " + successful + " из " + maximum + " фильмов, без ошибок");
        }
    } else {
        alert.setAlertType(Alert.AlertType.WARNING);
        alert.setTitle("Обработка завершена c ошибками");
        alert.setHeaderText("Обработка фильмов была завершена с ошибками.");
        alert.setContentText("Были обработаны " + successful + " из " + maximum + " фильмов, без ошибок");

        // Create expandable Exception.
        StringWriter sw = new StringWriter();
        PrintWriter pw = new PrintWriter(sw);

        errors.stream()
                .collect(Collectors.groupingBy(
                        MovieHandler.Error::getMovie,
                        Collectors.mapping(MovieHandler.Error::getMessage, Collectors.toList())
                ))
                .entrySet()
                .forEach(e -> {
                    Movie movie = e.getKey();

                    pw.println(movie.getTitle() + "(" + movie.getYear() + "):");

                    e.getValue().forEach(pw::println);

                    pw.println();
                    pw.println();
                });

        String exceptionText = sw.toString();

        Label label = new Label("Произошли ошибки с " + failed + " фильмами:");

        TextArea textArea = new TextArea(exceptionText);
        textArea.setEditable(false);
        textArea.setWrapText(true);

        textArea.setMaxWidth(Double.MAX_VALUE);
        textArea.setMaxHeight(Double.MAX_VALUE);
        GridPane.setVgrow(textArea, Priority.ALWAYS);
        GridPane.setHgrow(textArea, Priority.ALWAYS);

        GridPane expContent = new GridPane();
        expContent.setMaxWidth(Double.MAX_VALUE);
        expContent.add(label, 0, 0);
        expContent.add(textArea, 0, 1);

        alert.getDialogPane().setExpandableContent(expContent);
    }

    alert.showAndWait();
}
 
Example 19
Source File: ExceptionPopupView.java    From standalone-app with Apache License 2.0 4 votes vote down vote up
private Alert get() {
    Alert alert = new Alert(Alert.AlertType.ERROR);

    DialogHelper.enableClosing(alert);

    alert.getButtonTypes().clear();

    if (allowReport)
        alert.getButtonTypes().add(new ButtonType("Send Error Report", ButtonBar.ButtonData.HELP));

    alert.getButtonTypes().add(ButtonType.OK);

    alert.setTitle("An exception has occurred");
    alert.setHeaderText(null);
    alert.setContentText(message);
    alert.initOwner(stage);

    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    cause.printStackTrace(pw);
    String exceptionText = sw.toString();

    Label label = new Label("The exception stacktrace was:");

    TextArea textArea = new TextArea(exceptionText);
    textArea.setEditable(false);
    textArea.setWrapText(true);

    textArea.setMaxWidth(Double.MAX_VALUE);
    textArea.setMaxHeight(Double.MAX_VALUE);
    GridPane.setVgrow(textArea, Priority.ALWAYS);
    GridPane.setHgrow(textArea, Priority.ALWAYS);

    GridPane expContent = new GridPane();
    expContent.setMaxWidth(Double.MAX_VALUE);
    expContent.add(label, 0, 0);
    expContent.add(textArea, 0, 1);

    alert.getDialogPane().setExpandableContent(expContent);

    return alert;
}
 
Example 20
Source File: NewsView.java    From bisq with GNU Affero General Public License v3.0 4 votes vote down vote up
private AnchorPane createBisqDAOContent() {
    AnchorPane anchorPane = new AnchorPane();
    anchorPane.setMinWidth(373);

    GridPane bisqDAOPane = new GridPane();
    AnchorPane.setTopAnchor(bisqDAOPane, 0d);
    bisqDAOPane.setVgap(5);
    bisqDAOPane.setMaxWidth(373);

    int rowIndex = 0;
    TitledGroupBg theBisqDaoTitledGroup = addTitledGroupBg(bisqDAOPane, rowIndex, 3, Res.get("dao.news.bisqDAO.title"));
    theBisqDaoTitledGroup.getStyleClass().addAll("last", "dao-news-titled-group");
    Label daoTeaserContent = addMultilineLabel(bisqDAOPane, ++rowIndex, Res.get("dao.news.bisqDAO.description"));
    daoTeaserContent.getStyleClass().add("dao-news-teaser");
    Hyperlink hyperlink = addHyperlinkWithIcon(bisqDAOPane, ++rowIndex, Res.get("dao.news.bisqDAO.readMoreLink"), "https://bisq.network/docs/dao");
    hyperlink.getStyleClass().add("dao-news-link");

    GridPane pastContributorsPane = new GridPane();
    AnchorPane.setBottomAnchor(pastContributorsPane, 0d);

    pastContributorsPane.setVgap(5);
    pastContributorsPane.setMaxWidth(373);

    rowIndex = 0;
    TitledGroupBg contributorsTitledGroup = addTitledGroupBg(pastContributorsPane, rowIndex, 4, Res.get("dao.news.pastContribution.title"));
    contributorsTitledGroup.getStyleClass().addAll("last", "dao-news-titled-group");
    Label pastContributionDescription = addMultilineLabel(pastContributorsPane, ++rowIndex, Res.get("dao.news.pastContribution.description"));
    pastContributionDescription.getStyleClass().add("dao-news-content");
    Tuple3<Label, BsqAddressTextField, VBox> tuple = addLabelBsqAddressTextField(pastContributorsPane, ++rowIndex,
            Res.get("dao.news.pastContribution.yourAddress"),
            Layout.FIRST_ROW_DISTANCE);
    addressTextField = tuple.second;
    Button requestNowButton = addPrimaryActionButton(pastContributorsPane, ++rowIndex, Res.get("dao.news.pastContribution.requestNow"), 0);
    requestNowButton.setMaxWidth(Double.MAX_VALUE);
    GridPane.setHgrow(requestNowButton, Priority.ALWAYS);
    requestNowButton.setOnAction(e -> GUIUtil.openWebPage("https://bisq.network/docs/dao/genesis"));

    anchorPane.getChildren().addAll(bisqDAOPane, pastContributorsPane);

    return anchorPane;
}