From 1abda3914ad48628ab6893e1a703c8564c9008e5 Mon Sep 17 00:00:00 2001 From: Paulo Veiga Date: Fri, 9 Sep 2011 22:26:52 -0300 Subject: [PATCH] Support multiple nodes .. --- .../src/main/javascript/model/INodeModel.js | 29 ++++++++++++++++--- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/mindplot/src/main/javascript/model/INodeModel.js b/mindplot/src/main/javascript/model/INodeModel.js index 9f7dfee5..3c3ef719 100644 --- a/mindplot/src/main/javascript/model/INodeModel.js +++ b/mindplot/src/main/javascript/model/INodeModel.js @@ -194,7 +194,6 @@ mindplot.model.INodeModel = new Class({ throw "Unsupported operation"; }, - connectTo : function(parent) { $assert(parent, "parent can not be null"); var mindmap = this.getMindmap(); @@ -278,19 +277,41 @@ mindplot.model.INodeModel = new Class({ }, inspect : function() { - return '{ type: ' + this.getType() + + var result = '{ type: ' + this.getType() + ' , id: ' + this.getId() + - ' , text: ' + this.getText() + - ' }'; + ' , text: ' + this.getText(); + + var children = this.getChildren(); + if (children.length > 0) { + result = result + "{(size:" + children.length; + children.forEach(function(node) { + result = result + "=> (" + node.getPropertiesKeys() + ")"; + }.bind(this)); + } + + result = result + ' }'; + return result; }, copyTo : function(target) { var source = this; + // Copy properties ... var keys = source.getPropertiesKeys(); keys.forEach(function(key) { var value = source.getProperty(key); target.putProperty(key, value); }); + + // Copy childrens ... + var children = this.getChildren(); + var tmindmap = target.getMindmap(); + + children.forEach(function(snode) { + var tnode = tmindmap.createNode(snode.getType(), snode.getId()); + snode.copyTo(tnode); + target.appendChild(tnode); + }); + return target; } });