Search in sources :

Example 1 with FirstGroupNode

use of org.freeplane.features.map.FirstGroupNode in project freeplane by freeplane.

the class MMapController method addNewSummaryNodeStartEditing.

public void addNewSummaryNodeStartEditing(final NodeModel parentNode, final int start, final int end, final int summaryLevel, final boolean isLeft) {
    ModeController modeController = getMModeController();
    stopEditing();
    final NodeModel newSummaryNode = addNewNode(parentNode, end + 1, isLeft);
    final SummaryNode summary = modeController.getExtension(SummaryNode.class);
    summary.undoableActivateHook(newSummaryNode, SUMMARY);
    AlwaysUnfoldedNode unfolded = modeController.getExtension(AlwaysUnfoldedNode.class);
    unfolded.undoableActivateHook(newSummaryNode, unfolded);
    final FirstGroupNode firstGroupNodeHook = modeController.getExtension(FirstGroupNode.class);
    final NodeModel firstNodeInGroup = parentNode.getChildAt(start);
    if (SummaryNode.isSummaryNode(firstNodeInGroup))
        firstGroupNodeHook.undoableActivateHook(firstNodeInGroup, FIRST_GROUP);
    else {
        final NodeModel previousNode = firstNodeInGroup.previousNode(start, isLeft);
        if (previousNode == null || SummaryNode.isSummaryNode(previousNode) || !SummaryNode.isFirstGroupNode(previousNode)) {
            NodeModel newFirstGroup = addNewNode(parentNode, start, isLeft);
            firstGroupNodeHook.undoableActivateHook(newFirstGroup, FIRST_GROUP);
        }
        firstGroupNodeHook.undoableDeactivateHook(firstNodeInGroup);
    }
    int level = summaryLevel;
    for (int i = start + 1; i <= end; i++) {
        NodeModel node = parentNode.getChildAt(i);
        if (isLeft != node.isLeft())
            continue;
        if (SummaryNode.isSummaryNode(node))
            level++;
        else
            level = 0;
        if (level == summaryLevel && SummaryNode.isFirstGroupNode(node)) {
            if (level > 0)
                firstGroupNodeHook.undoableDeactivateHook(node);
            else
                deleteSingleNodeWithClones(node);
        }
    }
    final NodeModel firstSummaryChildNode = addNewNode(newSummaryNode, 0, isLeft);
    startEditingAfterSelect(firstSummaryChildNode);
    select(firstSummaryChildNode);
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) SummaryNode(org.freeplane.features.map.SummaryNode) AlwaysUnfoldedNode(org.freeplane.features.map.AlwaysUnfoldedNode) ModeController(org.freeplane.features.mode.ModeController) MModeController(org.freeplane.features.mode.mindmapmode.MModeController) FirstGroupNode(org.freeplane.features.map.FirstGroupNode) Point(java.awt.Point)

Aggregations

Point (java.awt.Point)1 AlwaysUnfoldedNode (org.freeplane.features.map.AlwaysUnfoldedNode)1 FirstGroupNode (org.freeplane.features.map.FirstGroupNode)1 NodeModel (org.freeplane.features.map.NodeModel)1 SummaryNode (org.freeplane.features.map.SummaryNode)1 ModeController (org.freeplane.features.mode.ModeController)1 MModeController (org.freeplane.features.mode.mindmapmode.MModeController)1