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