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

The following examples show how to use javafx.scene.layout.GridPane#setVgrow() . 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: StateMonitorView.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
private void createTableView() {
    TableGroupHeadline headline = new TableGroupHeadline(getTableHeadLine());
    GridPane.setRowIndex(headline, ++gridRow);
    GridPane.setMargin(headline, new Insets(Layout.GROUP_DISTANCE, -10, -10, -10));
    root.getChildren().add(headline);

    tableView = new TableView<>();
    tableView.setPlaceholder(new AutoTooltipLabel(Res.get("table.placeholder.noData")));
    tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
    tableView.setPrefHeight(100);

    createColumns();
    GridPane.setRowIndex(tableView, gridRow);
    GridPane.setHgrow(tableView, Priority.ALWAYS);
    GridPane.setVgrow(tableView, Priority.SOMETIMES);
    GridPane.setMargin(tableView, new Insets(Layout.FIRST_ROW_AND_GROUP_DISTANCE, -10, -25, -10));
    root.getChildren().add(tableView);

    tableView.setItems(sortedList);
}
 
Example 3
Source File: MyReputationView.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public void initialize() {
    addTitledGroupBg(root, gridRow, 3, Res.get("dao.bond.reputation.header"));

    amountInputTextField = addInputTextField(root, gridRow, Res.get("dao.bond.reputation.amount"),
            Layout.FIRST_ROW_DISTANCE);
    amountInputTextField.setValidator(bsqValidator);

    timeInputTextField = FormBuilder.addInputTextField(root, ++gridRow, Res.get("dao.bond.reputation.time"));
    timeInputTextField.setValidator(timeInputTextFieldValidator);

    saltInputTextField = FormBuilder.addInputTextField(root, ++gridRow, Res.get("dao.bond.reputation.salt"));
    saltInputTextField.setValidator(hexStringValidator);

    lockupButton = addButtonAfterGroup(root, ++gridRow, Res.get("dao.bond.reputation.lockupButton"));

    tableView = FormBuilder.addTableViewWithHeader(root, ++gridRow, Res.get("dao.bond.reputation.table.header"), 20, "last");
    createColumns();
    tableView.setItems(sortedList);
    GridPane.setVgrow(tableView, Priority.ALWAYS);

    createListeners();
}
 
Example 4
Source File: ProposalsView.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
private void createProposalsTableView() {
    proposalsHeadline = new TableGroupHeadline(Res.get("dao.proposal.active.header"));
    GridPane.setRowIndex(proposalsHeadline, ++gridRow);
    GridPane.setMargin(proposalsHeadline, new Insets(Layout.GROUP_DISTANCE, -10, -10, -10));
    root.getChildren().add(proposalsHeadline);

    tableView = new TableView<>();
    tableView.setPlaceholder(new AutoTooltipLabel(Res.get("table.placeholder.noData")));
    tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);

    createProposalColumns();
    GridPane.setRowIndex(tableView, gridRow);
    GridPane.setHgrow(tableView, Priority.ALWAYS);
    GridPane.setVgrow(tableView, Priority.SOMETIMES);
    GridPane.setMargin(tableView, new Insets(Layout.FIRST_ROW_AND_GROUP_DISTANCE, -10, 5, -10));
    root.getChildren().add(tableView);

    tableView.setItems(sortedList);
}
 
Example 5
Source File: DotHTMLLabelJavaFxNode.java    From gef with Eclipse Public License 2.0 6 votes vote down vote up
private void applyTableAlignAttributesOnTdPane(GridPane wrapper) {
	/*
	 * Graphviz documentation specifies for the ALIGN attribute on cells: If
	 * the cell does not contain text, then the contained image or table is
	 * centered.
	 *
	 * Further, by observation, unless the fixedsize attribute is set, in
	 * graphviz the inner table grows in both horizontal and vertical
	 * direction.
	 *
	 * TODO: revise these settings when the align attribute on table tags is
	 * implemented, as this may change some behaviour.
	 */
	GridPane.setHgrow(wrapper.getChildren().get(0), Priority.ALWAYS);
	GridPane.setVgrow(wrapper.getChildren().get(0), Priority.ALWAYS);
	wrapper.setAlignment(Pos.CENTER);
}
 
