- Fix Link node

- Finish local storage support
This commit is contained in:
Paulo Veiga 2011-11-30 00:32:24 -03:00
parent 334206ab19
commit bc87d0f311
5 changed files with 138 additions and 124 deletions

View File

@ -43,7 +43,7 @@ mindplot.LocalStorageManager = new Class({
// If I could not load it from a file, hard code one.
if (xml == null) {
xml = '<map name="6" version="pela"><topic central="true" text="General Status" id="1"/></map>';
throw "Map could not be loaded";
}
}

View File

@ -313,7 +313,7 @@ mindplot.Topic = new Class({
//Links
var links = model.getLinks();
for (var i = 0; i < links.length; i++) {
this._link = new mindplot.LinkIcon(links[i], this, designer);
this._link = new mindplot.LinkIcon(this,links[i]);
result.addIcon(this._link);
}

View File

@ -211,11 +211,9 @@ mindplot.XMLMindmapSerializer_Pela = new Class({
this._idsMap = new Hash();
// Start the loading process ...
var mindmap = new mindplot.model.Mindmap();
var version = rootElem.getAttribute("version");
mindmap.setVersion(version);
var mindmap = new mindplot.model.Mindmap(mapId, version);
var children = rootElem.childNodes;
for (var i = 0; i < children.length; i++) {
var child = children[i];

View File

@ -17,11 +17,13 @@
*/
mindplot.model.Mindmap = new Class({
Extends: mindplot.model.IMindmap,
initialize : function() {
initialize : function(id, version) {
$assert(id, "Id can not be null");
this._branches = [];
this._description = null;
this._version = null;
this._relationships = [];
this._version = $defined(version) ? version : 'pela';
this._id = id;
},
getDescription : function() {
@ -33,12 +35,12 @@ mindplot.model.Mindmap = new Class({
},
getId : function() {
return this._iconType;
return this._id;
},
setId : function(id) {
this._iconType = id;
this._id = id;
},
getVersion : function() {
@ -109,3 +111,10 @@ mindplot.model.Mindmap = new Class({
}
}
);
mindplot.model.Mindmap.buildEmpty = function(mapId) {
var result = new mindplot.model.Mindmap(mapId);
var node = result.createNode(mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE, 0);
result.addBranch(node);
return result;
};

View File

@ -25,7 +25,7 @@
$(document).fireEvent('loadcomplete', 'brix');
};
var mapId = '10'; // @todo: Must be changed ...
var mapId = 'mapId'; // @todo: Must be changed ...
var brixReady = false;
var mindReady = false;
var collab = 'standalone';
@ -58,7 +58,14 @@
// Load map from XML ...
var persitence = mindplot.PersitenceManager.getInstance();
var mindmap = persitence.load("map2");
var mindmap;
try {
mindmap = persitence.load(mapId);
} catch(e) {
// If the map could not be loaded, create a new empty map...
mindmap = mindplot.model.Mindmap.buildEmpty(mapId);
}
designer.loadMap(mindmap);
// If not problem has arisen, close the dialog ...