Search in sources :

Example 51 with NodeModel

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

the class NewSummaryAction method addNewSummaryNodeStartEditing.

private boolean addNewSummaryNodeStartEditing(final NodeModel firstNode, final NodeModel lastNode) {
    final NodeModel parentNode = firstNode.getParentNode();
    final ModeController modeController = Controller.getCurrentModeController();
    final boolean isLeft = firstNode.isLeft();
    start = parentNode.getIndex(firstNode);
    end = parentNode.getIndex(lastNode);
    if (end < start) {
        int temp = end;
        end = start;
        start = temp;
    }
    summaryLevel = SummaryNode.getSummaryLevel(firstNode);
    // selected nodes have different summary levels
    if (summaryLevel != SummaryNode.getSummaryLevel(lastNode))
        return false;
    int level = summaryLevel;
    for (int i = start + 1; i < end; i++) {
        NodeModel node = (NodeModel) parentNode.getChildAt(i);
        if (isLeft != node.isLeft())
            continue;
        if (SummaryNode.isSummaryNode(node))
            level++;
        else
            level = 0;
        // There is a higher summary node between the selected nodes
        if (level > summaryLevel)
            return false;
    }
    ((MMapController) modeController.getMapController()).addNewSummaryNodeStartEditing(parentNode, start, end, summaryLevel, isLeft);
    return true;
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) ModeController(org.freeplane.features.mode.ModeController)

Example 52 with NodeModel

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

the class NodeSorter method sortNodes.

private void sortNodes(final NodeModel parent, int fromIndex) {
    final int childCount = parent.getChildCount();
    if (fromIndex >= childCount)
        return;
    final Vector<NodeModel> sortVector = new Vector<NodeModel>(childCount - fromIndex);
    int nodeIndex = fromIndex;
    while (nodeIndex < childCount) {
        final NodeModel child = parent.getChildAt(nodeIndex);
        nodeIndex++;
        if (SummaryNode.isSummaryNode(child)) {
            sortNodes(child, 0);
            break;
        } else if (SummaryNode.isFirstGroupNode(child)) {
            break;
        } else
            sortVector.add(child);
    }
    Collections.sort(sortVector, comparator);
    final MMapController mapController = (MMapController) Controller.getCurrentModeController().getMapController();
    for (final NodeModel child : sortVector) {
        Controller.getCurrentModeController().getExtension(FreeNode.class).undoableDeactivateHook(child);
        mapController.moveNode(child, fromIndex++);
    }
    sortNodes(parent, nodeIndex);
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) FreeNode(org.freeplane.features.map.FreeNode) Vector(java.util.Vector)

Example 53 with NodeModel

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

the class SetAlwaysUnfoldedNodeFlagsAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    final NodeModel rootNode = Controller.getCurrentController().getMap().getRootNode();
    final NodeModel node = rootNode;
    setAlwaysUnfoldedNodeFlags(node);
}
Also used : NodeModel(org.freeplane.features.map.NodeModel)

Example 54 with NodeModel

use of org.freeplane.features.map.NodeModel 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);
    }
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) SummaryNodeFlag(org.freeplane.features.map.SummaryNodeFlag) SummaryLevels(org.freeplane.features.map.SummaryLevels) FirstGroupNodeFlag(org.freeplane.features.map.FirstGroupNodeFlag)

Example 55 with NodeModel

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

the class ConvertCloneToIndependentNodeAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    final MMapController mapController = (MMapController) Controller.getCurrentModeController().getMapController();
    final Collection<NodeModel> selectedNodes = Controller.getCurrentController().getSelection().getSelection();
    for (final NodeModel node : selectedNodes) mapController.convertClonesToIndependentNodes(node);
}
Also used : NodeModel(org.freeplane.features.map.NodeModel)

Aggregations

NodeModel (org.freeplane.features.map.NodeModel)450 ModeController (org.freeplane.features.mode.ModeController)100 MapModel (org.freeplane.features.map.MapModel)53 Controller (org.freeplane.features.mode.Controller)46 MapStyleModel (org.freeplane.features.styles.MapStyleModel)46 MMapController (org.freeplane.features.map.mindmapmode.MMapController)39 MapController (org.freeplane.features.map.MapController)38 Point (java.awt.Point)37 IStyle (org.freeplane.features.styles.IStyle)36 IActor (org.freeplane.core.undo.IActor)34 IMapSelection (org.freeplane.features.map.IMapSelection)33 ArrayList (java.util.ArrayList)22 NodeView (org.freeplane.view.swing.map.NodeView)20 URI (java.net.URI)19 Color (java.awt.Color)18 Component (java.awt.Component)17 ResourceController (org.freeplane.core.resources.ResourceController)17 MModeController (org.freeplane.features.mode.mindmapmode.MModeController)16 NodeStyleController (org.freeplane.features.nodestyle.NodeStyleController)15 MTextController (org.freeplane.features.text.mindmapmode.MTextController)15