use of org.freeplane.features.map.SummaryLevels in project freeplane by freeplane.
the class SummaryNodeMapUpdater method updateSummaryNodes.
private void updateSummaryNodes(NodeModel parentNode) {
final NodeModel[] nodes = parentNode.getChildren().toArray(new NodeModel[] {});
for (NodeModel node : nodes) {
SummaryLevels summaryLevels = null;
if (SummaryNode.isFirstGroupNode(node)) {
if (summaryLevels == null)
summaryLevels = new SummaryLevels(parentNode);
if (summaryLevels.findSummaryNode(node.getIndex()) == null)
node.removeExtension(FirstGroupNodeFlag.class);
}
if (SummaryNode.isSummaryNode(node)) {
if (summaryLevels == null)
summaryLevels = new SummaryLevels(parentNode);
final NodeModel groupBeginNode = summaryLevels.findGroupBeginNode(parentNode.previousNodeIndex(node.getIndex(), node.isLeft()));
if (groupBeginNode == null)
node.removeExtension(SummaryNodeFlag.class);
else {
if (!groupBeginNode.containsExtension(FirstGroupNodeFlag.class)) {
if (SummaryNode.isSummaryNode(groupBeginNode))
groupBeginNode.addExtension(FirstGroupNodeFlag.FIRST_GROUP);
else {
final NodeModel newFirstGroupNode = mapController.addNewNode(groupBeginNode.getParentNode(), groupBeginNode.getIndex(), groupBeginNode.isLeft());
newFirstGroupNode.addExtension(FirstGroupNodeFlag.FIRST_GROUP);
}
}
if (node.isFolded() || !node.hasChildren() || !node.getText().isEmpty()) {
node.removeExtension(SummaryNodeFlag.class);
final NodeModel newParent = mapController.addNewNode(node.getParentNode(), node.getIndex(), node.isLeft());
newParent.addExtension(SummaryNodeFlag.SUMMARY);
if (SummaryNode.isFirstGroupNode(node)) {
node.removeExtension(FirstGroupNodeFlag.class);
newParent.addExtension(FirstGroupNodeFlag.FIRST_GROUP);
}
mapController.moveNodeAndItsClones(node, newParent, 0, false, false);
}
}
} else if (SummaryNode.isFirstGroupNode(node) && (node.hasChildren() || !node.getText().isEmpty())) {
final NodeModel newFirstGroupNode = mapController.addNewNode(node.getParentNode(), node.getIndex(), node.isLeft());
node.removeExtension(FirstGroupNodeFlag.class);
newFirstGroupNode.addExtension(FirstGroupNodeFlag.FIRST_GROUP);
}
updateSummaryNodes(node);
}
}
use of org.freeplane.features.map.SummaryLevels in project freeplane by freeplane.
the class MMapController method deleteSingleSummaryNode.
private void deleteSingleSummaryNode(NodeModel summarynode) {
final NodeModel summaryParent = summarynode.getParentNode();
final SummaryLevels summaryLevels = new SummaryLevels(summaryParent);
final int summaryNodeIndex = summarynode.getIndex();
final int groupBeginNodeIndex = summaryLevels.findGroupBeginNodeIndex(summaryNodeIndex - 1);
deleteSingleNode(summaryParent, summaryNodeIndex);
deleteSingleNode(summaryParent, groupBeginNodeIndex);
}
Aggregations