<commit_before>/*
 * Unlicensed
 */

package javafx.scene.layout;

import javafx.beans.value.ObservableValue;
import javafx.geometry.HPos;
import javafx.geometry.Insets;
import javafx.geometry.VPos;
import javafx.scene.Node;
import jxtn.jfx.builders.JFX;

/**
 * {@link GridPane}建構器延伸（供客製化）
 *
 * @author AqD
 * @param <Z> 要建構的物件型態(需繼承{@link GridPane})
 * @param <B> 建構器本身的型態(需繼承{@link GridPaneBuilder})
 */
public interface GridPaneBuilderExt<Z extends GridPane, B extends GridPaneBuilder<Z, B>>
        extends javafx.scene.layout.PaneBuilderExt<Z, B>
{
    /**
     * 增加唯讀欄位
     *
     * @param row 列號
     * @param margin 邊界
     * @param label 欄位標題
     * @param source 資料來源
     * @return 自己
     */
    default B addFieldRO(int row, Insets margin, String label, ObservableValue<? extends String> source)
    {
        this.self().childrenAdd(
                JFX.label()
                        .GridPane_margin(margin)
                        .GridPane_rowIndex(row).GridPane_columnIndex(0)
                        .GridPane_fillWidth(true).GridPane_fillHeight(true)
                        .GridPane_halignment(HPos.RIGHT)
                        .GridPane_valignment(VPos.CENTER)
                        .text(label)
                        .afterBuild(lbl -> lbl.minWidthProperty().bind(lbl.prefWidthProperty()))
                        .build(),
                JFX.textField()
                        .GridPane_margin(margin)
                        .GridPane_rowIndex(row).GridPane_columnIndex(1)
                        .GridPane_fillWidth(true).GridPane_fillHeight(true)
                        .GridPane_halignment(HPos.LEFT)
                        .GridPane_valignment(VPos.TOP)
                        .GridPane_hgrow(Priority.ALWAYS)
                        .bindText(source)
                        .editable(false)
                        .build());
        return this.self();
    }

    /**
     * 增加自訂欄位
     *
     * @param row 列號
     * @param margin 邊界
     * @param label 欄位標題
     * @param fieldNode 欄位節點
     * @return 自己
     */
    default B addFieldCustom(int row, Insets margin, String label, Node fieldNode)
    {
        GridPane.setMargin(fieldNode, margin);
        GridPane.setRowIndex(fieldNode, row);
        GridPane.setColumnIndex(fieldNode, 1);
        GridPane.setFillWidth(fieldNode, true);
        GridPane.setFillHeight(fieldNode, true);
        GridPane.setHgrow(fieldNode, Priority.ALWAYS);
        this.self().childrenAdd(
                JFX.label()
                        .GridPane_margin(margin)
                        .GridPane_rowIndex(row).GridPane_columnIndex(0)
                        .GridPane_fillWidth(true).GridPane_fillHeight(true)
                        .text(label)
                        .afterBuild(lbl -> lbl.minWidthProperty().bind(lbl.prefWidthProperty()))
                        .build(),
                fieldNode);
        return this.self();
    }
}<commit_msg>GridPaneBuilderExt.addField*: add javadoc comments; fix GridPane parameters<commit_after>/*
 * Unlicensed
 */

package javafx.scene.layout;

import javafx.beans.value.ObservableValue;
import javafx.geometry.HPos;
import javafx.geometry.Insets;
import javafx.geometry.VPos;
import javafx.scene.Node;
import jxtn.jfx.builders.JFX;

/**
 * {@link GridPane}建構器延伸（供客製化）
 *
 * @author AqD
 * @param <Z> 要建構的物件型態(需繼承{@link GridPane})
 * @param <B> 建構器本身的型態(需繼承{@link GridPaneBuilder})
 */
public interface GridPaneBuilderExt<Z extends GridPane, B extends GridPaneBuilder<Z, B>>
        extends javafx.scene.layout.PaneBuilderExt<Z, B>
{
    /**
     * 增加唯讀欄位
     * <p>
     * 每個欄位佔第一行及第二行：
     * <ol>
     * <li>第一行顯示標籤({@code label})，向右中對齊</li>
     * <li>第二行顯示文字控制{@link javafx.scene.control.TextField}，向左上對齊，橫向填滿，連結資料{@code source}</li>
     * </ol>
     * </p>
     *
     * @param row 列號
     * @param margin 邊界
     * @param label 欄位標題
     * @param source 資料來源
     * @return 自己
     */
    default B addFieldRO(int row, Insets margin, String label, ObservableValue<? extends String> source)
    {
        this.self().childrenAdd(
                JFX.label()
                        .GridPane_margin(margin)
                        .GridPane_rowIndex(row).GridPane_columnIndex(0)
                        .GridPane_fillWidth(true).GridPane_fillHeight(true)
                        .GridPane_halignment(HPos.RIGHT)
                        .GridPane_valignment(VPos.CENTER)
                        .text(label)
                        .afterBuild(lbl -> lbl.minWidthProperty().bind(lbl.prefWidthProperty()))
                        .build(),
                JFX.textField()
                        .GridPane_margin(margin)
                        .GridPane_rowIndex(row).GridPane_columnIndex(1)
                        .GridPane_fillWidth(true).GridPane_fillHeight(true)
                        .GridPane_halignment(HPos.LEFT)
                        .GridPane_valignment(VPos.TOP)
                        .GridPane_hgrow(Priority.ALWAYS)
                        .bindText(source)
                        .editable(false)
                        .build());
        return this.self();
    }

    /**
     * 增加自訂欄位
     * <p>
     * 每個欄位佔第一行及第二行：
     * <ol>
     * <li>第一行顯示標籤({@code label})，向右中對齊</li>
     * <li>第二行顯示指定控制項({@code fieldNode})，向左上對齊，橫向填滿</li>
     * </ol>
     * </p>
     *
     * @param row 列號
     * @param margin 邊界
     * @param label 欄位標題
     * @param fieldNode 欄位節點
     * @return 自己
     */
    default B addFieldCustom(int row, Insets margin, String label, Node fieldNode)
    {
        GridPane.setMargin(fieldNode, margin);
        GridPane.setRowIndex(fieldNode, row);
        GridPane.setColumnIndex(fieldNode, 1);
        GridPane.setFillWidth(fieldNode, true);
        GridPane.setFillHeight(fieldNode, true);
        GridPane.setHgrow(fieldNode, Priority.ALWAYS);
        GridPane.setHalignment(fieldNode, HPos.LEFT);
        GridPane.setValignment(fieldNode, VPos.TOP);
        this.self().childrenAdd(
                JFX.label()
                        .GridPane_margin(margin)
                        .GridPane_rowIndex(row).GridPane_columnIndex(0)
                        .GridPane_fillWidth(true).GridPane_fillHeight(true)
                        .GridPane_halignment(HPos.RIGHT)
                        .GridPane_valignment(VPos.CENTER)
                        .text(label)
                        .afterBuild(lbl -> lbl.minWidthProperty().bind(lbl.prefWidthProperty()))
                        .build(),
                fieldNode);
        return this.self();
    }
}
{'fraction_non_alphanumeric': 0.11033114603998169, 'fraction_numerical': 0.001220814893941706, 'mean_word_length': 1.7630691399662732, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2892197', 'n_tokens_mistral': 2192, 'n_tokens_neox': 2183, 'n_words': 309}