Skip to content

Commit 4880391

Browse files
committed
Add deinitializeTree method
1 parent 6a46cfe commit 4880391

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

patternfx-core/src/main/java/com/techsenger/patternfx/core/AbstractParentComponent.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ public String toTreeString(BiConsumer<ParentViewModel<?>, StringBuilder> compone
8282
public ObservableList<ChildViewModel<?>> getChildren() {
8383
return children;
8484
}
85+
86+
@Override
87+
public void deinitializeTree() {
88+
component.deinitializeTree();
89+
}
8590
}
8691

8792
private final ObservableList<ChildComponent<?>> modifiableChildren = FXCollections.observableArrayList();
@@ -143,6 +148,14 @@ public String toTreeString(BiConsumer<ParentComponent<?>, StringBuilder> compone
143148
return toTreeString(depthFirstIterator(), componentAppender);
144149
}
145150

151+
@Override
152+
public void deinitializeTree() {
153+
var iterator = breadthFirstIterator();
154+
while (iterator.hasNext()) {
155+
iterator.next().deinitialize();
156+
}
157+
}
158+
146159
protected ObservableList<ChildComponent<?>> getModifiableChildren() {
147160
return modifiableChildren;
148161
}

patternfx-core/src/main/java/com/techsenger/patternfx/core/ParentComponent.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,12 @@ public interface ParentComponent<T extends ParentView<?, ?>> extends Component<T
6666
* @return a tree-formatted string representation of this component
6767
*/
6868
String toTreeString(BiConsumer<ParentComponent<?>, StringBuilder> componentAppender);
69+
70+
/**
71+
* Deinitializes this component and all its descendants as a sub-tree with this component as the root.
72+
*
73+
* The deinitialization is performed using a breadth-first traversal: the parent component is deinitialized first,
74+
* followed by its children level by level.
75+
*/
76+
void deinitializeTree();
6977
}

patternfx-core/src/main/java/com/techsenger/patternfx/core/ParentMediator.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,12 @@ public interface ParentMediator extends ComponentMediator {
6666
* @return a tree-formatted string representation of this component
6767
*/
6868
String toTreeString(BiConsumer<ParentViewModel<?>, StringBuilder> componentAppender);
69+
70+
/**
71+
* Deinitializes this component and all its descendants as a sub-tree with this component as the root.
72+
*
73+
* The deinitialization is performed using a breadth-first traversal: the parent component is deinitialized first,
74+
* followed by its children level by level.
75+
*/
76+
void deinitializeTree();
6977
}

0 commit comments

Comments
 (0)