/*
 * Unlicensed
 */

package javafx.scene.layout;

import javafx.beans.binding.Bindings;
import javafx.geometry.Insets;
import jxtn.jfx.builders.JFX;
import jxtn.jfx.meta.PathStep;

/**
 * {@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 root 資料來源
     * @param steps 資料屬性路徑
     * @return 自己
     */
    default B addFieldRO(int row, Insets margin, String label, Object root, String... steps)
    {
        this.self().childrenAdd(
                JFX.label()
                        .GridPane_margin(margin)
                        .GridPane_rowIndex(row).GridPane_columnIndex(0)
                        .GridPane_fillWidth(true).GridPane_fillHeight(true)
                        .text(label)
                        .build(),
                JFX.textField()
                        .GridPane_margin(margin)
                        .GridPane_rowIndex(row).GridPane_columnIndex(1)
                        .GridPane_fillWidth(true).GridPane_fillHeight(true)
                        .GridPane_hgrow(Priority.ALWAYS)
                        .bindText(Bindings.select(root, steps))
                        .editable(false)
                        .build());
        return this.self();
    }

    /**
     * 增加唯讀欄位
     *
     * @param row 列號
     * @param margin 邊界
     * @param label 欄位標題
     * @param step 屬性路徑(需已連結資料)
     * @return 自己
     */
    default B addFieldRO(int row, Insets margin, String label, PathStep<?, String> step)
    {
        this.self().childrenAdd(
                JFX.label()
                        .GridPane_margin(margin)
                        .GridPane_rowIndex(row).GridPane_columnIndex(0)
                        .GridPane_fillWidth(true).GridPane_fillHeight(true)
                        .text(label)
                        .build(),
                JFX.textField()
                        .GridPane_margin(margin)
                        .GridPane_rowIndex(row).GridPane_columnIndex(1)
                        .GridPane_fillWidth(true).GridPane_fillHeight(true)
                        .GridPane_hgrow(Priority.ALWAYS)
                        .bindText(step.bind())
                        .editable(false)
                        .build());
        return this.self();
    }
}

@@ -75,24 +75,29 @@
 ans.
-binding.Bindings
+value.ObservableValue
 ;%0D%0Ai
@@ -625,45 +625,19 @@
 ram 
-root %E8%B3%87%E6%96%99%E4%BE%86%E6%BA%90%0D%0A     * @param steps %E8%B3%87%E6%96%99%E5%B1%AC%E6%80%A7%E8%B7%AF%E5%BE%91
+source %E8%B3%87%E6%96%99%E4%BE%86%E6%BA%90
 %0D%0A  
@@ -731,34 +731,46 @@
 , Ob
-ject root, String... steps
+servableValue%3C? extends String%3E source
 )%0D%0A 
@@ -1440,36 +1440,14 @@
 ext(
-Bindings.select(root, steps)
+source
 )%0D%0A 

replace object/steps binding with direct ObservableValue