Example 6
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 7
Source File: VoteResultView.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
private void createCyclesTable() {
    TableGroupHeadline headline = new TableGroupHeadline(Res.get("dao.results.cycles.header"));
    GridPane.setRowIndex(headline, ++gridRow);
    GridPane.setMargin(headline, new Insets(Layout.GROUP_DISTANCE, -10, -10, -10));
    GridPane.setColumnSpan(headline, 2);
    root.getChildren().add(headline);

    cyclesTableView = new TableView<>();
    cyclesTableView.setPlaceholder(new AutoTooltipLabel(Res.get("table.placeholder.processingData")));
    cyclesTableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);

    createCycleColumns(cyclesTableView);

    GridPane.setRowIndex(cyclesTableView, gridRow);
    GridPane.setMargin(cyclesTableView, new Insets(Layout.FIRST_ROW_AND_GROUP_DISTANCE, -10, -15, -10));
    GridPane.setColumnSpan(cyclesTableView, 2);
    GridPane.setVgrow(cyclesTableView, Priority.SOMETIMES);
    root.getChildren().add(cyclesTableView);

    cyclesTableView.setItems(sortedCycleListItemList);
    sortedCycleListItemList.comparatorProperty().bind(cyclesTableView.comparatorProperty());


}
 
Example 8
Source File: DimReductionDataSetSample.java    From chart-fx with Apache License 2.0 5 votes vote down vote up
private static XYChart getChart(final boolean isWavelet) {
    DefaultNumericAxis xAxis = new DefaultNumericAxis("time", "turns");
    DefaultNumericAxis yAxis = new DefaultNumericAxis("frequency", "fs");
    final XYChart chart = new XYChart(xAxis, yAxis);
    chart.getXAxis().setName("time");
    chart.getXAxis().setUnit("turns");
    chart.getYAxis().setName("frequency");
    chart.getYAxis().setUnit("fs");
    if (isWavelet) {
        final ContourDataSetRenderer contourChartRenderer = new ContourDataSetRenderer();
        chart.getRenderers().set(0, contourChartRenderer);
        xAxis.setAutoRangeRounding(false);
        xAxis.setAutoRangePadding(0.0);
        yAxis.setAutoRangeRounding(false);
        yAxis.setAutoRangePadding(0.0);
    }
    chart.getPlugins().add(new ParameterMeasurements());
    chart.getPlugins().add(new Zoomer());
    chart.getPlugins().add(new TableViewer());
    chart.getPlugins().add(new EditAxis());
    chart.getPlugins().add(new DataPointTooltip());

    GridPane.setHgrow(chart, Priority.ALWAYS);
    GridPane.setVgrow(chart, Priority.ALWAYS);

    return chart;
}
 
Example 9
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 10
Source File: SignPaymentAccountsWindow.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
private void addSuccessContent() {
    removeContent();
    GridPane.setVgrow(descriptionLabel, Priority.ALWAYS);
    GridPane.setValignment(descriptionLabel, VPos.TOP);

    closeButton.setVisible(false);
    closeButton.setManaged(false);
    headLineLabel.setText(Res.get("popup.accountSigning.success.headline"));
    descriptionLabel.setText(Res.get("popup.accountSigning.success.description", selectedPaymentAccountsList.getItems().size()));
    ((AutoTooltipButton) actionButton).updateText(Res.get("shared.ok"));
    actionButton.setOnAction(a -> hide());
}
 
Example 11
Source File: BondsView.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void initialize() {
    tableView = FormBuilder.addTableViewWithHeader(root, ++gridRow, Res.get("dao.bond.allBonds.header"), "last");
    tableView.setItems(sortedList);
    GridPane.setVgrow(tableView, Priority.ALWAYS);
    addColumns();

    bondedReputationListener = c -> updateList();
    bondedRolesListener = c -> updateList();
}
 
