How to correctly delete Part [message #1802900] |
Mon, 18 February 2019 12:41  |
Eclipse User |
|
|
|
I'm iterating over a list of models and want to delete the corresponding ModelPart in some special cases.
2 questions about this:
1-How can I access the ModelPart within the Model? When I have the Part I can call part.getContent() to get the Model. Is there any similar method for getting the part from the model?
2-I found a way of getting the corresponding part by iterating over the Parent (root) part, which is a workaround in my opinion. However, even with the correct ModelPart I can't properly delete it. What am I doing wrong?
IRootPart<? extends Node> root = host.getRoot();
DeletionPolicy delPolicy = root.getAdapter(DeletionPolicy.class);
init(delPolicy); //I'm inside a handler
for (IVisualPart<? extends Node> a : new ArrayList<>(parent.getChildrenUnmodifiable())) {
if (a instanceof ModelPart) {
delPolicy.delete((IContentPart<? extends Node>) a);
}
}
commit(delPolicy);
[Updated on: Mon, 18 February 2019 13:53] by Moderator
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05972 seconds