More fixes.

This commit is contained in:
Paulo Veiga 2011-09-10 01:17:48 -03:00
parent 1abda3914a
commit c1e0d52ff5
10 changed files with 133 additions and 73 deletions

View File

@ -51,6 +51,14 @@
<mkdir dir="${basedir}/target/classes"/> <mkdir dir="${basedir}/target/classes"/>
<concat destfile="${basedir}/target/tmp/mindplot.js" append="false"> <concat destfile="${basedir}/target/tmp/mindplot.js" append="false">
<filelist dir="${basedir}/src/main/javascript/" files="header.js"/> <filelist dir="${basedir}/src/main/javascript/" files="header.js"/>
<filelist dir="${basedir}/src/main/javascript/libraries/"
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/" files="EventBus.js"/> <filelist dir="${basedir}/src/main/javascript/" files="EventBus.js"/>
<filelist dir="${basedir}/src/main/javascript/" files="model/IMindmap.js"/> <filelist dir="${basedir}/src/main/javascript/" files="model/IMindmap.js"/>
<filelist dir="${basedir}/src/main/javascript/" files="model/Mindmap.js"/> <filelist dir="${basedir}/src/main/javascript/" files="model/Mindmap.js"/>

View File

@ -23,6 +23,27 @@ mindplot.BrixActionDispatcher = new Class({
this._commandContext = commandContext; this._commandContext = commandContext;
}, },
dragTopic: function(topicId, position, order, parentTopic) {
var framework = this._getFramework();
var node = framework.getTopic(topicId);
// Set node order ...
if (order != null) {
node.setOrder(order);
} else if (position != null) {
// Set position ...
node.setPosition(position);
} else {
$assert("Illegal commnad state exception.");
}
// Finally, connect node ...
if ($defined(this._parentId)) {
var parentNode = topic.findTopics([this._parentId])[0];
node.disconnect();
node.connect(parentNode);
}
},
changeTextToTopic : function(topicsIds, text) { changeTextToTopic : function(topicsIds, text) {
var framework = this._getFramework(); var framework = this._getFramework();
var topicId; var topicId;
@ -127,7 +148,7 @@ mindplot.BrixActionDispatcher = new Class({
var topicId = topicsIds[0]; var topicId = topicsIds[0];
var topic = framework.getTopic(topicId); var topic = framework.getTopic(topicId);
$assert(topic, "Could not find topic with id:" + topicId); $assert(topic, "Could not find topic with id:" + topicId);
mindmap.disconnect(topic); topic.deleteNode();
} }
}); });

View File

@ -57,9 +57,9 @@ mindplot.MindmapDesigner = new Class({
// To prevent the user from leaving the page with changes ... // To prevent the user from leaving the page with changes ...
$(window).addEvent('beforeunload', function () { $(window).addEvent('beforeunload', function () {
if (this.needsSave()) { // if (this.needsSave()) {
// this.save(null, false) // this.save(null, false)
} // }
}.bind(this)); }.bind(this));
}, },

View File

@ -60,9 +60,11 @@ mindplot.collaboration.framework.brix.model.Mindmap = new Class({
var branches = this._brixModel.get("branches"); var branches = this._brixModel.get("branches");
for (var i = 0; i < branches.size(); i++) { for (var i = 0; i < branches.size(); i++) {
var node = branches.get(i); var node = branches.get(i);
if (node != null) {
var nodeModel = new mindplot.collaboration.framework.brix.model.NodeModel(this._brixFramework, node, this); var nodeModel = new mindplot.collaboration.framework.brix.model.NodeModel(this._brixFramework, node, this);
result.push(nodeModel); result.push(nodeModel);
} }
}
return result; return result;
}, },
@ -78,10 +80,14 @@ mindplot.collaboration.framework.brix.model.Mindmap = new Class({
var branches = this._brixModel.get("branches"); var branches = this._brixModel.get("branches");
for (var i = 0; i < branches.size(); i++) { for (var i = 0; i < branches.size(); i++) {
if (branches.get(i) == nodeModel.getBrixModel()) {
// @Todo: remove should remove null elements ...
var branch = branches.get(i);
if (branch != null) {
if (branch == nodeModel.getBrixModel()) {
branches.remove(i); branches.remove(i);
break; break;
}
} }
} }
}, },

View File