Example 12
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 13
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 14
Source File: OfferBookView.java    From bisq with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public void initialize() {
    root.setPadding(new Insets(15, 15, 5, 15));

    final TitledGroupBg titledGroupBg = addTitledGroupBg(root, gridRow, 2, Res.get("offerbook.availableOffers"));
    titledGroupBg.getStyleClass().add("last");

    HBox hBox = new HBox();
    hBox.setAlignment(Pos.CENTER_LEFT);
    hBox.setSpacing(35);
    hBox.setPadding(new Insets(10, 0, 0, 0));

    final Tuple3<VBox, Label, AutocompleteComboBox<TradeCurrency>> currencyBoxTuple = FormBuilder.addTopLabelAutocompleteComboBox(
            Res.get("offerbook.filterByCurrency"));
    final Tuple3<VBox, Label, AutocompleteComboBox<PaymentMethod>> paymentBoxTuple = FormBuilder.addTopLabelAutocompleteComboBox(
            Res.get("offerbook.filterByPaymentMethod"));

    createOfferButton = new AutoTooltipButton();
    createOfferButton.setMinHeight(40);
    createOfferButton.setGraphicTextGap(10);
    AnchorPane.setRightAnchor(createOfferButton, 0d);
    AnchorPane.setBottomAnchor(createOfferButton, 0d);

    hBox.getChildren().addAll(currencyBoxTuple.first, paymentBoxTuple.first, createOfferButton);
    AnchorPane.setLeftAnchor(hBox, 0d);
    AnchorPane.setTopAnchor(hBox, 0d);
    AnchorPane.setBottomAnchor(hBox, 0d);

    AnchorPane anchorPane = new AnchorPane();
    anchorPane.getChildren().addAll(hBox, createOfferButton);

    GridPane.setHgrow(anchorPane, Priority.ALWAYS);
    GridPane.setRowIndex(anchorPane, gridRow);
    GridPane.setColumnSpan(anchorPane, 2);
    GridPane.setMargin(anchorPane, new Insets(Layout.FIRST_ROW_DISTANCE, 0, 0, 0));
    root.getChildren().add(anchorPane);

    currencyComboBox = currencyBoxTuple.third;

    paymentMethodComboBox = paymentBoxTuple.third;
    paymentMethodComboBox.setCellFactory(GUIUtil.getPaymentMethodCellFactory());

    tableView = new TableView<>();

    GridPane.setRowIndex(tableView, ++gridRow);
    GridPane.setColumnIndex(tableView, 0);
    GridPane.setColumnSpan(tableView, 2);
    GridPane.setMargin(tableView, new Insets(10, 0, -10, 0));
    GridPane.setVgrow(tableView, Priority.ALWAYS);
    root.getChildren().add(tableView);

    marketColumn = getMarketColumn();

    priceColumn = getPriceColumn();
    tableView.getColumns().add(priceColumn);
    amountColumn = getAmountColumn();
    tableView.getColumns().add(amountColumn);
    volumeColumn = getVolumeColumn();
    tableView.getColumns().add(volumeColumn);
    paymentMethodColumn = getPaymentMethodColumn();
    tableView.getColumns().add(paymentMethodColumn);
    signingStateColumn = getSigningStateColumn();
    tableView.getColumns().add(signingStateColumn);
    avatarColumn = getAvatarColumn();
    tableView.getColumns().add(getActionColumn());
    tableView.getColumns().add(avatarColumn);

    tableView.getSortOrder().add(priceColumn);
    tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
    Label placeholder = new AutoTooltipLabel(Res.get("table.placeholder.noItems", Res.get("shared.multipleOffers")));
    placeholder.setWrapText(true);
    tableView.setPlaceholder(placeholder);

    marketColumn.setComparator(Comparator.comparing(
            o -> CurrencyUtil.getCurrencyPair(o.getOffer().getCurrencyCode()),
            Comparator.nullsFirst(Comparator.naturalOrder())
    ));
    priceColumn.setComparator(Comparator.comparing(o -> o.getOffer().getPrice(), Comparator.nullsFirst(Comparator.naturalOrder())));
    amountColumn.setComparator(Comparator.comparing(o -> o.getOffer().getMinAmount()));
    volumeColumn.setComparator(Comparator.comparing(o -> o.getOffer().getMinVolume(), Comparator.nullsFirst(Comparator.naturalOrder())));
    paymentMethodColumn.setComparator(Comparator.comparing(o -> o.getOffer().getPaymentMethod()));
    avatarColumn.setComparator(Comparator.comparing(o -> o.getOffer().getOwnerNodeAddress().getFullAddress()));

    nrOfOffersLabel = new AutoTooltipLabel("");
    nrOfOffersLabel.setId("num-offers");
    GridPane.setHalignment(nrOfOffersLabel, HPos.LEFT);
    GridPane.setVgrow(nrOfOffersLabel, Priority.NEVER);
    GridPane.setValignment(nrOfOffersLabel, VPos.TOP);
    GridPane.setRowIndex(nrOfOffersLabel, ++gridRow);
    GridPane.setColumnIndex(nrOfOffersLabel, 0);
    GridPane.setMargin(nrOfOffersLabel, new Insets(10, 0, 0, 0));
    root.getChildren().add(nrOfOffersLabel);

    offerListListener = c -> nrOfOffersLabel.setText(Res.get("offerbook.nrOffers", model.getOfferList().size()));

    // Fixes incorrect ordering of Available offers:
    // https://github.com/bisq-network/bisq-desktop/issues/588
    priceFeedUpdateCounterListener = (observable, oldValue, newValue) -> tableView.sort();
}
 
