mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-26 15:54:55 +01:00
Fix several issues.
This commit is contained in:
parent
2a4d96151b
commit
d84384364c
@ -91,7 +91,7 @@ mindplot.ActionDispatcher = new Class({
|
|||||||
throw "method must be implemented.";
|
throw "method must be implemented.";
|
||||||
},
|
},
|
||||||
|
|
||||||
changeShapeToTopic : function(topicsIds, shapeType) {
|
changeShapeTypeToTopic : function(topicsIds, shapeType) {
|
||||||
throw "method must be implemented.";
|
throw "method must be implemented.";
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -31,8 +31,9 @@ mindplot.BrixActionDispatcher = new Class({
|
|||||||
} else {
|
} else {
|
||||||
topicId = topicsIds[0];
|
topicId = topicsIds[0];
|
||||||
}
|
}
|
||||||
var topic = framework.getTopic(topicId);
|
var node = framework.getTopic(topicId);
|
||||||
topic.setText(text, true);
|
node.setText(text);
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
_getFramework:function () {
|
_getFramework:function () {
|
||||||
@ -41,10 +42,10 @@ mindplot.BrixActionDispatcher = new Class({
|
|||||||
|
|
||||||
addTopic : function(nodeModel, parentTopicId, animated) {
|
addTopic : function(nodeModel, parentTopicId, animated) {
|
||||||
var framework = this._getFramework();
|
var framework = this._getFramework();
|
||||||
var cmapindmap = framework.getModel();
|
var cmindmap = framework.getModel();
|
||||||
var centralTopic = cmapindmap.getCentralTopic();
|
var centralTopic = cmindmap.getCentralTopic();
|
||||||
|
|
||||||
var cnode = cmapindmap.createNode(nodeModel.getType(), nodeModel.getId());
|
var cnode = cmindmap.createNode(nodeModel.getType(), nodeModel.getId());
|
||||||
var position = nodeModel.getPosition();
|
var position = nodeModel.getPosition();
|
||||||
cnode.setPosition(position.x, position.y);
|
cnode.setPosition(position.x, position.y);
|
||||||
|
|
||||||
@ -84,7 +85,7 @@ mindplot.BrixActionDispatcher = new Class({
|
|||||||
}.bind(this));
|
}.bind(this));
|
||||||
},
|
},
|
||||||
|
|
||||||
changeShapeToTopic : function(topicsIds, shapeType) {
|
changeShapeTypeToTopic : function(topicsIds, shapeType) {
|
||||||
topicsIds.forEach(function(topicId) {
|
topicsIds.forEach(function(topicId) {
|
||||||
var framework = this._getFramework();
|
var framework = this._getFramework();
|
||||||
var topic = framework.getTopic(topicId);
|
var topic = framework.getTopic(topicId);
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
mindplot.IconGroup = new Class({
|
mindplot.IconGroup = new Class({
|
||||||
initialize : function(topicId, iconSize) {
|
initialize : function(topicId, iconSize) {
|
||||||
$assert(topicId, "topicId can not be null");
|
$assert($defined(topicId), "topicId can not be null");
|
||||||
$assert(iconSize, "iconSize can not be null");
|
$assert(iconSize, "iconSize can not be null");
|
||||||
|
|
||||||
this._icons = [];
|
this._icons = [];
|
||||||
|
@ -96,10 +96,9 @@ mindplot.LocalActionDispatcher = new Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
changeTextToTopic : function(topicsIds, text) {
|
changeTextToTopic : function(topicsIds, text) {
|
||||||
$assert(topicsIds, "topicsIds can not be null");
|
$assert($defined(topicsIds), "topicsIds can not be null");
|
||||||
|
|
||||||
var commandFunc = function(topic, value) {
|
var commandFunc = function(topic, value) {
|
||||||
|
|
||||||
var result = topic.getText();
|
var result = topic.getText();
|
||||||
topic.setText(value);
|
topic.setText(value);
|
||||||
return result;
|
return result;
|
||||||
@ -187,7 +186,7 @@ mindplot.LocalActionDispatcher = new Class({
|
|||||||
this.execute(command);
|
this.execute(command);
|
||||||
},
|
},
|
||||||
|
|
||||||
changeShapeToTopic : function(topicsIds, shapeType) {
|
changeShapeTypeToTopic : function(topicsIds, shapeType) {
|
||||||
$assert(topicsIds, "topicsIds can not be null");
|
$assert(topicsIds, "topicsIds can not be null");
|
||||||
$assert(shapeType, "shapeType can not be null");
|
$assert(shapeType, "shapeType can not be null");
|
||||||
|
|
||||||
@ -242,7 +241,7 @@ mindplot.CommandContext = new Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
findTopics:function(topicsIds) {
|
findTopics:function(topicsIds) {
|
||||||
$assert(topicsIds, "topicsIds can not be null");
|
$assert($defined(topicsIds), "topicsIds can not be null");
|
||||||
if (!(topicsIds instanceof Array)) {
|
if (!(topicsIds instanceof Array)) {
|
||||||
topicsIds = [topicsIds];
|
topicsIds = [topicsIds];
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,7 @@ 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));
|
||||||
},
|
},
|
||||||
@ -249,7 +249,7 @@ mindplot.MindmapDesigner = new Class({
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
if (nodes.length > 1) {
|
if (nodes.length != 1) {
|
||||||
|
|
||||||
// If there are more than one node selected,
|
// If there are more than one node selected,
|
||||||
core.Monitor.getInstance().logMessage('Could not create a topic. One topic must be selected.');
|
core.Monitor.getInstance().logMessage('Could not create a topic. One topic must be selected.');
|
||||||
@ -257,9 +257,9 @@ mindplot.MindmapDesigner = new Class({
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add new node ...
|
// Add new node ...
|
||||||
var centalTopic = nodes[0];
|
var parentTopic = nodes[0];
|
||||||
var parentTopicId = centalTopic.getId();
|
var parentTopicId = parentTopic.getId();
|
||||||
var childModel = centalTopic.createChildModel(this._layoutManager.needsPrepositioning());
|
var childModel = parentTopic.createChildModel(this._layoutManager.needsPrepositioning());
|
||||||
|
|
||||||
// Execute event ...
|
// Execute event ...
|
||||||
this._actionDispatcher.addTopic(childModel, parentTopicId, true);
|
this._actionDispatcher.addTopic(childModel, parentTopicId, true);
|
||||||
@ -615,7 +615,7 @@ mindplot.MindmapDesigner = new Class({
|
|||||||
var validateError = 'Central Topic shape can not be changed to line figure.';
|
var validateError = 'Central Topic shape can not be changed to line figure.';
|
||||||
var topicsIds = this.getModel().filterTopicsIds(validateFunc, validateError);
|
var topicsIds = this.getModel().filterTopicsIds(validateFunc, validateError);
|
||||||
if (topicsIds.length > 0) {
|
if (topicsIds.length > 0) {
|
||||||
this._actionDispatcher.changeShapeToTopic(topicsIds, shape);
|
this._actionDispatcher.changeShapeTypeToTopic(topicsIds, shape);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -998,7 +998,7 @@ mindplot.Topic = new Class({
|
|||||||
|
|
||||||
// Disconnect nodes ...
|
// Disconnect nodes ...
|
||||||
var targetTopic = outgoingLine.getTargetTopic();
|
var targetTopic = outgoingLine.getTargetTopic();
|
||||||
targetTopic._removeChild(this);
|
targetTopic.removeChild(this);
|
||||||
|
|
||||||
// Update model ...
|
// Update model ...
|
||||||
var childModel = this.getModel();
|
var childModel = this.getModel();
|
||||||
@ -1049,7 +1049,7 @@ mindplot.Topic = new Class({
|
|||||||
$assert(workspace, 'Workspace can not be null');
|
$assert(workspace, 'Workspace can not be null');
|
||||||
|
|
||||||
// Connect Graphical Nodes ...
|
// Connect Graphical Nodes ...
|
||||||
targetTopic._appendChild(this);
|
targetTopic.appendChild(this);
|
||||||
this._parent = targetTopic;
|
this._parent = targetTopic;
|
||||||
|
|
||||||
// Update model ...
|
// Update model ...
|
||||||
@ -1090,12 +1090,12 @@ mindplot.Topic = new Class({
|
|||||||
outgoingLine.redraw();
|
outgoingLine.redraw();
|
||||||
},
|
},
|
||||||
|
|
||||||
_appendChild : function(child) {
|
appendChild : function(child) {
|
||||||
var children = this._getChildren();
|
var children = this._getChildren();
|
||||||
children.push(child);
|
children.push(child);
|
||||||
},
|
},
|
||||||
|
|
||||||
_removeChild : function(child) {
|
removeChild : function(child) {
|
||||||
var children = this._getChildren();
|
var children = this._getChildren();
|
||||||
children.erase(child);
|
children.erase(child);
|
||||||
},
|
},
|
||||||
|
@ -1,10 +1,6 @@
|
|||||||
mindplot.collaboration.framework.AbstractCollaborativeFramework = new Class({
|
mindplot.collaboration.framework.AbstractCollaborativeFramework = new Class({
|
||||||
initialize: function(model, collaborativeModelFactory)
|
initialize: function(model) {
|
||||||
{
|
$assert(model, "model can not be null");
|
||||||
this._collaborativeModelFactory = collaborativeModelFactory;
|
|
||||||
if (!$defined(model)) {
|
|
||||||
model = this._buildInitialCollaborativeModel();
|
|
||||||
}
|
|
||||||
this._model = model;
|
this._model = model;
|
||||||
this._actionDispatcher = null;
|
this._actionDispatcher = null;
|
||||||
},
|
},
|
||||||
@ -18,31 +14,17 @@ mindplot.collaboration.framework.AbstractCollaborativeFramework = new Class({
|
|||||||
var cmind = this.getModel();
|
var cmind = this.getModel();
|
||||||
var mmind = new mindplot.model.Mindmap();
|
var mmind = new mindplot.model.Mindmap();
|
||||||
cmind.copyTo(mmind);
|
cmind.copyTo(mmind);
|
||||||
|
|
||||||
return mmind;
|
return mmind;
|
||||||
},
|
},
|
||||||
|
|
||||||
_buildInitialCollaborativeModel: function() {
|
_findTopic : function(nodes, id) {
|
||||||
|
|
||||||
var mindmap = this._collaborativeModelFactory.buildMindMap();
|
|
||||||
var centralTopic = mindmap.createNode(mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE);
|
|
||||||
mindmap.addBranch(centralTopic, true);
|
|
||||||
this.addMindmap(mindmap);
|
|
||||||
return mindmap;
|
|
||||||
},
|
|
||||||
|
|
||||||
addMindmap:function(model) {
|
|
||||||
throw "method to implement";
|
|
||||||
},
|
|
||||||
|
|
||||||
_findTopic : function(topics, id) {
|
|
||||||
var result;
|
var result;
|
||||||
for (var i = 0; i < topics.length; i++) {
|
for (var i = 0; i < nodes.length; i++) {
|
||||||
var topic = topics[i];
|
var node = nodes[i];
|
||||||
if (topic.getId() == id) {
|
if (node.getId() == id) {
|
||||||
result = topic;
|
result = node;
|
||||||
} else {
|
} else {
|
||||||
var children = topic.getChildren();
|
var children = node.getChildren();
|
||||||
result = this._findTopic(children, id)
|
result = this._findTopic(children, id)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,7 +36,7 @@ mindplot.collaboration.framework.AbstractCollaborativeFramework = new Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
getTopic:function(id) {
|
getTopic:function(id) {
|
||||||
$assert(id, "id can not be null")
|
$assert($defined(id), "id can not be null");
|
||||||
var branches = this.getModel().getBranches();
|
var branches = this.getModel().getBranches();
|
||||||
var result = this._findTopic(branches, id);
|
var result = this._findTopic(branches, id);
|
||||||
$assert(result, "Could not find topic:" + id);
|
$assert(result, "Could not find topic:" + id);
|
||||||
|
@ -17,12 +17,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
mindplot.collaboration.framework.AbstractCollaborativeModelFactory = new Class({
|
mindplot.collaboration.framework.AbstractCollaborativeModelFactory = new Class({
|
||||||
initialize:function() {
|
createNewMindmap:function() {
|
||||||
|
throw "Unsupported operation";
|
||||||
},
|
},
|
||||||
buildMindMap:function() {
|
buildMindmap:function(model) {
|
||||||
|
throw "Unsupported operation";
|
||||||
},
|
|
||||||
buildCollaborativeModelFor:function(model) {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
@ -19,17 +19,19 @@
|
|||||||
mindplot.collaboration.framework.brix.BrixCollaborativeModelFactory = new Class({
|
mindplot.collaboration.framework.brix.BrixCollaborativeModelFactory = new Class({
|
||||||
Extends:mindplot.collaboration.framework.AbstractCollaborativeModelFactory,
|
Extends:mindplot.collaboration.framework.AbstractCollaborativeModelFactory,
|
||||||
initialize:function(brixFramework) {
|
initialize:function(brixFramework) {
|
||||||
|
$assert(brixFramework, 'brixFramework can not be null');
|
||||||
this._brixFramework = brixFramework;
|
this._brixFramework = brixFramework;
|
||||||
},
|
},
|
||||||
|
|
||||||
buildMindMap:function() {
|
createNewMindmap : function() {
|
||||||
var mindmap = new mindplot.collaboration.framework.brix.model.Mindmap(this._brixFramework);
|
var mindmap = new mindplot.collaboration.framework.brix.model.Mindmap(this._brixFramework);
|
||||||
var node = mindmap.createNode(mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE, 0);
|
var node = mindmap.createNode(mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE, 0);
|
||||||
|
mindmap.setVersion('pela-brix');
|
||||||
mindmap.addBranch(node);
|
mindmap.addBranch(node);
|
||||||
return mindmap;
|
return mindmap;
|
||||||
},
|
},
|
||||||
|
|
||||||
buildCollaborativeModelFor:function(model) {
|
buildMindmap : function(model) {
|
||||||
return new mindplot.collaboration.framework.brix.model.Mindmap(this._brixFramework, model);
|
return new mindplot.collaboration.framework.brix.model.Mindmap(this._brixFramework, model);
|
||||||
}
|
}
|
||||||
});
|
});
|
@ -20,19 +20,18 @@ mindplot.collaboration.framework.brix.BrixFramework = new Class({
|
|||||||
Extends: mindplot.collaboration.framework.AbstractCollaborativeFramework,
|
Extends: mindplot.collaboration.framework.AbstractCollaborativeFramework,
|
||||||
initialize: function(model, app) {
|
initialize: function(model, app) {
|
||||||
this._app = app;
|
this._app = app;
|
||||||
var collaborativeModelFactory = new mindplot.collaboration.framework.brix.BrixCollaborativeModelFactory(this);
|
var factory = new mindplot.collaboration.framework.brix.BrixCollaborativeModelFactory(this);
|
||||||
var cModel = null;
|
|
||||||
var root = this.getBrixModel().getRoot();
|
var root = this.getBrixModel().getRoot();
|
||||||
if (!root.isEmpty()) {
|
var cmodel = null;
|
||||||
var brixMap = root.get("mindmap");
|
var brixMap = root.get("mindmap");
|
||||||
cModel = collaborativeModelFactory.buildCollaborativeModelFor(brixMap);
|
if (brixMap != null) {
|
||||||
|
cmodel = factory.buildMindmap(brixMap);
|
||||||
|
} else {
|
||||||
|
cmodel = factory.createNewMindmap();
|
||||||
|
root.put("mindmap", cmodel.getBrixModel());
|
||||||
}
|
}
|
||||||
this.parent(cModel, collaborativeModelFactory);
|
this.parent(cmodel);
|
||||||
},
|
console.log("cmodel:" + cmodel.inspect());
|
||||||
|
|
||||||
addMindmap:function(model) {
|
|
||||||
var root = this.getBrixModel().getRoot();
|
|
||||||
root.put("mindmap", model);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
getBrixModel:function() {
|
getBrixModel:function() {
|
||||||
|
@ -48,7 +48,6 @@ mindplot.collaboration.framework.brix.model.Mindmap = new Class({
|
|||||||
var model = this._brixFramework.getBrixModel().create("Map");
|
var model = this._brixFramework.getBrixModel().create("Map");
|
||||||
var branches = this._brixFramework.getBrixModel().create("List");
|
var branches = this._brixFramework.getBrixModel().create("List");
|
||||||
model.put("branches", branches);
|
model.put("branches", branches);
|
||||||
this._brixFramework.addMindmap(model);
|
|
||||||
return model;
|
return model;
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -75,29 +74,17 @@ mindplot.collaboration.framework.brix.model.Mindmap = new Class({
|
|||||||
|
|
||||||
removeBranch : function(nodeModel) {
|
removeBranch : function(nodeModel) {
|
||||||
$assert(nodeModel, "nodeModel can not be null");
|
$assert(nodeModel, "nodeModel can not be null");
|
||||||
|
$assert(nodeModel.getType() != mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE, "central topic can not be removed");
|
||||||
|
|
||||||
var branches = this._brixModel.get("branches");
|
var branches = this._brixModel.get("branches");
|
||||||
var brixModel = nodeModel.getBrixModel();
|
var brixModel = nodeModel.getBrixModel();
|
||||||
branches.remove(brixModel);
|
branches.remove(brixModel);
|
||||||
},
|
},
|
||||||
|
|
||||||
connect : function(parent, child) {
|
|
||||||
// Remove from the branch ...
|
|
||||||
var branches = this._brixModel.get("branches");
|
|
||||||
var childIndex = null;
|
|
||||||
for (var i = 0; i < branches.size(); i++) {
|
|
||||||
if (branches.get(i) == child.getBrixModel()) {
|
|
||||||
childIndex = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (childIndex != null) {
|
|
||||||
branches.remove(childIndex);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
createNode : function(type, id) {
|
createNode : function(type, id) {
|
||||||
return mindplot.collaboration.framework.brix.model.NodeModel.create(this._brixFramework, this, type, id);
|
return mindplot.collaboration.framework.brix.model.NodeModel.create(this._brixFramework, this, type, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -28,7 +28,10 @@ mindplot.collaboration.framework.brix.model.NodeModel = new Class({
|
|||||||
this._addBrixListeners();
|
this._addBrixListeners();
|
||||||
},
|
},
|
||||||
|
|
||||||
_addBrixListeners:function() {
|
_addBrixListeners : function() {
|
||||||
|
|
||||||
|
// Nodes creation should be cached ...
|
||||||
|
if (!this._brixModel.__registered) {
|
||||||
// Register listener for properties changes ....
|
// Register listener for properties changes ....
|
||||||
this._brixModel.addListener("valueChanged", function(event) {
|
this._brixModel.addListener("valueChanged", function(event) {
|
||||||
var key = event.getProperty();
|
var key = event.getProperty();
|
||||||
@ -40,11 +43,25 @@ mindplot.collaboration.framework.brix.model.NodeModel = new Class({
|
|||||||
if (!$defined(actionDispatcher[funName])) {
|
if (!$defined(actionDispatcher[funName])) {
|
||||||
throw "No implementation for:" + funName;
|
throw "No implementation for:" + funName;
|
||||||
}
|
}
|
||||||
actionDispatcher[funName](this.getId(), value);
|
console.log("This action dispatcher:" + funName);
|
||||||
|
actionDispatcher[funName]([this.getId()], value);
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
|
||||||
var children = this._brixModel.get("children");
|
var children = this._brixModel.get("children");
|
||||||
children.addListener("valuesAdded", this._childAddedListener.bind(this));
|
children.addListener("valuesAdded", function(event) {
|
||||||
|
var brixNodeModel = event.getValues().get(0);
|
||||||
|
|
||||||
|
var cmodel = new mindplot.collaboration.framework.brix.model.NodeModel(this._brixFramework, brixNodeModel, this.getMindmap());
|
||||||
|
|
||||||
|
// @Todo: This is not ok...
|
||||||
|
var model = new mindplot.model.NodeModel(cmodel.getType(), designer.getMindmap(), this.getId());
|
||||||
|
cmodel.copyTo(model);
|
||||||
|
|
||||||
|
this._brixFramework.getActionDispatcher().addTopic(model, this.getId(), true);
|
||||||
|
}.bind(this));
|
||||||
|
|
||||||
|
this._brixModel.__registered = true;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
getChildren : function() {
|
getChildren : function() {
|
||||||
@ -58,18 +75,6 @@ mindplot.collaboration.framework.brix.model.NodeModel = new Class({
|
|||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
|
|
||||||
_childAddedListener:function(event) {
|
|
||||||
var newValue = event.getValues().get(0);
|
|
||||||
var cmodel = new mindplot.collaboration.framework.brix.model.NodeModel(this._brixFramework, newValue, 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);
|
|
||||||
},
|
|
||||||
|
|
||||||
getBrixModel:function() {
|
getBrixModel:function() {
|
||||||
return this._brixModel;
|
return this._brixModel;
|
||||||
@ -89,12 +94,15 @@ mindplot.collaboration.framework.brix.model.NodeModel = new Class({
|
|||||||
return this._brixModel.getKeys();
|
return this._brixModel.getKeys();
|
||||||
},
|
},
|
||||||
|
|
||||||
connectTo : function(parent) {
|
getParent : function() {
|
||||||
var mindmap = this.getMindmap();
|
return this._brixModel._parent;
|
||||||
mindmap.connect(parent, this);
|
},
|
||||||
|
|
||||||
// @Todo: This must be persited ?Ummm...
|
appendChild : function(node) {
|
||||||
this._parent = parent;
|
$assert(node && node.isNodeModel(), 'Only NodeModel can be appended to Mindmap object');
|
||||||
|
var children = this._brixModel.get("children");
|
||||||
|
children.add(node.getBrixModel());
|
||||||
|
node.getBrixModel()._parent = this;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -104,10 +112,9 @@ mindplot.collaboration.framework.brix.model.NodeModel.create = function(brixFram
|
|||||||
$assert(type, 'type can not be null');
|
$assert(type, 'type can not be null');
|
||||||
$assert($defined(id), 'id can not be null');
|
$assert($defined(id), 'id can not be null');
|
||||||
|
|
||||||
|
|
||||||
var brixModel = brixFramework.getBrixModel().create("Map");
|
var brixModel = brixFramework.getBrixModel().create("Map");
|
||||||
brixModel.put("type", type);
|
brixModel.put("type", type);
|
||||||
brixModel.put("id", this._id);
|
brixModel.put("id", id);
|
||||||
|
|
||||||
var children = brixFramework.getBrixModel().create("List");
|
var children = brixFramework.getBrixModel().create("List");
|
||||||
brixModel.put("children", children);
|
brixModel.put("children", children);
|
||||||
|
@ -69,7 +69,7 @@ mindplot.model.IMindmap = new Class({
|
|||||||
$assert(!child.getParent(), 'Child model seems to be already connected');
|
$assert(!child.getParent(), 'Child model seems to be already connected');
|
||||||
|
|
||||||
// Connect node...
|
// Connect node...
|
||||||
parent._appendChild(child);
|
parent.appendChild(child);
|
||||||
|
|
||||||
// Remove from the branch ...
|
// Remove from the branch ...
|
||||||
this.removeBranch(child);
|
this.removeBranch(child);
|
||||||
@ -80,7 +80,7 @@ mindplot.model.IMindmap = new Class({
|
|||||||
$assert(child, 'Child can not be null.');
|
$assert(child, 'Child can not be null.');
|
||||||
$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);
|
||||||
},
|
},
|
||||||
@ -111,40 +111,21 @@ mindplot.model.IMindmap = new Class({
|
|||||||
|
|
||||||
var branches = this.getBranches();
|
var branches = this.getBranches();
|
||||||
result = result + "version:" + this.getVersion();
|
result = result + "version:" + this.getVersion();
|
||||||
|
result = result + " , [";
|
||||||
|
|
||||||
for (var i = 0; i < branches.length; i++) {
|
for (var i = 0; i < branches.length; i++) {
|
||||||
var node = branches[i];
|
var node = branches[i];
|
||||||
if (i != 0) {
|
if (i != 0) {
|
||||||
result = result + ', ';
|
result = result + ',\n ';
|
||||||
}
|
}
|
||||||
result = result + this._toString(node);
|
result = result + "(" + i + ") =>" + node.inspect();
|
||||||
}
|
}
|
||||||
|
result = result + "]";
|
||||||
|
|
||||||
result = result + ' } ';
|
result = result + ' } ';
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
|
|
||||||
_toString : function(node) {
|
|
||||||
var result = node.inspect();
|
|
||||||
var children = node.getChildren();
|
|
||||||
|
|
||||||
for (var i = 0; i < children.length; i++) {
|
|
||||||
var child = children[i];
|
|
||||||
|
|
||||||
if (i == 0) {
|
|
||||||
result = result + '-> {';
|
|
||||||
} else {
|
|
||||||
result = result + ', ';
|
|
||||||
}
|
|
||||||
|
|
||||||
result = result + this._toString(child);
|
|
||||||
|
|
||||||
if (i == children.length - 1) {
|
|
||||||
result = result + '}';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
},
|
|
||||||
|
|
||||||
copyTo : function(target) {
|
copyTo : function(target) {
|
||||||
var source = this;
|
var source = this;
|
||||||
var version = source.getVersion();
|
var version = source.getVersion();
|
||||||
|
@ -190,6 +190,16 @@ mindplot.model.INodeModel = new Class({
|
|||||||
return this.getParent() != null;
|
return this.getParent() != null;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
appendChild : function(node) {
|
||||||
|
throw "Unsupported operation";
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
connectTo : function(parent) {
|
||||||
|
$assert(parent, "parent can not be null");
|
||||||
|
var mindmap = this.getMindmap();
|
||||||
|
mindmap.connect(parent, this);
|
||||||
|
},
|
||||||
|
|
||||||
getPropertiesKeys : function() {
|
getPropertiesKeys : function() {
|
||||||
throw "Unsupported operation";
|
throw "Unsupported operation";
|
||||||
@ -268,7 +278,10 @@ mindplot.model.INodeModel = new Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
inspect : function() {
|
inspect : function() {
|
||||||
return '(type:' + this.getType() + ' , id: ' + this.getId() + ')';
|
return '{ type: ' + this.getType() +
|
||||||
|
' , id: ' + this.getId() +
|
||||||
|
' , text: ' + this.getText() +
|
||||||
|
' }';
|
||||||
},
|
},
|
||||||
|
|
||||||
copyTo : function(target) {
|
copyTo : function(target) {
|
||||||
@ -276,7 +289,7 @@ mindplot.model.INodeModel = new Class({
|
|||||||
var keys = source.getPropertiesKeys();
|
var keys = source.getPropertiesKeys();
|
||||||
keys.forEach(function(key) {
|
keys.forEach(function(key) {
|
||||||
var value = source.getProperty(key);
|
var value = source.getProperty(key);
|
||||||
target.putProperty(value);
|
target.putProperty(key, value);
|
||||||
});
|
});
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
@ -67,6 +67,12 @@ mindplot.model.NodeModel = new Class({
|
|||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
addChildren : function(){
|
||||||
|
$assert(child && child.isNodeModel(), 'Only NodeModel can be appended to Mindmap object');
|
||||||
|
this._children.push(child);
|
||||||
|
child._parent = this;
|
||||||
|
},
|
||||||
|
|
||||||
createLink : function(url) {
|
createLink : function(url) {
|
||||||
$assert(url, 'Link URL must be specified.');
|
$assert(url, 'Link URL must be specified.');
|
||||||
return new mindplot.model.LinkModel(url, this);
|
return new mindplot.model.LinkModel(url, this);
|
||||||
@ -116,13 +122,13 @@ mindplot.model.NodeModel = new Class({
|
|||||||
this._icons.pop();
|
this._icons.pop();
|
||||||
},
|
},
|
||||||
|
|
||||||
_appendChild : function(child) {
|
appendChild : function(child) {
|
||||||
$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;
|
||||||
},
|
},
|
||||||
|
|
||||||
_removeChild : function(child) {
|
removeChild : function(child) {
|
||||||
$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.erase(child);
|
this._children.erase(child);
|
||||||
child._parent = null;
|
child._parent = null;
|
||||||
@ -217,12 +223,6 @@ mindplot.model.NodeModel = new Class({
|
|||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
connectTo : function(parent) {
|
|
||||||
var mindmap = this.getMindmap();
|
|
||||||
mindmap.connect(parent, this);
|
|
||||||
this._parent = parent;
|
|
||||||
},
|
|
||||||
|
|
||||||
deleteNode : function() {
|
deleteNode : function() {
|
||||||
var mindmap = this._mindmap;
|
var mindmap = this._mindmap;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user