if (leaf.getDockables().size() == 1)
break;
Component component = currentChildMap.get(leaf.getName());
Dockable dockable = toolWindowManager.lookupDockable(dockId);
setConstraints(dockable,
getComponentFromWrapper(component, dockable),
null,
-1,
AggregationPosition.DEFAULT
);
}
} else {
Stack<Split> stack = new Stack<Split>();
stack.push((Split) multiSplitPaneModelRoot);
while (!stack.isEmpty()) {
Split split = stack.pop();
for (Node child : split.getChildren()) {
if (child instanceof DockableLeaf) {
DockableLeaf leaf = (DockableLeaf) child;
String[] dockIds = leaf.getDockables().toArray(new String[leaf.getDockables().size()]);
for (String dockId : dockIds) {
if (leaf.getDockables().size() == 1)
break;
Component component = currentChildMap.get(leaf.getName());
Dockable dockable = toolWindowManager.lookupDockable(dockId);
setConstraints(dockable,
getComponentFromWrapper(component, dockable),
null,
-1,
AggregationPosition.DEFAULT
);
}
} else if (child instanceof Split) {
stack.push((Split) child);
}
}
}
}
if (root instanceof Split) {
// Step Two: apply model 1...Aggregate
Stack<Split> stack = new Stack<Split>();
stack.push((Split) root);
while (!stack.isEmpty()) {
Split split = stack.pop();
for (Node child : split.getChildren()) {
if (child instanceof DockableLeaf) {
DockableLeaf leaf = (DockableLeaf) child;
List<String> ids = leaf.getDockables();
Dockable master = toolWindowManager.lookupDockable(leaf.getDockable());
for (int i = 1; i < ids.size(); i++) {
Dockable dockable = toolWindowManager.lookupDockable(ids.get(i));
setConstraints(dockable,
getComponentFromWrapper(currentChildMap.get(getLeaf(dockable).getName()), dockable),
master,
-1,
AggregationPosition.DEFAULT
);
}
} else if (child instanceof Split) {
stack.push((Split) child);
}
}
}
// Step Two: apply model 2...Isomorphing
Map<String, Component> newChildMap = new LinkedHashMap<String, Component>();
stack = new Stack<Split>();
stack.push((Split) root);
while (!stack.isEmpty()) {
Split split = stack.pop();
for (Node child : split.getChildren()) {
if (child instanceof DockableLeaf) {
DockableLeaf leaf = (DockableLeaf) child;
DockableLeaf currentLeaf = getLeaf(multiSplitPaneModelRoot, leaf.getDockable());
newChildMap.put(
leaf.getName(),
currentChildMap.get(currentLeaf.getName())
);
} else if (child instanceof Split) {
stack.push((Split) child);
}
}
}
multiSplitPane.getMultiSplitLayout().setChildMap(newChildMap);
} else {
DockableLeaf leaf = (DockableLeaf) root;
List<String> dockIds = leaf.getDockables();
Dockable masterDockable = toolWindowManager.lookupDockable(leaf.getDockable());
for (int i = 1; i < dockIds.size(); i++) {
String dockId = dockIds.get(i);
Dockable dockable = toolWindowManager.lookupDockable(dockId);
setConstraints(dockable,
getComponentFromWrapper(currentChildMap.get(getLeaf(dockable).getName()), dockable),
masterDockable,
-1,
AggregationPosition.DEFAULT