mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-22 14:17:57 +01:00
- Fix Link node
- Finish local storage support
This commit is contained in:
parent
334206ab19
commit
bc87d0f311
@ -43,7 +43,7 @@ mindplot.LocalStorageManager = new Class({
|
|||||||
|
|
||||||
// If I could not load it from a file, hard code one.
|
// If I could not load it from a file, hard code one.
|
||||||
if (xml == null) {
|
if (xml == null) {
|
||||||
xml = '<map name="6" version="pela"><topic central="true" text="General Status" id="1"/></map>';
|
throw "Map could not be loaded";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -313,7 +313,7 @@ mindplot.Topic = new Class({
|
|||||||
//Links
|
//Links
|
||||||
var links = model.getLinks();
|
var links = model.getLinks();
|
||||||
for (var i = 0; i < links.length; i++) {
|
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);
|
result.addIcon(this._link);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -211,11 +211,9 @@ mindplot.XMLMindmapSerializer_Pela = new Class({
|
|||||||
|
|
||||||
this._idsMap = new Hash();
|
this._idsMap = new Hash();
|
||||||
// Start the loading process ...
|
// Start the loading process ...
|
||||||
var mindmap = new mindplot.model.Mindmap();
|
|
||||||
|
|
||||||
var version = rootElem.getAttribute("version");
|
var version = rootElem.getAttribute("version");
|
||||||
mindmap.setVersion(version);
|
|
||||||
|
|
||||||
|
var mindmap = new mindplot.model.Mindmap(mapId, version);
|
||||||
var children = rootElem.childNodes;
|
var children = rootElem.childNodes;
|
||||||
for (var i = 0; i < children.length; i++) {
|
for (var i = 0; i < children.length; i++) {
|
||||||
var child = children[i];
|
var child = children[i];
|
||||||
@ -342,7 +340,7 @@ mindplot.XMLMindmapSerializer_Pela = new Class({
|
|||||||
|
|
||||||
_deserializeIcon : function(domElem, topic) {
|
_deserializeIcon : function(domElem, topic) {
|
||||||
var icon = domElem.getAttribute("id");
|
var icon = domElem.getAttribute("id");
|
||||||
icon = icon.replace("images/","icons/legacy/");
|
icon = icon.replace("images/", "icons/legacy/");
|
||||||
return topic.createIcon(icon);
|
return topic.createIcon(icon);
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -352,13 +350,13 @@ mindplot.XMLMindmapSerializer_Pela = new Class({
|
|||||||
|
|
||||||
_deserializeNote : function(domElem, topic) {
|
_deserializeNote : function(domElem, topic) {
|
||||||
var value = domElem.getAttribute("text");
|
var value = domElem.getAttribute("text");
|
||||||
if(!$defined(value)){
|
if (!$defined(value)) {
|
||||||
var children = domElem.childNodes;
|
var children = domElem.childNodes;
|
||||||
for (var i = 0; i < children.length; i++) {
|
for (var i = 0; i < children.length; i++) {
|
||||||
var child = children[i];
|
var child = children[i];
|
||||||
if(child.nodeType == Node.CDATA_SECTION_NODE){
|
if (child.nodeType == Node.CDATA_SECTION_NODE) {
|
||||||
value = child.nodeValue;
|
value = child.nodeValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return topic.createNote(value);
|
return topic.createNote(value);
|
||||||
|
@ -1,111 +1,120 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright [2011] [wisemapping]
|
* Copyright [2011] [wisemapping]
|
||||||
*
|
*
|
||||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||||
* "powered by wisemapping" text requirement on every single page;
|
* "powered by wisemapping" text requirement on every single page;
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the license at
|
* You may obtain a copy of the license at
|
||||||
*
|
*
|
||||||
* http://www.wisemapping.org/license
|
* http://www.wisemapping.org/license
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
mindplot.model.Mindmap = new Class({
|
mindplot.model.Mindmap = new Class({
|
||||||
Extends: mindplot.model.IMindmap,
|
Extends: mindplot.model.IMindmap,
|
||||||
initialize : function() {
|
initialize : function(id, version) {
|
||||||
this._branches = [];
|
$assert(id, "Id can not be null");
|
||||||
this._description = null;
|
this._branches = [];
|
||||||
this._version = null;
|
this._description = null;
|
||||||
this._relationships = [];
|
this._relationships = [];
|
||||||
},
|
this._version = $defined(version) ? version : 'pela';
|
||||||
|
this._id = id;
|
||||||
getDescription : function() {
|
},
|
||||||
return this._description;
|
|
||||||
},
|
getDescription : function() {
|
||||||
|
return this._description;
|
||||||
setDescription : function(value) {
|
},
|
||||||
this._description = value;
|
|
||||||
},
|
setDescription : function(value) {
|
||||||
|
this._description = value;
|
||||||
getId : function() {
|
},
|
||||||
return this._iconType;
|
|
||||||
},
|
getId : function() {
|
||||||
|
return this._id;
|
||||||
|
},
|
||||||
setId : function(id) {
|
|
||||||
this._iconType = id;
|
|
||||||
},
|
setId : function(id) {
|
||||||
|
this._id = id;
|
||||||
getVersion : function() {
|
},
|
||||||
return this._version;
|
|
||||||
},
|
getVersion : function() {
|
||||||
|
return this._version;
|
||||||
setVersion : function(version) {
|
},
|
||||||
this._version = version;
|
|
||||||
},
|
setVersion : function(version) {
|
||||||
|
this._version = version;
|
||||||
addBranch : function(nodeModel) {
|
},
|
||||||
$assert(nodeModel && nodeModel.isNodeModel(), 'Add node must be invoked with model objects');
|
|
||||||
var branches = this.getBranches();
|
addBranch : function(nodeModel) {
|
||||||
if (branches.length == 0) {
|
$assert(nodeModel && nodeModel.isNodeModel(), 'Add node must be invoked with model objects');
|
||||||
$assert(nodeModel.getType() == mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE, "First element must be the central topic");
|
var branches = this.getBranches();
|
||||||
nodeModel.setPosition(0, 0);
|
if (branches.length == 0) {
|
||||||
} else {
|
$assert(nodeModel.getType() == mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE, "First element must be the central topic");
|
||||||
$assert(nodeModel.getType() != mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE, "Mindmaps only have one cental topic");
|
nodeModel.setPosition(0, 0);
|
||||||
}
|
} else {
|
||||||
|
$assert(nodeModel.getType() != mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE, "Mindmaps only have one cental topic");
|
||||||
this._branches.push(nodeModel);
|
}
|
||||||
},
|
|
||||||
|
this._branches.push(nodeModel);
|
||||||
removeBranch : function(nodeModel) {
|
},
|
||||||
$assert(nodeModel && nodeModel.isNodeModel(), 'Remove node must be invoked with model objects');
|
|
||||||
return this._branches.erase(nodeModel);
|
removeBranch : function(nodeModel) {
|
||||||
},
|
$assert(nodeModel && nodeModel.isNodeModel(), 'Remove node must be invoked with model objects');
|
||||||
|
return this._branches.erase(nodeModel);
|
||||||
getBranches : function() {
|
},
|
||||||
return this._branches;
|
|
||||||
},
|
getBranches : function() {
|
||||||
|
return this._branches;
|
||||||
getRelationships : function() {
|
},
|
||||||
return this._relationships;
|
|
||||||
},
|
getRelationships : function() {
|
||||||
|
return this._relationships;
|
||||||
hasAlreadyAdded : function(node) {
|
},
|
||||||
var result = false;
|
|
||||||
|
hasAlreadyAdded : function(node) {
|
||||||
// Check in not connected nodes.
|
var result = false;
|
||||||
var branches = this._branches;
|
|
||||||
for (var i = 0; i < branches.length; i++) {
|
// Check in not connected nodes.
|
||||||
result = branches[i]._isChildNode(node);
|
var branches = this._branches;
|
||||||
if (result) {
|
for (var i = 0; i < branches.length; i++) {
|
||||||
break;
|
result = branches[i]._isChildNode(node);
|
||||||
}
|
if (result) {
|
||||||
}
|
break;
|
||||||
},
|
}
|
||||||
|
}
|
||||||
createNode : function(type, id) {
|
},
|
||||||
$assert(type, "node type can not be null");
|
|
||||||
return new mindplot.model.NodeModel(type, this, id);
|
createNode : function(type, id) {
|
||||||
},
|
$assert(type, "node type can not be null");
|
||||||
|
return new mindplot.model.NodeModel(type, this, id);
|
||||||
createRelationship : function(fromNode, toNode) {
|
},
|
||||||
$assert(fromNode, 'from node cannot be null');
|
|
||||||
$assert(toNode, 'to node cannot be null');
|
createRelationship : function(fromNode, toNode) {
|
||||||
|
$assert(fromNode, 'from node cannot be null');
|
||||||
return new mindplot.model.RelationshipModel(fromNode, toNode);
|
$assert(toNode, 'to node cannot be null');
|
||||||
},
|
|
||||||
|
return new mindplot.model.RelationshipModel(fromNode, toNode);
|
||||||
addRelationship : function(relationship) {
|
},
|
||||||
this._relationships.push(relationship);
|
|
||||||
},
|
addRelationship : function(relationship) {
|
||||||
|
this._relationships.push(relationship);
|
||||||
removeRelationship : function(relationship) {
|
},
|
||||||
this._relationships.erase(relationship);
|
|
||||||
}
|
removeRelationship : function(relationship) {
|
||||||
}
|
this._relationships.erase(relationship);
|
||||||
);
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
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;
|
||||||
|
};
|
@ -25,7 +25,7 @@
|
|||||||
$(document).fireEvent('loadcomplete', 'brix');
|
$(document).fireEvent('loadcomplete', 'brix');
|
||||||
};
|
};
|
||||||
|
|
||||||
var mapId = '10'; // @todo: Must be changed ...
|
var mapId = 'mapId'; // @todo: Must be changed ...
|
||||||
var brixReady = false;
|
var brixReady = false;
|
||||||
var mindReady = false;
|
var mindReady = false;
|
||||||
var collab = 'standalone';
|
var collab = 'standalone';
|
||||||
@ -58,7 +58,14 @@
|
|||||||
|
|
||||||
// Load map from XML ...
|
// Load map from XML ...
|
||||||
var persitence = mindplot.PersitenceManager.getInstance();
|
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);
|
designer.loadMap(mindmap);
|
||||||
|
|
||||||
// If not problem has arisen, close the dialog ...
|
// If not problem has arisen, close the dialog ...
|
||||||
|
Loading…
Reference in New Issue
Block a user