@ -21,6 +21,8 @@ mindplot.collaboration.framework.brix.model.NodeModel = new Class({
initialize : function(brixFramework, brixModel, mindmap) { initialize : function(brixFramework, brixModel, mindmap) {
$assert(brixFramework, "brixFramework can not null"); $assert(brixFramework, "brixFramework can not null");
$assert(brixModel, "brixModel can not null"); $assert(brixModel, "brixModel can not null");
$assert(mindmap && mindmap.getBranches, "mindmap can not null");
this.parent(mindmap); this.parent(mindmap);
this._brixModel = brixModel; this._brixModel = brixModel;
@ -33,10 +35,9 @@ mindplot.collaboration.framework.brix.model.NodeModel = new Class({
// Nodes creation should be cached ... // Nodes creation should be cached ...
if (!this._brixModel.__registered) { if (!this._brixModel.__registered) {
// Register listener for properties changes .... // Register listener for properties changes ....
var actionDispatcher = this._brixFramework.getActionDispatcher();
this._brixModel.addListener("valueChanged", function(event) { this._brixModel.addListener("valueChanged", function(event) {
var key = event.getProperty(); var key = event.getProperty();
var actionDispatcher = this._brixFramework.getActionDispatcher();
var value = event.getNewValue(); var value = event.getNewValue();
var funName = 'change' + key.capitalize() + 'ToTopic'; var funName = 'change' + key.capitalize() + 'ToTopic';
@ -44,6 +45,7 @@ mindplot.collaboration.framework.brix.model.NodeModel = new Class({
throw "No implementation for:" + funName; throw "No implementation for:" + funName;
} }
console.log("This action dispatcher:" + funName); console.log("This action dispatcher:" + funName);
actionDispatcher[funName]([this.getId()], value); actionDispatcher[funName]([this.getId()], value);
}.bind(this)); }.bind(this));
@ -57,7 +59,19 @@ mindplot.collaboration.framework.brix.model.NodeModel = new Class({
var model = new mindplot.model.NodeModel(cmodel.getType(), designer.getMindmap(), this.getId()); var model = new mindplot.model.NodeModel(cmodel.getType(), designer.getMindmap(), this.getId());
cmodel.copyTo(model); cmodel.copyTo(model);
this._brixFramework.getActionDispatcher().addTopic(model, this.getId(), true); actionDispatcher.addTopic(model, this.getId(), true);
}.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());
}
}.bind(this)); }.bind(this));
this._brixModel.__registered = true; this._brixModel.__registered = true;
@ -69,7 +83,8 @@ mindplot.collaboration.framework.brix.model.NodeModel = new Class({
var children = this._brixModel.get("children"); var children = this._brixModel.get("children");
for (var i = 0; i < children.size(); i++) { for (var i = 0; i < children.size(); i++) {
var node = children.get(i); var node = children.get(i);
var nodeModel = new mindplot.collaboration.framework.brix.model.NodeModel(this._brixFramework, node, this); var nodeModel = new mindplot.collaboration.framework.brix.model.NodeModel(this._brixFramework, node, this.getMindmap());
nodeModel.setParent(this);
result.push(nodeModel); result.push(nodeModel);
} }
return result; return result;
@ -98,11 +113,27 @@ mindplot.collaboration.framework.brix.model.NodeModel = new Class({
return this._brixModel._parent; return this._brixModel._parent;
}, },
setParent : function(parent) {
this._brixModel._parent = parent;
},
appendChild : function(node) { appendChild : function(node) {
$assert(node && node.isNodeModel(), 'Only NodeModel can be appended to Mindmap object'); $assert(node && node.isNodeModel(), 'Only NodeModel can be appended to Mindmap object');
var children = this._brixModel.get("children"); var children = this._brixModel.get("children");
children.add(node.getBrixModel()); children.add(node.getBrixModel());
node.getBrixModel()._parent = this; this.setParent(this);
},
removeChild : function(child) {
$assert(child && child.isNodeModel(), 'Only NodeModel can be appended to Mindmap object.');
var children = this._brixModel.get("children");
for (var i = 0; i < children.size(); i++) {
if (children.get(i) == child.getBrixModel()) {
children.remove(i);
break;
}
}
this.setParent(null);
} }
}); });

View File

@ -81,7 +81,6 @@ mindplot.model.IMindmap = new Class({
$assert(parent, 'Child model seems to be already connected'); $assert(parent, 'Child model seems to be already connected');
parent.removeChild(child); parent.removeChild(child);
this.addBranch(child); this.addBranch(child);
}, },

View File

@ -18,7 +18,7 @@
mindplot.model.INodeModel = new Class({ mindplot.model.INodeModel = new Class({
initialize: function(mindmap) { initialize: function(mindmap) {
$assert(mindmap, 'mindmap can not be null'); $assert(mindmap && mindmap.getBranches, 'mindmap can not be null');
this._mindmap = mindmap; this._mindmap = mindmap;
}, },
@ -200,6 +200,50 @@ mindplot.model.INodeModel = new Class({
mindmap.connect(parent, this); mindmap.connect(parent, this);
}, },
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;
},
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..
var parent = this.getParent();
if ($defined(parent)) {
mindmap.disconnect(this);
}
// It's an isolated node. It must be a hole branch ...
mindmap.removeBranch(this);
},
getPropertiesKeys : function() { getPropertiesKeys : function() {
throw "Unsupported operation"; throw "Unsupported operation";
}, },
@ -212,10 +256,6 @@ mindplot.model.INodeModel = new Class({
throw "Unsupported operation"; throw "Unsupported operation";
}, },
deleteNode : function() {
throw "Unsupported operation";
},
createLink : function(url) { createLink : function(url) {
throw "Unsupported operation"; throw "Unsupported operation";
}, },
@ -283,7 +323,7 @@ mindplot.model.INodeModel = new Class({
var children = this.getChildren(); var children = this.getChildren();
if (children.length > 0) { if (children.length > 0) {
result = result + "{(size:" + children.length; result = result + ", children: {(size:" + children.length;
children.forEach(function(node) { children.forEach(function(node) {
result = result + "=> (" + node.getPropertiesKeys() + ")"; result = result + "=> (" + node.getPropertiesKeys() + ")";
}.bind(this)); }.bind(this));
@ -293,26 +333,9 @@ mindplot.model.INodeModel = new Class({
return result; return result;
}, },
copyTo : function(target) { removeChild : function(child) {
var source = this; throw "Unsupported operation";
// 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;
} }
}); });

View File

@ -41,8 +41,7 @@ mindplot.model.NodeModel = new Class({
}, },
getProperties: function() getProperties: function() {
{
return this._properties; return this._properties;
}, },
@ -67,7 +66,7 @@ mindplot.model.NodeModel = new Class({
return result; return result;
}, },
addChildren : function(){ addChildren : function() {
$assert(child && child.isNodeModel(), 'Only NodeModel can be appended to Mindmap object'); $assert(child && child.isNodeModel(), 'Only NodeModel can be appended to Mindmap object');
this._children.push(child); this._children.push(child);
child._parent = this; child._parent = this;
@ -223,28 +222,6 @@ mindplot.model.NodeModel = new Class({
}, },
deleteNode : function() {
var mindmap = this._mindmap;
// if it has children nodes, Their must be disconnected.
var lenght = this._children;
for (var i = 0; i < lenght; i++) {
var child = this._children[i];
mindmap.disconnect(child);
}
var parent = this._parent;
if ($defined(parent)) {
// if it is connected, I must remove it from the parent..
mindmap.disconnect(this);
}
// It's an isolated node. It must be a hole branch ...
var branches = mindmap.getBranches();
branches.erase(this);
},
inspect : function() { inspect : function() {
return '(type:' + this.getType() + ' , id: ' + this.getId() + ')'; return '(type:' + this.getType() + ' , id: ' + this.getId() + ')';
} }

View File

@ -175,7 +175,7 @@ web2d.Workspace = new Class({
} }
if (element == this) { if (element == this) {
throw "It's not posible to add the group as a child of itself"; throw "It's not possible to add the group as a child of itself";
} }
var elementType = element.getType(); var elementType = element.getType();

View File

@ -12,17 +12,12 @@
<link rel="stylesheet" type="text/css" href="../css/editor.css"/> <link rel="stylesheet" type="text/css" href="../css/editor.css"/>
<link rel="stylesheet" type="text/css" href='/mindplot/src/main/javascript/libraries/moodialog/css/MooDialog.css'/> <link rel="stylesheet" type="text/css" href='/mindplot/src/main/javascript/libraries/moodialog/css/MooDialog.css'/>
<!--<script type='text/javascript' src='../js/wiseLibrary.js'></script>--> <!--<script type='text/javascript' src='../js/wiseLibrary.js'></script>-->
<script type='text/javascript' <script type='text/javascript'
src='https://ajax.googleapis.com/ajax/libs/mootools/1.3.2/mootools-yui-compressed.js'></script> src='https://ajax.googleapis.com/ajax/libs/mootools/1.3.2/mootools-yui-compressed.js'></script>
<script type='text/javascript' src='../js/mootools-more-1.3.2.1-yui.js'></script> <script type='text/javascript' src='../js/mootools-more-1.3.2.1-yui.js'></script>
<script type='text/javascript' src='/mindplot/src/main/javascript/libraries/moodialog/Overlay.js'></script>
<script type='text/javascript' src='/mindplot/src/main/javascript/libraries/moodialog/MooDialog.js'></script>
<script type='text/javascript' src='/mindplot/src/main/javascript/libraries/moodialog/MooDialog.Fx.js'></script>
<!--<script type='text/javascript' src='../js/common.js'></script>--> <!--<script type='text/javascript' src='../js/common.js'></script>-->
<!--<script type='text/javascript' src='../js/wiseEditorLibrary.js'></script>--> <!--<script type='text/javascript' src='../js/wiseEditorLibrary.js'></script>-->