Add new Tango serializer. Pending to comple migration.

This commit is contained in:
Paulo Veiga 2012-01-14 10:45:39 -03:00
parent 89060af08b
commit 1b3ad1b42d
12 changed files with 110 additions and 65 deletions

View File

@ -107,6 +107,8 @@
<filelist dir="${basedir}/src/main/javascript/" files="ModelCodeName.js"/> <filelist dir="${basedir}/src/main/javascript/" files="ModelCodeName.js"/>
<filelist dir="${basedir}/src/main/javascript/" <filelist dir="${basedir}/src/main/javascript/"
files="XMLMindmapSerializer_Pela.js"/> files="XMLMindmapSerializer_Pela.js"/>
<filelist dir="${basedir}/src/main/javascript/"
files="XMLMindmapSerializer_Tango.js"/>
<filelist dir="${basedir}/src/main/javascript/" <filelist dir="${basedir}/src/main/javascript/"
files="XMLMindmapSerializer_Beta.js"/> files="XMLMindmapSerializer_Beta.js"/>
<filelist dir="${basedir}/src/main/javascript/" files="Beta2PelaMigrator.js"/> <filelist dir="${basedir}/src/main/javascript/" files="Beta2PelaMigrator.js"/>

View File

@ -443,9 +443,6 @@ mindplot.Designer = new Class({
var nodeModel = branches[i]; var nodeModel = branches[i];
var nodeGraph = this._nodeModelToNodeGraph(nodeModel, false); var nodeGraph = this._nodeModelToNodeGraph(nodeModel, false);
// Now, refresh UI changes ...
nodeGraph.enableUICache(false);
// Update shrink render state... // Update shrink render state...
nodeGraph.setBranchVisibility(true); nodeGraph.setBranchVisibility(true);
} }
@ -480,6 +477,9 @@ mindplot.Designer = new Class({
_nodeModelToNodeGraph : function(nodeModel, isVisible) { _nodeModelToNodeGraph : function(nodeModel, isVisible) {
$assert(nodeModel, "Node model can not be null"); $assert(nodeModel, "Node model can not be null");
var children = nodeModel.getChildren().slice(); var children = nodeModel.getChildren().slice();
children = children.sort(function(a, b) {
return a.getOrder() - b.getOrder()
});
var nodeGraph = this._buildNodeGraph(nodeModel); var nodeGraph = this._buildNodeGraph(nodeModel);

View File

@ -17,5 +17,6 @@
*/ */
mindplot.ModelCodeName = { mindplot.ModelCodeName = {
BETA : "beta", BETA : "beta",
PELA : "pela" PELA : "pela",
TANGO : "tango"
}; };

View File

@ -0,0 +1,37 @@
/*
* 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.Pela2TangoMigrator = new Class({
initialize : function(pelaSerializer) {
this._pelaSerializer = pelaSerializer;
this._tangoSerializer = new mindplot.XMLMindmapSerializer_Tango();
},
toXML : function(mindmap) {
return this._tangoSerializer.toXML(mindmap);
},
loadFromDom : function(dom, mapId) {
$assert($defined(mapId), "mapId can not be null");
var mindmap = this._pelaSerializer.loadFromDom(dom, mapId);
mindmap.setVersion(mindplot.ModelCodeName.TANGO);
// @todo: Cocinar los ordenes ....
return mindmap;
}
});

View File

@ -260,7 +260,6 @@ mindplot.CommandContext = new Class({
createTopic:function(model, isVisible) { createTopic:function(model, isVisible) {
$assert(model, "model can not be null"); $assert(model, "model can not be null");
var result = this._designer._nodeModelToNodeGraph(model, isVisible); var result = this._designer._nodeModelToNodeGraph(model, isVisible);
result.enableUICache(false);
return result; return result;
}, },

View File

@ -41,38 +41,9 @@ mindplot.Topic = new Class({
this._registerEvents(); this._registerEvents();
} }
this._cacheUIEnabled = true;
this._iuCache = {};
}, },
isUICacheEnabled : function() {
return this._cacheUIEnabled;
},
enableUICache : function(value) {
this._cacheUIEnabled = value;
if (!value) {
this._flushUIUpdate();
}
// Propagate the change to the children nodes ...
var children = this._getChildren();
for (var i = 0; i < children.length; i++) {
var node = children[i];
node.enableUICache(value);
}
},
_flushUIUpdate: function() {
var position = this._iuCache['position'];
if (position) {
this.setPosition(position);
}
this._iuCache = {};
},
_registerEvents : function() { _registerEvents : function() {
this.setMouseEventsEnabled(true); this.setMouseEventsEnabled(true);
@ -829,32 +800,21 @@ mindplot.Topic = new Class({
var currentPos = model.getPosition(); var currentPos = model.getPosition();
model.setPosition(point.x, point.y); model.setPosition(point.x, point.y);
if (!this.isUICacheEnabled()) { // Elements are positioned in the center.
// Elements are positioned in the center. // All topic element must be positioned based on the innerShape.
// All topic element must be positioned based on the innerShape. var size = this.getSize();
var size = this.getSize();
var cx = Math.round(point.x - (size.width / 2)); var cx = Math.round(point.x - (size.width / 2));
var cy = Math.round(point.y - (size.height / 2)); var cy = Math.round(point.y - (size.height / 2));
// Update visual position. // Update visual position.
this._elem2d.setPosition(cx, cy); this._elem2d.setPosition(cx, cy);
// Update connection lines ... // Update connection lines ...
this._updateConnectionLines(); this._updateConnectionLines();
// Check object state. // Check object state.
this.invariant(); this.invariant();
} else {
this._iuCache['position'] = point;
}
if (!$defined(currentPos) || parseInt(currentPos.x) != parseInt(point.x) || parseInt(currentPos.y) != parseInt(point.y)) {
// Fire Listener events ...
mindplot.EventBus.instance.fireEvent(mindplot.EventBus.events.NodeMoveEvent, [this]);
}
}, },
getOutgoingLine : function() { getOutgoingLine : function() {

View File

@ -53,12 +53,17 @@ mindplot.XMLMindmapSerializerFactory._codeNames =
{ {
codeName:mindplot.ModelCodeName.BETA, codeName:mindplot.ModelCodeName.BETA,
serializer: mindplot.XMLMindmapSerializer_Beta, serializer: mindplot.XMLMindmapSerializer_Beta,
migrator:function() {//todo:error migrator:function() {
} }
}, },
{ {
codeName:mindplot.ModelCodeName.PELA, codeName:mindplot.ModelCodeName.PELA,
serializer:mindplot.XMLMindmapSerializer_Pela, serializer:mindplot.XMLMindmapSerializer_Pela,
migrator:mindplot.Beta2PelaMigrator migrator:mindplot.Beta2PelaMigrator
},
{
codeName:mindplot.ModelCodeName.TANGO,
serializer:mindplot.XMLMindmapSerializer_Tango,
migrator:mindplot.Pela2TangoMigrator
} }
]; ];

View File

@ -168,6 +168,7 @@ mindplot.XMLMindmapSerializer_Beta = new Class({
// Start the loading process ... // Start the loading process ...
var version = rootElem.getAttribute("version"); var version = rootElem.getAttribute("version");
version = !$defined(version) ? mindplot.ModelCodeName.BETA : version;
var mindmap = new mindplot.model.Mindmap(mapId, version); var mindmap = new mindplot.model.Mindmap(mapId, version);
var children = rootElem.childNodes; var children = rootElem.childNodes;

View File

@ -0,0 +1,21 @@
/*
* 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.XMLMindmapSerializer_Tango = new Class({
Extends: mindplot.XMLMindmapSerializer_Pela
});

View File

@ -41,9 +41,6 @@ mindplot.commands.DragTopicCommand = new Class({
// Cache nodes position ... // Cache nodes position ...
var topics = designer.getModel().getTopics(); var topics = designer.getModel().getTopics();
topics.forEach(function(topic) {
topic.enableUICache(true);
});
// In this case, topics are positioned using order ... // In this case, topics are positioned using order ...
origOrder = topic.getOrder(); origOrder = topic.getOrder();
@ -83,10 +80,6 @@ mindplot.commands.DragTopicCommand = new Class({
this._order = origOrder; this._order = origOrder;
this._position = origPosition; this._position = origPosition;
topics.forEach(function(topic) {
topic.enableUICache(false);
});
}, },
undoExecute: function(commandContext) { undoExecute: function(commandContext) {

View File

@ -22,7 +22,7 @@ mindplot.model.Mindmap = new Class({
this._branches = []; this._branches = [];
this._description = null; this._description = null;
this._relationships = []; this._relationships = [];
this._version = $defined(version) ? version : 'pela'; this._version = $defined(version) ? version : mindplot.ModelCodeName.TANGO;
this._id = id; this._id = id;
}, },

View File

@ -0,0 +1,26 @@
<map name="mapId" version="pela">
<topic central="true" id="0">
<topic position="127,-163" order="0" id="1"/>
<topic position="-127,-33" order="1" id="2"/>
<topic position="127,-130" order="2" id="3"/>
<topic position="-127,0" order="3" id="4"/>
<topic position="127,94" order="6" id="5">
<topic position="251,94" order="0" text="ddddddddddddddddddddd" id="8">
<topic position="364,55" order="0" id="9"/>
<topic position="364,81" order="1" id="10"/>
<topic position="364,107" order="2" id="11"/>
<topic position="364,133" order="3" id="12"/>
</topic>
</topic>
<topic position="-127,33" order="5" id="6"/>
<topic position="127,163" order="8" id="7"/>
<topic position="127,-35" order="4" id="13">
<topic position="216,-100" order="0" id="14"/>
<topic position="216,-74" order="1" id="15"/>
<topic position="216,3" order="4" id="16"/>
<topic position="216,-48" order="2" id="17"/>
<topic position="216,29" order="5" id="18"/>
<topic position="216,-22" order="3" id="19"/>
</topic>
</topic>
</map>