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