Example 15
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 16
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 17
Source File: ActionsDialog.java    From phoebus with Eclipse Public License 1.0 4 votes vote down vote up
/** @return Sub-pane for OpenDisplay action */
private GridPane createOpenDisplayDetails()
{
    final InvalidationListener update = whatever ->
    {
        if (updating  ||  selected_action_index < 0)
            return;
        actions.set(selected_action_index, getOpenDisplayAction());
    };

    final GridPane open_display_details = new GridPane();
    // open_display_details.setGridLinesVisible(true);
    open_display_details.setHgap(10);
    open_display_details.setVgap(10);

    open_display_details.add(new Label(Messages.ActionsDialog_Description), 0, 0);
    open_display_description.textProperty().addListener(update);
    open_display_details.add(open_display_description, 1, 0);
    GridPane.setHgrow(open_display_description, Priority.ALWAYS);

    open_display_details.add(new Label(Messages.ActionsDialog_DisplayPath), 0, 1);
    open_display_path.textProperty().addListener(update);
    final Button select = new Button("...");
    select.setOnAction(event ->
    {
        try
        {
            final String path = FilenameSupport.promptForRelativePath(widget, open_display_path.getText());
            if (path != null)
                open_display_path.setText(path);
            FilenameSupport.performMostAwfulTerribleNoGoodHack(action_list);
        }
        catch (Exception ex)
        {
            logger.log(Level.WARNING, "Cannot prompt for filename", ex);
        }
    });
    final HBox path_box = new HBox(open_display_path, select);
    HBox.setHgrow(open_display_path, Priority.ALWAYS);
    open_display_details.add(path_box, 1, 1);

    final HBox modes_box = new HBox(10);
    open_display_targets = new ToggleGroup();
    final Target[] modes = Target.values();
    for (int i=0; i<modes.length; ++i)
    {
        // Suppress deprecated legacy mode which is handled as WINDOW
        if (modes[i] == Target.STANDALONE)
            continue;

        final RadioButton target = new RadioButton(modes[i].toString());
        target.setToggleGroup(open_display_targets);
        target.selectedProperty().addListener(update);
        modes_box.getChildren().add(target);

        if (modes[i] == Target.TAB)
            open_display_pane.disableProperty().bind(target.selectedProperty().not());
    }
    open_display_pane.textProperty().addListener(update);
    open_display_details.add(modes_box, 0, 2, 2, 1);

    open_display_details.add(new Label("Pane:"), 0, 3);
    open_display_details.add(open_display_pane, 1, 3);

    open_display_macros = new MacrosTable(new Macros());
    open_display_macros.addListener(update);
    open_display_details.add(open_display_macros.getNode(), 0, 4, 2, 1);
    GridPane.setHgrow(open_display_macros.getNode(), Priority.ALWAYS);
    GridPane.setVgrow(open_display_macros.getNode(), Priority.ALWAYS);

    return open_display_details;
}
 
