Clean up copyComponentsMaintainParent
This commit is contained in:
parent
34b2a0a221
commit
95aedeaaf3
@ -267,20 +267,10 @@ public class RocketActions {
|
|||||||
|
|
||||||
for (int i = 0; i < components.size(); i++) {
|
for (int i = 0; i < components.size(); i++) {
|
||||||
if (components.contains(components.get(i).getParent())) {
|
if (components.contains(components.get(i).getParent())) {
|
||||||
RocketComponent oldChild = components.get(i);
|
RocketComponent originalParent = components.get(i).getParent();
|
||||||
RocketComponent oldParent = oldChild.getParent();
|
int originalParentIdx = components.indexOf(originalParent);
|
||||||
|
|
||||||
int index = components.indexOf(oldParent);
|
result.get(originalParentIdx).addChild(result.get(i));
|
||||||
int childPos = oldParent.getChildPosition(oldChild);
|
|
||||||
|
|
||||||
RocketComponent newChild = result.get(i);
|
|
||||||
RocketComponent newParent = result.get(index);
|
|
||||||
|
|
||||||
// Add the newly copied child to the parent
|
|
||||||
newParent.addChild(newChild, childPos);
|
|
||||||
|
|
||||||
// Remove the old child from the parent
|
|
||||||
newParent.removeChild(oldChild);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user