mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-22 06:07:57 +01:00
Move persistence clases to persistence package.
This commit is contained in:
parent
e401d73cb6
commit
9e44804314
@ -68,6 +68,7 @@
|
||||
<filelist dir="${basedir}/src/main/javascript/" files="DesignerKeyboard.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/" files="NodeGraph.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/" files="Topic.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/" files="TextTopic.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/" files="CentralTopic.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/" files="MainTopic.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/" files="DragTopic.js"/>
|
||||
@ -81,18 +82,18 @@
|
||||
<!--<filelist dir="${basedir}/src/main/javascript/" files="RichTextEditor.js"/>-->
|
||||
<filelist dir="${basedir}/src/main/javascript/" files="TextEditorFactory.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/" files="util/Shape.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/" files="ModelCodeName.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/" files="persistence/ModelCodeName.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/"
|
||||
files="XMLMindmapSerializer_Pela.js"/>
|
||||
files="persistence/XMLSerializer_Pela.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/"
|
||||
files="XMLMindmapSerializer_Tango.js"/>
|
||||
files="persistence/XMLSerializer_Tango.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/"
|
||||
files="Pela2TangoMigrator.js"/>
|
||||
files="persistence/Pela2TangoMigrator.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/"
|
||||
files="XMLMindmapSerializer_Beta.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/" files="Beta2PelaMigrator.js"/>
|
||||
files="persistence/XMLSerializer_Beta.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/" files="persistence/Beta2PelaMigrator.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/"
|
||||
files="XMLMindmapSerializerFactory.js"/>
|
||||
files="persistence/XMLSerializerFactory.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/" files="PersistenceManager.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/" files="RestPersistenceManager.js"/>
|
||||
<filelist dir="${basedir}/src/main/javascript/" files="LocalStorageManager.js"/>
|
||||
@ -245,23 +246,7 @@
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<!-- <plugin>
|
||||
<groupId>com.google.jstestdriver</groupId>
|
||||
<artifactId>maven-jstestdriver-plugin</artifactId>
|
||||
<version>1.2.2-SNAPSHOT</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>run-tests</id>
|
||||
<phase>test</phase>
|
||||
<goals>
|
||||
<goal>test</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<config>${basedir}/src/test/jsTestDriver.conf</config>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin> -->
|
||||
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
@ -34,7 +34,7 @@ mindplot.BrixActionDispatcher = new Class({
|
||||
// Set position ...
|
||||
node.setPosition(position);
|
||||
} else {
|
||||
$assert("Illegal commnad state exception.");
|
||||
$assert("Illegal commnand state exception.");
|
||||
}
|
||||
// Finally, connect node ...
|
||||
if ($defined(this._parentId)) {
|
@ -422,7 +422,7 @@ mindplot.Designer = new Class({
|
||||
$assert(mindmapModel, "mindmapModel can not be null");
|
||||
this._mindmap = mindmapModel;
|
||||
|
||||
try {
|
||||
// try {
|
||||
// Init layout manager ...
|
||||
var size = {width:25,height:25};
|
||||
var layoutManager = new mindplot.layout.LayoutManager(mindmapModel.getCentralTopic().getId(), size);
|
||||
@ -460,9 +460,9 @@ mindplot.Designer = new Class({
|
||||
mindplot.EventBus.instance.fireEvent(mindplot.EventBus.events.DoLayout);
|
||||
|
||||
this.fireEvent('loadSuccess');
|
||||
} catch(e) {
|
||||
this.fireEvent('loadError',e);
|
||||
}
|
||||
// } catch(e) {
|
||||
// this.fireEvent('loadError',e);
|
||||
// }
|
||||
},
|
||||
|
||||
getMindmap : function() {
|
||||
|
136
mindplot/src/main/javascript/MediaTopic.js
Normal file
136
mindplot/src/main/javascript/MediaTopic.js
Normal file
@ -0,0 +1,136 @@
|
||||
/*
|
||||
* Copyright [2011] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
mindplot.MediaTopic = new Class({
|
||||
Extends:mindplot.Topic,
|
||||
initialize : function(model, options) {
|
||||
this.parent(model, options);
|
||||
},
|
||||
|
||||
getInnerShape : function() {
|
||||
if (!$defined(this._innerShape)) {
|
||||
// Create inner box.
|
||||
var model = this.getModel();
|
||||
|
||||
this._innerShape = new web2d.Image();
|
||||
this._innerShape.setHref(model.getImageUrl());
|
||||
this._innerShape.setPosition(0, 0);
|
||||
}
|
||||
return this._innerShape;
|
||||
},
|
||||
|
||||
getOuterShape : function() {
|
||||
if (!$defined(this._outerShape)) {
|
||||
var rect = new web2d.Rect(0, mindplot.Topic.OUTER_SHAPE_ATTRIBUTES);
|
||||
rect.setPosition(-2, -3);
|
||||
rect.setOpacity(0);
|
||||
this._outerShape = rect;
|
||||
}
|
||||
|
||||
return this._outerShape;
|
||||
},
|
||||
|
||||
|
||||
_buildShape : function() {
|
||||
var groupAttributes = {width: 100, height:100,coordSizeWidth:100,coordSizeHeight:100};
|
||||
var group = new web2d.Group(groupAttributes);
|
||||
this._set2DElement(group);
|
||||
|
||||
// Shape must be build based on the model width ...
|
||||
var outerShape = this.getOuterShape();
|
||||
var innerShape = this.getInnerShape();
|
||||
var shrinkConnector = this.getShrinkConnector();
|
||||
|
||||
// Add to the group ...
|
||||
group.appendChild(outerShape);
|
||||
group.appendChild(innerShape);
|
||||
|
||||
// Update figure size ...
|
||||
// var model = this.getModel();
|
||||
// if (model.getLinks().length != 0 || model.getNotes().length != 0 || model.getIcons().length != 0) {
|
||||
// this.getOrBuildIconGroup();
|
||||
// }
|
||||
|
||||
if (this.getType() != mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) {
|
||||
shrinkConnector.addToWorkspace(group);
|
||||
}
|
||||
|
||||
// Register listeners ...
|
||||
this._registerDefaultListenersToElement(group, this);
|
||||
|
||||
|
||||
},
|
||||
|
||||
workoutOutgoingConnectionPoint : function(targetPosition) {
|
||||
$assert(targetPosition, 'targetPoint can not be null');
|
||||
var pos = this.getPosition();
|
||||
|
||||
var result;
|
||||
result = new core.Point();
|
||||
var groupPosition = this._elem2d.getPosition();
|
||||
var innerShareSize = this.getInnerShape().getSize();
|
||||
var isAtRight = mindplot.util.Shape.isAtRight(targetPosition, pos);
|
||||
|
||||
result = mindplot.util.Shape.calculateRectConnectionPoint(pos, this.getSize(), isAtRight, true);
|
||||
return result;
|
||||
},
|
||||
|
||||
createDragNode : function(layoutManager) {
|
||||
var result = this.parent(layoutManager);
|
||||
|
||||
// Is the node already connected ?
|
||||
var targetTopic = this.getOutgoingConnectedTopic();
|
||||
if ($defined(targetTopic)) {
|
||||
result.connectTo(targetTopic);
|
||||
result.setVisibility(false);
|
||||
}
|
||||
return result;
|
||||
},
|
||||
|
||||
_adjustShapes : function() {
|
||||
if (this._isInWorkspace) {
|
||||
|
||||
var size = this.getModel().getSize();
|
||||
this.setSize(size, true);
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
_updatePositionOnChangeSize : function(oldSize, newSize) {
|
||||
|
||||
var xOffset = Math.round((newSize.width - oldSize.width) / 2);
|
||||
var pos = this.getPosition();
|
||||
if ($defined(pos)) {
|
||||
if (pos.x > 0) {
|
||||
pos.x = pos.x + xOffset;
|
||||
} else {
|
||||
pos.x = pos.x - xOffset;
|
||||
}
|
||||
this.setPosition(pos);
|
||||
}
|
||||
},
|
||||
|
||||
updateTopicShape : function() {
|
||||
// Todo: verify ...
|
||||
},
|
||||
|
||||
closeEditors : function() {
|
||||
//@Todo:
|
||||
}
|
||||
});
|
@ -28,7 +28,7 @@ mindplot.PersistenceManager = new Class({
|
||||
var mapId = mindmap.getId();
|
||||
$assert(mapId, "mapId can not be null");
|
||||
|
||||
var serializer = mindplot.XMLMindmapSerializerFactory.getSerializerFromMindmap(mindmap);
|
||||
var serializer = mindplot.persistence.XMLSerializerFactory.getSerializerFromMindmap(mindmap);
|
||||
var domMap = serializer.toXML(mindmap);
|
||||
var mapXml = core.Utils.innerXML(domMap);
|
||||
|
||||
@ -59,7 +59,7 @@ mindplot.PersistenceManager = new Class({
|
||||
$assert(mapId, "mapId can not be null");
|
||||
$assert(mapDom, "mapDom can not be null");
|
||||
|
||||
var serializer = mindplot.XMLMindmapSerializerFactory.getSerializerFromDocument(mapDom);
|
||||
var serializer = mindplot.persistence.XMLSerializerFactory.getSerializerFromDocument(mapDom);
|
||||
return serializer.loadFromDom(mapDom, mapId);
|
||||
},
|
||||
|
||||
|
@ -1,158 +0,0 @@
|
||||
/*
|
||||
* Copyright [2011] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
mindplot.RichTextEditor = mindplot.TextEditor.extend({
|
||||
initialize:function(screenManager,actionRunner){
|
||||
this.parent(screenManager, actionRunner);
|
||||
},
|
||||
_buildEditor:function(){
|
||||
//Create editor ui
|
||||
this._size = {width:440, height:200};
|
||||
this._myOverlay = new Element('div').setStyles({position:"absolute", display: "none", zIndex: "8", top: "50%", left:"50%", marginLeft:"-200px", marginTop:"-90px", width:"400px", height:"180px"});
|
||||
var inputContainer = new Element('div').setStyles({border:"none", overflow:"auto"}).inject(this._myOverlay);
|
||||
this.inputText = new Element('textarea').setProperties({tabindex:'-1', id:"inputText2", value:""}).setStyles({width:"398px", height:"175px", border:"none", background:"transparent"}).inject(inputContainer);
|
||||
this._myOverlay.inject(this._screenManager.getContainer());
|
||||
this._editorNode = new web2d.Rect(0.3,mindplot.Topic.OUTER_SHAPE_ATTRIBUTES);
|
||||
this._editorNode.setSize(50,20);
|
||||
this._editorNode.setVisibility(false);
|
||||
this._designer.getWorkSpace().appendChild(this._editorNode);
|
||||
this._addListeners();
|
||||
},
|
||||
_registerListeners:function(){
|
||||
|
||||
$(this._myOverlay).addEvent('click', function(event){
|
||||
event.preventDefault();
|
||||
event.stop();
|
||||
}.bindWithEvent(this));
|
||||
$(this._myOverlay).addEvent('dblclick', function(event){
|
||||
event.preventDefault();
|
||||
event.stop();
|
||||
}.bindWithEvent(this));
|
||||
},
|
||||
getFocusEvent:function(node){
|
||||
var screenSize = this._designer.getWorkSpace().getSize();
|
||||
var coordOrigin = this._designer.getWorkSpace()._workspace.getCoordOrigin();
|
||||
var middlePosition = {x:parseInt(screenSize.width)/2 + parseInt(coordOrigin.x), y:parseInt(screenSize.height)/2 + parseInt(coordOrigin.y)};
|
||||
|
||||
this._designer.getWorkSpace().enableWorkspaceEvents(false);
|
||||
var position = node.getPosition().clone();
|
||||
var size = node.getSize();
|
||||
this._editorNode.setPosition(position.x-(size.width/2), position.y-(size.height/2));
|
||||
position = this._editorNode.getPosition();
|
||||
this._editorNode.setSize(size.width, size.height);
|
||||
this._editorNode.moveToFront();
|
||||
this._editorNode.setVisibility(true);
|
||||
var scale = web2d.peer.utils.TransformUtil.workoutScale(node.getOuterShape());
|
||||
// scale.width=1;
|
||||
// scale.height = 1;
|
||||
var steps = 10;
|
||||
this._delta = {width:((this._size.width/scale.width)-size.width)/steps, height:((this._size.height/scale.height)-size.height)/steps};
|
||||
var finx = (middlePosition.x-(((this._size.width)/2)/scale.width));
|
||||
var finy = (middlePosition.y-((this._size.height/2)/scale.height));
|
||||
var step = 10;
|
||||
var d = {x:(position.x - finx)/step, y:(position.y - finy)/step};
|
||||
var _animEffect = null;
|
||||
var effect = function(){
|
||||
if(step>=0){
|
||||
var xStep= (position.x -finx)/step;
|
||||
var yStep= (position.y -finy)/step;
|
||||
var pos = {x:position.x - d.x*(10-step), y: position.y -d.y *(10-step)};
|
||||
|
||||
var size = this._editorNode.getSize();
|
||||
this._editorNode.setSize(size.width + this._delta.width, size.height + this._delta.height);
|
||||
this._editorNode.setPosition(pos.x, pos.y);
|
||||
if(step>0)
|
||||
this._editorNode.setOpacity(1-step/10);
|
||||
step--;
|
||||
}else{
|
||||
$clear(_animEffect);
|
||||
this._editorNode.setSize((this._size.width/scale.width), (this._size.height/scale.height));
|
||||
this.init(node);
|
||||
}
|
||||
}.bind(this);
|
||||
_animEffect = effect.periodical(10);
|
||||
$(this.inputText).value = $defined(this.initialText)&& this.initialText!=""? this.initialText: node.getText();
|
||||
this._editor = new nicEditor({iconsPath: '../images/nicEditorIcons.gif', buttonList : ['bold','italic','underline','removeformat','forecolor', 'fontSize', 'fontFamily', 'xhtml']}).panelInstance("inputText2");
|
||||
},
|
||||
init:function(node){
|
||||
this._currentNode = node;
|
||||
this._applyChanges = false;
|
||||
$(this._myOverlay.setStyle('display','block'));
|
||||
inst = this._editor.instanceById("inputText2");
|
||||
inst.elm.focus();
|
||||
|
||||
|
||||
|
||||
//becarefull this._editor is not mootools!!
|
||||
this._editor.addEvent('blur',function(event){
|
||||
this._myOverlay.setStyle('display','none');
|
||||
var text = this._text;
|
||||
this._text = this._editor.instanceById("inputText2").getContent();
|
||||
if(text!=this._text){
|
||||
this._applyChanges = true;
|
||||
}
|
||||
console.log('bye');
|
||||
this.lostFocusListener();
|
||||
this._editor.removeInstance("inputText2");
|
||||
this._editor.destruct();
|
||||
this._editor = null;
|
||||
|
||||
}.bind(this));
|
||||
|
||||
this._editor.fireEvent();
|
||||
$(this.inputText).focus();
|
||||
},
|
||||
getText:function(){
|
||||
return this._text;
|
||||
},
|
||||
lostFocusListener:function(){
|
||||
this._hideNode();
|
||||
if (this._currentNode != null)
|
||||
{
|
||||
if(this._applyChanges)
|
||||
{
|
||||
this._updateModel();
|
||||
}
|
||||
this._applyChanges=true;
|
||||
this._currentNode = null;
|
||||
}
|
||||
},
|
||||
_hideNode:function(){
|
||||
var _animEffect = null;
|
||||
var step = 10;
|
||||
var position = this._editorNode.getPosition();
|
||||
var finx = this._currentNode.getPosition().x - this._currentNode.getSize().width/2;
|
||||
var finy = this._currentNode.getPosition().y - this._currentNode.getSize().height/2;
|
||||
var d = {x:(position.x - finx)/step, y:(position.y - finy)/step};
|
||||
var effect = function(){
|
||||
if(step>=0){
|
||||
var pos = {x:position.x - d.x*(10-step), y: position.y - d.y*(10-step)};
|
||||
|
||||
var size = this._editorNode.getSize();
|
||||
this._editorNode.setSize(size.width - this._delta.width, size.height - this._delta.height);
|
||||
this._editorNode.setPosition(pos.x, pos.y);
|
||||
this._editorNode.setOpacity(step/10);
|
||||
step--;
|
||||
}else{
|
||||
$clear(_animEffect);
|
||||
this._designer.getWorkSpace().enableWorkspaceEvents(true);
|
||||
this._editorNode.setVisibility(false); }
|
||||
}.bind(this);
|
||||
_animEffect = effect.periodical(10);
|
||||
}
|
||||
});
|
@ -19,7 +19,7 @@
|
||||
mindplot.ShirinkConnector = new Class({
|
||||
initialize: function(topic) {
|
||||
|
||||
var ellipse = new web2d.Elipse(mindplot.Topic.prototype.INNER_RECT_ATTRIBUTES);
|
||||
var ellipse = new web2d.Elipse(mindplot.TextTopic.prototype.INNER_RECT_ATTRIBUTES);
|
||||
this._ellipse = ellipse;
|
||||
ellipse.setFill('rgb(62,118,179)');
|
||||
|
||||
|
590
mindplot/src/main/javascript/TextTopic.js
Normal file
590
mindplot/src/main/javascript/TextTopic.js
Normal file
@ -0,0 +1,590 @@
|
||||
/*
|
||||
* Copyright [2011] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
mindplot.TextTopic = new Class({
|
||||
Extends:mindplot.Topic,
|
||||
initialize : function(model, options) {
|
||||
this._textEditor = new mindplot.MultilineTextEditor(this);
|
||||
this.parent(model, options);
|
||||
},
|
||||
|
||||
_registerEvents : function() {
|
||||
|
||||
this.parent();
|
||||
this.addEvent('dblclick', function (event) {
|
||||
this._textEditor.show();
|
||||
event.stopPropagation(true);
|
||||
}.bind(this));
|
||||
|
||||
this._textEditor.addEvent('input', function(event, text) {
|
||||
var textShape = this.getTextShape();
|
||||
// var oldText = textShape.getText();
|
||||
|
||||
// this._setText(text, false);
|
||||
// @Todo: I must resize, no change the position ...
|
||||
// textShape.setText(oldText);
|
||||
}.bind(this));
|
||||
|
||||
},
|
||||
|
||||
setShapeType : function(type) {
|
||||
this._setShapeType(type, true);
|
||||
|
||||
},
|
||||
|
||||
_setShapeType : function(type, updateModel) {
|
||||
// Remove inner shape figure ...
|
||||
var model = this.getModel();
|
||||
if ($defined(updateModel) && updateModel) {
|
||||
model.setShapeType(type);
|
||||
}
|
||||
|
||||
var oldInnerShape = this.getInnerShape();
|
||||
if (oldInnerShape != null) {
|
||||
|
||||
this._removeInnerShape();
|
||||
|
||||
// Create a new one ...
|
||||
var innerShape = this.getInnerShape();
|
||||
|
||||
// Update figure size ...
|
||||
var size = model.getSize();
|
||||
this.setSize(size, true);
|
||||
|
||||
var group = this.get2DElement();
|
||||
group.appendChild(innerShape);
|
||||
|
||||
// Move text to the front ...
|
||||
var text = this.getTextShape();
|
||||
text.moveToFront();
|
||||
|
||||
//Move iconGroup to front ...
|
||||
var iconGroup = this.getIconGroup();
|
||||
if ($defined(iconGroup)) {
|
||||
iconGroup.moveToFront();
|
||||
}
|
||||
//Move connector to front
|
||||
var connector = this.getShrinkConnector();
|
||||
if ($defined(connector)) {
|
||||
connector.moveToFront();
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
getShapeType : function() {
|
||||
var model = this.getModel();
|
||||
var result = model.getShapeType();
|
||||
if (!$defined(result)) {
|
||||
result = this._defaultShapeType();
|
||||
}
|
||||
return result;
|
||||
},
|
||||
|
||||
getInnerShape : function() {
|
||||
if (!$defined(this._innerShape)) {
|
||||
// Create inner box.
|
||||
this._innerShape = this.buildShape(mindplot.TextTopic.INNER_RECT_ATTRIBUTES);
|
||||
|
||||
// Update bgcolor ...
|
||||
var bgColor = this.getBackgroundColor();
|
||||
this._setBackgroundColor(bgColor, false);
|
||||
|
||||
// Update border color ...
|
||||
var brColor = this.getBorderColor();
|
||||
this._setBorderColor(brColor, false);
|
||||
|
||||
// Define the pointer ...
|
||||
if (this.getType() != mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) {
|
||||
this._innerShape.setCursor('move');
|
||||
} else {
|
||||
this._innerShape.setCursor('default');
|
||||
}
|
||||
|
||||
}
|
||||
return this._innerShape;
|
||||
},
|
||||
|
||||
buildShape : function(attributes, type) {
|
||||
var result;
|
||||
if (!$defined(type)) {
|
||||
type = this.getShapeType();
|
||||
}
|
||||
|
||||
if (type == mindplot.model.INodeModel.SHAPE_TYPE_RECT) {
|
||||
result = new web2d.Rect(0, attributes);
|
||||
}
|
||||
else if (type == mindplot.model.INodeModel.SHAPE_TYPE_ELIPSE) {
|
||||
result = new web2d.Rect(0.9, attributes);
|
||||
}
|
||||
else if (type == mindplot.model.INodeModel.SHAPE_TYPE_ROUNDED_RECT) {
|
||||
result = new web2d.Rect(0.3, attributes);
|
||||
}
|
||||
else if (type == mindplot.model.INodeModel.SHAPE_TYPE_LINE) {
|
||||
result = new web2d.Line({strokeColor:"#495879",strokeWidth:1});
|
||||
result.setSize = function(width, height) {
|
||||
this.size = {width:width, height:height};
|
||||
result.setFrom(0, height);
|
||||
result.setTo(width, height);
|
||||
|
||||
// Lines will have the same color of the default connection lines...
|
||||
var stokeColor = mindplot.ConnectionLine.getStrokeColor();
|
||||
result.setStroke(1, 'solid', stokeColor);
|
||||
};
|
||||
|
||||
result.getSize = function() {
|
||||
return this.size;
|
||||
};
|
||||
|
||||
result.setPosition = function() {
|
||||
};
|
||||
|
||||
var setStrokeFunction = result.setStroke;
|
||||
result.setFill = function() {
|
||||
|
||||
};
|
||||
|
||||
result.setStroke = function() {
|
||||
|
||||
};
|
||||
}
|
||||
else {
|
||||
$assert(false, "Unsupported figure type:" + type);
|
||||
}
|
||||
result.setPosition(0, 0);
|
||||
return result;
|
||||
},
|
||||
|
||||
|
||||
getOuterShape : function() {
|
||||
if (!$defined(this._outerShape)) {
|
||||
var rect = this.buildShape(mindplot.Topic.OUTER_SHAPE_ATTRIBUTES, mindplot.model.INodeModel.SHAPE_TYPE_ROUNDED_RECT);
|
||||
rect.setPosition(-2, -3);
|
||||
rect.setOpacity(0);
|
||||
this._outerShape = rect;
|
||||
}
|
||||
|
||||
return this._outerShape;
|
||||
},
|
||||
|
||||
getTextShape : function() {
|
||||
if (!$defined(this._text)) {
|
||||
this._text = this._buildTextShape(false);
|
||||
|
||||
// Set Text ...
|
||||
var text = this.getText();
|
||||
this._setText(text, false);
|
||||
}
|
||||
return this._text;
|
||||
},
|
||||
|
||||
|
||||
_buildTextShape : function(readOnly) {
|
||||
var result = new web2d.Text();
|
||||
var family = this.getFontFamily();
|
||||
var size = this.getFontSize();
|
||||
var weight = this.getFontWeight();
|
||||
var style = this.getFontStyle();
|
||||
result.setFont(family, size, style, weight);
|
||||
|
||||
var color = this.getFontColor();
|
||||
result.setColor(color);
|
||||
|
||||
if (!readOnly) {
|
||||
// Propagate mouse events ...
|
||||
if (this.getType() != mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) {
|
||||
result.setCursor('move');
|
||||
} else {
|
||||
result.setCursor('default');
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
},
|
||||
|
||||
_getInnerPadding : function() {
|
||||
throw "this must be implemented";
|
||||
},
|
||||
|
||||
setFontFamily : function(value, updateModel) {
|
||||
var textShape = this.getTextShape();
|
||||
textShape.setFontFamily(value);
|
||||
if ($defined(updateModel) && updateModel) {
|
||||
var model = this.getModel();
|
||||
model.setFontFamily(value);
|
||||
}
|
||||
this._adjustShapes(updateModel);
|
||||
},
|
||||
|
||||
setFontSize : function(value, updateModel) {
|
||||
|
||||
var textShape = this.getTextShape();
|
||||
textShape.setSize(value);
|
||||
|
||||
if ($defined(updateModel) && updateModel) {
|
||||
var model = this.getModel();
|
||||
model.setFontSize(value);
|
||||
}
|
||||
this._adjustShapes(updateModel);
|
||||
|
||||
},
|
||||
|
||||
setFontStyle : function(value, updateModel) {
|
||||
var textShape = this.getTextShape();
|
||||
textShape.setStyle(value);
|
||||
if ($defined(updateModel) && updateModel) {
|
||||
var model = this.getModel();
|
||||
model.setFontStyle(value);
|
||||
}
|
||||
this._adjustShapes(updateModel);
|
||||
},
|
||||
|
||||
setFontWeight : function(value, updateModel) {
|
||||
var textShape = this.getTextShape();
|
||||
textShape.setWeight(value);
|
||||
if ($defined(updateModel) && updateModel) {
|
||||
var model = this.getModel();
|
||||
model.setFontWeight(value);
|
||||
}
|
||||
this._adjustShapes();
|
||||
},
|
||||
|
||||
getFontWeight : function() {
|
||||
var model = this.getModel();
|
||||
var result = model.getFontWeight();
|
||||
if (!$defined(result)) {
|
||||
var font = this._defaultFontStyle();
|
||||
result = font.weight;
|
||||
}
|
||||
return result;
|
||||
},
|
||||
|
||||
getFontFamily : function() {
|
||||
var model = this.getModel();
|
||||
var result = model.getFontFamily();
|
||||
if (!$defined(result)) {
|
||||
var font = this._defaultFontStyle();
|
||||
result = font.font;
|
||||
}
|
||||
return result;
|
||||
},
|
||||
|
||||
getFontColor : function() {
|
||||
var model = this.getModel();
|
||||
var result = model.getFontColor();
|
||||
if (!$defined(result)) {
|
||||
var font = this._defaultFontStyle();
|
||||
result = font.color;
|
||||
}
|
||||
return result;
|
||||
},
|
||||
|
||||
getFontStyle : function() {
|
||||
var model = this.getModel();
|
||||
var result = model.getFontStyle();
|
||||
if (!$defined(result)) {
|
||||
var font = this._defaultFontStyle();
|
||||
result = font.style;
|
||||
}
|
||||
return result;
|
||||
},
|
||||
|
||||
getFontSize : function() {
|
||||
var model = this.getModel();
|
||||
var result = model.getFontSize();
|
||||
if (!$defined(result)) {
|
||||
var font = this._defaultFontStyle();
|
||||
result = font.size;
|
||||
}
|
||||
return result;
|
||||
},
|
||||
|
||||
setFontColor : function(value, updateModel) {
|
||||
var textShape = this.getTextShape();
|
||||
textShape.setColor(value);
|
||||
if ($defined(updateModel) && updateModel) {
|
||||
var model = this.getModel();
|
||||
model.setFontColor(value);
|
||||
}
|
||||
},
|
||||
|
||||
_setText : function(text, updateModel) {
|
||||
var textShape = this.getTextShape();
|
||||
textShape.setText(text == null ? this._defaultText() : text);
|
||||
|
||||
if ($defined(updateModel) && updateModel) {
|
||||
var model = this.getModel();
|
||||
model.setText(text);
|
||||
}
|
||||
},
|
||||
|
||||
setText : function(text) {
|
||||
// Avoid empty nodes ...
|
||||
if (text.trim().length == 0) {
|
||||
text = null;
|
||||
}
|
||||
|
||||
this._setText(text, true);
|
||||
this._adjustShapes();
|
||||
},
|
||||
|
||||
getText : function() {
|
||||
var model = this.getModel();
|
||||
var result = model.getText();
|
||||
if (!$defined(result)) {
|
||||
result = this._defaultText();
|
||||
}
|
||||
return result;
|
||||
},
|
||||
|
||||
setBackgroundColor : function(color) {
|
||||
this._setBackgroundColor(color, true);
|
||||
},
|
||||
|
||||
_setBackgroundColor : function(color, updateModel) {
|
||||
var innerShape = this.getInnerShape();
|
||||
innerShape.setFill(color);
|
||||
|
||||
var connector = this.getShrinkConnector();
|
||||
connector.setFill(color);
|
||||
|
||||
if ($defined(updateModel) && updateModel) {
|
||||
var model = this.getModel();
|
||||
model.setBackgroundColor(color);
|
||||
}
|
||||
},
|
||||
|
||||
getBackgroundColor : function() {
|
||||
var model = this.getModel();
|
||||
var result = model.getBackgroundColor();
|
||||
if (!$defined(result)) {
|
||||
result = this._defaultBackgroundColor();
|
||||
}
|
||||
return result;
|
||||
},
|
||||
|
||||
setBorderColor : function(color) {
|
||||
this._setBorderColor(color, true);
|
||||
},
|
||||
|
||||
_setBorderColor : function(color, updateModel) {
|
||||
var innerShape = this.getInnerShape();
|
||||
innerShape.setAttribute('strokeColor', color);
|
||||
|
||||
var connector = this.getShrinkConnector();
|
||||
connector.setAttribute('strokeColor', color);
|
||||
|
||||
|
||||
if ($defined(updateModel) && updateModel) {
|
||||
var model = this.getModel();
|
||||
model.setBorderColor(color);
|
||||
}
|
||||
},
|
||||
|
||||
getBorderColor : function() {
|
||||
var model = this.getModel();
|
||||
var result = model.getBorderColor();
|
||||
if (!$defined(result)) {
|
||||
result = this._defaultBorderColor();
|
||||
}
|
||||
return result;
|
||||
},
|
||||
|
||||
_buildShape : function() {
|
||||
var groupAttributes = {width: 100, height:100,coordSizeWidth:100,coordSizeHeight:100};
|
||||
var group = new web2d.Group(groupAttributes);
|
||||
this._set2DElement(group);
|
||||
|
||||
// Shape must be build based on the model width ...
|
||||
var outerShape = this.getOuterShape();
|
||||
var innerShape = this.getInnerShape();
|
||||
var textShape = this.getTextShape();
|
||||
var shrinkConnector = this.getShrinkConnector();
|
||||
|
||||
// Add to the group ...
|
||||
group.appendChild(outerShape);
|
||||
group.appendChild(innerShape);
|
||||
group.appendChild(textShape);
|
||||
|
||||
// Update figure size ...
|
||||
var model = this.getModel();
|
||||
if (model.getLinks().length != 0 || model.getNotes().length != 0 || model.getIcons().length != 0) {
|
||||
this.getOrBuildIconGroup();
|
||||
}
|
||||
|
||||
if (this.getType() != mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) {
|
||||
shrinkConnector.addToWorkspace(group);
|
||||
}
|
||||
|
||||
// Register listeners ...
|
||||
this._registerDefaultListenersToElement(group, this);
|
||||
},
|
||||
|
||||
|
||||
showTextEditor : function(text) {
|
||||
this._textEditor.show(text);
|
||||
},
|
||||
|
||||
showLinkEditor : function() {
|
||||
|
||||
var topicId = this.getId();
|
||||
var model = this.getModel();
|
||||
var editorModel = {
|
||||
getValue : function() {
|
||||
var links = model.getLinks();
|
||||
var result;
|
||||
if (links.length > 0)
|
||||
result = links[0].getUrl();
|
||||
|
||||
return result;
|
||||
},
|
||||
|
||||
setValue : function(value) {
|
||||
var dispatcher = mindplot.ActionDispatcher.getInstance();
|
||||
if (!$defined(value)) {
|
||||
dispatcher.removeLinkFromTopic(topicId);
|
||||
}
|
||||
else {
|
||||
dispatcher.changeLinkToTopic(topicId, value);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
this.closeEditors();
|
||||
var editor = new mindplot.widget.LinkEditor(editorModel);
|
||||
editor.show();
|
||||
},
|
||||
|
||||
|
||||
closeEditors : function() {
|
||||
this._textEditor.close(true);
|
||||
},
|
||||
|
||||
/**
|
||||
* Point: references the center of the rect shape.!!!
|
||||
*/
|
||||
setPosition : function(point) {
|
||||
$assert(point, "position can not be null");
|
||||
point.x = Math.ceil(point.x);
|
||||
point.y = Math.ceil(point.y);
|
||||
|
||||
// Update model's position ...
|
||||
var model = this.getModel();
|
||||
model.setPosition(point.x, point.y);
|
||||
|
||||
// Elements are positioned in the center.
|
||||
// All topic element must be positioned based on the innerShape.
|
||||
var size = this.getSize();
|
||||
|
||||
var cx = point.x - (size.width / 2);
|
||||
var cy = point.y - (size.height / 2);
|
||||
|
||||
// Update visual position.
|
||||
this._elem2d.setPosition(cx, cy);
|
||||
|
||||
// Update connection lines ...
|
||||
this._updateConnectionLines();
|
||||
|
||||
// Check object state.
|
||||
this.invariant();
|
||||
},
|
||||
|
||||
getOutgoingConnectedTopic : function() {
|
||||
var result = null;
|
||||
var line = this.getOutgoingLine();
|
||||
if ($defined(line)) {
|
||||
result = line.getTargetTopic();
|
||||
}
|
||||
return result;
|
||||
},
|
||||
|
||||
_setTopicVisibility : function(value) {
|
||||
this.parent(value);
|
||||
|
||||
var textShape = this.getTextShape();
|
||||
textShape.setVisibility(value);
|
||||
|
||||
},
|
||||
|
||||
setOpacity : function(opacity) {
|
||||
this.parent();
|
||||
|
||||
var textShape = this.getTextShape();
|
||||
textShape.setOpacity(opacity);
|
||||
},
|
||||
|
||||
_updatePositionOnChangeSize : function(oldSize, newSize) {
|
||||
$assert(false, "this method must be overwrited.");
|
||||
},
|
||||
|
||||
createDragNode : function(layoutManager) {
|
||||
var result = this.parent(layoutManager);
|
||||
|
||||
// Is the node already connected ?
|
||||
var targetTopic = this.getOutgoingConnectedTopic();
|
||||
if ($defined(targetTopic)) {
|
||||
result.connectTo(targetTopic);
|
||||
result.setVisibility(false);
|
||||
}
|
||||
|
||||
// If a drag node is create for it, let's hide the editor.
|
||||
this._textEditor.close();
|
||||
|
||||
return result;
|
||||
},
|
||||
|
||||
_adjustShapes : function() {
|
||||
if (this._isInWorkspace) {
|
||||
var textShape = this.getTextShape();
|
||||
var textWidth = textShape.getWidth();
|
||||
|
||||
var textHeight = textShape.getHeight();
|
||||
textHeight = textHeight != 0 ? textHeight : 20;
|
||||
|
||||
var topicPadding = this._getInnerPadding();
|
||||
|
||||
// Adjust the icon size to the size of the text ...
|
||||
var iconGroup = this.getOrBuildIconGroup();
|
||||
var fontHeight = this.getTextShape().getFontHeight();
|
||||
iconGroup.setPosition(topicPadding, topicPadding);
|
||||
iconGroup.seIconSize(fontHeight, fontHeight);
|
||||
|
||||
// Add a extra padding between the text and the icons
|
||||
var iconsWidth = iconGroup.getSize().width;
|
||||
if (iconsWidth != 0) {
|
||||
|
||||
iconsWidth = iconsWidth + (textHeight / 4);
|
||||
}
|
||||
|
||||
var height = textHeight + (topicPadding * 2);
|
||||
var width = textWidth + iconsWidth + (topicPadding * 2);
|
||||
|
||||
this.setSize({width:width,height:height});
|
||||
|
||||
// Position node ...
|
||||
textShape.setPosition(topicPadding + iconsWidth, topicPadding);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
mindplot.TextTopic.INNER_RECT_ATTRIBUTES = {stroke:'2 solid'};
|
||||
|
||||
|
||||
|
@ -26,7 +26,6 @@ mindplot.widget = {};
|
||||
mindplot.model = {};
|
||||
mindplot.collaboration = {};
|
||||
mindplot.collaboration.framework = {};
|
||||
mindplot.collaboration.framework.brix = {};
|
||||
mindplot.collaboration.framework.brix.model = {};
|
||||
mindplot.persistence = {};
|
||||
|
||||
mindplot.layout = {};
|
||||
|
@ -82,6 +82,15 @@ mindplot.model.INodeModel = new Class({
|
||||
return result;
|
||||
},
|
||||
|
||||
setImageUrl:function(url) {
|
||||
this.putProperty('imageUrl', url);
|
||||
|
||||
},
|
||||
|
||||
getImageUrl:function() {
|
||||
return this.getProperty('imageUrl');
|
||||
},
|
||||
|
||||
getMindmap : function() {
|
||||
return this._mindmap;
|
||||
},
|
||||
|
@ -22,7 +22,7 @@ mindplot.model.Mindmap = new Class({
|
||||
this._branches = [];
|
||||
this._description = null;
|
||||
this._relationships = [];
|
||||
this._version = $defined(version) ? version : mindplot.ModelCodeName.TANGO;
|
||||
this._version = $defined(version) ? version : mindplot.persistence.ModelCodeName.TANGO;
|
||||
this._id = id;
|
||||
},
|
||||
|
||||
|
@ -15,10 +15,10 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
mindplot.Beta2PelaMigrator = new Class({
|
||||
mindplot.persistence.Beta2PelaMigrator = new Class({
|
||||
initialize : function(betaSerializer) {
|
||||
this._betaSerializer = betaSerializer;
|
||||
this._pelaSerializer = new mindplot.XMLMindmapSerializer_Pela();
|
||||
this._pelaSerializer = new mindplot.persistence.XMLSerializer_Pela();
|
||||
},
|
||||
|
||||
toXML : function(mindmap) {
|
||||
@ -28,7 +28,7 @@ mindplot.Beta2PelaMigrator = new Class({
|
||||
loadFromDom : function(dom, mapId) {
|
||||
$assert($defined(mapId), "mapId can not be null");
|
||||
var mindmap = this._betaSerializer.loadFromDom(dom, mapId);
|
||||
mindmap.setVersion(mindplot.ModelCodeName.PELA);
|
||||
mindmap.setVersion(mindplot.persistence.ModelCodeName.PELA);
|
||||
return mindmap;
|
||||
}
|
||||
});
|
@ -15,7 +15,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
mindplot.ModelCodeName = {
|
||||
mindplot.persistence.ModelCodeName = {
|
||||
BETA : "beta",
|
||||
PELA : "pela",
|
||||
TANGO : "tango"
|
@ -15,10 +15,10 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
mindplot.Pela2TangoMigrator = new Class({
|
||||
mindplot.persistence.Pela2TangoMigrator = new Class({
|
||||
initialize : function(pelaSerializer) {
|
||||
this._pelaSerializer = pelaSerializer;
|
||||
this._tangoSerializer = new mindplot.XMLMindmapSerializer_Tango();
|
||||
this._tangoSerializer = new mindplot.persistence.XMLSerializer_Tango();
|
||||
},
|
||||
|
||||
toXML : function(mindmap) {
|
||||
@ -28,7 +28,7 @@ mindplot.Pela2TangoMigrator = new Class({
|
||||
loadFromDom : function(dom, mapId) {
|
||||
$assert($defined(mapId), "mapId can not be null");
|
||||
var mindmap = this._pelaSerializer.loadFromDom(dom, mapId);
|
||||
mindmap.setVersion(mindplot.ModelCodeName.TANGO);
|
||||
mindmap.setVersion(mindplot.persistence.ModelCodeName.TANGO);
|
||||
this._fixOrder(mindmap);
|
||||
return mindmap;
|
||||
},
|
@ -15,23 +15,23 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
mindplot.XMLMindmapSerializerFactory = {};
|
||||
mindplot.persistence.XMLSerializerFactory = {};
|
||||
|
||||
mindplot.XMLMindmapSerializerFactory.getSerializerFromMindmap = function(mindmap) {
|
||||
return mindplot.XMLMindmapSerializerFactory.getSerializer(mindmap.getVersion());
|
||||
mindplot.persistence.XMLSerializerFactory.getSerializerFromMindmap = function(mindmap) {
|
||||
return mindplot.persistence.XMLSerializerFactory.getSerializer(mindmap.getVersion());
|
||||
};
|
||||
|
||||
mindplot.XMLMindmapSerializerFactory.getSerializerFromDocument = function(domDocument) {
|
||||
mindplot.persistence.XMLSerializerFactory.getSerializerFromDocument = function(domDocument) {
|
||||
var rootElem = domDocument.documentElement;
|
||||
return mindplot.XMLMindmapSerializerFactory.getSerializer(rootElem.getAttribute("version"))
|
||||
return mindplot.persistence.XMLSerializerFactory.getSerializer(rootElem.getAttribute("version"))
|
||||
};
|
||||
|
||||
|
||||
mindplot.XMLMindmapSerializerFactory.getSerializer = function(version) {
|
||||
mindplot.persistence.XMLSerializerFactory.getSerializer = function(version) {
|
||||
if (!$defined(version)) {
|
||||
version = mindplot.ModelCodeName.BETA;
|
||||
version = mindplot.persistence.ModelCodeName.BETA;
|
||||
}
|
||||
var codeNames = mindplot.XMLMindmapSerializerFactory._codeNames;
|
||||
var codeNames = mindplot.persistence.XMLSerializerFactory._codeNames;
|
||||
var found = false;
|
||||
var serializer = null;
|
||||
for (var i = 0; i < codeNames.length; i++) {
|
||||
@ -48,22 +48,22 @@ mindplot.XMLMindmapSerializerFactory.getSerializer = function(version) {
|
||||
return serializer;
|
||||
};
|
||||
|
||||
mindplot.XMLMindmapSerializerFactory._codeNames =
|
||||
mindplot.persistence.XMLSerializerFactory._codeNames =
|
||||
[
|
||||
{
|
||||
codeName:mindplot.ModelCodeName.BETA,
|
||||
serializer: mindplot.XMLMindmapSerializer_Beta,
|
||||
codeName:mindplot.persistence.ModelCodeName.BETA,
|
||||
serializer: mindplot.persistence.XMLSerializer_Beta,
|
||||
migrator:function() {
|
||||
}
|
||||
},
|
||||
{
|
||||
codeName:mindplot.ModelCodeName.PELA,
|
||||
serializer:mindplot.XMLMindmapSerializer_Pela,
|
||||
migrator:mindplot.Beta2PelaMigrator
|
||||
codeName:mindplot.persistence.ModelCodeName.PELA,
|
||||
serializer:mindplot.persistence.XMLSerializer_Pela,
|
||||
migrator:mindplot.persistence.Beta2PelaMigrator
|
||||
},
|
||||
{
|
||||
codeName:mindplot.ModelCodeName.TANGO,
|
||||
serializer:mindplot.XMLMindmapSerializer_Tango,
|
||||
migrator:mindplot.Pela2TangoMigrator
|
||||
codeName:mindplot.persistence.ModelCodeName.TANGO,
|
||||
serializer:mindplot.persistence.XMLSerializer_Tango,
|
||||
migrator:mindplot.persistence.Pela2TangoMigrator
|
||||
}
|
||||
];
|
@ -14,7 +14,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
mindplot.XMLMindmapSerializer_Beta = new Class({
|
||||
mindplot.persistence.XMLSerializer_Beta = new Class({
|
||||
|
||||
toXML : function(mindmap) {
|
||||
$assert(mindmap, "Can not save a null mindmap");
|
||||
@ -164,11 +164,11 @@ mindplot.XMLMindmapSerializer_Beta = new Class({
|
||||
var rootElem = dom.documentElement;
|
||||
|
||||
// Is a wisemap?.
|
||||
$assert(rootElem.tagName == mindplot.XMLMindmapSerializer_Beta.MAP_ROOT_NODE, "This seem not to be a map document.");
|
||||
$assert(rootElem.tagName == mindplot.persistence.XMLSerializer_Beta.MAP_ROOT_NODE, "This seem not to be a map document.");
|
||||
|
||||
// Start the loading process ...
|
||||
var version = rootElem.getAttribute("version");
|
||||
version = !$defined(version) ? mindplot.ModelCodeName.BETA : version;
|
||||
version = !$defined(version) ? mindplot.persistence.ModelCodeName.BETA : version;
|
||||
var mindmap = new mindplot.model.Mindmap(mapId, version);
|
||||
|
||||
var children = rootElem.childNodes;
|
||||
@ -288,4 +288,4 @@ mindplot.XMLMindmapSerializer_Beta = new Class({
|
||||
return topic.createNote(domElem.getAttribute("text"));
|
||||
}});
|
||||
|
||||
mindplot.XMLMindmapSerializer_Beta.MAP_ROOT_NODE = 'map';
|
||||
mindplot.persistence.XMLSerializer_Beta.MAP_ROOT_NODE = 'map';
|
@ -16,7 +16,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
mindplot.XMLMindmapSerializer_Pela = new Class({
|
||||
mindplot.persistence.XMLSerializer_Pela = new Class({
|
||||
|
||||
toXML : function(mindmap) {
|
||||
$assert(mindmap, "Can not save a null mindmap");
|
||||
@ -217,7 +217,7 @@ mindplot.XMLMindmapSerializer_Pela = new Class({
|
||||
var rootElem = dom.documentElement;
|
||||
|
||||
// Is a wisemap?.
|
||||
$assert(rootElem.tagName == mindplot.XMLMindmapSerializer_Pela.MAP_ROOT_NODE, "This seem not to be a map document.");
|
||||
$assert(rootElem.tagName == mindplot.persistence.XMLSerializer_Pela.MAP_ROOT_NODE, "This seem not to be a map document.");
|
||||
|
||||
this._idsMap = new Hash();
|
||||
// Start the loading process ...
|
||||
@ -262,27 +262,15 @@ mindplot.XMLMindmapSerializer_Pela = new Class({
|
||||
}
|
||||
|
||||
var topic = mindmap.createNode(type, id);
|
||||
|
||||
var text = domElem.getAttribute('text');
|
||||
if ($defined(text)) {
|
||||
topic.setText(text);
|
||||
}
|
||||
|
||||
var order = domElem.getAttribute('order');
|
||||
if ($defined(order)) {
|
||||
topic.setOrder(parseInt(order));
|
||||
}
|
||||
|
||||
var shape = domElem.getAttribute('shape');
|
||||
if ($defined(shape)) {
|
||||
topic.setShapeType(shape);
|
||||
}
|
||||
|
||||
var isShrink = domElem.getAttribute('shrink');
|
||||
if ($defined(isShrink)) {
|
||||
topic.setChildrenShrunken(isShrink);
|
||||
}
|
||||
|
||||
var fontStyle = domElem.getAttribute('fontStyle');
|
||||
if ($defined(fontStyle)) {
|
||||
var font = fontStyle.split(';');
|
||||
@ -317,6 +305,27 @@ mindplot.XMLMindmapSerializer_Pela = new Class({
|
||||
if ($defined(borderColor)) {
|
||||
topic.setBorderColor(borderColor);
|
||||
}
|
||||
//
|
||||
// } else {
|
||||
// var sizeStr = domElem.getAttribute('size');
|
||||
// $assert(sizeStr, "size can not be null");
|
||||
// var size = sizeStr.split(',');
|
||||
// topic.setSize(size[0], size[1]);
|
||||
//
|
||||
// var url = domElem.getAttribute('image');
|
||||
// $assert(url, "url can not be null");
|
||||
// topic.setImageUrl(url);
|
||||
// }
|
||||
|
||||
var order = domElem.getAttribute('order');
|
||||
if ($defined(order)) {
|
||||
topic.setOrder(parseInt(order));
|
||||
}
|
||||
|
||||
var isShrink = domElem.getAttribute('shrink');
|
||||
if ($defined(isShrink)) {
|
||||
topic.setChildrenShrunken(isShrink);
|
||||
}
|
||||
|
||||
var position = domElem.getAttribute('position');
|
||||
if ($defined(position)) {
|
||||
@ -415,4 +424,4 @@ mindplot.XMLMindmapSerializer_Pela = new Class({
|
||||
}
|
||||
});
|
||||
|
||||
mindplot.XMLMindmapSerializer_Pela.MAP_ROOT_NODE = 'map';
|
||||
mindplot.persistence.XMLSerializer_Pela.MAP_ROOT_NODE = 'map';
|
@ -16,6 +16,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
mindplot.XMLMindmapSerializer_Tango = new Class({
|
||||
Extends: mindplot.XMLMindmapSerializer_Pela
|
||||
mindplot.persistence.XMLSerializer_Tango = new Class({
|
||||
Extends: mindplot.persistence.XMLSerializer_Pela
|
||||
});
|
@ -6,14 +6,14 @@ TestCase("Model Migration Tests",{
|
||||
ids=[];
|
||||
var domDocument = core.Utils.createDocumentFromText(mapXml);
|
||||
|
||||
var betaSerializer = new mindplot.XMLMindmapSerializer_Beta();
|
||||
var betaSerializer = new mindplot.persistence.XMLSerializer_Beta();
|
||||
var betaMap = betaSerializer.loadFromDom(domDocument);
|
||||
|
||||
var serializer = mindplot.XMLMindmapSerializerFactory.getSerializerFromDocument(domDocument);
|
||||
var serializer = mindplot.persistence.XMLSerializerFactory.getSerializerFromDocument(domDocument);
|
||||
var mindmap = serializer.loadFromDom(domDocument);
|
||||
|
||||
//Assert that the new model is Pela
|
||||
assertEquals(mindplot.ModelCodeName.PELA, mindmap.getVersion());
|
||||
assertEquals(mindplot.persistence.ModelCodeName.PELA, mindmap.getVersion());
|
||||
|
||||
//Assert same number of branches
|
||||
var betaBranches = betaMap.getBranches();
|
||||
|
@ -100,7 +100,7 @@
|
||||
// Store SVG o native map...
|
||||
if (suffix == "freemind") {
|
||||
var mindmap = designer.getMindmap();
|
||||
var serializer = mindplot.XMLMindmapSerializerFactory.getSerializerFromMindmap(mindmap);
|
||||
var serializer = mindplot.persistence.XMLSerializerFactory.getSerializerFromMindmap(mindmap);
|
||||
var domMap = serializer.toXML(mindmap);
|
||||
form.mapXml.value = core.Utils.innerXML(domMap);
|
||||
} else {
|
||||
|
@ -29,12 +29,12 @@
|
||||
// Load map from XML file persisted on disk...
|
||||
var persistence = mindplot.PersistenceManager.getInstance();
|
||||
var mindmap;
|
||||
try {
|
||||
// try {
|
||||
mindmap = persistence.load(mapId);
|
||||
} catch(e) {
|
||||
// } catch(e) {
|
||||
// If the map could not be loaded, create a new empty map...
|
||||
mindmap = mindplot.model.Mindmap.buildEmpty(mapId);
|
||||
}
|
||||
// mindmap = mindplot.model.Mindmap.buildEmpty(mapId);
|
||||
// }
|
||||
designer.loadMap(mindmap);
|
||||
});
|
||||
|
||||
|
@ -42,5 +42,6 @@
|
||||
<topic position="410,-97" order="2" text="Anyplace, Anytime" id="9"/>
|
||||
<topic position="386,-73" order="3" text="Free!!!" id="10"/>
|
||||
</topic>
|
||||
<topic type="media" size="50,50" image="http://m3.licdn.com/mpr/mpr/shrink_100_100/p/3/000/070/205/1461ef2.jpg" prop="" order="9" position="-336,-100"/>
|
||||
</topic>
|
||||
</map>
|
@ -29,7 +29,7 @@
|
||||
designer = buildDesigner(editorProperties);
|
||||
|
||||
var domDocument = core.Utils.createDocumentFromText(mapXml);
|
||||
var serializer = mindplot.XMLMindmapSerializerFactory.getSerializerFromDocument(domDocument);
|
||||
var serializer = mindplot.persistence.XMLSerializerFactory.getSerializerFromDocument(domDocument);
|
||||
var mindmap = serializer.loadFromDom(domDocument, mapId);
|
||||
|
||||
// Now, load the map ...
|
||||
|
@ -103,7 +103,7 @@
|
||||
// Store SVG o native map...
|
||||
if (suffix == "freemind") {
|
||||
var mindmap = designer.getMindmap();
|
||||
var serializer = mindplot.XMLMindmapSerializerFactory.getSerializerFromMindmap(mindmap);
|
||||
var serializer = mindplot.persistence.XMLSerializerFactory.getSerializerFromMindmap(mindmap);
|
||||
var domMap = serializer.toXML(mindmap);
|
||||
form.mapXml.value = core.Utils.innerXML(domMap);
|
||||
} else {
|
||||
|
@ -42,7 +42,7 @@
|
||||
designer = buildDesigner(editorProperties);
|
||||
|
||||
var domDocument = core.Utils.createDocumentFromText(mapXml);
|
||||
var serializer = mindplot.XMLMindmapSerializerFactory.getSerializerFromDocument(domDocument);
|
||||
var serializer = mindplot.persistence.MLSerializerFactory.getSerializerFromDocument(domDocument);
|
||||
var mindmap = serializer.loadFromDom(domDocument, mapId);
|
||||
|
||||
// Now, load the map ...
|
||||
|
Loading…
Reference in New Issue
Block a user