Example 18
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 19
Source File: LockFileAlreadyExistsDialog.java    From paintera with GNU General Public License v2.0 4 votes vote down vote up
public static void showDialog(final LockFile.UnableToCreateLock exception)
{
	final Alert alert = new Alert(AlertType.ERROR);
	alert.setTitle("Paintera");
	alert.setHeaderText("Unable to create lock file.");

	final Label instructions = new Label(
			"If no other Paintera instance is accessing the same project please delete lock file and try to " +
					"restart Paintera.");
	instructions.setWrapText(true);

	final GridPane  content      = new GridPane();
	final Label     fileLabel    = new Label("Lock File");
	final Label     messageLabel = new Label("Message");
	final TextField fileField    = new TextField(exception.getLockFile().getAbsolutePath());
	final TextField messageField = new TextField(exception.getMessage());
	fileField.setTooltip(new Tooltip(fileField.getText()));
	messageField.setTooltip(new Tooltip(messageField.getText()));

	fileField.setEditable(false);
	messageField.setEditable(false);

	GridPane.setHgrow(fileField, Priority.ALWAYS);
	GridPane.setHgrow(messageField, Priority.ALWAYS);

	content.add(fileLabel, 0, 0);
	content.add(messageLabel, 0, 1);
	content.add(fileField, 1, 0);
	content.add(messageField, 1, 1);

	final VBox contentBox = new VBox(instructions, content);

	alert.getDialogPane().setContent(contentBox);

	final StringWriter stringWriter = new StringWriter();
	exception.printStackTrace(new PrintWriter(stringWriter));
	final String   exceptionText = stringWriter.toString();
	final TextArea textArea      = new TextArea(exceptionText);
	textArea.setEditable(false);
	textArea.setWrapText(true);

	LOG.trace("Exception text (length={}): {}", exceptionText.length(), exceptionText);

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

	//		final GridPane expandableContent = new GridPane();
	//		expandableContent.setMaxWidth( Double.MAX_VALUE );
	//
	//		expandableContent.add( child, columnIndex, rowIndex );

	alert.getDialogPane().setExpandableContent(textArea);

	//		alert.setResizable( true );
	alert.showAndWait();
}
 
Example 20
Source File: AbstractChartMeasurement.java    From chart-fx with Apache License 2.0 4 votes vote down vote up
public AbstractChartMeasurement(final ParameterMeasurements plugin, final String measurementName, final AxisMode axisMode, final int requiredNumberOfIndicators,
        final int requiredNumberOfDataSets) {
    if (plugin == null) {
        throw new IllegalArgumentException("plugin is null");
    }
    this.plugin = plugin;
    this.measurementName = measurementName;
    this.axisMode = axisMode;
    this.requiredNumberOfIndicators = requiredNumberOfIndicators;
    this.requiredNumberOfDataSets = requiredNumberOfDataSets;

    plugin.getChartMeasurements().add(this);

    alert = new Alert(AlertType.CONFIRMATION);
    alert.setTitle("Measurement Config Dialog");
    alert.setHeaderText("Please, select data set and/or other parameters:");
    alert.initModality(Modality.APPLICATION_MODAL);

    final DecorationPane decorationPane = new DecorationPane();
    decorationPane.getChildren().add(gridPane);
    alert.getDialogPane().setContent(decorationPane);
    alert.getButtonTypes().setAll(buttonOK, buttonDefault, buttonRemove);
    alert.setOnCloseRequest(evt -> alert.close());
    // add data set selector if necessary (ie. more than one data set available)
    dataSetSelector = new DataSetSelector(plugin, requiredNumberOfDataSets);
    if (dataSetSelector.getNumberDataSets() >= 1) {
        lastLayoutRow = shiftGridPaneRowOffset(dataSetSelector.getChildren(), lastLayoutRow);
        gridPane.getChildren().addAll(dataSetSelector.getChildren());
    }

    valueIndicatorSelector = new ValueIndicatorSelector(plugin, axisMode, requiredNumberOfIndicators); // NOPMD
    lastLayoutRow = shiftGridPaneRowOffset(valueIndicatorSelector.getChildren(), lastLayoutRow);
    gridPane.getChildren().addAll(valueIndicatorSelector.getChildren());
    valueField.setMouseTransparent(true);
    GridPane.setVgrow(dataViewWindow, Priority.NEVER);
    dataViewWindow.setOnMouseClicked(mouseHandler);

    getValueIndicatorsUser().addListener(valueIndicatorsUserChangeListener);

    dataViewWindow.nameProperty().bindBidirectional(title);
    setTitle(AbstractChartMeasurement.this.getClass().getSimpleName()); // NOPMD

    dataSet.addListener(dataSetChangeListener);
    dataSetChangeListener.changed(dataSet, null, null);

    getMeasurementPlugin().getDataView().getVisibleChildren().add(dataViewWindow);
}