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

The following examples show how to use javafx.scene.layout.GridPane#setHgrow() . 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: SpreadView.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public void initialize() {
    tableView = new TableView<>();

    int gridRow = 0;
    GridPane.setRowIndex(tableView, gridRow);
    GridPane.setVgrow(tableView, Priority.ALWAYS);
    GridPane.setHgrow(tableView, Priority.ALWAYS);
    root.getChildren().add(tableView);
    Label placeholder = new AutoTooltipLabel(Res.get("table.placeholder.noData"));
    placeholder.setWrapText(true);
    tableView.setPlaceholder(placeholder);

    TableColumn<SpreadItem, SpreadItem> currencyColumn = getCurrencyColumn();
    tableView.getColumns().add(currencyColumn);
    numberOfOffersColumn = getNumberOfOffersColumn();
    tableView.getColumns().add(numberOfOffersColumn);
    numberOfBuyOffersColumn = getNumberOfBuyOffersColumn();
    tableView.getColumns().add(numberOfBuyOffersColumn);
    numberOfSellOffersColumn = getNumberOfSellOffersColumn();
    tableView.getColumns().add(numberOfSellOffersColumn);
    totalAmountColumn = getTotalAmountColumn();
    tableView.getColumns().add(totalAmountColumn);
    TableColumn<SpreadItem, SpreadItem> spreadColumn = getSpreadColumn();
    tableView.getColumns().add(spreadColumn);
    tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);

    currencyColumn.setComparator(Comparator.comparing(o -> CurrencyUtil.getNameByCode(o.currencyCode)));
    numberOfOffersColumn.setComparator(Comparator.comparingInt(o3 -> o3.numberOfOffers));
    numberOfBuyOffersColumn.setComparator(Comparator.comparingInt(o3 -> o3.numberOfBuyOffers));
    numberOfSellOffersColumn.setComparator(Comparator.comparingInt(o2 -> o2.numberOfSellOffers));
    totalAmountColumn.setComparator(Comparator.comparing(o -> o.totalAmount));
    spreadColumn.setComparator(Comparator.comparingDouble(o -> o.percentageValue));

    numberOfOffersColumn.setSortType(TableColumn.SortType.DESCENDING);
    tableView.getSortOrder().add(numberOfOffersColumn);
    itemListChangeListener = c -> updateHeaders();
}
 
Example 3
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 4
Source File: NotificationBar.java    From yfiton with Apache License 2.0 6 votes vote down vote up
void updatePane() {
    actionsBar = ActionUtils.createButtonBar(getActions());
    actionsBar.opacityProperty().bind(transition);
    GridPane.setHgrow(actionsBar, Priority.SOMETIMES);
    pane.getChildren().clear();

    int row = 0;

    if (title != null) {
        pane.add(title, 0, row++);
    }

    pane.add(label, 0, row);
    pane.add(actionsBar, 1, row);

    if (isCloseButtonVisible()) {
        pane.add(closeBtn, 2, 0, 1, row + 1);
    }
}
 
Example 5
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 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: PreferencesView.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
private void initializeDisplayOptions() {
        TitledGroupBg titledGroupBg = addTitledGroupBg(root, ++gridRow, 5, Res.get("setting.preferences.displayOptions"), Layout.GROUP_DISTANCE);
        GridPane.setColumnSpan(titledGroupBg, 1);

//        showOwnOffersInOfferBook = addLabelCheckBox(root, gridRow, Res.get("setting.preferences.showOwnOffers"), Layout.FIRST_ROW_AND_GROUP_DISTANCE);
        showOwnOffersInOfferBook = addSlideToggleButton(root, gridRow, Res.get("setting.preferences.showOwnOffers"), Layout.FIRST_ROW_AND_GROUP_DISTANCE);
        useAnimations = addSlideToggleButton(root, ++gridRow, Res.get("setting.preferences.useAnimations"));
        useDarkMode = addSlideToggleButton(root, ++gridRow, Res.get("setting.preferences.useDarkMode"));
        // useStickyMarketPriceCheckBox = addLabelCheckBox(root, ++gridRow, "Use sticky market price:", "").second;
        sortMarketCurrenciesNumerically = addSlideToggleButton(root, ++gridRow, Res.get("setting.preferences.sortWithNumOffers"));
        resetDontShowAgainButton = addButton(root, ++gridRow, Res.get("setting.preferences.resetAllFlags"), 0);
        resetDontShowAgainButton.getStyleClass().add("compact-button");
        resetDontShowAgainButton.setMaxWidth(Double.MAX_VALUE);
        GridPane.setHgrow(resetDontShowAgainButton, Priority.ALWAYS);
        GridPane.setColumnIndex(resetDontShowAgainButton, 0);
    }
 
