Fix several errors removing a node ...
parent
f3a13dfe7a
commit
f3da916965
|
@ -122,7 +122,7 @@ mindplot.ConnectionLine = new Class({
|
|||
var targetPosition = targetTopic.getPosition();
|
||||
var offset = mindplot.Topic.CONNECTOR_WIDTH / 2;
|
||||
var targetTopicSize = targetTopic.getSize();
|
||||
var y;
|
||||
var y, x;
|
||||
if (targetTopic.getShapeType() == mindplot.model.TopicShape.LINE) {
|
||||
y = targetTopicSize.height;
|
||||
} else {
|
||||
|
@ -133,14 +133,17 @@ mindplot.ConnectionLine = new Class({
|
|||
var connector = targetTopic.getShrinkConnector();
|
||||
if ($defined(connector)) {
|
||||
if (Math.sign(targetPosition.x) > 0) {
|
||||
var x = targetTopicSize.width;
|
||||
x = targetTopicSize.width;
|
||||
connector.setPosition(x, y);
|
||||
}
|
||||
else {
|
||||
var x = -mindplot.Topic.CONNECTOR_WIDTH;
|
||||
x = -mindplot.Topic.CONNECTOR_WIDTH;
|
||||
}
|
||||
console.log("conector:" + x + ", " + y);
|
||||
connector.setPosition(x, y);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
setStroke:function (color, style, opacity) {
|
||||
|
|
|
@ -506,7 +506,6 @@ mindplot.Designer = new Class({
|
|||
$assert(mindmapModel, "mindmapModel can not be null");
|
||||
this._mindmap = mindmapModel;
|
||||
|
||||
// try {
|
||||
// Init layout manager ...
|
||||
var size = {width:25, height:25};
|
||||
var layoutManager = new mindplot.layout.LayoutManager(mindmapModel.getCentralTopic().getId(), size);
|
||||
|
@ -543,9 +542,6 @@ mindplot.Designer = new Class({
|
|||
mindplot.EventBus.instance.fireEvent(mindplot.EventBus.events.DoLayout);
|
||||
|
||||
this.fireEvent('loadSuccess');
|
||||
// } catch(e) {
|
||||
// this.fireEvent('loadError', e);
|
||||
// }
|
||||
},
|
||||
|
||||
getMindmap:function () {
|
||||
|
@ -591,7 +587,7 @@ mindplot.Designer = new Class({
|
|||
_relationshipModelToRelationship:function (model) {
|
||||
$assert(model, "Node model can not be null");
|
||||
|
||||
var result = this._buildRelationship(model);
|
||||
var result = this._buildRelationshipShape(model);
|
||||
|
||||
var sourceTopic = result.getSourceTopic();
|
||||
sourceTopic.addRelationship(result);
|
||||
|
@ -602,7 +598,6 @@ mindplot.Designer = new Class({
|
|||
result.setVisibility(sourceTopic.isVisible() && targetTopic.isVisible());
|
||||
|
||||
this._workspace.appendChild(result);
|
||||
result.redraw();
|
||||
return result;
|
||||
},
|
||||
|
||||
|
@ -623,7 +618,7 @@ mindplot.Designer = new Class({
|
|||
this.getModel().removeRelationship(relationship);
|
||||
},
|
||||
|
||||
_buildRelationship:function (model) {
|
||||
_buildRelationshipShape:function (model) {
|
||||
var dmodel = this.getModel();
|
||||
|
||||
var sourceTopicId = model.getFromNode();
|
||||
|
@ -674,16 +669,20 @@ mindplot.Designer = new Class({
|
|||
// If there are more than one node selected,
|
||||
$notify($msg('ENTITIES_COULD_NOT_BE_DELETED'));
|
||||
return;
|
||||
} else if (topics.length == 1 && topics[0].getTopicType() == mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) {
|
||||
$notify($msg('CENTRAL_TOPIC_CAN_NOT_BE_DELETED'));
|
||||
return;
|
||||
}
|
||||
|
||||
// Filter the lists ...
|
||||
var validateFunc = function (object) {
|
||||
return object.getType() == mindplot.Relationship.type || object.getTopicType() != mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE
|
||||
};
|
||||
var validateError = $msg('CENTRAL_TOPIC_CAN_NOT_BE_DELETED');
|
||||
var model = this.getModel();
|
||||
var topicIds = model.filterTopicsIds(validateFunc, validateError);
|
||||
var relIds = model.filterSelectedRelationships().map(function (rel) {
|
||||
// If the central topic has been selected, I must filter ir
|
||||
var topicIds = topics.filter(function (topic) {
|
||||
return topic.getTopicType() != mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE
|
||||
}).map(function (topic) {
|
||||
return topic.getId()
|
||||
});
|
||||
|
||||
|
||||
var relIds = topics.map(function (rel) {
|
||||
return rel.getId();
|
||||
});
|
||||
|
||||
|
|
|
@ -42,11 +42,11 @@ mindplot.DesignerKeyboard = new Class({
|
|||
var model = designer.getModel();
|
||||
var keyboardEvents = {
|
||||
'backspace':function (event) {
|
||||
designer.deleteSelectedEntities();
|
||||
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
designer.deleteSelectedEntities();
|
||||
|
||||
}.bind(this),
|
||||
|
||||
'space':function () {
|
||||
|
@ -73,129 +73,123 @@ mindplot.DesignerKeyboard = new Class({
|
|||
}.bind(this),
|
||||
|
||||
'meta+enter':function (event) {
|
||||
designer.createChildForSelectedNode();
|
||||
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
designer.createChildForSelectedNode();
|
||||
|
||||
}.bind(this),
|
||||
|
||||
'ctrl+z':function () {
|
||||
designer.undo();
|
||||
|
||||
event.preventDefault(event);
|
||||
event.stopPropagation();
|
||||
|
||||
designer.undo();
|
||||
}.bind(this),
|
||||
|
||||
'meta+z':function (event) {
|
||||
designer.undo();
|
||||
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
designer.undo();
|
||||
|
||||
}.bind(this),
|
||||
|
||||
'ctrl+z+shift':function (event) {
|
||||
designer.redo();
|
||||
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
designer.redo();
|
||||
}.bind(this),
|
||||
|
||||
'meta+z+shift':function (event) {
|
||||
designer.redo();
|
||||
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
designer.redo();
|
||||
}.bind(this),
|
||||
|
||||
'ctrl+y':function (event) {
|
||||
designer.redo();
|
||||
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
designer.redo();
|
||||
|
||||
}.bind(this),
|
||||
|
||||
'meta+y':function (event) {
|
||||
designer.redo();
|
||||
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
designer.redo();
|
||||
|
||||
}.bind(this),
|
||||
|
||||
'ctrl+a':function (event) {
|
||||
designer.selectAll();
|
||||
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
designer.selectAll();
|
||||
},
|
||||
|
||||
'ctrl+b':function (event) {
|
||||
designer.changeFontWeight();
|
||||
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
designer.changeFontWeight();
|
||||
},
|
||||
|
||||
'meta+b':function (event) {
|
||||
designer.changeFontWeight();
|
||||
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
designer.changeFontWeight();
|
||||
},
|
||||
|
||||
'ctrl+s':function (event) {
|
||||
event.preventDefault();
|
||||
$('save').fireEvent('click');
|
||||
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
$('save').fireEvent('click');
|
||||
},
|
||||
|
||||
'meta+s':function (event) {
|
||||
event.preventDefault();
|
||||
$('save').fireEvent('click');
|
||||
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
$('save').fireEvent('click');
|
||||
},
|
||||
|
||||
'ctrl+i':function (event) {
|
||||
designer.changeFontStyle();
|
||||
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
designer.changeFontStyle();
|
||||
},
|
||||
|
||||
'meta+i':function (event) {
|
||||
designer.changeFontStyle();
|
||||
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
designer.changeFontStyle();
|
||||
},
|
||||
|
||||
'meta+shift+a':function (event) {
|
||||
designer.deselectAll();
|
||||
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
designer.deselectAll();
|
||||
},
|
||||
|
||||
'ctrl+shift+a':function (event) {
|
||||
designer.deselectAll();
|
||||
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
designer.deselectAll();
|
||||
},
|
||||
|
||||
'meta+a':function (event) {
|
||||
designer.selectAll();
|
||||
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
designer.selectAll();
|
||||
},
|
||||
|
||||
'right':function () {
|
||||
|
|
|
@ -17,6 +17,12 @@
|
|||
*/
|
||||
mindplot.Relationship = new Class({
|
||||
Extends:mindplot.ConnectionLine,
|
||||
Static:{
|
||||
getStrokeColor:function () {
|
||||
return '#9b74e6';
|
||||
},
|
||||
type: "Relationship"
|
||||
},
|
||||
initialize:function (sourceNode, targetNode, model) {
|
||||
$assert(sourceNode, "sourceNode can not be null");
|
||||
$assert(targetNode, "targetNode can not be null");
|
||||
|
@ -161,6 +167,8 @@ mindplot.Relationship = new Class({
|
|||
|
||||
this.parent(workspace);
|
||||
this._positionArrows();
|
||||
this.redraw();
|
||||
|
||||
},
|
||||
|
||||
_initializeControlPointController:function () {
|
||||
|
@ -310,9 +318,3 @@ mindplot.Relationship = new Class({
|
|||
return this._model.getId();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
mindplot.Relationship.type = "Relationship";
|
||||
mindplot.Relationship.getStrokeColor = function () {
|
||||
return '#9b74e6';
|
||||
};
|
||||
|
|
|
@ -30,10 +30,14 @@ mindplot.commands.DeleteCommand = new Class({
|
|||
},
|
||||
|
||||
execute:function (commandContext) {
|
||||
var topics = commandContext.findTopics(this._topicIds);
|
||||
|
||||
// If a parent has been selected for deletion, the children must be excluded from the delete ...
|
||||
var topics = this._filterChildren(this._topicIds, commandContext);
|
||||
|
||||
|
||||
if (topics.length > 0) {
|
||||
topics.forEach(
|
||||
function (topic, index) {
|
||||
function (topic) {
|
||||
var model = topic.getModel();
|
||||
|
||||
// Delete relationships
|
||||
|
@ -45,9 +49,8 @@ mindplot.commands.DeleteCommand = new Class({
|
|||
commandContext.deleteRelationship(relationship);
|
||||
}
|
||||
|
||||
// Delete the node itself ...
|
||||
this._deletedTopicModels.push(model);
|
||||
|
||||
// Is connected?.
|
||||
var outTopic = topic.getOutgoingConnectedTopic();
|
||||
var outTopicId = null;
|
||||
if (outTopic != null) {
|
||||
|
@ -72,9 +75,7 @@ mindplot.commands.DeleteCommand = new Class({
|
|||
|
||||
undoExecute:function (commandContext) {
|
||||
|
||||
var topics = commandContext.findTopics(this._topicIds);
|
||||
var parent = commandContext.findTopics(this._parentTopicIds);
|
||||
|
||||
this._deletedTopicModels.forEach(
|
||||
function (model, index) {
|
||||
var topic = commandContext.createTopic(model);
|
||||
|
@ -95,5 +96,28 @@ mindplot.commands.DeleteCommand = new Class({
|
|||
this._deletedTopicModels = [];
|
||||
this._parentTopicIds = [];
|
||||
this._deletedRelModel = [];
|
||||
},
|
||||
|
||||
_filterChildren:function (topicIds, commandContext) {
|
||||
var topics = commandContext.findTopics(topicIds);
|
||||
|
||||
var result = [];
|
||||
topics.forEach(function (topic) {
|
||||
var parent = topic.getParent();
|
||||
var found = false;
|
||||
while (parent != null && !found) {
|
||||
found = topicIds.contains(parent.getId());
|
||||
if (found) {
|
||||
break;
|
||||
}
|
||||
parent = parent.getParent();
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
result.push(topic);
|
||||
}
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
});
|
|
@ -198,7 +198,7 @@ mindplot.layout.BalancedSorter = new Class({
|
|||
var factor = node.getOrder() % 2 == 0 ? 2 : 1;
|
||||
for (var i = 0; i < children.length; i++) {
|
||||
var order = i == 0 && factor == 1 ? 1 : (factor * i);
|
||||
$assert(children[i].getOrder() == order, "Missing order elements. Missing order: " + (i * factor));
|
||||
$assert(children[i].getOrder() == order, "Missing order elements. Missing order: " + (i * factor) + ". Parent:" + node.getId() + ",Node:" + children[i].getId());
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ mindplot.layout.OriginalLayout = new Class({
|
|||
this._treeSet.disconnect(nodeId);
|
||||
|
||||
// Fire a basic validation ...
|
||||
sorter.verify(this._treeSet, node);
|
||||
parent.getSorter().verify(this._treeSet, parent);
|
||||
},
|
||||
|
||||
layout:function () {
|
||||
|
@ -88,8 +88,12 @@ mindplot.layout.OriginalLayout = new Class({
|
|||
var nodeId = node.getId();
|
||||
var children = this._treeSet.getChildren(node);
|
||||
var parent = this._treeSet.getParent(node);
|
||||
var childrenOrderMoved = children.some(function(child) { return child.hasOrderChanged(); });
|
||||
var childrenSizeChanged = children.some(function(child) { return child.hasSizeChanged(); });
|
||||
var childrenOrderMoved = children.some(function (child) {
|
||||
return child.hasOrderChanged();
|
||||
});
|
||||
var childrenSizeChanged = children.some(function (child) {
|
||||
return child.hasSizeChanged();
|
||||
});
|
||||
|
||||
// If ether any of the nodes has been changed of position or the height of the children is not
|
||||
// the same, children nodes must be repositioned ....
|
||||
|
|
|
@ -108,6 +108,17 @@ mindplot.model.Mindmap = new Class({
|
|||
|
||||
deleteRelationship:function (relationship) {
|
||||
this._relationships.erase(relationship);
|
||||
},
|
||||
|
||||
findNodeById:function (id) {
|
||||
var result;
|
||||
for (var i = 0; i < this._branches; i++) {
|
||||
var branch = this._branches[i];
|
||||
result = branch.findNodeById(id)
|
||||
if (result) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
|
|
@ -184,9 +184,26 @@ mindplot.model.NodeModel = new Class({
|
|||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
},
|
||||
|
||||
findNodeById : function(id) {
|
||||
var result = null;
|
||||
if (this.getId() == id) {
|
||||
return this;
|
||||
} else {
|
||||
var children = this.getChildren();
|
||||
for (var i = 0; i < children.length; i++) {
|
||||
var child = children[i];
|
||||
result = child.findNodeById(id);
|
||||
if (result) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
},
|
||||
|
||||
|
||||
inspect : function() {
|
||||
return '(type:' + this.getType() + ' , id: ' + this.getId() + ')';
|
||||
}
|
||||
|
|
|
@ -410,6 +410,11 @@ mindplot.persistence.XMLSerializer_Pela = new Class({
|
|||
if (srcId == destId) {
|
||||
return null;
|
||||
}
|
||||
// Is the connections points valid ?. If it's not, do not load the relationship ...
|
||||
if (mindmap.findNodeById(srcId) == null || mindmap.findNodeById(destId)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var model = mindmap.createRelationship(srcId, destId);
|
||||
model.setLineType(lineType);
|
||||
if ($defined(srcCtrlPoint) && srcCtrlPoint != "") {
|
||||
|
|
Loading…
Reference in New Issue