Add remove node support.

This commit is contained in:
Paulo Veiga
2011-09-11 00:07:43 -03:00
parent c1e0d52ff5
commit 5a08728686
11 changed files with 69 additions and 149 deletions

View File

@@ -52,12 +52,12 @@
<concat destfile="${basedir}/target/tmp/mindplot.js" append="false">
<filelist dir="${basedir}/src/main/javascript/" files="header.js"/>
<filelist dir="${basedir}/src/main/javascript/libraries/"
<filelist dir="${basedir}/src/main/javascript/libraries/moodialog/"
files="Overlay.js"/>
<filelist dir="${basedir}/src/main/javascript/libraries/"
files="MooDialog.js"/>
<filelist dir="${basedir}/src/main/javascript/libraries/"
files="MooDialog.Fx.js"/>
<filelist dir="${basedir}/src/main/javascript/libraries/moodialog/"
files="MooDialog.js"/>
<filelist dir="${basedir}/src/main/javascript/libraries/moodialog/"
files="MooDialog.Fx.js"/>
<filelist dir="${basedir}/src/main/javascript/" files="EventBus.js"/>
<filelist dir="${basedir}/src/main/javascript/" files="model/IMindmap.js"/>

View File

@@ -26,6 +26,7 @@ mindplot.MindmapDesigner = new Class({
// Dispatcher manager ...
var commandContext = new mindplot.CommandContext(this);
this._actionDispatcher = new mindplot.BrixActionDispatcher(commandContext);
// this._actionDispatcher = new mindplot.LocalActionDispatcher(commandContext);
// this._actionDispatcher = new mindplot.LocalActionDispatcher(commandContext);
this._actionDispatcher.addEvent("modelUpdate", function(event) {
this.fireEvent("modelUpdate", event);

View File

@@ -71,7 +71,12 @@ mindplot.collaboration.framework.brix.model.Mindmap = new Class({
addBranch : function(nodeModel) {
$assert(nodeModel, "nodeModel can not be null");
var branches = this._brixModel.get("branches");
branches.add(nodeModel.getBrixModel());
// @Todo: Hack ?
var newModel = mindplot.collaboration.framework.brix.model.NodeModel.create(this._brixFramework, this, nodeModel.getType(), nodeModel.getId());
nodeModel.copyTo(newModel);
branches.add(newModel);
},
removeBranch : function(nodeModel) {

View File

@@ -63,17 +63,19 @@ mindplot.collaboration.framework.brix.model.NodeModel = new Class({
}.bind(this));
children.addListener("valuesRemoved", function(event) {
console.log("remove node:" + funName);
var brixChildren = event.getValues();
for (var i = 0; i < brixChildren.size(); i++) {
var brixNodeModel = brixChildren.get(i);
var cmodel = new mindplot.collaboration.framework.brix.model.NodeModel(this._brixFramework, brixNodeModel, this.getMindmap());
actionDispatcher.deleteTopics(cmodel.getId());
try {
var brixChildren = event.getValues();
for (var i = 0; i < brixChildren.size(); i++) {
var brixNodeModel = brixChildren.get(i);
var cmodel = new mindplot.collaboration.framework.brix.model.NodeModel(this._brixFramework, brixNodeModel, this.getMindmap());
actionDispatcher.deleteTopics([cmodel.getId()]);
}
} catch(e) {
console.trace();
console.log(e);
}
}.bind(this));
this._brixModel.__registered = true;
}
},
@@ -106,7 +108,7 @@ mindplot.collaboration.framework.brix.model.NodeModel = new Class({
},
getPropertiesKeys : function() {
return this._brixModel.getKeys();
return this._brixModel.getKeys().erase('children');
},
getParent : function() {

View File

@@ -225,23 +225,16 @@ mindplot.model.INodeModel = new Class({
deleteNode : function() {
var mindmap = this.getMindmap();
// if it has children nodes, Their must be disconnected.
var children = this.getChildren();
var length = children.length;
for (var i = 0; i < length; i++) {
var child = children[i];
mindmap.disconnect(child);
}
// if it is connected, I must remove it from the parent..
console.log(mindmap.inspect());
var parent = this.getParent();
if ($defined(parent)) {
mindmap.disconnect(this);
parent.removeChild(this);
} else {
// If it has not parent, it must be an isolate topic ...
mindmap.removeBranch(this);
}
// It's an isolated node. It must be a hole branch ...
mindmap.removeBranch(this);
console.log(mindmap.inspect());
},
getPropertiesKeys : function() {
@@ -325,7 +318,13 @@ mindplot.model.INodeModel = new Class({
if (children.length > 0) {
result = result + ", children: {(size:" + children.length;
children.forEach(function(node) {
result = result + "=> (" + node.getPropertiesKeys() + ")";
result = result + "=> (";
var keys = node.getPropertiesKeys();
keys.forEach(function(key) {
var value = node.getProperty(key);
result = result + key + ":" + value + ",";
});
result = result + "}"
}.bind(this));
}

View File

@@ -59,7 +59,7 @@ mindplot.model.NodeModel = new Class({
return cnode;
});
result._properties = this._properties.clone();
result._properties = Object.clone(this._properties);
result._icons = this._icons.clone();
result._links = this._links.clone();
result._notes = this._notes.clone();