Example 8
Source File: AlarmAreaView.java    From phoebus with Eclipse Public License 1.0 6 votes vote down vote up
private Label newAreaLabel(final String item_name)
{
    final Label label = new Label(item_name);
    label.setBorder(border);
    label.setAlignment(Pos.CENTER);
    label.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
    label.setFont(font);
    GridPane.setHgrow(label, Priority.ALWAYS);
    GridPane.setVgrow(label, Priority.ALWAYS);
    return label;
}
 
Example 9
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 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: SegmentMeshExporterDialog.java    From paintera with GNU General Public License v2.0 5 votes vote down vote up
private int createCommonDialog(final GridPane contents)
{
	int row = 0;

	contents.add(new Label("Scale"), 0, row);
	contents.add(scale, 1, row);
	GridPane.setFillWidth(scale, true);
	++row;

	contents.add(new Label("Format"), 0, row);

	final List<String>           typeNames = Stream.of(FILETYPE.values()).map(FILETYPE::name).collect(Collectors
			.toList());
	final ObservableList<String> options   = FXCollections.observableArrayList(typeNames);
	fileFormats = new ComboBox<>(options);
	fileFormats.getSelectionModel().select(0);
	fileFormats.setMinWidth(0);
	fileFormats.setMaxWidth(Double.POSITIVE_INFINITY);
	contents.add(fileFormats, 1, row);
	fileFormats.maxWidth(300);
	GridPane.setFillWidth(fileFormats, true);
	GridPane.setHgrow(fileFormats, Priority.ALWAYS);

	++row;

	contents.add(new Label("Save to:"), 0, row);
	contents.add(filePath, 1, row);

	this.getDialogPane().getButtonTypes().addAll(ButtonType.CANCEL, ButtonType.OK);
	this.getDialogPane().lookupButton(ButtonType.OK).disableProperty().bind(this.isError);

	return row;
}
 
Example 12
Source File: GenericBackendDialogN5.java    From paintera with GNU General Public License v2.0 5 votes vote down vote up
private Node initializeNode(
		final Node rootNode,
		final String datasetPromptText,
		final Node browseNode)
{
	final MenuButton datasetDropDown = new MenuButton();
	final StringBinding datasetDropDownText = Bindings.createStringBinding(() -> dataset.get() == null || dataset.get().length() == 0 ? datasetPromptText : datasetPromptText + ": " + dataset.get(), dataset);
	final ObjectBinding<Tooltip> datasetDropDownTooltip = Bindings.createObjectBinding(() -> Optional.ofNullable(dataset.get()).map(Tooltip::new).orElse(null), dataset);
	datasetDropDown.tooltipProperty().bind(datasetDropDownTooltip);
	datasetDropDown.disableProperty().bind(this.isN5Valid.not());
	datasetDropDown.textProperty().bind(datasetDropDownText);
	datasetChoices.addListener((ListChangeListener<String>) change -> {
		final MatchSelection matcher = MatchSelection.fuzzySorted(datasetChoices, s -> {
			dataset.set(s);
			datasetDropDown.hide();
		});
		LOG.debug("Updating dataset dropdown to fuzzy matcher with choices: {}", datasetChoices);
		final CustomMenuItem menuItem = new CustomMenuItem(matcher, false);
		// clear style to avoid weird blue highlight
		menuItem.getStyleClass().clear();
		datasetDropDown.getItems().setAll(menuItem);
		datasetDropDown.setOnAction(e -> {datasetDropDown.show(); matcher.requestFocus();});
	});
	final GridPane grid = new GridPane();
	grid.add(rootNode, 0, 0);
	grid.add(datasetDropDown, 0, 1);
	GridPane.setHgrow(rootNode, Priority.ALWAYS);
	GridPane.setHgrow(datasetDropDown, Priority.ALWAYS);
	grid.add(browseNode, 1, 0);

	return grid;
}
 
