Skip to content

Commit 3e530de

Browse files
committed
implement new util method for disabling all children nodes
1 parent ef16240 commit 3e530de

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

src/main/java/gr/sqlbrowserfx/nodes/DbConfigBox.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,10 @@ public String getUrl() {
153153
}
154154

155155
public void showLoader(boolean show) {
156-
Platform.runLater(() -> this.loader.setVisible(show));
156+
Platform.runLater(() -> {
157+
JavaFXUtils.setChildrenDisabled(this, show);
158+
this.loader.setVisible(show);
159+
});
157160
}
158161

159162

src/main/java/gr/sqlbrowserfx/utils/JavaFXUtils.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import javafx.application.Platform;
1010
import javafx.event.Event;
1111
import javafx.scene.Node;
12+
import javafx.scene.Parent;
1213
import javafx.scene.image.Image;
1314
import javafx.scene.image.ImageView;
1415
import javafx.scene.input.KeyCode;
@@ -95,5 +96,19 @@ public static void timer(int delay, Runnable action) {
9596
timer.setRepeats(false);
9697
timer.start();
9798
}
99+
100+
public static void setChildrenDisabled(Node node, boolean disable) {
101+
if (node instanceof Parent parent) {
102+
for (Node child : parent.getChildrenUnmodifiable()) {
103+
child.setDisable(disable);
104+
// Recursively apply to children if the child is also a Parent
105+
if (child instanceof Parent) {
106+
setChildrenDisabled(child, disable);
107+
}
108+
}
109+
} else {
110+
node.setDisable(disable);
111+
}
112+
}
98113

99114
}

0 commit comments

Comments
 (0)