mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-29 17:04:59 +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();
|
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,55 +371,10 @@ 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) {
|
|
||||||
$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;
|
|
||||||
|
|
||||||
// Building node graph ...
|
// Building node graph ...
|
||||||
var branches = mindmapModel.getBranches();
|
var branches = mindmapModel.getBranches();
|
||||||
@ -446,12 +390,10 @@ mindplot.MindmapDesigner = new Class({
|
|||||||
for (var j = 0; j < relationships.length; j++) {
|
for (var j = 0; j < relationships.length; j++) {
|
||||||
this._relationshipModelToRelationship(relationships[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() {
|
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