Example 13
Source File: GroupAndDatasetStructure.java    From paintera with GNU General Public License v2.0 5 votes vote down vote up
public Node createNode()
{
	final TextField groupField = new TextField(group.getValue());
	groupField.setMinWidth(0);
	groupField.setMaxWidth(Double.POSITIVE_INFINITY);
	groupField.setPromptText(groupPromptText);
	groupField.textProperty().bindBidirectional(group);
	final ComboBox<String> datasetDropDown = new ComboBox<>(datasetChoices);
	datasetDropDown.setPromptText(datasetPromptText);
	datasetDropDown.setEditable(false);
	datasetDropDown.valueProperty().bindBidirectional(dataset);
	datasetDropDown.setMinWidth(groupField.getMinWidth());
	datasetDropDown.setPrefWidth(groupField.getPrefWidth());
	datasetDropDown.setMaxWidth(groupField.getMaxWidth());
	datasetDropDown.disableProperty().bind(this.isDropDownReady);
	final GridPane grid = new GridPane();
	grid.add(groupField, 0, 0);
	grid.add(datasetDropDown, 0, 1);
	GridPane.setHgrow(groupField, Priority.ALWAYS);
	GridPane.setHgrow(datasetDropDown, Priority.ALWAYS);
	final Button button = new Button("Browse");
	button.setOnAction(event -> {
		Optional.ofNullable(onBrowseClicked.apply(group.getValue(), grid.getScene())).ifPresent(group::setValue);
	});
	grid.add(button, 1, 0);

	groupField.effectProperty().bind(
			Bindings.createObjectBinding(
					() -> groupField.isFocused() ? this.textFieldNoErrorEffect : groupErrorEffect.get(),
					groupErrorEffect,
					groupField.focusedProperty()
			                            ));

	return grid;
}
 
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: 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 16
Source File: AlertHelper.java    From AsciidocFX with Apache License 2.0 4 votes vote down vote up
static Alert buildDeleteAlertDialog(List<Path> pathsLabel) {
    Alert deleteAlert = new WindowModalAlert(Alert.AlertType.WARNING, null, ButtonType.YES, ButtonType.CANCEL);
    deleteAlert.setHeaderText("Do you want to delete selected path(s)?");
    DialogPane dialogPane = deleteAlert.getDialogPane();

    ObservableList<Path> paths = Optional.ofNullable(pathsLabel)
            .map(FXCollections::observableList)
            .orElse(FXCollections.emptyObservableList());

    if (paths.isEmpty()) {
        dialogPane.setContentText("There are no files selected.");
        deleteAlert.getButtonTypes().clear();
        deleteAlert.getButtonTypes().add(ButtonType.CANCEL);
        return deleteAlert;
    }

    ListView<Path> listView = new ListView<>(paths);
    listView.setId("listOfPaths");

    GridPane gridPane = new GridPane();
    gridPane.addRow(0, listView);
    GridPane.setHgrow(listView, Priority.ALWAYS);

    double minWidth = 200.0;
    double maxWidth = Screen.getScreens().stream()
            .mapToDouble(s -> s.getBounds().getWidth() / 3)
            .min().orElse(minWidth);

    double prefWidth = paths.stream()
            .map(String::valueOf)
            .mapToDouble(s -> s.length() * 7)
            .max()
            .orElse(maxWidth);

    double minHeight = IntStream.of(paths.size())
            .map(e -> e * 70)
            .filter(e -> e <= 300 && e >= 70)
            .findFirst()
            .orElse(200);

    gridPane.setMinWidth(minWidth);
    gridPane.setPrefWidth(prefWidth);
    gridPane.setPrefHeight(minHeight);
    dialogPane.setContent(gridPane);
    return deleteAlert;
}
 
Example 17
Source File: ConfigController.java    From logbook-kai with MIT License 4 votes vote down vote up
private void bouyomiChanInit() {
    AppBouyomiConfig config = AppBouyomiConfig.get();

    this.enableBouyomi.setSelected(config.isEnable());
    this.bouyomiHost.setText(config.getHost());
    this.bouyomiPort.setText(Integer.toString(config.getPort()));
    this.bouyomiTryExecute.setSelected(config.isTryExecute());
    this.bouyomiPath.setText(config.getBouyomiPath());

    BouyomiDefaultSettings settings = BouyomiChanUtils.getDefaultSettings();
    int row = 0;
    for (BouyomiSetting setting : settings.getSettings()) {
        BouyomiChanUtils.Type type = BouyomiChanUtils.Type.valueOf(setting.getId());

        AppBouyomiText bouyomiConfig = config.getText()
                .get(setting.getId());

        CheckBox checkBox = new CheckBox(setting.getLabel());
        checkBox.setSelected(true);

        TextField text = new TextField(setting.getText());
        TextFlow params = new TextFlow();
        for (Params param : setting.getParams()) {
            Hyperlink link = new Hyperlink(param.getComment());
            link.setFocusTraversable(false);
            link.setOnAction(ev -> {
                text.replaceSelection(param.getTag());
            });
            params.getChildren().add(link);
        }
        if (bouyomiConfig != null) {
            checkBox.setSelected(bouyomiConfig.isEnable());
            text.setText(bouyomiConfig.getText());
        }

        this.bouyomiTexts.add(checkBox, 0, row);
        this.bouyomiTexts.add(text, 1, row);
        GridPane.setHgrow(text, Priority.ALWAYS);
        this.bouyomiTexts.add(params, 1, ++row);
        row++;

        this.enableBouyomiTextMap.put(type, checkBox::isSelected);
        this.bouyomiTextMap.put(type, text::getText);
    }
}
 
