mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-26 07:44:56 +01:00
Support connection in any node.
This commit is contained in:
parent
5a08728686
commit
304f9f4c97
@ -64,13 +64,12 @@ mindplot.BrixActionDispatcher = new Class({
|
||||
addTopic : function(nodeModel, parentTopicId, animated) {
|
||||
var framework = this._getFramework();
|
||||
var cmindmap = framework.getModel();
|
||||
var centralTopic = cmindmap.getCentralTopic();
|
||||
|
||||
var cparent = $defined(parentTopicId) ? framework.getTopic(parentTopicId) : cmindmap.getCentralTopic();
|
||||
var cnode = cmindmap.createNode(nodeModel.getType(), nodeModel.getId());
|
||||
var position = nodeModel.getPosition();
|
||||
cnode.setPosition(position.x, position.y);
|
||||
nodeModel.copyTo(cnode);
|
||||
|
||||
cnode.connectTo(centralTopic);
|
||||
cnode.connectTo(cparent);
|
||||
},
|
||||
|
||||
changeFontSizeToTopic : function(topicsIds, size) {
|
||||
@ -145,11 +144,10 @@ mindplot.BrixActionDispatcher = new Class({
|
||||
var framework = this._getFramework();
|
||||
var mindmap = framework.getModel();
|
||||
|
||||
var topicId = topicsIds[0];
|
||||
topicsIds.forEach(function(topicId) {
|
||||
var topic = framework.getTopic(topicId);
|
||||
$assert(topic, "Could not find topic with id:" + topicId);
|
||||
topic.deleteNode();
|
||||
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -25,25 +25,25 @@ mindplot.MainTopic = new Class({
|
||||
INNER_RECT_ATTRIBUTES : {stroke:'0.5 solid #009900'},
|
||||
|
||||
createSiblingModel : function(positionate) {
|
||||
var siblingModel = null;
|
||||
var result = null;
|
||||
var parentTopic = this.getOutgoingConnectedTopic();
|
||||
if (parentTopic != null) {
|
||||
// Create a new node ...
|
||||
var model = this.getModel();
|
||||
var mindmap = model.getMindmap();
|
||||
siblingModel = mindmap.createNode(mindplot.model.INodeModel.MAIN_TOPIC_TYPE);
|
||||
result = mindmap.createNode(mindplot.model.INodeModel.MAIN_TOPIC_TYPE);
|
||||
|
||||
// Positionate following taking into account the sibling positon.
|
||||
// Positionate following taking into account the sibling position.
|
||||
if (positionate && parentTopic.getType() == mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) {
|
||||
var pos = this.getPosition();
|
||||
siblingModel.setPosition(pos.x, pos.y);
|
||||
result.setPosition(pos.x, pos.y);
|
||||
}
|
||||
|
||||
// Create a new node ...
|
||||
var order = this.getOrder() + 1;
|
||||
siblingModel.setOrder(order);
|
||||
result.setOrder(order);
|
||||
}
|
||||
return siblingModel;
|
||||
return result;
|
||||
},
|
||||
|
||||
createChildModel : function(prepositionate) {
|
||||
|
@ -23,7 +23,6 @@ mindplot.collaboration.framework.brix.model.NodeModel = new Class({
|
||||
$assert(brixModel, "brixModel can not null");
|
||||
$assert(mindmap && mindmap.getBranches, "mindmap can not null");
|
||||
|
||||
|
||||
this.parent(mindmap);
|
||||
this._brixModel = brixModel;
|
||||
this._brixFramework = brixFramework;
|
||||
@ -51,15 +50,24 @@ mindplot.collaboration.framework.brix.model.NodeModel = new Class({
|
||||
|
||||
var children = this._brixModel.get("children");
|
||||
children.addListener("valuesAdded", function(event) {
|
||||
var brixNodeModel = event.getValues().get(0);
|
||||
try {
|
||||
|
||||
var brixChildren = event.getValues();
|
||||
for (var i = 0; i < brixChildren.size(); i++) {
|
||||
var brixNodeModel = brixChildren.get(0);
|
||||
|
||||
var cmodel = new mindplot.collaboration.framework.brix.model.NodeModel(this._brixFramework, brixNodeModel, this.getMindmap());
|
||||
|
||||
// @Todo: This is not ok...
|
||||
// @Todo: This is not ok. Is using designer global variable.
|
||||
var model = new mindplot.model.NodeModel(cmodel.getType(), designer.getMindmap(), this.getId());
|
||||
cmodel.copyTo(model);
|
||||
|
||||
actionDispatcher.addTopic(model, this.getId(), true);
|
||||
}
|
||||
} catch(e) {
|
||||
console.trace();
|
||||
}
|
||||
|
||||
}.bind(this));
|
||||
|
||||
children.addListener("valuesRemoved", function(event) {
|
||||
@ -72,7 +80,6 @@ mindplot.collaboration.framework.brix.model.NodeModel = new Class({
|
||||
}
|
||||
} catch(e) {
|
||||
console.trace();
|
||||
console.log(e);
|
||||
}
|
||||
|
||||
}.bind(this));
|
||||
@ -108,7 +115,12 @@ mindplot.collaboration.framework.brix.model.NodeModel = new Class({
|
||||
},
|
||||
|
||||
getPropertiesKeys : function() {
|
||||
return this._brixModel.getKeys().erase('children');
|
||||
var keys = this._brixModel.getKeys();
|
||||
keys.erase('children');
|
||||
keys.erase('icons');
|
||||
keys.erase('links');
|
||||
keys.erase('notes');
|
||||
return keys;
|
||||
},
|
||||
|
||||
getParent : function() {
|
||||
|
@ -225,7 +225,7 @@ mindplot.model.INodeModel = new Class({
|
||||
deleteNode : function() {
|
||||
var mindmap = this.getMindmap();
|
||||
|
||||
console.log(mindmap.inspect());
|
||||
console.log("Before:" + mindmap.inspect());
|
||||
var parent = this.getParent();
|
||||
if ($defined(parent)) {
|
||||
parent.removeChild(this);
|
||||
@ -234,7 +234,7 @@ mindplot.model.INodeModel = new Class({
|
||||
mindmap.removeBranch(this);
|
||||
}
|
||||
// It's an isolated node. It must be a hole branch ...
|
||||
console.log(mindmap.inspect());
|
||||
console.log("After:" + mindmap.inspect());
|
||||
},
|
||||
|
||||
getPropertiesKeys : function() {
|
||||
|
@ -35,6 +35,10 @@ mindplot.model.NodeModel = new Class({
|
||||
this._notes = [];
|
||||
},
|
||||
|
||||
getPropertiesKeys : function() {
|
||||
return Object.keys(this._properties);
|
||||
},
|
||||
|
||||
putProperty : function(key, value) {
|
||||
$defined(key, 'key can not be null');
|
||||
this._properties[key] = value;
|
||||
|
@ -211,7 +211,7 @@ mindplot.widget.Menu = new Class({
|
||||
|
||||
$('addTopic').addEvent('click', function() {
|
||||
this.clear();
|
||||
designer.createSiblingForSelectedNode();
|
||||
designer.createChildForSelectedNode();
|
||||
}.bind(this));
|
||||
|
||||
$('deleteTopic').addEvent('click', function() {
|
||||
|
Loading…
Reference in New Issue
Block a user