mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-22 14:17:57 +01:00
Adding new node with Brix integration
This commit is contained in:
parent
b699c2670c
commit
d75ceba363
@ -31,6 +31,16 @@ mindplot.BrixActionDispatcher = new Class({
|
||||
}
|
||||
var topic = framework.getTopic(topicsIds[0]);
|
||||
topic.setText(text, true);
|
||||
},
|
||||
|
||||
addTopic:function(model, parentTopicId, animated) {
|
||||
var framework = mindplot.collaboration.CollaborationManager.getInstance().getCollaborativeFramework();
|
||||
var mindmap = framework.getModel();
|
||||
var centralTopic = mindmap.getCentralTopic();
|
||||
var newNode = mindmap.createNode(model.getType(), model.getId());
|
||||
var position = model.getPosition();
|
||||
newNode.setPosition(position.x, position.y);
|
||||
newNode.connectTo(centralTopic);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -24,8 +24,8 @@ 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.BrixActionDispatcher(commandContext);
|
||||
// this._actionDispatcher = new mindplot.LocalActionDispatcher(commandContext);
|
||||
|
||||
this._actionDispatcher.addEvent("modelUpdate", function(event) {
|
||||
this._fireEvent("modelUpdate", event);
|
||||
|
@ -21,6 +21,16 @@ mindplot.collaboration.frameworks.AbstractCollaborativeFramework = new Class({
|
||||
var id = branch.getId();
|
||||
var node = mindmap.createNode(type,id);
|
||||
node.setText(branch.getText());
|
||||
var position = branch.getPosition();
|
||||
node.setPosition(position.x, position.y);
|
||||
var children = branch.getChildren();
|
||||
children.forEach(function(child){
|
||||
var node2 = new mindplot.model.NodeModel(child.getType(),mindmap, child.getId());
|
||||
node2.setText(child.getText());
|
||||
var pos = child.getPosition();
|
||||
node2.setPosition(pos.x, pos.y);
|
||||
node._appendChild(node2);
|
||||
});
|
||||
mindmap.addBranch(node);
|
||||
}.bind(this));
|
||||
return mindmap;
|
||||
@ -38,6 +48,16 @@ mindplot.collaboration.frameworks.AbstractCollaborativeFramework = new Class({
|
||||
for(var i = 0; i<branches.length; i++){
|
||||
if(branches[i].getId()==id){
|
||||
return branches[i];
|
||||
}else {
|
||||
|
||||
var children = branches[i].getChildren();
|
||||
for(var j=0; j<children.length; j++){
|
||||
if(children[j].getId()==id){
|
||||
return children[j];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
@ -27,7 +27,7 @@ mindplot.collaboration.frameworks.brix.model.Mindmap = new Class({
|
||||
var branches = this._brixModel.get("branches");
|
||||
for(var i=0; i<branches.size(); i++){
|
||||
var node = branches.get(i);
|
||||
var nodeModel = new mindplot.collaboration.frameworks.brix.model.NodeModel(node, this._brixFramework);
|
||||
var nodeModel = new mindplot.collaboration.frameworks.brix.model.NodeModel(node, this._brixFramework, null, this);
|
||||
this.addBranch(nodeModel, false);
|
||||
}
|
||||
}
|
||||
|
@ -32,20 +32,47 @@ mindplot.collaboration.frameworks.brix.model.NodeModel = new Class({
|
||||
}else{
|
||||
var text = this._brixModel.get("text");
|
||||
this.setText(text, false);
|
||||
var position = this._brixModel.get("position");
|
||||
this.setPosition(position.get("x"),position.get("y"), false);
|
||||
var children = this._brixModel.get("children");
|
||||
for(var i=0; i<children.size(); i++){
|
||||
var bChild = children.get(i);
|
||||
var child= new mindplot.collaboration.frameworks.brix.model.NodeModel(bChild, this._brixFramework, null, mindmap);
|
||||
this._appendChild(child, false);
|
||||
}
|
||||
}
|
||||
this._addBrixListeners();
|
||||
},
|
||||
_addBrixListeners:function(){
|
||||
this._brixModel.addListener("valueChanged", this._valuechangeListener.bindWithEvent(this));
|
||||
this._brixModel.get("children").addListener("valuesAdded", this._childAddedListener.bindWithEvent(this));
|
||||
},
|
||||
_valuechangeListener:function(event){
|
||||
this._brixFramework.getActionDispatcher().changeTextOnTopic(this.getId(),event.getNewValue());
|
||||
},
|
||||
_childAddedListener:function(event){
|
||||
var newValue = event.getValues().get(0);
|
||||
var cmodel = new mindplot.collaboration.frameworks.brix.model.NodeModel(newValue,this._brixFramework, null, this.getMindmap());
|
||||
this._appendChild(cmodel, false);
|
||||
|
||||
var model = new mindplot.model.NodeModel(newValue.get("type"),designer.getMindmap(), newValue.get("id"));
|
||||
var position = newValue.get("position");
|
||||
var x = position.get("x");
|
||||
var y = position.get("y");
|
||||
model.setPosition(x, y);
|
||||
this._brixFramework.getActionDispatcher().addTopic(model, this.getId(), true);
|
||||
},
|
||||
_createBrixModel:function(){
|
||||
var model = this._brixFramework.getBrixModel().create("Map");
|
||||
model.put("type",this._type);
|
||||
model.put("id",this._id);
|
||||
model.put("text",this._type==mindplot.model.NodeModel.CENTRAL_TOPIC_TYPE?"Central Topic":"Main Topic");
|
||||
var position = this._brixFramework.getBrixModel().create("Map");
|
||||
position.put("x",0);
|
||||
position.put("y",0);
|
||||
model.put("position",position);
|
||||
var children = this._brixFramework.getBrixModel().create("List");
|
||||
model.put("children", children);
|
||||
return model;
|
||||
},
|
||||
getBrixModel:function(){
|
||||
@ -174,10 +201,11 @@ mindplot.collaboration.frameworks.brix.model.NodeModel = new Class({
|
||||
this._icons.pop();
|
||||
},
|
||||
|
||||
_appendChild : function(child) {
|
||||
$assert(child && child.isNodeModel(), 'Only NodeModel can be appended to Mindmap object');
|
||||
this._children.push(child);
|
||||
child._parent = this;
|
||||
_appendChild : function(child, updateModel) {
|
||||
this.parent(child);
|
||||
if(!$defined(updateModel) || ($defined(updateModel) && updateModel)){
|
||||
this.getBrixModel().get("children").add(child.getBrixModel());
|
||||
}
|
||||
},
|
||||
|
||||
_removeChild : function(child) {
|
||||
@ -186,19 +214,13 @@ mindplot.collaboration.frameworks.brix.model.NodeModel = new Class({
|
||||
child._parent = null;
|
||||
},
|
||||
|
||||
setPosition : function(x, y) {
|
||||
$assert(x, "x coordinate must be defined");
|
||||
$assert(y, "y coordinate must be defined");
|
||||
|
||||
if (!$defined(this._position)) {
|
||||
this._position = new core.Point();
|
||||
setPosition : function(x, y, updateModel) {
|
||||
this.parent(x,y);
|
||||
if(!$defined(updateModel) || ($defined(updateModel) && updateModel)){
|
||||
var position = this.getBrixModel().get("position");
|
||||
position.put("x",this._position.x);
|
||||
position.put("y",this._position.y);
|
||||
}
|
||||
this._position.x = parseInt(x);
|
||||
this._position.y = parseInt(y);
|
||||
},
|
||||
|
||||
getPosition : function() {
|
||||
return this._position;
|
||||
},
|
||||
|
||||
setFinalPosition : function(x, y) {
|
||||
@ -318,12 +340,6 @@ mindplot.collaboration.frameworks.brix.model.NodeModel = new Class({
|
||||
|
||||
},
|
||||
|
||||
connectTo : function(parent) {
|
||||
var mindmap = this.getMindmap();
|
||||
mindmap.connect(parent, this);
|
||||
this._parent = parent;
|
||||
},
|
||||
|
||||
disconnect : function() {
|
||||
var mindmap = this.getMindmap();
|
||||
mindmap.disconnect(this);
|
||||
|
@ -5,7 +5,7 @@
|
||||
<!--[if lt IE 9]>
|
||||
<meta http-equiv="X-UA-Compatible" content="chrome=1">
|
||||
<![endif]-->
|
||||
<!--<script type="text/javascript" src="http://docs.google.com/brix/static/api/js/jsapi.nocache.js"></script>-->
|
||||
<script type="text/javascript" src="http://docs.google.com/brix/static/api/js/jsapi.nocache.js"></script>
|
||||
<!-- Internet Explorer 8 Hack -->
|
||||
<meta http-equiv="Content-type" content="text/html; charset=UTF-8"/>
|
||||
<title>WiseMapping - Editor </title>
|
||||
|
Loading…
Reference in New Issue
Block a user