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;
}
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);
}
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);
}
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);
}
}
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);
}
Aggregations