mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-22 14:17:57 +01:00
Refactor loader.
This commit is contained in:
parent
6871f88cbb
commit
bd305fa14e
@ -359,17 +359,6 @@ mindplot.MindmapDesigner = new Class({
|
||||
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) {
|
||||
var persistantManager = mindplot.PersistanceManager;
|
||||
var mindmap = this._mindmap;
|
||||
@ -382,55 +371,10 @@ mindplot.MindmapDesigner = new Class({
|
||||
this._actionRunner.markAsChangeBase();
|
||||
},
|
||||
|
||||
loadFromCollaborativeModel: function(collaborationManager) {
|
||||
var mindmap = collaborationManager.buildWiseModel();
|
||||
this._loadMap(1, mindmap);
|
||||
|
||||
// Place the focus on the Central Topic
|
||||
var centralTopic = this.getModel().getCentralTopic();
|
||||
this.goToNode.attempt(centralTopic, this);
|
||||
},
|
||||
|
||||
loadFromXML : function(mapId, xmlContent) {
|
||||
$assert(xmlContent, 'mindmapId can not be null');
|
||||
$assert(xmlContent, 'xmlContent can not be null');
|
||||
|
||||
// Explorer Hack with local files ...
|
||||
var domDocument = core.Utils.createDocumentFromText(xmlContent);
|
||||
|
||||
var serializer = mindplot.XMLMindmapSerializerFactory.getSerializerFromDocument(domDocument);
|
||||
var mindmap = serializer.loadFromDom(domDocument);
|
||||
|
||||
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;
|
||||
loadMap : function(mindmapModel) {
|
||||
$assert(mindmapModel, "mindmapModel can not be null");
|
||||
this._mindmap = mindmapModel;
|
||||
|
||||
// Building node graph ...
|
||||
var branches = mindmapModel.getBranches();
|
||||
@ -446,12 +390,10 @@ mindplot.MindmapDesigner = new Class({
|
||||
for (var j = 0; j < relationships.length; j++) {
|
||||
this._relationshipModelToRelationship(relationships[j]);
|
||||
}
|
||||
}
|
||||
|
||||
this.getModel().getTopics().forEach(function(topic) {
|
||||
delete topic.getModel()._finalPosition;
|
||||
});
|
||||
|
||||
// Place the focus on the Central Topic
|
||||
var centralTopic = this.getModel().getCentralTopic();
|
||||
this.goToNode.attempt(centralTopic, this);
|
||||
},
|
||||
|
||||
getMindmap : function() {
|
||||
@ -572,8 +514,7 @@ mindplot.MindmapDesigner = new Class({
|
||||
},
|
||||
|
||||
_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;
|
||||
node.disconnect(this._workspace);
|
||||
|
||||
|
@ -44,14 +44,18 @@
|
||||
brixReady = resource == 'brix' ? true : brixReady;
|
||||
mindReady = resource == 'mind' ? true : mindReady;
|
||||
|
||||
if (mindReady) {
|
||||
designer = buildDesigner();
|
||||
}
|
||||
|
||||
// If both resources has been loaded, start loading the framework...
|
||||
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 (!window.hasUnexpectedErrors) {
|
||||
@ -59,14 +63,18 @@
|
||||
}
|
||||
});
|
||||
|
||||
} else if (local) {
|
||||
// Only for debug and local development...
|
||||
var desig = buildDesigner();
|
||||
|
||||
var mapId = '1';
|
||||
} else if (local && mindReady) {
|
||||
// Load map from XML ...
|
||||
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) {
|
||||
waitDialog.deactivate();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user