- Fix wrong state issue when the topic is restored.

This commit is contained in:
Paulo Gustavo Veiga 2012-09-27 20:18:12 -03:00
parent f6e5018272
commit 1e5e11a309
4 changed files with 12 additions and 13 deletions

View File

@ -116,7 +116,6 @@ mindplot.Designer = new Class({
},
addEvent:function (type, listener) {
if (type == mindplot.TopicEvent.EDIT || type == mindplot.TopicEvent.CLICK) {
var editor = mindplot.TopicEventDispatcher.getInstance();
@ -207,12 +206,8 @@ mindplot.Designer = new Class({
_buildNodeGraph:function (model, readOnly) {
var workspace = this._workspace;
// Create node graph ...
var topic = mindplot.NodeGraph.create(model, {readOnly:readOnly});
// Append it to the workspace ...
this.getModel().addTopic(topic);
// Add Topic events ...
@ -248,7 +243,7 @@ mindplot.Designer = new Class({
}
}
$assert(targetTopic, "Could not find a topic to connect");
topic.connectTo(targetTopic, workspace);
topic.connectTo(targetTopic, this._workspace);
}
topic.addEvent('ontblur', function () {
@ -602,6 +597,7 @@ mindplot.Designer = new Class({
});
var nodeGraph = this._buildNodeGraph(nodeModel, this.isReadOnly());
nodeGraph.setVisibility(false);
this._workspace.appendChild(nodeGraph);
for (var i = 0; i < children.length; i++) {

View File

@ -269,8 +269,8 @@ mindplot.CommandContext = new Class({
return mindmap.createNode(mindplot.NodeModel.MAIN_TOPIC_TYPE);
},
connect:function (childTopic, parentTopic, isVisible) {
childTopic.connectTo(parentTopic, this._designer._workspace, isVisible);
connect:function (childTopic, parentTopic) {
childTopic.connectTo(parentTopic, this._designer._workspace);
},
disconnect:function (topic) {

View File

@ -1023,7 +1023,7 @@ mindplot.Topic = new Class({
model.setOrder(value);
},
connectTo:function (targetTopic, workspace, isVisible) {
connectTo:function (targetTopic, workspace) {
$assert(!this._outgoingLine, 'Could not connect an already connected node');
$assert(targetTopic != this, 'Circular connection are not allowed');
$assert(targetTopic, 'Parent Graph can not be null');
@ -1040,9 +1040,8 @@ mindplot.Topic = new Class({
// Create a connection line ...
var outgoingLine = new mindplot.ConnectionLine(this, targetTopic);
if ($defined(isVisible)) {
outgoingLine.setVisibility(isVisible);
}
outgoingLine.setVisibility(this.isVisible());
this._outgoingLine = outgoingLine;
workspace.appendChild(outgoingLine);
@ -1074,7 +1073,6 @@ mindplot.Topic = new Class({
if (this.isInWorkspace()) {
mindplot.EventBus.instance.fireEvent(mindplot.EventBus.events.NodeConnectEvent, {parentNode:targetTopic.getModel(), childNode:this.getModel()});
}
},
appendChild:function (child) {

View File

@ -96,6 +96,11 @@ mindplot.commands.DeleteCommand = new Class({
commandContext.addRelationship(model);
}.bind(this));
// Finally display the topics ...
this._deletedTopicModels.each(function (topicModel) {
var topics = commandContext.findTopics(topicModel.getId());
topics[0].setBranchVisibility(true);
}, this);
// Focus on last recovered topic ..
if (this._deletedTopicModels.length > 0) {