mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-26 07:44:56 +01:00
Refactor loader.
This commit is contained in:
parent
6871f88cbb
commit
bd305fa14e
@ -26,7 +26,7 @@ mindplot.MindmapDesigner = new Class({
|
|||||||
// Dispatcher manager ...
|
// Dispatcher manager ...
|
||||||
var commandContext = new mindplot.CommandContext(this);
|
var commandContext = new mindplot.CommandContext(this);
|
||||||
// this._actionDispatcher = new mindplot.BrixActionDispatcher(commandContext);
|
// this._actionDispatcher = new mindplot.BrixActionDispatcher(commandContext);
|
||||||
this._actionDispatcher = new mindplot.LocalActionDispatcher(commandContext);
|
this._actionDispatcher = new mindplot.LocalActionDispatcher(commandContext);
|
||||||
this._actionDispatcher.addEvent("modelUpdate", function(event) {
|
this._actionDispatcher.addEvent("modelUpdate", function(event) {
|
||||||
this.fireEvent("modelUpdate", event);
|
this.fireEvent("modelUpdate", event);
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
@ -359,17 +359,6 @@ mindplot.MindmapDesigner = new Class({
|
|||||||
return this._actionRunner.hasBeenChanged();
|
return this._actionRunner.hasBeenChanged();
|
||||||
},
|
},
|
||||||
|
|
||||||
autoSaveEnabled : function(value) {
|
|
||||||
if ($defined(value) && value) {
|
|
||||||
var autosave = function() {
|
|
||||||
if (this.needsSave()) {
|
|
||||||
this.save(null, false);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
autosave.bind(this).periodical(30000);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
save : function(onSavedHandler, saveHistory) {
|
save : function(onSavedHandler, saveHistory) {
|
||||||
var persistantManager = mindplot.PersistanceManager;
|
var persistantManager = mindplot.PersistanceManager;
|
||||||
var mindmap = this._mindmap;
|
var mindmap = this._mindmap;
|
||||||
@ -382,76 +371,29 @@ mindplot.MindmapDesigner = new Class({
|
|||||||
this._actionRunner.markAsChangeBase();
|
this._actionRunner.markAsChangeBase();
|
||||||
},
|
},
|
||||||
|
|
||||||
loadFromCollaborativeModel: function(collaborationManager) {
|
|
||||||
var mindmap = collaborationManager.buildWiseModel();
|
|
||||||
this._loadMap(1, mindmap);
|
|
||||||
|
|
||||||
// Place the focus on the Central Topic
|
loadMap : function(mindmapModel) {
|
||||||
var centralTopic = this.getModel().getCentralTopic();
|
$assert(mindmapModel, "mindmapModel can not be null");
|
||||||
this.goToNode.attempt(centralTopic, this);
|
this._mindmap = mindmapModel;
|
||||||
},
|
|
||||||
|
|
||||||
loadFromXML : function(mapId, xmlContent) {
|
// Building node graph ...
|
||||||
$assert(xmlContent, 'mindmapId can not be null');
|
var branches = mindmapModel.getBranches();
|
||||||
$assert(xmlContent, 'xmlContent can not be null');
|
for (var i = 0; i < branches.length; i++) {
|
||||||
|
// NodeModel -> NodeGraph ...
|
||||||
|
var nodeModel = branches[i];
|
||||||
|
var nodeGraph = this._nodeModelToNodeGraph(nodeModel, false);
|
||||||
|
|
||||||
// Explorer Hack with local files ...
|
// Update shrink render state...
|
||||||
var domDocument = core.Utils.createDocumentFromText(xmlContent);
|
nodeGraph.setBranchVisibility(true);
|
||||||
|
}
|
||||||
var serializer = mindplot.XMLMindmapSerializerFactory.getSerializerFromDocument(domDocument);
|
var relationships = mindmapModel.getRelationships();
|
||||||
var mindmap = serializer.loadFromDom(domDocument);
|
for (var j = 0; j < relationships.length; j++) {
|
||||||
|
this._relationshipModelToRelationship(relationships[j]);
|
||||||
this._loadMap(mapId, mindmap);
|
|
||||||
|
|
||||||
// Place the focus on the Central Topic
|
|
||||||
var centralTopic = this.getModel().getCentralTopic();
|
|
||||||
this.goToNode(centralTopic);
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
load : function(mapId) {
|
|
||||||
$assert(mapId, 'mapName can not be null');
|
|
||||||
|
|
||||||
// Build load function ...
|
|
||||||
var persistantManager = mindplot.PersistanceManager;
|
|
||||||
|
|
||||||
// Loading mindmap ...
|
|
||||||
var mindmap = persistantManager.load(mapId);
|
|
||||||
|
|
||||||
// Finally, load the map in the editor ...
|
|
||||||
this._loadMap(mapId, mindmap);
|
|
||||||
|
|
||||||
// Place the focus on the Central Topic
|
|
||||||
var centralTopic = this.getModel().getCentralTopic();
|
|
||||||
this.goToNode.attempt(centralTopic, this);
|
|
||||||
},
|
|
||||||
|
|
||||||
_loadMap : function(mapId, mindmapModel) {
|
|
||||||
var designer = this;
|
|
||||||
if (mindmapModel != null) {
|
|
||||||
mindmapModel.setId(mapId);
|
|
||||||
designer._mindmap = mindmapModel;
|
|
||||||
|
|
||||||
// Building node graph ...
|
|
||||||
var branches = mindmapModel.getBranches();
|
|
||||||
for (var i = 0; i < branches.length; i++) {
|
|
||||||
// NodeModel -> NodeGraph ...
|
|
||||||
var nodeModel = branches[i];
|
|
||||||
var nodeGraph = this._nodeModelToNodeGraph(nodeModel, false);
|
|
||||||
|
|
||||||
// Update shrink render state...
|
|
||||||
nodeGraph.setBranchVisibility(true);
|
|
||||||
}
|
|
||||||
var relationships = mindmapModel.getRelationships();
|
|
||||||
for (var j = 0; j < relationships.length; j++) {
|
|
||||||
this._relationshipModelToRelationship(relationships[j]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.getModel().getTopics().forEach(function(topic) {
|
// Place the focus on the Central Topic
|
||||||
delete topic.getModel()._finalPosition;
|
var centralTopic = this.getModel().getCentralTopic();
|
||||||
});
|
this.goToNode.attempt(centralTopic, this);
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
getMindmap : function() {
|
getMindmap : function() {
|
||||||
@ -572,8 +514,7 @@ mindplot.MindmapDesigner = new Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
_removeNode : function(node) {
|
_removeNode : function(node) {
|
||||||
if (node.getTopicType() != mindplot.model.NodeModel.CENTRAL_TOPIC_TYPE)
|
if (node.getTopicType() != mindplot.model.NodeModel.CENTRAL_TOPIC_TYPE) {
|
||||||
{
|
|
||||||
var parent = node._parent;
|
var parent = node._parent;
|
||||||
node.disconnect(this._workspace);
|
node.disconnect(this._workspace);
|
||||||
|
|
||||||
@ -607,7 +548,7 @@ mindplot.MindmapDesigner = new Class({
|
|||||||
var relIds = model.filterRelationIds(validateFunc, validateError);
|
var relIds = model.filterRelationIds(validateFunc, validateError);
|
||||||
|
|
||||||
if (topicsIds.length > 0 || relIds.length > 0) {
|
if (topicsIds.length > 0 || relIds.length > 0) {
|
||||||
this._actionDispatcher.deleteTopics(topicsIds,relIds);
|
this._actionDispatcher.deleteTopics(topicsIds, relIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
@ -44,14 +44,18 @@
|
|||||||
brixReady = resource == 'brix' ? true : brixReady;
|
brixReady = resource == 'brix' ? true : brixReady;
|
||||||
mindReady = resource == 'mind' ? true : mindReady;
|
mindReady = resource == 'mind' ? true : mindReady;
|
||||||
|
|
||||||
|
if (mindReady) {
|
||||||
|
designer = buildDesigner();
|
||||||
|
}
|
||||||
|
|
||||||
// If both resources has been loaded, start loading the framework...
|
// If both resources has been loaded, start loading the framework...
|
||||||
if (brixReady && mindReady) {
|
if (brixReady && mindReady) {
|
||||||
var designer = buildDesigner();
|
|
||||||
mindplot.collaboration.framework.brix.BrixFramework.init(function() {
|
|
||||||
var collaborationManager = mindplot.collaboration.CollaborationManager.getInstance();
|
|
||||||
if (collaborationManager.isCollaborativeFrameworkReady()) {
|
|
||||||
designer.loadFromCollaborativeModel(collaborationManager);
|
|
||||||
|
|
||||||
|
mindplot.collaboration.framework.brix.BrixFramework.init(function() {
|
||||||
|
var manager = mindplot.collaboration.CollaborationManager.getInstance();
|
||||||
|
if (manager.isCollaborativeFrameworkReady()) {
|
||||||
|
var mindmap = manager.buildWiseModel();
|
||||||
|
designer.loadMap(mindmap);
|
||||||
}
|
}
|
||||||
// If not problem has arisen, close the dialog ...
|
// If not problem has arisen, close the dialog ...
|
||||||
if (!window.hasUnexpectedErrors) {
|
if (!window.hasUnexpectedErrors) {
|
||||||
@ -59,14 +63,18 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
} else if (local) {
|
} else if (local && mindReady) {
|
||||||
// Only for debug and local development...
|
// Load map from XML ...
|
||||||
var desig = buildDesigner();
|
|
||||||
|
|
||||||
var mapId = '1';
|
|
||||||
var mapXml = '<map name="38298" version="pela"><topic central="true" text="test\nThis is working ?" id="1"/></map>';
|
var mapXml = '<map name="38298" version="pela"><topic central="true" text="test\nThis is working ?" id="1"/></map>';
|
||||||
desig.loadFromXML(mapId, mapXml);
|
var domDocument = core.Utils.createDocumentFromText(mapXml);
|
||||||
|
var serializer = mindplot.XMLMindmapSerializerFactory.getSerializerFromDocument(domDocument);
|
||||||
|
var mindmap = serializer.loadFromDom(domDocument);
|
||||||
|
mindmap.setId('1');
|
||||||
|
|
||||||
|
// Now, load the map ...
|
||||||
|
designer.loadMap(mindmap);
|
||||||
|
|
||||||
|
// If not problem has arisen, close the dialog ...
|
||||||
if (!window.hasUnexpectedErrors) {
|
if (!window.hasUnexpectedErrors) {
|
||||||
waitDialog.deactivate();
|
waitDialog.deactivate();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user