package moe.tristan.easyfxml.util;

import javafx.scene.Node;
import javafx.scene.layout.AnchorPane;

/**
 * Small DOM-related utils for JavaFX nodes.
 */
public final class Nodes {

    private Nodes() {
    }

    /**
     * Centers a node that is inside an enclosing {@link AnchorPane}.
     *
     * @param node       The node to center
     * @param marginSize The margins to keep on the sides
     */
    public static void centerNode(final Node node, final Double marginSize) {
        AnchorPane.setTopAnchor(node, marginSize);
        AnchorPane.setBottomAnchor(node, marginSize);
        AnchorPane.setLeftAnchor(node, marginSize);
        AnchorPane.setRightAnchor(node, marginSize);
    }

}

@@ -29,16 +29,59 @@
 .util;%0A%0A
+import javafx.beans.value.ObservableValue;%0A
 import j
@@ -738,10 +738,756 @@
 %0A    %7D%0A%0A
+    public static void hideAndResizeParentIf(%0A        final Node node,%0A        final ObservableValue%3C? extends Boolean%3E condition%0A    ) %7B%0A        autoresizeContainerOn(node, condition);%0A        bindContentBiasCalculationTo(node, condition);%0A    %7D%0A%0A    public static void autoresizeContainerOn(%0A        final Node node,%0A        final ObservableValue%3C?%3E observableValue%0A    ) %7B%0A        observableValue.addListener((observable, oldValue, newValue) -%3E node.autosize());%0A    %7D%0A%0A    public static void bindContentBiasCalculationTo(%0A        final Node node,%0A        final ObservableValue%3C? extends Boolean%3E observableValue%0A    ) %7B%0A        node.visibleProperty().bind(observableValue);%0A        node.managedProperty().bind(node.visibleProperty());%0A    %7D%0A%0A
 %7D%0A

Add a helper method for auto-hiding and resizing the parent of a node