Example 18
Source File: SortManager.java    From PDF4Teachers with Apache License 2.0 4 votes vote down vote up
public void setup(GridPane parent, String selectedButtonName, String... buttonsName){

        int row = 0;
        for(String buttonName : buttonsName){

            if(buttonName.equals("\n")){
                row++; continue;
            }

            Button button = new Button(buttonName);
            button.setGraphic(Builders.buildImage(getClass().getResource("/img/Sort/up.png")+"", 0, 0));
            button.setAlignment(Pos.CENTER_LEFT);
            button.setMaxWidth(Double.MAX_VALUE);
            GridPane.setHgrow(button, Priority.ALWAYS);
            BooleanProperty order = new SimpleBooleanProperty(true);
            buttons.put(button, order);
            parent.addRow(row, button);

            if(selectedButtonName.equals(buttonName)){
                selectedButton.set(button);
                button.setStyle("-fx-background-color: " + selectedColor + ";");
            }else button.setStyle("-fx-background-color: " + StyleManager.getHexAccentColor() + ";");

            // Image de l'ordre
            order.addListener(new ChangeListener<>() {
                @Override public void changed(ObservableValue<? extends Boolean> observableValue, Boolean lastOrder, Boolean newOrder) {
                    button.setGraphic(Builders.buildImage(getClass().getResource(newOrder ? "/img/Sort/up.png" : "/img/Sort/down.png") + "", 0, 0));
                }
            });

            // Change selectedButton lors du clic ET update l'ordre
            button.setOnAction(actionEvent -> {
                if(selectedButton.get() == button){
                    order.set(!order.get());
                    updateSort.call(button.getText(), order.get());
                }else selectedButton.set(button);
            });
        }
        if(selectedButton.get() == null){
            selectedButton.set(buttons.keySet().iterator().next());
            buttons.keySet().iterator().next().setStyle("-fx-background-color: " + selectedColor);
        }

        // Couleurs des boutons
        selectedButton.addListener((observableValue, lastSelected, newSelected) -> {
            lastSelected.setStyle("-fx-background-color: " + StyleManager.getHexAccentColor() + ";");
            newSelected.setStyle("-fx-background-color: " + selectedColor + ";");
            updateSort.call(newSelected.getText(), buttons.get(newSelected).get());
        });
    }
 
Example 19
Source File: FormPane.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
private void _setFormConstraints(TextArea field) {
    GridPane.setHgrow(field, Priority.ALWAYS);
    GridPane.setVgrow(field, Priority.ALWAYS);
}
 
Example 20
Source File: PluginParametersPane.java    From constellation with Apache License 2.0 4 votes vote down vote up
@Override
public Pane getParamPane(final PluginParametersNode node) {
    if (node.getChildren().isEmpty()) {
        return null;
    }

    final GridPane paramGroupPane = new PluginParametersPane();
    paramGroupPane.setMinHeight(0);
    GridPane.setHalignment(paramGroupPane, HPos.LEFT);
    paramGroupPane.setPadding(Insets.EMPTY);

    int row = 0;
    final DoubleProperty descriptionWidth = new SimpleDoubleProperty();
    DoubleProperty maxLabelWidth = new SimpleDoubleProperty();

    for (final PluginParametersNode child : node.getChildren()) {
        while (child.getFormatter().nextElement(child)) {
            final RowConstraints rowConstraints = new RowConstraints();
            rowConstraints.setVgrow(Priority.NEVER);
            rowConstraints.setFillHeight(true);
            paramGroupPane.getRowConstraints().addAll(rowConstraints);

            final LabelDescriptionBox label = child.getFormatter().getParamLabel(child);
            if (label != null) {
                paramGroupPane.add(label, 0, row);
                GridPane.setValignment(label, VPos.TOP);
                GridPane.setHgrow(label, Priority.ALWAYS);
                GridPane.setFillHeight(label, false);

                label.bindDescriptionToProperty(descriptionWidth);
                maxLabelWidth = label.updateBindingWithLabelWidth(maxLabelWidth);
            }

            final Pane paramPane = child.getFormatter().getParamPane(child);
            if (paramPane != null) {
                paramPane.setStyle("-fx-padding: " + PADDING);
                GridPane.setValignment(paramPane, VPos.TOP);
                GridPane.setFillHeight(paramPane, false);
                if (label == null) {
                    paramGroupPane.add(paramPane, 0, row, 2, 1);
                } else {
                    paramGroupPane.add(paramPane, 1, row);
                }
            }

            final Button paramHelp = child.getFormatter().getParamHelp(child);
            if (paramHelp != null) {
                paramGroupPane.add(paramHelp, 2, row);
                GridPane.setMargin(paramHelp, new Insets(PADDING, PADDING, 0, 0));
                GridPane.setValignment(paramHelp, VPos.TOP);
                GridPane.setFillHeight(paramHelp, false);
            }

            row++;
        }
    }

    descriptionWidth.bind(Bindings.max(50, maxLabelWidth));

    return paramGroupPane;
}